diff --git a/app/models/notifier.rb b/app/models/notifier.rb index eef797d6e..9e286aa2f 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -9,7 +9,8 @@ class Notifier def generate recipients.map do |recipient| - Notification.create! user: recipient, creator: event.creator, bubble: bubble, resource: resource, body: body + Notification.create! user: recipient, creator: event.creator, + bubble: bubble, resource: resource, title: title, body: body end end @@ -18,6 +19,10 @@ class Notifier @event = event end + def title + bubble.title + end + def body raise NotImplementedError end diff --git a/app/models/notifier/commented.rb b/app/models/notifier/commented.rb index 72cd01602..8b416a517 100644 --- a/app/models/notifier/commented.rb +++ b/app/models/notifier/commented.rb @@ -1,5 +1,9 @@ class Notifier::Commented < Notifier private + def title + "RE: " + super + end + def body "#{event.creator.name}" end diff --git a/app/views/notifications/_notification.html.erb b/app/views/notifications/_notification.html.erb index faf721470..6e55e5b75 100644 --- a/app/views/notifications/_notification.html.erb +++ b/app/views/notifications/_notification.html.erb @@ -5,7 +5,7 @@
- <%= "RE: " if notification.resource.is_a?(Comment) %><%= notification.bubble.title %> + <%= notification.title %> <%= notification.body %> ยท <%= time_ago_in_words(notification.created_at) %> ago
diff --git a/db/migrate/20250109153649_create_notifications.rb b/db/migrate/20250109153649_create_notifications.rb index c2d97b93f..6a493d514 100644 --- a/db/migrate/20250109153649_create_notifications.rb +++ b/db/migrate/20250109153649_create_notifications.rb @@ -6,6 +6,7 @@ class CreateNotifications < ActiveRecord::Migration[8.1] t.references :bubble, null: false, foreign_key: true t.references :resource, null: false, polymorphic: true, index: true t.boolean :read, default: false, null: false + t.text :title, null: false t.text :body, null: false t.timestamps diff --git a/db/schema.rb b/db/schema.rb index d8a702e39..23aa986a1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -183,6 +183,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_01_09_153649) do t.string "resource_type", null: false t.integer "resource_id", null: false t.boolean "read", default: false, null: false + t.text "title", null: false t.text "body", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false diff --git a/test/fixtures/notifications.yml b/test/fixtures/notifications.yml index 802dcf68b..656331761 100644 --- a/test/fixtures/notifications.yml +++ b/test/fixtures/notifications.yml @@ -4,7 +4,8 @@ logo_created_kevin: bubble: logo resource: logo (Bubble) read: false - body: "created: The logo isn't big enough" + title: Logo isn't big enough + body: "Added by: David" created_at: <%= 1.week.ago %> layout_created_kevin: @@ -13,5 +14,6 @@ layout_created_kevin: bubble: layout resource: layout_overflowing_david (Comment) read: false - body: "re: Layout is broken" + title: "RE: Layout is broken" + body: "David" created_at: <%= 1.week.ago %>