1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Conversation.Participation.RecipientShip do
8 alias Pleroma.Conversation.Participation
14 schema "conversation_participation_recipient_ships" do
15 belongs_to(:user, User, type: FlakeId.Ecto.CompatType)
16 belongs_to(:participation, Participation)
19 def creation_cng(struct, params) do
21 |> cast(params, [:user_id, :participation_id])
22 |> validate_required([:user_id, :participation_id])
25 def create(%User{} = user, participation), do: create([user], participation)
27 def create(users, participation) do
28 Enum.each(users, fn user ->
30 |> creation_cng(%{user_id: user.id, participation_id: participation.id})