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
7e9647b1
Commit
7e9647b1
authored
Jul 08, 2017
by
lain
Browse files
Fix undo activity.
parent
e343c0c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/twitter_api/representers/activity_representer.ex
View file @
7e9647b1
...
...
@@ -72,6 +72,26 @@ def to_map(%Activity{data: %{"type" => "Follow", "published" => created_at, "obj
}
end
# TODO:
# Make this more proper. Just a placeholder to not break the frontend.
def
to_map
(%
Activity
{
data:
%{
"type"
=>
"Undo"
,
"published"
=>
created_at
,
"object"
=>
undid_activity
}}
=
activity
,
%{
user:
user
}
=
opts
)
do
created_at
=
created_at
|>
Utils
.
date_to_asctime
text
=
"
#{
user
.
nickname
}
undid the action at
#{
undid_activity
}
"
%{
"id"
=>
activity
.
id
,
"user"
=>
UserView
.
render
(
"show.json"
,
%{
user:
user
,
for:
opts
[
:for
]}),
"attentions"
=>
[],
"statusnet_html"
=>
text
,
"text"
=>
text
,
"is_local"
=>
activity
.
local
,
"is_post_verb"
=>
false
,
"created_at"
=>
created_at
,
"in_reply_to_status_id"
=>
nil
,
"external_url"
=>
activity
.
data
[
"id"
]
}
end
def
to_map
(%
Activity
{
data:
%{
"object"
=>
%{
"content"
=>
content
}
=
object
}}
=
activity
,
%{
user:
user
}
=
opts
)
do
created_at
=
object
[
"published"
]
|>
Utils
.
date_to_asctime
like_count
=
object
[
"like_count"
]
||
0
...
...
test/web/twitter_api/representers/activity_representer_test.exs
View file @
7e9647b1
...
...
@@ -132,4 +132,15 @@ test "an activity" do
assert
ActivityRepresenter
.
to_map
(
activity
,
%{
user:
user
,
for:
follower
,
mentioned:
[
mentioned_user
]})
==
expected_status
end
test
"an undo for a follow"
do
follower
=
insert
(
:user
)
followed
=
insert
(
:user
)
{
:ok
,
follow
}
=
ActivityPub
.
follow
(
follower
,
followed
)
{
:ok
,
unfollow
}
=
ActivityPub
.
unfollow
(
follower
,
followed
)
map
=
ActivityRepresenter
.
to_map
(
unfollow
,
%{
user:
follower
})
assert
map
[
"is_post_verb"
]
==
false
end
end
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