mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-24 18:15:19 +00:00
PleromaAPI: Add unreacting.
This commit is contained in:
parent
391c736292
commit
4cb603e1df
|
@ -41,7 +41,19 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do
|
|||
|
||||
def react_with_emoji(%{assigns: %{user: user}} = conn, %{"id" => activity_id, "emoji" => emoji}) do
|
||||
with {:ok, _activity, _object} <- CommonAPI.react_with_emoji(activity_id, user, emoji),
|
||||
activity = Activity.get_by_id(activity_id) do
|
||||
activity <- Activity.get_by_id(activity_id) do
|
||||
conn
|
||||
|> put_view(StatusView)
|
||||
|> render("show.json", %{activity: activity, for: user, as: :activity})
|
||||
end
|
||||
end
|
||||
|
||||
def unreact_with_emoji(%{assigns: %{user: user}} = conn, %{
|
||||
"id" => activity_id,
|
||||
"emoji" => emoji
|
||||
}) do
|
||||
with {:ok, _activity, _object} <- CommonAPI.unreact_with_emoji(activity_id, user, emoji),
|
||||
activity <- Activity.get_by_id(activity_id) do
|
||||
conn
|
||||
|> put_view(StatusView)
|
||||
|> render("show.json", %{activity: activity, for: user, as: :activity})
|
||||
|
|
|
@ -305,6 +305,7 @@ defmodule Pleroma.Web.Router do
|
|||
pipe_through(:oauth_write)
|
||||
patch("/conversations/:id", PleromaAPIController, :update_conversation)
|
||||
post("/statuses/:id/react_with_emoji", PleromaAPIController, :react_with_emoji)
|
||||
post("/statuses/:id/unreact_with_emoji", PleromaAPIController, :unreact_with_emoji)
|
||||
post("/notifications/read", PleromaAPIController, :read_notification)
|
||||
|
||||
patch("/accounts/update_avatar", AccountController, :update_avatar)
|
||||
|
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|
||||
alias Pleroma.Conversation.Participation
|
||||
alias Pleroma.Notification
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
|
@ -41,6 +42,10 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|
||||
assert %{"id" => id} = json_response(result, 200)
|
||||
assert to_string(activity.id) == id
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
||||
assert object.data["reaction_count"] == 0
|
||||
end
|
||||
|
||||
test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do
|
||||
|
|
Loading…
Reference in a new issue