Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alex Gleason
pleroma
Commits
6acbe45e
Commit
6acbe45e
authored
4 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Builder: Extract common features of likes and reactions.
parent
ef55d240
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/web/activity_pub/builder.ex
+12
-2
12 additions, 2 deletions
lib/pleroma/web/activity_pub/builder.ex
with
12 additions
and
2 deletions
lib/pleroma/web/activity_pub/builder.ex
+
12
−
2
View file @
6acbe45e
...
...
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
@spec
emoji_react
(
User
.
t
(),
Object
.
t
(),
String
.
t
())
::
{
:ok
,
map
(),
keyword
()}
def
emoji_react
(
actor
,
object
,
emoji
)
do
with
{
:ok
,
data
,
meta
}
<-
like
(
actor
,
object
)
do
with
{
:ok
,
data
,
meta
}
<-
object_action
(
actor
,
object
)
do
data
=
data
|>
Map
.
put
(
"content"
,
emoji
)
...
...
@@ -64,6 +64,17 @@ def delete(actor, object_id) do
@spec
like
(
User
.
t
(),
Object
.
t
())
::
{
:ok
,
map
(),
keyword
()}
def
like
(
actor
,
object
)
do
with
{
:ok
,
data
,
meta
}
<-
object_action
(
actor
,
object
)
do
data
=
data
|>
Map
.
put
(
"type"
,
"Like"
)
{
:ok
,
data
,
meta
}
end
end
@spec
object_action
(
User
.
t
(),
Object
.
t
())
::
{
:ok
,
map
(),
keyword
()}
defp
object_action
(
actor
,
object
)
do
object_actor
=
User
.
get_cached_by_ap_id
(
object
.
data
[
"actor"
])
# Address the actor of the object, and our actor's follower collection if the post is public.
...
...
@@ -85,7 +96,6 @@ def like(actor, object) do
%{
"id"
=>
Utils
.
generate_activity_id
(),
"actor"
=>
actor
.
ap_id
,
"type"
=>
"Like"
,
"object"
=>
object
.
data
[
"id"
],
"to"
=>
to
,
"cc"
=>
cc
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment