From 2d30dd439f8726927c9ab517c75585a191ee4a82 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Wed, 16 Feb 2022 15:22:08 +1000 Subject: [PATCH] DEV: Add chat_quoted notification type (#15968) This is needed for the notification sent when quoting chat messages inside a post. --- .../discourse-common/addon/lib/icon-library.js | 1 + app/models/notification.rb | 3 ++- app/services/post_alerter.rb | 9 +++++++-- spec/requests/api/schemas/json/site_response.json | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse-common/addon/lib/icon-library.js b/app/assets/javascripts/discourse-common/addon/lib/icon-library.js index edf8160c3e4..7a8588f91be 100644 --- a/app/assets/javascripts/discourse-common/addon/lib/icon-library.js +++ b/app/assets/javascripts/discourse-common/addon/lib/icon-library.js @@ -48,6 +48,7 @@ const REPLACEMENTS = { "notification.membership_request_consolidated": "users", "notification.reaction": "bell", "notification.votes_released": "plus", + "notification.chat_quoted": "quote-right", }; export function replaceIcon(source, destination) { diff --git a/app/models/notification.rb b/app/models/notification.rb index 98722001866..7adb5ce665d 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -109,7 +109,8 @@ class Notification < ActiveRecord::Base chat_mention: 29, chat_message: 30, chat_invitation: 31, - chat_group_mention: 32 + chat_group_mention: 32, + chat_quoted: 33 ) end diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index f58e94872bc..6f4af85d081 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -429,8 +429,13 @@ class PostAlerter return end - # linked, quoted, mentioned may be suppressed if you already have a reply notification - if type == Notification.types[:quoted] || type == Notification.types[:linked] || type == Notification.types[:mentioned] + # linked, quoted, mentioned, chat_quoted may be suppressed if you already have a reply notification + if [ + Notification.types[:quoted], + Notification.types[:linked], + Notification.types[:mentioned], + Notification.types[:chat_quoted] + ].include?(type) return if existing_notifications.find { |n| n.notification_type == Notification.types[:replied] } end diff --git a/spec/requests/api/schemas/json/site_response.json b/spec/requests/api/schemas/json/site_response.json index a65eea3cf67..adee9695dde 100644 --- a/spec/requests/api/schemas/json/site_response.json +++ b/spec/requests/api/schemas/json/site_response.json @@ -103,6 +103,9 @@ }, "chat_group_mention": { "type": "integer" + }, + "chat_quoted": { + "type": "integer" } }, "required": [