From 3ce11b830ee69d8557146fce6d3507337298259d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 13 Nov 2020 17:01:53 -0600 Subject: Add capability for emoji reaction push notifications --- lib/pleroma/web/push/impl.ex | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex index da535aa68..f91cb1d40 100644 --- a/lib/pleroma/web/push/impl.ex +++ b/lib/pleroma/web/push/impl.ex @@ -16,7 +16,7 @@ defmodule Pleroma.Web.Push.Impl do require Logger import Ecto.Query - @types ["Create", "Follow", "Announce", "Like", "Move"] + @types ["Create", "Follow", "Announce", "Like", "Move", "EmojiReact"] @doc "Performs sending notifications for user subscriptions" @spec perform(Notification.t()) :: list(any) | :error | {:error, :unknown_type} @@ -149,6 +149,15 @@ defmodule Pleroma.Web.Push.Impl do "@#{actor.nickname} repeated: #{Utils.scrub_html_and_truncate(content, 80)}" end + def format_body( + %{activity: %{data: %{"type" => "EmojiReact", "content" => content}}}, + actor, + _object, + _mastodon_type + ) do + "@#{actor.nickname} has reacted with #{content}" + end + def format_body( %{activity: %{data: %{"type" => type}}} = notification, actor, @@ -179,6 +188,7 @@ defmodule Pleroma.Web.Push.Impl do "reblog" -> "New Repeat" "favourite" -> "New Favorite" "pleroma:chat_mention" -> "New Chat Message" + "pleroma:emoji_reaction" -> "New Reaction" type -> "New #{String.capitalize(type || "event")}" end end -- cgit v1.2.3 From 83ec2f1384611c385e79ddfd23566ddc173a8a4a Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 17 Nov 2020 18:33:40 +0000 Subject: Allow subscribing for pleroma:emoji_reaction push notifications --- lib/pleroma/web/push/subscription.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/push/subscription.ex b/lib/pleroma/web/push/subscription.ex index 5b5aa0d59..95425b986 100644 --- a/lib/pleroma/web/push/subscription.ex +++ b/lib/pleroma/web/push/subscription.ex @@ -25,7 +25,7 @@ defmodule Pleroma.Web.Push.Subscription do timestamps() end - @supported_alert_types ~w[follow favourite mention reblog pleroma:chat_mention]a + @supported_alert_types ~w[follow favourite mention reblog pleroma:chat_mention pleroma:emoji_reaction]a defp alerts(%{data: %{alerts: alerts}}) do alerts = Map.take(alerts, @supported_alert_types) -- cgit v1.2.3 From 67a6abd071fd4e9f62c032fe952b65b957140bc5 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 17 Nov 2020 19:15:11 +0000 Subject: Update OpenAPI spec/schema and test to verify support for pleroma:emoji_reaction subscriptions --- lib/pleroma/web/api_spec/operations/subscription_operation.ex | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/api_spec/operations/subscription_operation.ex b/lib/pleroma/web/api_spec/operations/subscription_operation.ex index 775dd795d..77e70005b 100644 --- a/lib/pleroma/web/api_spec/operations/subscription_operation.ex +++ b/lib/pleroma/web/api_spec/operations/subscription_operation.ex @@ -146,6 +146,11 @@ defmodule Pleroma.Web.ApiSpec.SubscriptionOperation do allOf: [BooleanLike], nullable: true, description: "Receive chat notifications?" + }, + "pleroma:emoji_reaction": %Schema{ + allOf: [BooleanLike], + nullable: true, + description: "Receive emoji reaction notifications?" } } } -- cgit v1.2.3 From 5d0bc5e028c94ab1c7ebf746b5d01af1fbef396f Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 17 Nov 2020 20:21:48 +0000 Subject: Support both pleroma:chat_mention and pleroma:emoji_reaction for /api/v1/push/subscription --- lib/pleroma/web/api_spec/operations/subscription_operation.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/api_spec/operations/subscription_operation.ex b/lib/pleroma/web/api_spec/operations/subscription_operation.ex index 77e70005b..67c7ea8f3 100644 --- a/lib/pleroma/web/api_spec/operations/subscription_operation.ex +++ b/lib/pleroma/web/api_spec/operations/subscription_operation.ex @@ -215,6 +215,16 @@ defmodule Pleroma.Web.ApiSpec.SubscriptionOperation do allOf: [BooleanLike], nullable: true, description: "Receive poll notifications?" + }, + "pleroma:chat_mention": %Schema{ + allOf: [BooleanLike], + nullable: true, + description: "Receive chat notifications?" + }, + "pleroma:emoji_reaction": %Schema{ + allOf: [BooleanLike], + nullable: true, + description: "Receive emoji reaction notifications?" } } } -- cgit v1.2.3 From 499faa82f6e9bc400b059a7fd3e5a910eebe1a58 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 17 Nov 2020 19:51:37 +0000 Subject: Synchronize reaction notification text with PleromaFE's style --- lib/pleroma/web/push/impl.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex index f91cb1d40..82152dffa 100644 --- a/lib/pleroma/web/push/impl.ex +++ b/lib/pleroma/web/push/impl.ex @@ -155,7 +155,7 @@ defmodule Pleroma.Web.Push.Impl do _object, _mastodon_type ) do - "@#{actor.nickname} has reacted with #{content}" + "@#{actor.nickname} reacted with #{content}" end def format_body( -- cgit v1.2.3 From ccddedb504e5f03655c128edb074671b1f815f24 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 17 Nov 2020 20:33:30 +0000 Subject: Credo --- lib/pleroma/web/push/subscription.ex | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/pleroma/web/push/subscription.ex b/lib/pleroma/web/push/subscription.ex index 95425b986..749a573ba 100644 --- a/lib/pleroma/web/push/subscription.ex +++ b/lib/pleroma/web/push/subscription.ex @@ -25,6 +25,7 @@ defmodule Pleroma.Web.Push.Subscription do timestamps() end + # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength @supported_alert_types ~w[follow favourite mention reblog pleroma:chat_mention pleroma:emoji_reaction]a defp alerts(%{data: %{alerts: alerts}}) do -- cgit v1.2.3