Skip to content
GitLab
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
2827dfea
Commit
2827dfea
authored
Mar 08, 2019
by
Eugenij
Browse files
Allow an admin to delete a user status
parent
3c04460c
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/common_api/common_api.ex
View file @
2827dfea
...
...
@@ -30,7 +30,7 @@ def follow(follower, followed) do
def
delete
(
activity_id
,
user
)
do
with
%
Activity
{
data:
%{
"object"
=>
%{
"id"
=>
object_id
}}}
<-
Repo
.
get
(
Activity
,
activity_id
),
%
Object
{}
=
object
<-
Object
.
normalize
(
object_id
),
true
<-
u
ser
.
info
.
is_moderator
||
user
.
ap_id
==
object
.
data
[
"actor"
],
true
<-
U
ser
.
superuser?
(
user
)
||
user
.
ap_id
==
object
.
data
[
"actor"
],
{
:ok
,
_
}
<-
unpin
(
activity_id
,
user
),
{
:ok
,
delete
}
<-
ActivityPub
.
delete
(
object
)
do
{
:ok
,
delete
}
...
...
test/web/mastodon_api/mastodon_api_controller_test.exs
View file @
2827dfea
...
...
@@ -371,6 +371,30 @@ test "when you didn't create it", %{conn: conn} do
assert
Repo
.
get
(
Activity
,
activity
.
id
)
==
activity
end
test
"when you're an admin or moderator"
,
%{
conn:
conn
}
do
activity1
=
insert
(
:note_activity
)
activity2
=
insert
(
:note_activity
)
admin
=
insert
(
:user
,
info:
%{
is_admin:
true
})
moderator
=
insert
(
:user
,
info:
%{
is_moderator:
true
})
res_conn
=
conn
|>
assign
(
:user
,
admin
)
|>
delete
(
"/api/v1/statuses/
#{
activity1
.
id
}
"
)
assert
%{}
=
json_response
(
res_conn
,
200
)
res_conn
=
conn
|>
assign
(
:user
,
moderator
)
|>
delete
(
"/api/v1/statuses/
#{
activity2
.
id
}
"
)
assert
%{}
=
json_response
(
res_conn
,
200
)
refute
Repo
.
get
(
Activity
,
activity1
.
id
)
refute
Repo
.
get
(
Activity
,
activity2
.
id
)
end
end
describe
"filters"
do
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment