Add API to join and leave an event
This commit is contained in:
committed by
Thomas Citharel
parent
421fbda9fa
commit
250f0b3bd1
@@ -600,6 +600,16 @@ defmodule Mobilizon.Events do
|
||||
Repo.get_by!(Participant, event_id: event_id, actor_id: actor_id)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Get a single participant
|
||||
"""
|
||||
def get_participant(event_id, actor_id) do
|
||||
case Repo.get_by(Participant, event_id: event_id, actor_id: actor_id) do
|
||||
nil -> {:error, :participant_not_found}
|
||||
participant -> {:ok, participant}
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Creates a participant.
|
||||
|
||||
@@ -665,6 +675,18 @@ defmodule Mobilizon.Events do
|
||||
Participant.changeset(participant, %{})
|
||||
end
|
||||
|
||||
@doc """
|
||||
Get the default participant role depending on the event visbility
|
||||
"""
|
||||
def get_default_participant_role(%Event{} = event) do
|
||||
case event.visibility do
|
||||
# Participant
|
||||
:public -> 1
|
||||
# Not approved
|
||||
_ -> 0
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
List event participation requests for an actor
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user