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
a3e82c5c
Commit
a3e82c5c
authored
May 02, 2017
by
lain
Browse files
Save context in likes / announces.
parent
16f8406e
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/activity_pub/activity_pub.ex
View file @
a3e82c5c
...
...
@@ -55,7 +55,8 @@ def like(%User{ap_id: ap_id} = user, %Object{data: %{ "id" => id}} = object) do
"type"
=>
"Like"
,
"actor"
=>
ap_id
,
"object"
=>
id
,
"to"
=>
[
User
.
ap_followers
(
user
),
object
.
data
[
"actor"
]]
"to"
=>
[
User
.
ap_followers
(
user
),
object
.
data
[
"actor"
]],
"context"
=>
object
.
data
[
"context"
]
}
{
:ok
,
activity
}
=
insert
(
data
)
...
...
@@ -177,7 +178,8 @@ def announce(%User{ap_id: ap_id} = user, %Object{data: %{"id" => id}} = object)
"type"
=>
"Announce"
,
"actor"
=>
ap_id
,
"object"
=>
id
,
"to"
=>
[
User
.
ap_followers
(
user
),
object
.
data
[
"actor"
]]
"to"
=>
[
User
.
ap_followers
(
user
),
object
.
data
[
"actor"
]],
"context"
=>
object
.
data
[
"context"
]
}
{
:ok
,
activity
}
=
insert
(
data
)
...
...
test/web/activity_pub/activity_pub_test.exs
View file @
a3e82c5c
...
...
@@ -125,6 +125,7 @@ test "adds a like activity to the db" do
assert
like_activity
.
data
[
"type"
]
==
"Like"
assert
like_activity
.
data
[
"object"
]
==
object
.
data
[
"id"
]
assert
like_activity
.
data
[
"to"
]
==
[
User
.
ap_followers
(
user
),
note_activity
.
data
[
"actor"
]]
assert
like_activity
.
data
[
"context"
]
==
object
.
data
[
"context"
]
assert
object
.
data
[
"like_count"
]
==
1
assert
object
.
data
[
"likes"
]
==
[
user
.
ap_id
]
...
...
@@ -174,6 +175,7 @@ test "adds an announce activity to the db" do
assert
announce_activity
.
data
[
"to"
]
==
[
User
.
ap_followers
(
user
),
note_activity
.
data
[
"actor"
]]
assert
announce_activity
.
data
[
"object"
]
==
object
.
data
[
"id"
]
assert
announce_activity
.
data
[
"actor"
]
==
user
.
ap_id
assert
announce_activity
.
data
[
"context"
]
==
object
.
data
[
"context"
]
end
end
...
...
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