ChatController: Add last_read_id option to mark_as_read.
This commit is contained in:
parent
2cdaac4330
commit
801e668a97
4 changed files with 58 additions and 7 deletions
|
|
@ -65,6 +65,30 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
|
|||
|
||||
assert cm_ref.unread == false
|
||||
end
|
||||
|
||||
test "it given a `last_read_id` ", %{conn: conn, user: user} do
|
||||
other_user = insert(:user)
|
||||
|
||||
{: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)
|
||||
object = Object.normalize(create, false)
|
||||
cm_ref = MessageReference.for_chat_and_object(chat, object)
|
||||
|
||||
assert cm_ref.unread == true
|
||||
|
||||
result =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/pleroma/chats/#{chat.id}/read", %{"last_read_id" => cm_ref.id})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert result["unread"] == 1
|
||||
|
||||
cm_ref = MessageReference.for_chat_and_object(chat, object)
|
||||
|
||||
assert cm_ref.unread == false
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /api/v1/pleroma/chats/:id/messages" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue