forked from AkkomaGang/akkoma
PleromaAPIController: Fixes and refactoring.
This commit is contained in:
parent
04a2910f33
commit
6068d2254e
2 changed files with 7 additions and 12 deletions
|
@ -23,17 +23,12 @@ def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id})
|
||||||
with %Activity{} = activity <- Activity.get_by_id_with_object(activity_id),
|
with %Activity{} = activity <- Activity.get_by_id_with_object(activity_id),
|
||||||
%Object{data: %{"reactions" => emoji_reactions}} <- Object.normalize(activity) do
|
%Object{data: %{"reactions" => emoji_reactions}} <- Object.normalize(activity) do
|
||||||
reactions =
|
reactions =
|
||||||
Enum.reduce(emoji_reactions, %{}, fn {emoji, users}, res ->
|
emoji_reactions
|
||||||
users =
|
|> Enum.map(fn {emoji, users} ->
|
||||||
users
|
users = Enum.map(users, &User.get_cached_by_ap_id/1)
|
||||||
|> Enum.map(&User.get_cached_by_ap_id/1)
|
{emoji, AccountView.render("accounts.json", %{users: users, for: user, as: :user})}
|
||||||
|
|
||||||
res
|
|
||||||
|> Map.put(
|
|
||||||
emoji,
|
|
||||||
AccountView.render("accounts.json", %{users: users, for: user, as: :user})
|
|
||||||
)
|
|
||||||
end)
|
end)
|
||||||
|
|> Enum.into(%{})
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> json(reactions)
|
|> json(reactions)
|
||||||
|
@ -49,7 +44,7 @@ def react_with_emoji(%{assigns: %{user: user}} = conn, %{"id" => activity_id, "e
|
||||||
activity = Activity.get_by_id(activity_id) do
|
activity = Activity.get_by_id(activity_id) do
|
||||||
conn
|
conn
|
||||||
|> put_view(StatusView)
|
|> put_view(StatusView)
|
||||||
|> render("status.json", %{activity: activity, for: user, as: :activity})
|
|> render("show.json", %{activity: activity, for: user, as: :activity})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1263,7 +1263,7 @@ test "it can handle Listen activities" do
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.listen(user, %{"title" => "lain radio episode 1"})
|
{:ok, activity} = CommonAPI.listen(user, %{"title" => "lain radio episode 1"})
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, _modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue