Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pleroma
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hécate
pleroma
Commits
6bd7070b
Commit
6bd7070b
authored
May 25, 2020
by
lain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transmogrifier: Use a simpler way to get mentions.
parent
5fef4052
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
17 deletions
+26
-17
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
+7
-3
test/web/activity_pub/transmogrifier_test.exs
test/web/activity_pub/transmogrifier_test.exs
+19
-14
No files found.
lib/pleroma/web/activity_pub/transmogrifier.ex
View file @
6bd7070b
...
...
@@ -1045,10 +1045,14 @@ def add_hashtags(object) do
Map
.
put
(
object
,
"tag"
,
tags
)
end
# TODO These should be added on our side on insertion, it doesn't make much
# sense to regenerate these all the time
def
add_mention_tags
(
object
)
do
{
enabled_receivers
,
disabled_receivers
}
=
Utils
.
get_notified_from_object
(
object
)
potential_receivers
=
enabled_receivers
++
disabled_receivers
mentions
=
Enum
.
map
(
potential_receivers
,
&
build_mention_tag
/
1
)
to
=
object
[
"to"
]
||
[]
cc
=
object
[
"cc"
]
||
[]
mentioned
=
User
.
get_users_from_set
(
to
++
cc
,
local_only:
false
)
mentions
=
Enum
.
map
(
mentioned
,
&
build_mention_tag
/
1
)
tags
=
object
[
"tag"
]
||
[]
Map
.
put
(
object
,
"tag"
,
tags
++
mentions
)
...
...
test/web/activity_pub/transmogrifier_test.exs
View file @
6bd7070b
...
...
@@ -1094,23 +1094,28 @@ test "it turns mentions into tags" do
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
status:
"hey, @
#{
other_user
.
nickname
}
, how are ya? #2hu"
})
{
:ok
,
modified
}
=
Transmogrifier
.
prepare_outgoing
(
activity
.
data
)
object
=
modified
[
"object"
]
with_mock
Pleroma
.
Notification
,
get_notified_from_activity:
fn
_
,
_
->
[]
end
do
{
:ok
,
modified
}
=
Transmogrifier
.
prepare_outgoing
(
activity
.
data
)
expected_mention
=
%{
"href"
=>
other_user
.
ap_id
,
"name"
=>
"@
#{
other_user
.
nickname
}
"
,
"type"
=>
"Mention"
}
object
=
modified
[
"object"
]
expected_tag
=
%{
"href"
=>
Pleroma
.
Web
.
Endpoint
.
url
()
<>
"/tags/2hu"
,
"type"
=>
"Hashtag
"
,
"name"
=>
"#2hu
"
}
expected_mention
=
%{
"href"
=>
other_user
.
ap_id
,
"name"
=>
"@
#{
other_user
.
nickname
}
"
,
"type"
=>
"Mention
"
}
assert
Enum
.
member?
(
object
[
"tag"
],
expected_tag
)
assert
Enum
.
member?
(
object
[
"tag"
],
expected_mention
)
expected_tag
=
%{
"href"
=>
Pleroma
.
Web
.
Endpoint
.
url
()
<>
"/tags/2hu"
,
"type"
=>
"Hashtag"
,
"name"
=>
"#2hu"
}
refute
called
(
Pleroma
.
Notification
.
get_notified_from_activity
(
:_
,
:_
))
assert
Enum
.
member?
(
object
[
"tag"
],
expected_tag
)
assert
Enum
.
member?
(
object
[
"tag"
],
expected_mention
)
end
end
test
"it adds the sensitive property"
do
...
...
Write
Preview
Markdown
is supported
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