Fix failing tests
This commit is contained in:
parent
18a4cbb244
commit
2bbec33c71
@ -108,17 +108,20 @@ defmodule Pleroma.Activity do
|
|||||||
%{
|
%{
|
||||||
id: data["id"],
|
id: data["id"],
|
||||||
context: data["context"],
|
context: data["context"],
|
||||||
type: "tombstone",
|
type: "Tombstone",
|
||||||
published: data["published"],
|
published: data["published"],
|
||||||
deleted: deleted
|
deleted: deleted
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def swap_data_with_tombstone(activity) do
|
def swap_data_with_tombstone(activity) do
|
||||||
tombstone = get_tombstone(activity)
|
with tombstone = get_tombstone(activity),
|
||||||
|
Notification.clear(activity),
|
||||||
activity
|
{:ok, changed_activity} =
|
||||||
|> change(%{data: tombstone})
|
activity
|
||||||
|> Repo.update()
|
|> change(%{data: tombstone})
|
||||||
|
|> Repo.update() do
|
||||||
|
{:ok, changed_activity}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -75,10 +75,14 @@ defmodule Pleroma.Notification do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear(user) do
|
def clear(%User{} = user) do
|
||||||
query = from(n in Notification, where: n.user_id == ^user.id)
|
from(n in Notification, where: n.user_id == ^user.id)
|
||||||
|
|> Repo.delete_all()
|
||||||
|
end
|
||||||
|
|
||||||
Repo.delete_all(query)
|
def clear(%Activity{} = activity) do
|
||||||
|
from(n in Notification, where: n.activity_id == ^activity.id)
|
||||||
|
|> Repo.delete_all()
|
||||||
end
|
end
|
||||||
|
|
||||||
def dismiss(%{id: user_id} = _user, id) do
|
def dismiss(%{id: user_id} = _user, id) do
|
||||||
|
@ -586,7 +586,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do
|
def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do
|
||||||
with false <- String.starts_with?(inReplyTo, "http"),
|
with false <- is_nil(inReplyTo),
|
||||||
|
false <- String.starts_with?(inReplyTo, "http"),
|
||||||
{:ok, %{data: replied_to_object}} <- get_obj_helper(inReplyTo) do
|
{:ok, %{data: replied_to_object}} <- get_obj_helper(inReplyTo) do
|
||||||
Map.put(object, "inReplyTo", replied_to_object["external_url"] || inReplyTo)
|
Map.put(object, "inReplyTo", replied_to_object["external_url"] || inReplyTo)
|
||||||
else
|
else
|
||||||
|
@ -31,7 +31,7 @@ defmodule Pleroma.ActivityTest do
|
|||||||
deleted = DateTime.utc_now()
|
deleted = DateTime.utc_now()
|
||||||
|
|
||||||
assert Pleroma.Activity.get_tombstone(activity, deleted) == %{
|
assert Pleroma.Activity.get_tombstone(activity, deleted) == %{
|
||||||
id: activity.data["object"]["id"],
|
id: activity.data["id"],
|
||||||
context: activity.data["context"],
|
context: activity.data["context"],
|
||||||
type: "Tombstone",
|
type: "Tombstone",
|
||||||
published: activity.data["published"],
|
published: activity.data["published"],
|
||||||
|
@ -23,9 +23,9 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
|
|||||||
|
|
||||||
{:ok, [delete]} = OStatus.handle_incoming(incoming)
|
{:ok, [delete]} = OStatus.handle_incoming(incoming)
|
||||||
|
|
||||||
refute Repo.get(Activity, note.id)
|
assert Repo.get(Activity, note.id).data["type"] == "Tombstone"
|
||||||
refute Repo.get(Activity, like.id)
|
assert Repo.get(Activity, like.id).data["type"] == "Tombstone"
|
||||||
refute Object.get_by_ap_id(note.data["object"]["id"])
|
assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone"
|
||||||
assert Repo.get(Activity, second_note.id)
|
assert Repo.get(Activity, second_note.id)
|
||||||
assert Object.get_by_ap_id(second_note.data["object"]["id"])
|
assert Object.get_by_ap_id(second_note.data["object"]["id"])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user