Commit 8af55728 authored by Roman Chvanikov's avatar Roman Chvanikov Committed by lain

Fix tests

parent 45f790be
......@@ -47,9 +47,10 @@ defmodule Pleroma.Conversation do
"""
def create_or_bump_for(activity) do
with true <- Pleroma.Web.ActivityPub.Visibility.is_direct?(activity),
object <- Pleroma.Object.normalize(activity),
"Create" <- activity.data["type"],
"Note" <- activity.data["object"]["type"],
ap_id when is_binary(ap_id) <- activity.data["object"]["context"] do
"Note" <- object.data["type"],
ap_id when is_binary(ap_id) and byte_size(ap_id) > 0 <- object.data["context"] do
{:ok, conversation} = create_for_ap_id(ap_id)
users = User.get_users_from_set(activity.recipients, false)
......
......@@ -67,24 +67,22 @@ defmodule Pleroma.Conversation.ParticipationTest do
"in_reply_to_status_id" => activity_one.id
})
assert [participation_one, participation_two] =
Participation.for_user(user)
|> Repo.preload(:conversation)
assert [participation_one, participation_two] = Participation.for_user(user)
assert participation_one.conversation.ap_id == activity_three.data["object"]["context"]
assert participation_two.conversation.ap_id == activity_two.data["object"]["context"]
object2 = Pleroma.Object.normalize(activity_two)
object3 = Pleroma.Object.normalize(activity_three)
assert participation_one.conversation.ap_id == object3.data["context"]
assert participation_two.conversation.ap_id == object2.data["context"]
# Pagination
assert [participation_one] =
Participation.for_user(user, %{limit: 1})
|> Repo.preload(:conversation)
assert [participation_one] = Participation.for_user(user, %{"limit" => 1})
assert participation_one.conversation.ap_id == activity_three.data["object"]["context"]
assert participation_one.conversation.ap_id == object3.data["context"]
# With last_activity_id
assert [participation_one] =
Participation.for_user_with_last_activity_id(user, %{limit: 1})
|> Repo.preload(:conversation)
Participation.for_user_with_last_activity_id(user, %{"limit" => 1})
assert participation_one.last_activity_id == activity_three.id
end
......
......@@ -22,7 +22,8 @@ defmodule Pleroma.ConversationTest do
user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey"})
context = activity.data["object"]["context"]
object = Pleroma.Object.normalize(activity)
context = object.data["context"]
conversation = Conversation.get_for_ap_id(context)
......@@ -37,7 +38,8 @@ defmodule Pleroma.ConversationTest do
{:ok, activity} =
CommonAPI.post(har, %{"status" => "Hey @#{jafnhar.nickname}", "visibility" => "direct"})
context = activity.data["object"]["context"]
object = Pleroma.Object.normalize(activity)
context = object.data["context"]
conversation =
Conversation.get_for_ap_id(context)
......@@ -58,7 +60,8 @@ defmodule Pleroma.ConversationTest do
"in_reply_to_status_id" => activity.id
})
context = activity.data["object"]["context"]
object = Pleroma.Object.normalize(activity)
context = object.data["context"]
conversation_two =
Conversation.get_for_ap_id(context)
......@@ -81,7 +84,8 @@ defmodule Pleroma.ConversationTest do
"in_reply_to_status_id" => activity.id
})
context = activity.data["object"]["context"]
object = Pleroma.Object.normalize(activity)
context = object.data["context"]
conversation_three =
Conversation.get_for_ap_id(context)
......
......@@ -208,11 +208,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
}
{:ok, %Activity{} = activity} = ActivityPub.insert(data)
object = Pleroma.Object.normalize(activity)
assert is_binary(activity.data["context"])
assert is_binary(activity.data["object"]["context"])
assert is_binary(object.data["context"])
assert activity.data["context_id"]
assert activity.data["object"]["context_id"]
assert object.data["context_id"]
end
test "adds an id to a given object if it lacks one and is a note and inserts it to the object database" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment