Pleroma Conversations API: Add a way to set recipients.
This commit is contained in:
parent
eee98aaa73
commit
3af6d14da7
6 changed files with 120 additions and 2 deletions
|
|
@ -99,4 +99,24 @@ defmodule Pleroma.Conversation.Participation do
|
|||
def get(id) do
|
||||
Repo.get(__MODULE__, id)
|
||||
end
|
||||
|
||||
def set_recipients(participation, user_ids) do
|
||||
Repo.transaction(fn ->
|
||||
query =
|
||||
from(r in RecipientShip,
|
||||
where: r.participation_id == ^participation.id
|
||||
)
|
||||
|
||||
Repo.delete_all(query)
|
||||
|
||||
users =
|
||||
from(u in User,
|
||||
where: u.id in ^user_ids
|
||||
)
|
||||
|> Repo.all()
|
||||
|
||||
RecipientShip.create(users, participation)
|
||||
:ok
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue