Add favoriting to Mastodon API.
This commit is contained in:
parent
66e4c710d4
commit
454dc18570
8 changed files with 47 additions and 21 deletions
|
|
@ -87,4 +87,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
render conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity}
|
||||
end
|
||||
end
|
||||
|
||||
def fav_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
|
||||
with {:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.favorite(ap_id_or_id, user),
|
||||
%Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do
|
||||
render conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
|> Enum.map(fn (user) -> AccountView.render("mention.json", %{user: user}) end)
|
||||
|
||||
repeated = opts[:for] && opts[:for].ap_id in (object["announcements"] || [])
|
||||
favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || [])
|
||||
|
||||
%{
|
||||
id: activity.id,
|
||||
|
|
@ -36,7 +37,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
reblogs_count: announcement_count,
|
||||
favourites_count: like_count,
|
||||
reblogged: !!repeated,
|
||||
favourited: false, # fix
|
||||
favourited: !!favorited,
|
||||
muted: false,
|
||||
sensitive: sensitive,
|
||||
spoiler_text: "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue