Merge branch 'feature/participate-dropdown' into 'master'

Add a dropdown on participate menu, disallow listing participations

Closes #174

See merge request framasoft/mobilizon!200
This commit is contained in:
Thomas Citharel
2019-09-26 17:41:14 +02:00
34 changed files with 655 additions and 439 deletions

View File

@@ -122,14 +122,18 @@ defmodule Mobilizon.Service.Export.Feed do
%FeedToken{actor: actor, user: %User{} = user} <- Events.get_feed_token(token) do
case actor do
%Actor{} = actor ->
events = fetch_identity_going_to_events(actor)
events = actor |> fetch_identity_participations() |> participations_to_events()
{:ok, build_actor_feed(actor, events, false)}
nil ->
with actors <- Users.get_actors_for_user(user),
events <-
actors
|> Enum.map(&Events.list_event_participations_for_actor/1)
|> Enum.map(fn actor ->
actor
|> Events.list_event_participations_for_actor()
|> participations_to_events()
end)
|> Enum.concat() do
{:ok, build_user_feed(events, user, token)}
end
@@ -137,12 +141,18 @@ defmodule Mobilizon.Service.Export.Feed do
end
end
defp fetch_identity_going_to_events(%Actor{} = actor) do
defp fetch_identity_participations(%Actor{} = actor) do
with events <- Events.list_event_participations_for_actor(actor) do
events
end
end
defp participations_to_events(participations) do
participations
|> Enum.map(& &1.event_id)
|> Enum.map(&Events.get_event_with_preload!/1)
end
# Build an atom feed from actor and it's public events
@spec build_user_feed(list(), User.t(), String.t()) :: String.t()
defp build_user_feed(events, %User{email: email}, token) do

View File

@@ -33,7 +33,7 @@ defmodule Mobilizon.Service.Export.ICalendar do
dtend: event.ends_on,
description: event.description,
uid: event.uuid,
categories: [event.category] ++ (event.tags |> Enum.map(& &1.slug))
categories: event.tags |> Enum.map(& &1.slug)
}
end
@@ -52,7 +52,8 @@ defmodule Mobilizon.Service.Export.ICalendar do
@spec export_private_actor(Actor.t()) :: String.t()
def export_private_actor(%Actor{} = actor) do
with events <- Events.list_event_participations_for_actor(actor) do
with events <-
actor |> Events.list_event_participations_for_actor() |> participations_to_events() do
{:ok, %ICalendar{events: events |> Enum.map(&do_export_event/1)} |> ICalendar.to_ics()}
end
end
@@ -107,7 +108,11 @@ defmodule Mobilizon.Service.Export.ICalendar do
with actors <- Users.get_actors_for_user(user),
events <-
actors
|> Enum.map(&Events.list_event_participations_for_actor/1)
|> Enum.map(fn actor ->
actor
|> Events.list_event_participations_for_actor()
|> participations_to_events()
end)
|> Enum.concat() do
{:ok,
%ICalendar{events: events |> Enum.map(&do_export_event/1)} |> ICalendar.to_ics()}
@@ -115,4 +120,10 @@ defmodule Mobilizon.Service.Export.ICalendar do
end
end
end
defp participations_to_events(participations) do
participations
|> Enum.map(& &1.event_id)
|> Enum.map(&Events.get_event_with_preload!/1)
end
end