mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 16:40:29 +00:00
Merge branch 'fix/unpinnable-polls' into 'develop'
fix not being able to pin polls See merge request pleroma/pleroma!2172
This commit is contained in:
commit
15cb1f6804
2 changed files with 17 additions and 1 deletions
|
@ -315,8 +315,9 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
with %Activity{
|
with %Activity{
|
||||||
actor: ^user_ap_id,
|
actor: ^user_ap_id,
|
||||||
data: %{"type" => "Create"},
|
data: %{"type" => "Create"},
|
||||||
object: %Object{data: %{"type" => "Note"}}
|
object: %Object{data: %{"type" => object_type}}
|
||||||
} = activity <- get_by_id_or_ap_id(id_or_ap_id),
|
} = activity <- get_by_id_or_ap_id(id_or_ap_id),
|
||||||
|
true <- object_type in ["Note", "Article", "Question"],
|
||||||
true <- Visibility.is_public?(activity),
|
true <- Visibility.is_public?(activity),
|
||||||
{:ok, _user} <- User.add_pinnned_activity(user, activity) do
|
{:ok, _user} <- User.add_pinnned_activity(user, activity) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
|
|
|
@ -324,6 +324,21 @@ defmodule Pleroma.Web.CommonAPITest do
|
||||||
assert %User{pinned_activities: [^id]} = user
|
assert %User{pinned_activities: [^id]} = user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "pin poll", %{user: user} do
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post(user, %{
|
||||||
|
"status" => "How is fediverse today?",
|
||||||
|
"poll" => %{"options" => ["Absolutely outstanding", "Not good"], "expires_in" => 20}
|
||||||
|
})
|
||||||
|
|
||||||
|
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
||||||
|
|
||||||
|
id = activity.id
|
||||||
|
user = refresh_record(user)
|
||||||
|
|
||||||
|
assert %User{pinned_activities: [^id]} = user
|
||||||
|
end
|
||||||
|
|
||||||
test "unlisted statuses can be pinned", %{user: user} do
|
test "unlisted statuses can be pinned", %{user: user} do
|
||||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!", "visibility" => "unlisted"})
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!", "visibility" => "unlisted"})
|
||||||
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
||||||
|
|
Loading…
Reference in a new issue