CommonAPI: Don't make repeating announces possible
This commit is contained in:
parent
6e0b046771
commit
2e58fe08cd
4 changed files with 30 additions and 53 deletions
|
|
@ -268,6 +268,16 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
{:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user)
|
||||
end
|
||||
|
||||
test "can't repeat a repeat" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
|
||||
{:ok, %Activity{} = announce, _} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
refute match?({:ok, %Activity{}, _}, CommonAPI.repeat(announce.id, user))
|
||||
end
|
||||
|
||||
test "repeating a status privately" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
|
@ -294,8 +304,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, %Activity{} = activity, object} = CommonAPI.repeat(activity.id, user)
|
||||
{:ok, ^activity, ^object} = CommonAPI.repeat(activity.id, user)
|
||||
{:ok, %Activity{} = announce, object} = CommonAPI.repeat(activity.id, user)
|
||||
{:ok, ^announce, ^object} = CommonAPI.repeat(activity.id, user)
|
||||
end
|
||||
|
||||
test "favoriting a status twice returns the status" do
|
||||
|
|
@ -369,7 +379,9 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
user = refresh_record(user)
|
||||
|
||||
assert {:ok, ^activity} = CommonAPI.unpin(activity.id, user)
|
||||
id = activity.id
|
||||
|
||||
assert match?({:ok, %{id: ^id}}, CommonAPI.unpin(activity.id, user))
|
||||
|
||||
user = refresh_record(user)
|
||||
|
||||
|
|
|
|||
|
|
@ -358,26 +358,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "get_by_id_or_ap_id/1" do
|
||||
test "get activity by id" do
|
||||
activity = insert(:note_activity)
|
||||
%Pleroma.Activity{} = note = Utils.get_by_id_or_ap_id(activity.id)
|
||||
assert note.id == activity.id
|
||||
end
|
||||
|
||||
test "get activity by ap_id" do
|
||||
activity = insert(:note_activity)
|
||||
%Pleroma.Activity{} = note = Utils.get_by_id_or_ap_id(activity.data["object"])
|
||||
assert note.id == activity.id
|
||||
end
|
||||
|
||||
test "get activity by object when type isn't `Create` " do
|
||||
activity = insert(:like_activity)
|
||||
%Pleroma.Activity{} = like = Utils.get_by_id_or_ap_id(activity.id)
|
||||
assert like.data["object"] == activity.data["object"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "to_master_date/1" do
|
||||
test "removes microseconds from date (NaiveDateTime)" do
|
||||
assert Utils.to_masto_date(~N[2015-01-23 23:50:07.123]) == "2015-01-23T23:50:07.000Z"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue