unpin when deleting a status
This commit is contained in:
parent
e4b2cfa7b5
commit
b594a54d0c
@ -14,6 +14,7 @@ defmodule Pleroma.Web.CommonAPI do
|
|||||||
with %Activity{data: %{"object" => %{"id" => object_id}}} <- Repo.get(Activity, activity_id),
|
with %Activity{data: %{"object" => %{"id" => object_id}}} <- Repo.get(Activity, activity_id),
|
||||||
%Object{} = object <- Object.normalize(object_id),
|
%Object{} = object <- Object.normalize(object_id),
|
||||||
true <- user.info.is_moderator || user.ap_id == object.data["actor"],
|
true <- user.info.is_moderator || user.ap_id == object.data["actor"],
|
||||||
|
{:ok, _} <- unpin(activity_id, user),
|
||||||
{:ok, delete} <- ActivityPub.delete(object) do
|
{:ok, delete} <- ActivityPub.delete(object) do
|
||||||
{:ok, delete}
|
{:ok, delete}
|
||||||
end
|
end
|
||||||
|
@ -109,6 +109,11 @@ defmodule Pleroma.Web.CommonAPI.Test do
|
|||||||
|
|
||||||
test "pin status", %{user: user, activity: activity} do
|
test "pin status", %{user: user, activity: activity} do
|
||||||
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
||||||
|
|
||||||
|
id = activity.id
|
||||||
|
user = refresh_record(user)
|
||||||
|
|
||||||
|
assert %User{info: %{pinned_activities: [^id]}} = user
|
||||||
end
|
end
|
||||||
|
|
||||||
test "only self-authored can be pinned", %{activity: activity} do
|
test "only self-authored can be pinned", %{activity: activity} do
|
||||||
@ -131,7 +136,25 @@ defmodule Pleroma.Web.CommonAPI.Test do
|
|||||||
test "unpin status", %{user: user, activity: activity} do
|
test "unpin status", %{user: user, activity: activity} do
|
||||||
{:ok, activity} = CommonAPI.pin(activity.id, user)
|
{:ok, activity} = CommonAPI.pin(activity.id, user)
|
||||||
|
|
||||||
|
user = refresh_record(user)
|
||||||
|
|
||||||
assert {:ok, ^activity} = CommonAPI.unpin(activity.id, user)
|
assert {:ok, ^activity} = CommonAPI.unpin(activity.id, user)
|
||||||
|
|
||||||
|
user = refresh_record(user)
|
||||||
|
|
||||||
|
assert %User{info: %{pinned_activities: []}} = user
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should unpin status 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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user