Merge branch 'recipients-experiments' into 'develop'
[akkoma] / lib / pleroma / web / push / impl.ex
index 125f337558d6c7f15f4788458b17b1d631feeff5..cdb827e7664820f7d08088ad489a7e7f21a033ef 100644 (file)
@@ -32,7 +32,7 @@ defmodule Pleroma.Web.Push.Impl do
     mastodon_type = notification.type
     gcm_api_key = Application.get_env(:web_push_encryption, :gcm_api_key)
     avatar_url = User.avatar_url(actor)
-    object = Object.normalize(activity)
+    object = Object.normalize(activity, false)
     user = User.get_cached_by_id(user_id)
     direct_conversation_id = Activity.direct_conversation_id(activity, user)
 
@@ -124,6 +124,13 @@ defmodule Pleroma.Web.Push.Impl do
 
   def format_body(activity, actor, object, mastodon_type \\ nil)
 
+  def format_body(_activity, actor, %{data: %{"type" => "ChatMessage", "content" => content}}, _) do
+    case content do
+      nil -> "@#{actor.nickname}: (Attachment)"
+      content -> "@#{actor.nickname}: #{Utils.scrub_html_and_truncate(content, 80)}"
+    end
+  end
+
   def format_body(
         %{activity: %{data: %{"type" => "Create"}}},
         actor,
@@ -171,6 +178,7 @@ defmodule Pleroma.Web.Push.Impl do
       "follow_request" -> "New Follow Request"
       "reblog" -> "New Repeat"
       "favourite" -> "New Favorite"
+      "pleroma:chat_mention" -> "New Chat Message"
       type -> "New #{String.capitalize(type || "event")}"
     end
   end