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
19b6a823
Commit
19b6a823
authored
Jan 11, 2019
by
kaniini
Browse files
Merge branch 'bugfix/pinned-statuses' into 'develop'
Unpin when deleting a status See merge request
pleroma/pleroma!655
parents
eeb9e632
728587fd
Pipeline
#6176
passed with stages
in 3 minutes and 30 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/common_api/common_api.ex
View file @
19b6a823
...
...
@@ -14,6 +14,7 @@ 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
<-
user
.
info
.
is_moderator
||
user
.
ap_id
==
object
.
data
[
"actor"
],
{
:ok
,
_
}
<-
unpin
(
activity_id
,
user
),
{
:ok
,
delete
}
<-
ActivityPub
.
delete
(
object
)
do
{
:ok
,
delete
}
end
...
...
test/web/common_api/common_api_test.exs
View file @
19b6a823
...
...
@@ -109,6 +109,11 @@ test "favoriting a status twice returns an error" do
test
"pin status"
,
%{
user:
user
,
activity:
activity
}
do
assert
{
:ok
,
^
activity
}
=
CommonAPI
.
pin
(
activity
.
id
,
user
)
id
=
activity
.
id
user
=
refresh_record
(
user
)
assert
%
User
{
info:
%{
pinned_activities:
[
^
id
]}}
=
user
end
test
"only self-authored can be pinned"
,
%{
activity:
activity
}
do
...
...
@@ -131,7 +136,25 @@ test "max pinned statuses", %{user: user, activity: activity_one} do
test
"unpin status"
,
%{
user:
user
,
activity:
activity
}
do
{
:ok
,
activity
}
=
CommonAPI
.
pin
(
activity
.
id
,
user
)
user
=
refresh_record
(
user
)
assert
{
:ok
,
^
activity
}
=
CommonAPI
.
unpin
(
activity
.
id
,
user
)
user
=
refresh_record
(
user
)
assert
%
User
{
info:
%{
pinned_activities:
[]}}
=
user
end
test
"should unpin when deleting a status"
,
%{
user:
user
,
activity:
activity
}
do
{
:ok
,
activity
}
=
CommonAPI
.
pin
(
activity
.
id
,
user
)
user
=
refresh_record
(
user
)
assert
{
:ok
,
_
}
=
CommonAPI
.
delete
(
activity
.
id
,
user
)
user
=
refresh_record
(
user
)
assert
%
User
{
info:
%{
pinned_activities:
[]}}
=
user
end
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