mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-30 01:01:12 +00:00
c4439c630f
grep -rl '# Copyright © .* Pleroma' * | xargs sed -i 's;Copyright © .* Pleroma .*;Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>;'
35 lines
975 B
Elixir
35 lines
975 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Conversation.Participation.RecipientShip do
|
|
use Ecto.Schema
|
|
|
|
alias Pleroma.Conversation.Participation
|
|
alias Pleroma.Repo
|
|
alias Pleroma.User
|
|
|
|
import Ecto.Changeset
|
|
|
|
schema "conversation_participation_recipient_ships" do
|
|
belongs_to(:user, User, type: FlakeId.Ecto.CompatType)
|
|
belongs_to(:participation, Participation)
|
|
end
|
|
|
|
def creation_cng(struct, params) do
|
|
struct
|
|
|> cast(params, [:user_id, :participation_id])
|
|
|> validate_required([:user_id, :participation_id])
|
|
end
|
|
|
|
def create(%User{} = user, participation), do: create([user], participation)
|
|
|
|
def create(users, participation) do
|
|
Enum.each(users, fn user ->
|
|
%__MODULE__{}
|
|
|> creation_cng(%{user_id: user.id, participation_id: participation.id})
|
|
|> Repo.insert!()
|
|
end)
|
|
end
|
|
end
|