Participations: Add marking as read and unread.
This commit is contained in:
parent
d1da6b155a
commit
64c1c3a407
3 changed files with 43 additions and 0 deletions
|
|
@ -28,4 +28,22 @@ defmodule Pleroma.Conversation.Participation do
|
|||
|> creation_cng(%{user_id: user.id, conversation_id: conversation.id})
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
def read_cng(struct, params) do
|
||||
struct
|
||||
|> cast(params, [:read])
|
||||
|> validate_required([:read])
|
||||
end
|
||||
|
||||
def mark_as_read(participation) do
|
||||
participation
|
||||
|> read_cng(%{read: true})
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
def mark_as_unread(participation) do
|
||||
participation
|
||||
|> read_cng(%{read: false})
|
||||
|> Repo.update()
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue