FIX: do not include username in assign push notification

FIX: do not include username in assign push notification

From cd6f61683e33a14b1dbf9473e3a6883c53f69839 Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Wed, 5 Dec 2018 08:42:02 +1100
Subject: [PATCH] FIX: do not include username in assign push notification


diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 86a5b40..1af4e65 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -18,7 +18,7 @@ en:
     already_claimed: "That topic has already been claimed."
     flag_assigned: "Sorry, that flag's topic is assigned to another user"
     flag_unclaimed: "You must claim that topic before acting on the flag"
-    topic_assigned_excerpt: "@%{username} assigned you the topic '%{title}'"
+    topic_assigned_excerpt: "assigned you the topic '%{title}'"
   assign_mailer:
     title: "Assign Mailer"
     subject_template: "[%{email_prefix}] %{assignee_name} assigned you to '%{topic_title}'!"
diff --git a/lib/topic_assigner.rb b/lib/topic_assigner.rb
index fb88e0a..1513fd3 100644
--- a/lib/topic_assigner.rb
+++ b/lib/topic_assigner.rb
@@ -215,8 +215,9 @@ SQL
       alerter.create_notification_alert(
         user: assign_to,
         post: first_post,
+        username: @assigned_by.username,
         notification_type: Notification.types[:custom],
-        excerpt: I18n.t("discourse_assign.topic_assigned_excerpt", title: @topic.title, username: @assigned_by.username)
+        excerpt: I18n.t("discourse_assign.topic_assigned_excerpt", title: @topic.title)
       )
     end
 
diff --git a/spec/lib/topic_assigner_spec.rb b/spec/lib/topic_assigner_spec.rb
index 6a522a7..c32341e 100644
--- a/spec/lib/topic_assigner_spec.rb
+++ b/spec/lib/topic_assigner_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe TopicAssigner do
       end
 
       expect(messages.length).to eq(1)
-      expect(messages.first.data[:excerpt]).to eq("@#{moderator2.username} assigned you the topic '#{topic.title}'")
+      expect(messages.first.data[:excerpt]).to eq("assigned you the topic '#{topic.title}'")
 
       expect(TopicQuery.new(
         moderator, assigned: moderator.username

GitHub

1 Like

I thought the issue was that the topic OP was in the push notification?

I kinda liked it when I knew who assigned me some stuff.

EDIT: nevermind, I missed the + username: @assigned_by.username change :+1:

1 Like

Yeah it will show that now, that is the username parameter

1 Like