FIX: uses new event notifications types

FIX: uses new event notifications types

diff --git a/app/models/discourse_post_event/event.rb b/app/models/discourse_post_event/event.rb
index 5c777db..a62ae9b 100644
--- a/app/models/discourse_post_event/event.rb
+++ b/app/models/discourse_post_event/event.rb
@@ -176,7 +176,7 @@ module DiscoursePostEvent
         end
 
       user.notifications.create!(
-        notification_type: Notification.types[:custom],
+        notification_type: Notification.types[:event_invitation] || Notification.types[:custom],
         topic_id: post.topic_id,
         post_number: post.post_number,
         data: {
diff --git a/assets/javascripts/discourse/widgets/event-invitation-notification-item.js.es6 b/assets/javascripts/discourse/widgets/event-invitation-notification-item.js.es6
new file mode 100644
index 0000000..bd69365
--- /dev/null
+++ b/assets/javascripts/discourse/widgets/event-invitation-notification-item.js.es6
@@ -0,0 +1,32 @@
+import I18n from "I18n";
+import { createWidgetFrom } from "discourse/widgets/widget";
+import { DefaultNotificationItem } from "discourse/widgets/default-notification-item";
+import { formatUsername } from "discourse/lib/utilities";
+import { iconNode } from "discourse-common/lib/icon-library";
+
+createWidgetFrom(
+  DefaultNotificationItem,
+  "event-invitation-notification-item",
+  {
+    notificationTitle(notificationName, data) {
+      return data.title ? I18n.t(data.title) : "";
+    },
+
+    text(notificationName, data) {
+      const username = formatUsername(data.display_username);
+
+      let description;
+      if (data.topic_title) {
+        description = `<span data-topic-id="${this.attrs.topic_id}">${data.topic_title}</span>`;
+      } else {
+        description = this.description(data);
+      }
+
+      return I18n.t(data.message, { description, username });
+    },
+
+    icon(notificationName, data) {
+      return iconNode(`notification.${data.message}`);
+    }
+  }
+);
diff --git a/assets/javascripts/discourse/widgets/event-reminder-notification-item.js.es6 b/assets/javascripts/discourse/widgets/event-reminder-notification-item.js.es6
new file mode 100644
index 0000000..e5e4837
--- /dev/null
+++ b/assets/javascripts/discourse/widgets/event-reminder-notification-item.js.es6
@@ -0,0 +1,28 @@
+import I18n from "I18n";
+import { createWidgetFrom } from "discourse/widgets/widget";
+import { DefaultNotificationItem } from "discourse/widgets/default-notification-item";
+import { formatUsername } from "discourse/lib/utilities";
+import { iconNode } from "discourse-common/lib/icon-library";
+
+createWidgetFrom(DefaultNotificationItem, "event-reminder-notification-item", {
+  notificationTitle(notificationName, data) {
+    return data.title ? I18n.t(data.title) : "";
+  },
+
+  text(notificationName, data) {
+    const username = formatUsername(data.display_username);
+
+    let description;
+    if (data.topic_title) {
+      description = `<span data-topic-id="${this.attrs.topic_id}">${data.topic_title}</span>`;
+    } else {
+      description = this.description(data);
+    }
+
+    return I18n.t(data.message, { description, username });
+  },
+
+  icon(notificationName, data) {
+    return iconNode(`notification.${data.message}`);
+  }
+});
diff --git a/assets/javascripts/initializers/discourse-post-event-decorator.js.es6 b/assets/javascripts/initializers/discourse-post-event-decorator.js.es6
index 02cee22..bad1f20 100644
--- a/assets/javascripts/initializers/discourse-post-event-decorator.js.es6
+++ b/assets/javascripts/initializers/discourse-post-event-decorator.js.es6
@@ -219,6 +219,11 @@ function initializeDiscoursePostEventDecorator(api) {
   );
 
   api.replaceIcon(
+    "notification.discourse_calendar.invite_user_predefined_attendance_notification",
+    "calendar-day"
+  );
+
+  api.replaceIcon(
     "notification.discourse_post_event.notifications.before_event_reminder",
     "calendar-day"
   );
diff --git a/jobs/regular/discourse_post_event/send_reminder.rb b/jobs/regular/discourse_post_event/send_reminder.rb
index dd8084b..32e33db 100644
--- a/jobs/regular/discourse_post_event/send_reminder.rb
+++ b/jobs/regular/discourse_post_event/send_reminder.rb
@@ -13,7 +13,7 @@ module Jobs
 
       already_notified_users = Notification.where(
         read: false,
-        notification_type: Notification.types[:custom],
+        notification_type: Notification.types[:event_reminder] || Notification.types[:custom],
         topic_id: event.post.topic_id,
         post_number: 1
       )
@@ -42,7 +42,7 @@ module Jobs
 
       invitees.find_each do |invitee|
         invitee.user.notifications.create!(
-          notification_type: Notification.types[:custom],
+          notification_type: Notification.types[:event_reminder] || Notification.types[:custom],
           topic_id: event.post.topic_id,
           post_number: event.post.post_number,
           data: {
diff --git a/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb b/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb
index c701e9c..7f4a0a6 100644
--- a/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb
+++ b/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb
@@ -33,7 +33,7 @@ describe Jobs::DiscoursePostEventSendReminder do
     end
 
     going_user_unread_notification.notifications.create!(
-      notification_type: Notification.types[:custom],
+      notification_type: Notification.types[:event_reminder],
       topic_id: post_1.topic_id,
       post_number: 1,
       data: {}.to_json

GitHub sha: 2f45fd76