Include join state in StatusView
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
3482b5d3a3
commit
4d9ddd4f4b
2 changed files with 22 additions and 6 deletions
|
@ -345,8 +345,8 @@ def join_helper(user, id, participation_message) do
|
|||
end
|
||||
end
|
||||
|
||||
def leave(%User{} = user, event_id) do
|
||||
with %Activity{} = join_activity <- Utils.get_existing_join(user, event_id),
|
||||
def leave(%User{ap_id: participant_ap_id} = user, event_id) do
|
||||
with %Activity{} = join_activity <- Utils.get_existing_join(participant_ap_id, event_id),
|
||||
{:ok, undo, _} <- Builder.undo(user, join_activity),
|
||||
{:ok, activity, _} <- Pipeline.common_pipeline(undo, local: true) do
|
||||
{:ok, activity}
|
||||
|
|
|
@ -367,6 +367,8 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
|||
|
||||
{pinned?, pinned_at} = pin_data(object, user)
|
||||
|
||||
IO.inspect(opts[:for])
|
||||
|
||||
%{
|
||||
id: to_string(activity.id),
|
||||
uri: object.data["id"],
|
||||
|
@ -418,7 +420,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
|||
pinned_at: pinned_at,
|
||||
content_type: opts[:with_source] && (object.data["content_type"] || "text/plain"),
|
||||
quotes_count: object.data["quotesCount"] || 0,
|
||||
event: build_event(object.data)
|
||||
event: build_event(object.data, opts[:for])
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -595,18 +597,20 @@ def build_emojis(emojis) do
|
|||
end)
|
||||
end
|
||||
|
||||
defp build_event(%{"type" => "Event"} = data) do
|
||||
defp build_event(%{"type" => "Event"} = data, for_user) do
|
||||
IO.inspect(for_user)
|
||||
%{
|
||||
name: data["name"],
|
||||
start_time: data["startTime"],
|
||||
end_time: data["endTime"],
|
||||
join_mode: data["joinMode"],
|
||||
participants_count: data["participation_count"],
|
||||
location: build_event_location(data["location"])
|
||||
location: build_event_location(data["location"]),
|
||||
join_state: build_event_join_state(for_user, data["id"])
|
||||
}
|
||||
end
|
||||
|
||||
defp build_event(_), do: nil
|
||||
defp build_event(_, _), do: nil
|
||||
|
||||
defp build_event_location(%{"type" => "Place", "name" => name}) do
|
||||
%{name: name}
|
||||
|
@ -614,6 +618,18 @@ defp build_event_location(%{"type" => "Place", "name" => name}) do
|
|||
|
||||
defp build_event_location(_), do: nil
|
||||
|
||||
defp build_event_join_state(%{ap_id: actor}, id) do
|
||||
IO.inspect(actor)
|
||||
IO.inspect(id)
|
||||
latest_join = Pleroma.Web.ActivityPub.Utils.get_existing_join(actor, id)
|
||||
|
||||
if latest_join do
|
||||
latest_join.data["state"]
|
||||
end
|
||||
end
|
||||
|
||||
defp build_event_join_state(_, _), do: nil
|
||||
|
||||
defp present?(nil), do: false
|
||||
defp present?(false), do: false
|
||||
defp present?(_), do: true
|
||||
|
|
Loading…
Reference in a new issue