Merge branch 'emoji-reaction-api-change-2' into 'develop'
Emoji reaction api change 2 See merge request pleroma/pleroma!2140
This commit is contained in:
commit
ecff8e92ff
|
@ -98,6 +98,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mastodon API: Add `emoji_reactions` property to Statuses
|
- Mastodon API: Add `emoji_reactions` property to Statuses
|
||||||
- Mastodon API: Change emoji reaction reply format
|
- Mastodon API: Change emoji reaction reply format
|
||||||
- Notifications: Added `pleroma:emoji_reaction` notification type
|
- Notifications: Added `pleroma:emoji_reaction` notification type
|
||||||
|
- Mastodon API: Change emoji reaction reply format once more
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -29,7 +29,7 @@ Has these additional fields under the `pleroma` object:
|
||||||
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
|
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
|
||||||
- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
|
- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
|
||||||
- `thread_muted`: true if the thread the post belongs to is muted
|
- `thread_muted`: true if the thread the post belongs to is muted
|
||||||
- `emoji_reactions`: A list with emoji / reaction count tuples. Contains no information about the reacting users, for that use the `emoji_reactions_by` endpoint.
|
- `emoji_reactions`: A list with emoji / reaction maps. The format is {emoji: "☕", count: 1}. Contains no information about the reacting users, for that use the `emoji_reactions_by` endpoint.
|
||||||
|
|
||||||
## Attachments
|
## Attachments
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
|
||||||
* Example Response:
|
* Example Response:
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
["😀", [{"id" => "xyz.."...}, {"id" => "zyx..."}]],
|
{"emoji": "😀", "count": 2, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]},
|
||||||
["☕", [{"id" => "abc..."}]]
|
{"emoji": "☕", "count": 1, "accounts": [{"id" => "abc..."}]}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
|
@ -256,7 +256,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
||||||
emoji_reactions =
|
emoji_reactions =
|
||||||
with %{data: %{"reactions" => emoji_reactions}} <- object do
|
with %{data: %{"reactions" => emoji_reactions}} <- object do
|
||||||
Enum.map(emoji_reactions, fn [emoji, users] ->
|
Enum.map(emoji_reactions, fn [emoji, users] ->
|
||||||
[emoji, length(users)]
|
%{emoji: emoji, count: length(users)}
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
_ -> []
|
_ -> []
|
||||||
|
|
|
@ -49,7 +49,12 @@ def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id})
|
||||||
emoji_reactions
|
emoji_reactions
|
||||||
|> Enum.map(fn [emoji, users] ->
|
|> Enum.map(fn [emoji, users] ->
|
||||||
users = Enum.map(users, &User.get_cached_by_ap_id/1)
|
users = Enum.map(users, &User.get_cached_by_ap_id/1)
|
||||||
{emoji, AccountView.render("index.json", %{users: users, for: user, as: :user})}
|
|
||||||
|
%{
|
||||||
|
emoji: emoji,
|
||||||
|
count: length(users),
|
||||||
|
accounts: AccountView.render("index.json", %{users: users, for: user, as: :user})
|
||||||
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -36,7 +36,10 @@ test "has an emoji reaction list" do
|
||||||
activity = Repo.get(Activity, activity.id)
|
activity = Repo.get(Activity, activity.id)
|
||||||
status = StatusView.render("show.json", activity: activity)
|
status = StatusView.render("show.json", activity: activity)
|
||||||
|
|
||||||
assert status[:pleroma][:emoji_reactions] == [["☕", 2], ["🍵", 1]]
|
assert status[:pleroma][:emoji_reactions] == [
|
||||||
|
%{emoji: "☕", count: 2},
|
||||||
|
%{emoji: "🍵", count: 1}
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
|
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
|
||||||
|
|
|
@ -71,7 +71,7 @@ test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do
|
||||||
|> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
|
|> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|
||||||
[["🎅", [represented_user]]] = result
|
[%{"emoji" => "🎅", "count" => 1, "accounts" => [represented_user]}] = result
|
||||||
assert represented_user["id"] == other_user.id
|
assert represented_user["id"] == other_user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue