alias Pleroma.Conversation.Participation
alias Pleroma.Web.ActivityPub.ActivityPub
+ alias Pleroma.Web.MastodonAPI.ConversationView
alias Pleroma.Web.MastodonAPI.StatusView
- alias Pleroma.Repo
+
+ def conversation(%{assigns: %{user: user}} = conn, %{"id" => participation_id}) do
+ with %Participation{} = participation <- Participation.get(participation_id),
+ true <- user.id == participation.user_id do
+ conn
+ |> put_view(ConversationView)
+ |> render("participation.json", %{participation: participation, for: user})
+ end
+ end
def conversation_statuses(
%{assigns: %{user: user}} = conn,
participation =
participation_id
- |> Participation.get()
- |> Repo.preload(:conversation)
+ |> Participation.get(preload: [:conversation])
if user.id == participation.user_id do
activities =
|> render("index.json", %{activities: activities, for: user, as: :activity})
end
end
+
+ def update_conversation(
+ %{assigns: %{user: user}} = conn,
+ %{"id" => participation_id, "recipients" => recipients}
+ ) do
+ participation =
+ participation_id
+ |> Participation.get()
+
+ with true <- user.id == participation.user_id,
+ {:ok, participation} <- Participation.set_recipients(participation, recipients) do
+ conn
+ |> put_view(ConversationView)
+ |> render("participation.json", %{participation: participation, for: user})
+ end
+ end
end