Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
806550c9
Commit
806550c9
authored
Apr 03, 2018
by
lain
Browse files
Use user url in mention if we have it.
parent
b3b7ab5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/formatter.ex
View file @
806550c9
...
...
@@ -189,7 +189,9 @@ def add_user_links({subs, text}, mentions) do
subs
=
subs
++
Enum
.
map
(
mentions
,
fn
{
match
,
%
User
{
ap_id:
ap_id
},
uuid
}
->
Enum
.
map
(
mentions
,
fn
{
match
,
%
User
{
ap_id:
ap_id
,
info:
info
},
uuid
}
->
ap_id
=
info
[
"source_data"
][
"url"
]
||
ap_id
short_match
=
String
.
split
(
match
,
"@"
)
|>
tl
()
|>
hd
()
{
uuid
,
"<span><a href='
#{
ap_id
}
'>@<span>
#{
short_match
}
</span></a></span>"
}
end
)
...
...
test/formatter_test.exs
View file @
806550c9
...
...
@@ -64,7 +64,13 @@ test "turning urls into links" do
test
"gives a replacement for user links"
do
text
=
"@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me"
gsimg
=
insert
(
:user
,
%{
nickname:
"gsimg"
})
archaeme
=
insert
(
:user
,
%{
nickname:
"archaeme"
})
archaeme
=
insert
(
:user
,
%{
nickname:
"archaeme"
,
info:
%{
"source_data"
=>
%{
"url"
=>
"https://archeme/@archaeme"
}}
})
archaeme_remote
=
insert
(
:user
,
%{
nickname:
"archaeme@archae.me"
})
mentions
=
Pleroma
.
Formatter
.
parse_mentions
(
text
)
...
...
@@ -76,7 +82,7 @@ test "gives a replacement for user links" do
expected_text
=
"<span><a href='
#{
gsimg
.
ap_id
}
'>@<span>gsimg</span></a></span> According to <span><a href='
#{
archaeme
.
ap_id
"https://archeme/@
archaeme
"
}
'>@<span>archaeme</span></a></span>, that is @daggsy. Also hello <span><a href='
#{
archaeme_remote
.
ap_id
}
'>@<span>archaeme</span></a></span>"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment