Revert "FEATURE: Send notification when member was accepted to group. (#7503)"

Revert “FEATURE: Send notification when member was accepted to group. (#7503)”

This reverts commit 42c82d544ecfe138da5b0b5a336be2109179cf26.

diff --git a/app/assets/javascripts/discourse-common/lib/icon-library.js.es6 b/app/assets/javascripts/discourse-common/lib/icon-library.js.es6
index e945fc2..a875180 100644
--- a/app/assets/javascripts/discourse-common/lib/icon-library.js.es6
+++ b/app/assets/javascripts/discourse-common/lib/icon-library.js.es6
@@ -35,8 +35,7 @@ const REPLACEMENTS = {
   "notification.topic_reminder": "far-clock",
   "notification.watching_first_post": "far-dot-circle",
   "notification.group_message_summary": "group",
-  "notification.post_approved": "check",
-  "notification.group_invite": "user-plus"
+  "notification.post_approved": "check"
 };
 
 // TODO: use lib/svg_sprite/fa4-renames.json here
diff --git a/app/assets/javascripts/discourse/components/concerns/notification-types.js.es6.erb b/app/assets/javascripts/discourse/components/concerns/notification-types.js.es6.erb
deleted file mode 100644
index 476ea70..0000000
--- a/app/assets/javascripts/discourse/components/concerns/notification-types.js.es6.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<% Notification.types.each do |key, value| %>
-export const <%= key.upcase %>_TYPE = <%= value %>;
-<% end %>
diff --git a/app/assets/javascripts/discourse/widgets/notification-item.js.es6 b/app/assets/javascripts/discourse/widgets/notification-item.js.es6
index e727659..a298e1a 100644
--- a/app/assets/javascripts/discourse/widgets/notification-item.js.es6
+++ b/app/assets/javascripts/discourse/widgets/notification-item.js.es6
@@ -10,15 +10,13 @@ import {
   formatUsername
 } from "discourse/lib/utilities";
 import { setTransientHeader } from "discourse/lib/ajax";
-import { groupPath, userPath } from "discourse/lib/url";
+import { userPath } from "discourse/lib/url";
 import { iconNode } from "discourse-common/lib/icon-library";
-import {
-  LIKED_TYPE,
-  INVITED_TYPE,
-  GROUP_SUMMARY_TYPE,
-  LIKED_CONSOLIDATED_TYPE,
-  GROUP_INVITE_TYPE
-} from "discourse/components/concerns/notification-types";
+
+const LIKED_TYPE = 5;
+const INVITED_TYPE = 8;
+const GROUP_SUMMARY_TYPE = 16;
+export const LIKED_CONSOLIDATED_TYPE = 19;
 
 createWidget("notification-item", {
   tagName: "li",
@@ -74,10 +72,6 @@ createWidget("notification-item", {
       );
     }
 
-    if (attrs.notification_type === GROUP_INVITE_TYPE) {
-      return groupPath(data.group_name);
-    }
-
     if (data.group_id) {
       return userPath(data.username + "/messages/group/" + data.group_name);
     }
@@ -120,11 +114,8 @@ createWidget("notification-item", {
 
     if (notificationType === GROUP_SUMMARY_TYPE) {
       const count = data.inbox_count;
-      const groupName = data.group_name;
-      return I18n.t(scope, { count, group_name: groupName });
-    } else if (notificationType === GROUP_INVITE_TYPE) {
-      const groupName = data.group_name;
-      return I18n.t(scope, { group_name: groupName });
+      const group_name = data.group_name;
+      return I18n.t(scope, { count, group_name });
     }
 
     const username = formatUsername(data.display_username);
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 5cdfb6d..7a632eb 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -341,7 +341,7 @@ class GroupsController < ApplicationController
       raise Discourse::InvalidParameters.new(:user_id) if user.blank?
 
       if params[:accept]
-        group.add(user, notify: true)
+        group.add(user)
         GroupActionLogger.new(current_user, group).log_add_user_to_group(user)
       end
 
diff --git a/app/models/group.rb b/app/models/group.rb
index 04327c9..bb0adf7 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -506,20 +506,9 @@ class Group < ActiveRecord::Base
 
   PUBLISH_CATEGORIES_LIMIT = 10
 
-  def add(user, notify: false)
+  def add(user)
     self.users.push(user) unless self.users.include?(user)
 
-    if notify
-      Notification.create!(
-        notification_type: Notification.types[:group_invite],
-        user_id: user.id,
-        data: {
-          group_id: id,
-          group_name: name
-        }.to_json
-      )
-    end
-
     if self.categories.count < PUBLISH_CATEGORIES_LIMIT
       MessageBus.publish('/categories', {
         categories: ActiveModel::ArraySerializer.new(self.categories).as_json
diff --git a/app/models/notification.rb b/app/models/notification.rb
index c0be484..c54d449 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -63,8 +63,7 @@ class Notification < ActiveRecord::Base
                         watching_first_post: 17,
                         topic_reminder: 18,
                         liked_consolidated: 19,
-                        post_approved: 20,
-                        group_invite: 21
+                        post_approved: 20
                        )
   end
 
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index f11cf84..828b067 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1689,7 +1689,6 @@ en:
       granted_badge: "Earned '{{description}}'"
       topic_reminder: "<span>{{username}}</span> {{description}}"
       watching_first_post: "<span>New Topic</span> {{description}}"
-      group_invite: "Invited to '{{group_name}}'"
 
       group_message_summary:
         one: "{{count}} message in your {{group_name}} inbox"
diff --git a/test/javascripts/fixtures/notification_fixtures.js.es6 b/test/javascripts/fixtures/notification_fixtures.js.es6
index 5e3c1bd..0ebf8bd 100644
--- a/test/javascripts/fixtures/notification_fixtures.js.es6
+++ b/test/javascripts/fixtures/notification_fixtures.js.es6
@@ -1,5 +1,5 @@
 /*jshint maxlen:10000000 */
-import { LIKED_CONSOLIDATED_TYPE } from "discourse/components/concerns/notification-types";
+import { LIKED_CONSOLIDATED_TYPE } from "discourse/widgets/notification-item";
 
 export default {
   "/notifications": {
diff --git a/test/javascripts/fixtures/site-fixtures.js.es6 b/test/javascripts/fixtures/site-fixtures.js.es6
index a567dcd..25d1dc3 100644
--- a/test/javascripts/fixtures/site-fixtures.js.es6
+++ b/test/javascripts/fixtures/site-fixtures.js.es6
@@ -1,4 +1,4 @@
-import { LIKED_CONSOLIDATED_TYPE } from "discourse/components/concerns/notification-types";
+import { LIKED_CONSOLIDATED_TYPE } from "discourse/widgets/notification-item";
 
 export default {
   "site.json": {

GitHub sha: dfcc2e7a

@ZogStriP @pmusaraj Is a follow up required here considering that this was reverted?

Yes, Bianca has a new PR up: FEATURE: Send notification when member was accepted to group. by nbianca · Pull Request #7614 · discourse/discourse · GitHub

3 Likes