Emoji reactions: Change cache and reply format
This commit is contained in:
parent
04c9ca5d68
commit
dd3fc50ea4
6 changed files with 70 additions and 40 deletions
|
|
@ -867,6 +867,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
test "adds an emoji reaction activity to the db" do
|
||||
user = insert(:user)
|
||||
reactor = insert(:user)
|
||||
third_user = insert(:user)
|
||||
fourth_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"})
|
||||
assert object = Object.normalize(activity)
|
||||
|
||||
|
|
@ -881,7 +883,21 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert reaction_activity.data["to"] == [User.ap_followers(reactor), activity.data["actor"]]
|
||||
assert reaction_activity.data["context"] == object.data["context"]
|
||||
assert object.data["reaction_count"] == 1
|
||||
assert object.data["reactions"]["🔥"] == [reactor.ap_id]
|
||||
assert object.data["reactions"] == [["🔥", [reactor.ap_id]]]
|
||||
|
||||
{:ok, _reaction_activity, object} = ActivityPub.react_with_emoji(third_user, object, "☕")
|
||||
|
||||
assert object.data["reaction_count"] == 2
|
||||
assert object.data["reactions"] == [["🔥", [reactor.ap_id]], ["☕", [third_user.ap_id]]]
|
||||
|
||||
{:ok, _reaction_activity, object} = ActivityPub.react_with_emoji(fourth_user, object, "🔥")
|
||||
|
||||
assert object.data["reaction_count"] == 3
|
||||
|
||||
assert object.data["reactions"] == [
|
||||
["🔥", [fourth_user.ap_id, reactor.ap_id]],
|
||||
["☕", [third_user.ap_id]]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -919,7 +935,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
object = Object.get_by_ap_id(object.data["id"])
|
||||
assert object.data["reaction_count"] == 0
|
||||
assert object.data["reactions"] == %{}
|
||||
assert object.data["reactions"] == []
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -31,13 +31,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
{:ok, activity} = CommonAPI.post(user, %{"status" => "dae cofe??"})
|
||||
|
||||
{:ok, _, _} = CommonAPI.react_with_emoji(activity.id, user, "☕")
|
||||
{:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
||||
{:ok, _, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵")
|
||||
{:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
||||
activity = Repo.get(Activity, activity.id)
|
||||
status = StatusView.render("show.json", activity: activity)
|
||||
|
||||
assert status[:pleroma][:emoji_reactions]["🍵"] == 1
|
||||
assert status[:pleroma][:emoji_reactions]["☕"] == 2
|
||||
assert status[:pleroma][:emoji_reactions] == [["☕", 2], ["🍵", 1]]
|
||||
end
|
||||
|
||||
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
|
||||
|
|
@ -189,7 +188,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
expires_at: nil,
|
||||
direct_conversation_id: nil,
|
||||
thread_muted: false,
|
||||
emoji_reactions: %{}
|
||||
emoji_reactions: []
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
|
||||
|> json_response(200)
|
||||
|
||||
assert result == %{}
|
||||
assert result == []
|
||||
|
||||
{:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "🎅")
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
|
||||
|> json_response(200)
|
||||
|
||||
[represented_user] = result["🎅"]
|
||||
[["🎅", [represented_user]]] = result
|
||||
assert represented_user["id"] == other_user.id
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue