diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c6ad4fd9..150fd27cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
API Changes +- **Breaking** EmojiReactions: Change endpoints and responses to align with Mastodon - **Breaking** Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body) - **Breaking:** Admin API: Return link alongside with token on password reset - **Breaking:** Admin API: `PUT /api/pleroma/admin/reports/:id` is now `PATCH /api/pleroma/admin/reports`, see admin_api.md for details diff --git a/docs/API/differences_in_mastoapi_responses.md b/docs/API/differences_in_mastoapi_responses.md index ebf842b7e..06de90f71 100644 --- a/docs/API/differences_in_mastoapi_responses.md +++ b/docs/API/differences_in_mastoapi_responses.md @@ -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` - `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 -- `emoji_reactions`: A list with emoji / reaction maps. The format is `{emoji: "☕", count: 1, reacted: true}`. 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 `{name: "☕", count: 1, me: true}`. Contains no information about the reacting users, for that use the `/statuses/:id/reactions` endpoint. ## Attachments diff --git a/docs/API/pleroma_api.md b/docs/API/pleroma_api.md index c7125c1cd..07e0af5e5 100644 --- a/docs/API/pleroma_api.md +++ b/docs/API/pleroma_api.md @@ -432,21 +432,21 @@ The status posting endpoint takes an additional parameter, `in_reply_to_conversa Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character. -## `POST /api/v1/pleroma/statuses/:id/react_with_emoji` +## `PUT /api/v1/pleroma/statuses/:id/reactions/:emoji` ### React to a post with a unicode emoji -* Method: `POST` +* Method: `PUT` * Authentication: required * Params: `emoji`: A single character unicode emoji * Response: JSON, the status. -## `POST /api/v1/pleroma/statuses/:id/unreact_with_emoji` +## `DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji` ### Remove a reaction to a post with a unicode emoji -* Method: `POST` +* Method: `DELETE` * Authentication: required * Params: `emoji`: A single character unicode emoji * Response: JSON, the status. -## `GET /api/v1/pleroma/statuses/:id/emoji_reactions_by` +## `GET /api/v1/pleroma/statuses/:id/reactions` ### Get an object of emoji to account mappings with accounts that reacted to the post * Method: `GET` * Authentication: optional @@ -455,7 +455,7 @@ Emoji reactions work a lot like favourites do. They make it possible to react to * Example Response: ```json [ - {"emoji": "😀", "count": 2, "reacted": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}, - {"emoji": "☕", "count": 1, "reacted": false, "accounts": [{"id" => "abc..."}]} + {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}, + {"name": "☕", "count": 1, "me": false, "accounts": [{"id" => "abc..."}]} ] ``` diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 6cb158bbf..e1e92034f 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -242,9 +242,9 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} with %{data: %{"reactions" => emoji_reactions}} <- object do Enum.map(emoji_reactions, fn [emoji, users] -> %{ - emoji: emoji, + name: emoji, count: length(users), - reacted: !!(opts[:for] && opts[:for].ap_id in users) + me: !!(opts[:for] && opts[:for].ap_id in users) } end) else diff --git a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex index d76e39795..108e48438 100644 --- a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex @@ -53,10 +53,10 @@ def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id}) |> Enum.filter(& &1) %{ - emoji: emoji, + name: emoji, count: length(users), accounts: AccountView.render("index.json", %{users: users, for: user, as: :user}), - reacted: !!(user && user.ap_id in user_ap_ids) + me: !!(user && user.ap_id in user_ap_ids) } end) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index e86bc3cc3..897215698 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -271,7 +271,7 @@ defmodule Pleroma.Web.Router do scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do pipe_through(:api) - get("/statuses/:id/emoji_reactions_by", PleromaAPIController, :emoji_reactions_by) + get("/statuses/:id/reactions", PleromaAPIController, :emoji_reactions_by) end scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do @@ -287,8 +287,8 @@ defmodule Pleroma.Web.Router do pipe_through(:authenticated_api) 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) + put("/statuses/:id/reactions/:emoji", PleromaAPIController, :react_with_emoji) + delete("/statuses/:id/reactions/:emoji", PleromaAPIController, :unreact_with_emoji) post("/notifications/read", PleromaAPIController, :read_notification) patch("/accounts/update_avatar", AccountController, :update_avatar) diff --git a/priv/static/index.html b/priv/static/index.html index bf7ee958b..6e1f751ce 100644 --- a/priv/static/index.html +++ b/priv/static/index.html @@ -1 +1 @@ -Pleroma
\ No newline at end of file +Pleroma
\ No newline at end of file diff --git a/priv/static/static/font/fontello.1581007281335.woff b/priv/static/static/font/fontello.1581007281335.woff deleted file mode 100644 index f6e0f80fc..000000000 Binary files a/priv/static/static/font/fontello.1581007281335.woff and /dev/null differ diff --git a/priv/static/static/font/fontello.1581007281335.woff2 b/priv/static/static/font/fontello.1581007281335.woff2 deleted file mode 100644 index 5bd824c7d..000000000 Binary files a/priv/static/static/font/fontello.1581007281335.woff2 and /dev/null differ diff --git a/priv/static/static/font/fontello.1581007281335.eot b/priv/static/static/font/fontello.1581425930672.eot similarity index 86% rename from priv/static/static/font/fontello.1581007281335.eot rename to priv/static/static/font/fontello.1581425930672.eot index 3aae7d472..0de06da29 100644 Binary files a/priv/static/static/font/fontello.1581007281335.eot and b/priv/static/static/font/fontello.1581425930672.eot differ diff --git a/priv/static/static/font/fontello.1581007281335.svg b/priv/static/static/font/fontello.1581425930672.svg similarity index 97% rename from priv/static/static/font/fontello.1581007281335.svg rename to priv/static/static/font/fontello.1581425930672.svg index 44beba9a2..b905a0f6c 100644 --- a/priv/static/static/font/fontello.1581007281335.svg +++ b/priv/static/static/font/fontello.1581425930672.svg @@ -76,6 +76,8 @@ + + diff --git a/priv/static/static/font/fontello.1581007281335.ttf b/priv/static/static/font/fontello.1581425930672.ttf similarity index 86% rename from priv/static/static/font/fontello.1581007281335.ttf rename to priv/static/static/font/fontello.1581425930672.ttf index d3d19affe..5a9cefeec 100644 Binary files a/priv/static/static/font/fontello.1581007281335.ttf and b/priv/static/static/font/fontello.1581425930672.ttf differ diff --git a/priv/static/static/font/fontello.1581425930672.woff b/priv/static/static/font/fontello.1581425930672.woff new file mode 100644 index 000000000..28f4dda9d Binary files /dev/null and b/priv/static/static/font/fontello.1581425930672.woff differ diff --git a/priv/static/static/font/fontello.1581425930672.woff2 b/priv/static/static/font/fontello.1581425930672.woff2 new file mode 100644 index 000000000..81a10daee Binary files /dev/null and b/priv/static/static/font/fontello.1581425930672.woff2 differ diff --git a/priv/static/static/fontello.1581425930672.css b/priv/static/static/fontello.1581425930672.css new file mode 100644 index 000000000..70a43d019 Binary files /dev/null and b/priv/static/static/fontello.1581425930672.css differ diff --git a/priv/static/static/fontello.json b/priv/static/static/fontello.json index 829241b55..5a7086a23 100755 --- a/priv/static/static/fontello.json +++ b/priv/static/static/fontello.json @@ -339,6 +339,12 @@ "css": "arrow-curved", "code": 59426, "src": "iconic" + }, + { + "uid": "0ddd3e8201ccc7d41f7b7c9d27eca6c1", + "css": "link", + "code": 59427, + "src": "fontawesome" } ] -} \ No newline at end of file +} diff --git a/priv/static/static/js/app.0aac253187b2af873849.js b/priv/static/static/js/app.0aac253187b2af873849.js deleted file mode 100644 index 3f2f39e83..000000000 Binary files a/priv/static/static/js/app.0aac253187b2af873849.js and /dev/null differ diff --git a/priv/static/static/js/app.0aac253187b2af873849.js.map b/priv/static/static/js/app.0aac253187b2af873849.js.map deleted file mode 100644 index b2503292e..000000000 Binary files a/priv/static/static/js/app.0aac253187b2af873849.js.map and /dev/null differ diff --git a/priv/static/static/js/app.f8af8a9b83e330e80903.js b/priv/static/static/js/app.f8af8a9b83e330e80903.js new file mode 100644 index 000000000..f755c141a Binary files /dev/null and b/priv/static/static/js/app.f8af8a9b83e330e80903.js differ diff --git a/priv/static/static/js/app.f8af8a9b83e330e80903.js.map b/priv/static/static/js/app.f8af8a9b83e330e80903.js.map new file mode 100644 index 000000000..106368819 Binary files /dev/null and b/priv/static/static/js/app.f8af8a9b83e330e80903.js.map differ diff --git a/priv/static/static/js/vendors~app.c26cf2fc57e9c1975e8d.js b/priv/static/static/js/vendors~app.52ac194cbc427f97f06e.js similarity index 81% rename from priv/static/static/js/vendors~app.c26cf2fc57e9c1975e8d.js rename to priv/static/static/js/vendors~app.52ac194cbc427f97f06e.js index bffb28fa7..f59457df6 100644 Binary files a/priv/static/static/js/vendors~app.c26cf2fc57e9c1975e8d.js and b/priv/static/static/js/vendors~app.52ac194cbc427f97f06e.js differ diff --git a/priv/static/static/js/vendors~app.52ac194cbc427f97f06e.js.map b/priv/static/static/js/vendors~app.52ac194cbc427f97f06e.js.map new file mode 100644 index 000000000..b0ccd82fb Binary files /dev/null and b/priv/static/static/js/vendors~app.52ac194cbc427f97f06e.js.map differ diff --git a/priv/static/static/js/vendors~app.c26cf2fc57e9c1975e8d.js.map b/priv/static/static/js/vendors~app.c26cf2fc57e9c1975e8d.js.map deleted file mode 100644 index 044d577a6..000000000 Binary files a/priv/static/static/js/vendors~app.c26cf2fc57e9c1975e8d.js.map and /dev/null differ diff --git a/priv/static/sw-pleroma.js b/priv/static/sw-pleroma.js index f55ef0112..42ef52ad4 100644 Binary files a/priv/static/sw-pleroma.js and b/priv/static/sw-pleroma.js differ diff --git a/test/web/mastodon_api/views/status_view_test.exs b/test/web/mastodon_api/views/status_view_test.exs index fc110417c..ba58e48e8 100644 --- a/test/web/mastodon_api/views/status_view_test.exs +++ b/test/web/mastodon_api/views/status_view_test.exs @@ -37,15 +37,15 @@ test "has an emoji reaction list" do status = StatusView.render("show.json", activity: activity) assert status[:pleroma][:emoji_reactions] == [ - %{emoji: "☕", count: 2, reacted: false}, - %{emoji: "🍵", count: 1, reacted: false} + %{name: "☕", count: 2, me: false}, + %{name: "🍵", count: 1, me: false} ] status = StatusView.render("show.json", activity: activity, for: user) assert status[:pleroma][:emoji_reactions] == [ - %{emoji: "☕", count: 2, reacted: true}, - %{emoji: "🍵", count: 1, reacted: false} + %{name: "☕", count: 2, me: true}, + %{name: "🍵", count: 1, me: false} ] end diff --git a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs index be5007de5..36868db38 100644 --- a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs @@ -14,7 +14,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do import Pleroma.Factory - test "POST /api/v1/pleroma/statuses/:id/react_with_emoji", %{conn: conn} do + test "PUT /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do user = insert(:user) other_user = insert(:user) @@ -24,18 +24,19 @@ test "POST /api/v1/pleroma/statuses/:id/react_with_emoji", %{conn: conn} do conn |> assign(:user, other_user) |> assign(:token, insert(:oauth_token, user: other_user, scopes: ["write:statuses"])) - |> post("/api/v1/pleroma/statuses/#{activity.id}/react_with_emoji", %{"emoji" => "☕"}) + |> put("/api/v1/pleroma/statuses/#{activity.id}/reactions/☕") |> json_response(200) + # We return the status, but this our implementation detail. assert %{"id" => id} = result assert to_string(activity.id) == id assert result["pleroma"]["emoji_reactions"] == [ - %{"emoji" => "☕", "count" => 1, "reacted" => true} + %{"name" => "☕", "count" => 1, "me" => true} ] end - test "POST /api/v1/pleroma/statuses/:id/unreact_with_emoji", %{conn: conn} do + test "DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do user = insert(:user) other_user = insert(:user) @@ -46,7 +47,7 @@ test "POST /api/v1/pleroma/statuses/:id/unreact_with_emoji", %{conn: conn} do conn |> assign(:user, other_user) |> assign(:token, insert(:oauth_token, user: other_user, scopes: ["write:statuses"])) - |> post("/api/v1/pleroma/statuses/#{activity.id}/unreact_with_emoji", %{"emoji" => "☕"}) + |> delete("/api/v1/pleroma/statuses/#{activity.id}/reactions/☕") assert %{"id" => id} = json_response(result, 200) assert to_string(activity.id) == id @@ -56,7 +57,7 @@ test "POST /api/v1/pleroma/statuses/:id/unreact_with_emoji", %{conn: conn} do assert object.data["reaction_count"] == 0 end - test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do + test "GET /api/v1/pleroma/statuses/:id/reactions", %{conn: conn} do user = insert(:user) other_user = insert(:user) doomed_user = insert(:user) @@ -65,7 +66,7 @@ test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do result = conn - |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by") + |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions") |> json_response(200) assert result == [] @@ -77,11 +78,10 @@ test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do result = conn - |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by") + |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions") |> json_response(200) - [%{"emoji" => "🎅", "count" => 1, "accounts" => [represented_user], "reacted" => false}] = - result + [%{"name" => "🎅", "count" => 1, "accounts" => [represented_user], "me" => false}] = result assert represented_user["id"] == other_user.id @@ -89,10 +89,10 @@ test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do conn |> assign(:user, other_user) |> assign(:token, insert(:oauth_token, user: other_user, scopes: ["read:statuses"])) - |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by") + |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions") |> json_response(200) - assert [%{"emoji" => "🎅", "count" => 1, "accounts" => [_represented_user], "reacted" => true}] = + assert [%{"name" => "🎅", "count" => 1, "accounts" => [_represented_user], "me" => true}] = result end