Add backend for group invitations

For #887
This commit is contained in:
Massedil
2025-11-04 18:00:41 +01:00
committed by setop
parent 249c5bf178
commit bb71ec763c
6 changed files with 196 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
defmodule Mobilizon.Invitation do
@moduledoc """
Represents a local invitation to a group.
"""
use Ecto.Schema
import Ecto.Changeset
alias Mobilizon.Actors.Actor
schema "invitations" do
# We need read_after_writes because the uuid is generated by
# the database gen_random_uuid() function
field :token, :string, read_after_writes: true
# label can't be NULL in database
# default: "" permit to set it to "" if label is nil
field :label, :string, default: ""
belongs_to :group, Actor
timestamps()
end
def changeset(invitation, attrs) do
invitation
|> cast(attrs, [:label, :group_id])
|> validate_required([:group_id])
end
end