"""
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)
"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
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)
{: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)
"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)
"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)
}
{: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