Add API to join and leave an event

This commit is contained in:
Chocobozzz
2019-02-01 15:38:35 +01:00
committed by Thomas Citharel
parent 421fbda9fa
commit 250f0b3bd1
12 changed files with 430 additions and 74 deletions

View File

@@ -138,15 +138,10 @@ defmodule Mobilizon.Actors.User do
{:ok, user}
end
def owns_actor(%User{default_actor_id: default_actor_id}, %Actor{id: actor_id})
when default_actor_id == actor_id do
{:is_owned, true}
end
def owns_actor(%User{actors: actors}, actor_id) do
case Enum.any?(actors, fn a -> a.id == actor_id end) do
true -> {:is_owned, true}
_ -> {:is_owned, false}
case Enum.find(actors, fn a -> a.id == actor_id end) do
nil -> {:is_owned, false}
actor -> {:is_owned, true, actor}
end
end
end