parent
785209dece
commit
0f5bea2465
4 changed files with 53 additions and 2 deletions
|
@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## Unreleased
|
||||
## 2.5.0 - 10/06/2022
|
||||
|
||||
### Changed
|
||||
- Allow users to remove their emails if instance does not need email to register
|
||||
|
@ -21,6 +21,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Ability to log slow Ecto queries by configuring `:pleroma, :telemetry, :slow_queries_logging`
|
||||
- Added Phoenix LiveDashboard at `/phoenix/live_dashboard`
|
||||
- Added `/manifest.json` for progressive web apps.
|
||||
- Readded mastoFE
|
||||
- Added support for custom emoji reactions
|
||||
- Added `emoji_url` in notifications to allow for custom emoji rendering
|
||||
|
||||
### Fixed
|
||||
- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
|
||||
|
|
|
@ -164,4 +164,22 @@ def maybe_quote(name) when is_binary(name) do
|
|||
end
|
||||
|
||||
def maybe_quote(name), do: name
|
||||
|
||||
def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => []}), do: nil
|
||||
|
||||
def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => tags}) do
|
||||
tag =
|
||||
tags
|
||||
|> Enum.find(fn tag -> tag["type"] == "Emoji" && tag["name"] == stripped_name(emoji) end)
|
||||
|
||||
if is_nil(tag) do
|
||||
nil
|
||||
else
|
||||
tag
|
||||
|> Map.get("icon")
|
||||
|> Map.get("url")
|
||||
end
|
||||
end
|
||||
|
||||
def emoji_url(_), do: nil
|
||||
end
|
||||
|
|
|
@ -138,7 +138,9 @@ defp put_report(response, activity) do
|
|||
end
|
||||
|
||||
defp put_emoji(response, activity) do
|
||||
Map.put(response, :emoji, activity.data["content"])
|
||||
response
|
||||
|> Map.put(:emoji, activity.data["content"])
|
||||
|> Map.put(:emoji_url, Pleroma.Emoji.emoji_url(activity.data))
|
||||
end
|
||||
|
||||
defp put_chat_message(response, activity, reading_user, opts) do
|
||||
|
|
|
@ -188,6 +188,34 @@ test "EmojiReact notification" do
|
|||
pleroma: %{is_seen: false, is_muted: false},
|
||||
type: "pleroma:emoji_reaction",
|
||||
emoji: "☕",
|
||||
emoji_url: nil,
|
||||
account: AccountView.render("show.json", %{user: other_user, for: user}),
|
||||
status: StatusView.render("show.json", %{activity: activity, for: user}),
|
||||
created_at: Utils.to_masto_date(notification.inserted_at)
|
||||
}
|
||||
|
||||
test_notifications_rendering([notification], user, [expected])
|
||||
end
|
||||
|
||||
test "EmojiReact notification with custom emoji" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#morb"})
|
||||
{:ok, _activity} = CommonAPI.react_with_emoji(activity.id, other_user, ":dinosaur:")
|
||||
|
||||
activity = Repo.get(Activity, activity.id)
|
||||
|
||||
[notification] = Notification.for_user(user)
|
||||
|
||||
assert notification
|
||||
|
||||
expected = %{
|
||||
id: to_string(notification.id),
|
||||
pleroma: %{is_seen: false, is_muted: false},
|
||||
type: "pleroma:emoji_reaction",
|
||||
emoji: ":dinosaur:",
|
||||
emoji_url: "http://localhost:4001/emoji/dino walking.gif",
|
||||
account: AccountView.render("show.json", %{user: other_user, for: user}),
|
||||
status: StatusView.render("show.json", %{activity: activity, for: user}),
|
||||
created_at: Utils.to_masto_date(notification.inserted_at)
|
||||
|
|
Loading…
Reference in a new issue