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
e90f8f6c
Commit
e90f8f6c
authored
Mar 30, 2018
by
lain
Browse files
TwApi ActivityView: Add delete activities.
parent
1f32ba05
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/twitter_api/views/activity_view.ex
View file @
e90f8f6c
...
...
@@ -8,6 +8,26 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
alias
Pleroma
.
Activity
alias
Pleroma
.
Formatter
def
render
(
"activity.json"
,
%{
activity:
%{
data:
%{
"type"
=>
"Delete"
}}
=
activity
}
=
opts
)
do
user
=
User
.
get_cached_by_ap_id
(
activity
.
data
[
"actor"
])
created_at
=
activity
.
data
[
"published"
]
|>
Utils
.
date_to_asctime
()
%{
"id"
=>
activity
.
id
,
"uri"
=>
activity
.
data
[
"object"
],
"user"
=>
UserView
.
render
(
"show.json"
,
%{
user:
user
,
for:
opts
[
:for
]}),
"attentions"
=>
[],
"statusnet_html"
=>
"deleted notice {{tag"
,
"text"
=>
"deleted notice {{tag"
,
"is_local"
=>
activity
.
local
,
"is_post_verb"
=>
false
,
"created_at"
=>
created_at
,
"in_reply_to_status_id"
=>
nil
,
"external_url"
=>
activity
.
data
[
"id"
],
"activity_type"
=>
"delete"
}
end
def
render
(
"activity.json"
,
%{
activity:
%{
data:
%{
"type"
=>
"Follow"
}}
=
activity
}
=
opts
)
do
user
=
User
.
get_cached_by_ap_id
(
activity
.
data
[
"actor"
])
created_at
=
activity
.
data
[
"published"
]
||
DateTime
.
to_iso8601
(
activity
.
inserted_at
)
...
...
test/web/twitter_api/views/activity_view_test.exs
View file @
e90f8f6c
...
...
@@ -126,7 +126,6 @@ test "A follow activity" do
user
=
insert
(
:user
)
other_user
=
insert
(
:user
,
%{
nickname:
"shp"
})
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
"status"
=>
"Hey @shp!"
})
{
:ok
,
follower
}
=
User
.
follow
(
user
,
other_user
)
{
:ok
,
follow
}
=
ActivityPub
.
follow
(
follower
,
other_user
)
...
...
@@ -148,4 +147,30 @@ test "A follow activity" do
assert
result
==
expected
end
test
"a delete activity"
do
user
=
insert
(
:user
)
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
"status"
=>
"Hey @shp!"
})
{
:ok
,
delete
}
=
CommonAPI
.
delete
(
activity
.
id
,
user
)
result
=
ActivityView
.
render
(
"activity.json"
,
activity:
delete
)
expected
=
%{
"activity_type"
=>
"delete"
,
"attentions"
=>
[],
"created_at"
=>
delete
.
data
[
"published"
]
|>
Utils
.
date_to_asctime
(),
"external_url"
=>
delete
.
data
[
"id"
],
"id"
=>
delete
.
id
,
"in_reply_to_status_id"
=>
nil
,
"is_local"
=>
true
,
"is_post_verb"
=>
false
,
"statusnet_html"
=>
"deleted notice {{tag"
,
"text"
=>
"deleted notice {{tag"
,
"uri"
=>
delete
.
data
[
"object"
],
"user"
=>
UserView
.
render
(
"show.json"
,
user:
user
)
}
assert
result
==
expected
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