{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
{:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
{:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
{:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
{:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)
assert cm_ref.unread == true
cm_ref = MessageReference.for_chat_and_object(chat, object)
assert cm_ref.unread == true
{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
{:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
{:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
{:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
{:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)
assert cm_ref.unread == true
cm_ref = MessageReference.for_chat_and_object(chat, object)
assert cm_ref.unread == true
file = %Plug.Upload{
content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
file = %Plug.Upload{
content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
{:ok, other_message} = CommonAPI.post_chat_message(recipient, user, "nico nico ni")
{:ok, other_message} = CommonAPI.post_chat_message(recipient, user, "nico nico ni")
assert %{data: %{"type" => "Tombstone"}} = Object.get_by_id(object.id)
# Deleting other people's messages just removes the reference
assert %{data: %{"type" => "Tombstone"}} = Object.get_by_id(object.id)
# Deleting other people's messages just removes the reference
setup do: oauth_access(["read:chats"])
test "it does not return chats with deleted users", %{conn: conn, user: user} do
setup do: oauth_access(["read:chats"])
test "it does not return chats with deleted users", %{conn: conn, user: user} do
Enum.each(1..30, fn _ ->
recipient = insert(:user)
{:ok, _} = Chat.get_or_create(user.id, recipient.ap_id)
Enum.each(1..30, fn _ ->
recipient = insert(:user)
{:ok, _} = Chat.get_or_create(user.id, recipient.ap_id)
- assert length(result) == 30
+ assert length(result) == 20
+ last_id = List.last(result)["id"]
+
+ result =
+ conn
+ |> get("/api/v2/pleroma/chats?max_id=#{last_id}")
+ |> json_response_and_validate_schema(200)
+
+ assert length(result) == 10
end
test "it return a list of chats the current user is participating in, in descending order of updates",
end
test "it return a list of chats the current user is participating in, in descending order of updates",
- :timer.sleep(1000)
- {:ok, _chat_2} = Chat.get_or_create(user.id, jafnhar.ap_id)
- :timer.sleep(1000)
+ {:ok, chat_1} = time_travel(chat_1, -3)
+ {:ok, chat_2} = Chat.get_or_create(user.id, jafnhar.ap_id)
+ {:ok, _chat_2} = time_travel(chat_2, -2)
|> json_response_and_validate_schema(200)
ids = Enum.map(result, & &1["id"])
|> json_response_and_validate_schema(200)
ids = Enum.map(result, & &1["id"])
|> json_response_and_validate_schema(200)
account_ids = Enum.map(result, &get_in(&1, ["account", "id"]))
|> json_response_and_validate_schema(200)
account_ids = Enum.map(result, &get_in(&1, ["account", "id"]))