ChatController: Make last_read_id mandatory.
This commit is contained in:
parent
680fa5fa36
commit
fe2a5d0614
3 changed files with 11 additions and 27 deletions
|
|
@ -340,10 +340,11 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
|||
title: "MarkAsReadRequest",
|
||||
description: "POST body for marking a number of chat messages as read",
|
||||
type: :object,
|
||||
required: [:last_read_id],
|
||||
properties: %{
|
||||
last_read_id: %Schema{
|
||||
type: :string,
|
||||
description: "The content of your message. Optional."
|
||||
description: "The content of your message."
|
||||
}
|
||||
},
|
||||
example: %{
|
||||
|
|
|
|||
|
|
@ -109,10 +109,13 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
|
|||
end
|
||||
end
|
||||
|
||||
def mark_as_read(%{assigns: %{user: %{id: user_id}}} = conn, %{id: id}) do
|
||||
def mark_as_read(
|
||||
%{body_params: %{last_read_id: last_read_id}, assigns: %{user: %{id: user_id}}} = conn,
|
||||
%{id: id}
|
||||
) do
|
||||
with %Chat{} = chat <- Repo.get_by(Chat, id: id, user_id: user_id),
|
||||
{_n, _} <-
|
||||
MessageReference.set_all_seen_for_chat(chat, conn.body_params[:last_read_id]) do
|
||||
MessageReference.set_all_seen_for_chat(chat, last_read_id) do
|
||||
conn
|
||||
|> put_view(ChatView)
|
||||
|> render("show.json", chat: chat)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue