mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-18 07:48:19 +00:00
Push.Impl: support edits
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
16a31872fe
commit
6486211064
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.Push.Impl do
|
||||||
require Logger
|
require Logger
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
@types ["Create", "Follow", "Announce", "Like", "Move", "EmojiReact"]
|
@types ["Create", "Follow", "Announce", "Like", "Move", "EmojiReact", "Update"]
|
||||||
|
|
||||||
@doc "Performs sending notifications for user subscriptions"
|
@doc "Performs sending notifications for user subscriptions"
|
||||||
@spec perform(Notification.t()) :: list(any) | :error | {:error, :unknown_type}
|
@spec perform(Notification.t()) :: list(any) | :error | {:error, :unknown_type}
|
||||||
|
@ -167,6 +167,15 @@ defmodule Pleroma.Web.Push.Impl do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_body(
|
||||||
|
%{activity: %{data: %{"type" => "Update"}}},
|
||||||
|
actor,
|
||||||
|
_object,
|
||||||
|
_mastodon_type
|
||||||
|
) do
|
||||||
|
"@#{actor.nickname} edited a status"
|
||||||
|
end
|
||||||
|
|
||||||
def format_title(activity, mastodon_type \\ nil)
|
def format_title(activity, mastodon_type \\ nil)
|
||||||
|
|
||||||
def format_title(%{activity: %{data: %{"directMessage" => true}}}, _mastodon_type) do
|
def format_title(%{activity: %{data: %{"directMessage" => true}}}, _mastodon_type) do
|
||||||
|
@ -180,6 +189,7 @@ defmodule Pleroma.Web.Push.Impl do
|
||||||
"follow_request" -> "New Follow Request"
|
"follow_request" -> "New Follow Request"
|
||||||
"reblog" -> "New Repeat"
|
"reblog" -> "New Repeat"
|
||||||
"favourite" -> "New Favorite"
|
"favourite" -> "New Favorite"
|
||||||
|
"update" -> "New Update"
|
||||||
"pleroma:emoji_reaction" -> "New Reaction"
|
"pleroma:emoji_reaction" -> "New Reaction"
|
||||||
type -> "New #{String.capitalize(type || "event")}"
|
type -> "New #{String.capitalize(type || "event")}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -200,6 +200,21 @@ defmodule Pleroma.Web.Push.ImplTest do
|
||||||
"New Reaction"
|
"New Reaction"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "renders title and body for update activity" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, activity} = CommonAPI.post(user, %{status: "lorem ipsum"})
|
||||||
|
|
||||||
|
{:ok, activity} = CommonAPI.update(user, activity, %{status: "edited status"})
|
||||||
|
object = Object.normalize(activity, fetch: false)
|
||||||
|
|
||||||
|
assert Impl.format_body(%{activity: activity, type: "update"}, user, object) ==
|
||||||
|
"@#{user.nickname} edited a status"
|
||||||
|
|
||||||
|
assert Impl.format_title(%{activity: activity, type: "update"}) ==
|
||||||
|
"New Update"
|
||||||
|
end
|
||||||
|
|
||||||
test "renders title for create activity with direct visibility" do
|
test "renders title for create activity with direct visibility" do
|
||||||
user = insert(:user, nickname: "Bob")
|
user = insert(:user, nickname: "Bob")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue