OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
add work package processed notification setting
ulferts61357f50918f
diff --git a/app/models/notification.rb b/app/models/notification.rbindex bfb23667c0b..a35475c811c 100644--- a/app/models/notification.rb+++ b/app/models/notification.rb@@ -1,28 +1,17 @@class Notification < ApplicationRecord- enum reason_ian: {+ REASONS = {mentioned: 0,involved: 1,watched: 2,subscribed: 3,commented: 4,- created: 5- }, _prefix: :ian- enum reason_mail: {- mentioned: 0,- involved: 1,- watched: 2,- subscribed: 3,- commented: 4,- created: 5- }, _prefix: :mail- enum reason_mail_digest: {- mentioned: 0,- involved: 1,- watched: 2,- subscribed: 3,- commented: 4,- created: 5- }, _prefix: :mail_digest+ created: 5,+ processed: 6+ }.freeze++ enum reason_ian: REASONS, _prefix: :ian+ enum reason_mail: REASONS, _prefix: :mail+ enum reason_mail_digest: REASONS, _prefix: :mail_digestbelongs_to :recipient, class_name: 'User'belongs_to :actor, class_name: 'User'diff --git a/app/services/notifications/journal_wp_notification_service.rb b/app/services/notifications/journal_wp_notification_service.rbindex c0654f0e7a5..0fb8b4103bb 100644--- a/app/services/notifications/journal_wp_notification_service.rb+++ b/app/services/notifications/journal_wp_notification_service.rb@@ -86,6 +86,7 @@ class Notifications::JournalWpNotificationServiceadd_receiver(receivers, settings_of_subscribed(journal), :subscribed)add_receiver(receivers, settings_of_commented(journal), :commented)add_receiver(receivers, settings_of_created(journal), :created)+ add_receiver(receivers, settings_of_processed(journal), :processed)remove_self_recipient(receivers, journal)@@ -138,6 +139,14 @@ class Notifications::JournalWpNotificationService:work_package_created)end+ def settings_of_processed(journal)+ scope = !journal.initial? && journal.details.has_key?(:status_id) ? User.all : User.none++ applicable_settings(scope,+ journal.data.project,+ :work_package_processed)+ end+def applicable_settings(user_scope, project, reason)NotificationSetting.applicable(project)@@ -181,7 +190,6 @@ class Notifications::JournalWpNotificationServicedef send_notification_setting?(journal)notify_for_wp_updated?(journal) ||- notify_for_status?(journal) ||notify_for_priority(journal)end@@ -210,11 +218,6 @@ class Notifications::JournalWpNotificationServicenotification_enabled?('work_package_updated') && !journal.initial?end- def notify_for_status?(journal)- notification_enabled?('status_updated') &&- journal.details.has_key?(:status_id)- end-def notify_for_priority(journal)notification_enabled?('work_package_priority_updated') &&journal.details.has_key?(:priority_id)diff --git a/app/services/user_preferences/update_service.rb b/app/services/user_preferences/update_service.rbindex 62c1086686e..1b0331ac440 100644--- a/app/services/user_preferences/update_service.rb+++ b/app/services/user_preferences/update_service.rb@@ -83,7 +83,7 @@ module UserPreferenceson_duplicate_key_update: {conflict_target: conflict_target,index_predicate: index_predicate,- columns: %i[watched involved mentioned work_package_commented work_package_created all]+ columns: %i[watched involved mentioned work_package_commented work_package_created work_package_processed all]},validate: false).idsdiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 8ef125f5f75..74dacd42405 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1806,7 +1806,6 @@ en:label_start_to_start: "start to start"label_statistics: "Statistics"label_status: "Status"- label_status_updated: "Work package status updated"label_stay_logged_in: "Stay logged in"label_storage_free_space: "Remaining disk space"label_storage_used_space: "Used disk space"diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex 507fca1a8ed..9f0c09d121b 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -584,6 +584,7 @@ en:watched: 'I am watching'work_package_commented: 'Work package commented'work_package_created: 'Work package created'+ work_package_processed: 'Work package status changed'all: 'All events'add: 'Add setting for project'already_selected: 'This project is already selected'diff --git a/config/settings.yml b/config/settings.ymlindex 6e00b10c71c..b566bba2a3c 100644--- a/config/settings.yml+++ b/config/settings.yml@@ -237,7 +237,6 @@ notified_events:serialized: truedefault:- work_package_updated- - status_updated- work_package_priority_updated- news_added- news_comment_addeddiff --git a/db/migrate/20210802114054_add_notification_setting_options.rb b/db/migrate/20210802114054_add_notification_setting_options.rbindex a8a5cc2e281..4d4bf070325 100644--- a/db/migrate/20210802114054_add_notification_setting_options.rb+++ b/db/migrate/20210802114054_add_notification_setting_options.rb@@ -3,6 +3,7 @@ class AddNotificationSettingOptions < ActiveRecord::Migration[6.1]change_table :notification_settings, bulk: true do |t|t.boolean :work_package_commented, default: falset.boolean :work_package_created, default: false+ t.boolean :work_package_processed, default: falseend# TODO: remove existing notification setting from settingsdiff --git a/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.html b/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.htmlindex ab81926b5aa..5fa7136f3a1 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.html@@ -62,6 +62,16 @@[attr.aria-label]="text.work_package_commented_header"/></td>+<td>+ <input+ type="checkbox"+ [checked]="setting.workPackageProcessed || setting.all"+ [disabled]="setting.all"+ (change)="update({ workPackageProcessed: $event.target.checked })"+ data-qa-notification-type="work_package_processed"+ [attr.aria-label]="text.work_package_processed_header"+ />+</td><td><inputtype="checkbox"diff --git a/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.tsindex e3d2a83b636..f6fd517da7c 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/row/notification-setting-row.component.ts@@ -30,6 +30,7 @@ export class NotificationSettingRowComponent implements OnInit {watched_header: this.I18n.t('js.notifications.settings.watched'),work_package_commented_header: this.I18n.t('js.notifications.settings.work_package_commented'),work_package_created_header: this.I18n.t('js.notifications.settings.work_package_created'),+ work_package_processed_header: this.I18n.t('js.notifications.settings.work_package_processed'),any_event_header: this.I18n.t('js.notifications.settings.all'),default_all_projects: this.I18n.t('js.notifications.settings.default_all_projects'),add_setting: this.I18n.t('js.notifications.settings.add'),diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.htmlindex d075b3f589c..1e7d25a1118 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html@@ -56,6 +56,13 @@</div></div></th>+ <th>+ <div class="generic-table--sort-header-outer">+ <div class="generic-table--sort-header">+ <span [textContent]="text.work_package_processed_header"></span>+ </div>+ </div>+ </th><th><div class="generic-table--sort-header-outer"><div class="generic-table--sort-header">diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.tsindex 47fc4e8ac0f..8d08843ef24 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts@@ -36,6 +36,7 @@ export class NotificationSettingsTableComponent {watched_header: this.I18n.t('js.notifications.settings.watched'),work_package_commented_header: this.I18n.t('js.notifications.settings.work_package_commented'),work_package_created_header: this.I18n.t('js.notifications.settings.work_package_created'),+ work_package_processed_header: this.I18n.t('js.notifications.settings.work_package_processed'),any_event_header: this.I18n.t('js.notifications.settings.all'),default_all_projects: this.I18n.t('js.notifications.settings.default_all_projects'),};diff --git a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts b/frontend/src/app/features/user-preferences/state/notification-setting.model.tsindex 03f428a336d..cd3b6c3f206 100644--- a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts+++ b/frontend/src/app/features/user-preferences/state/notification-setting.model.ts@@ -10,6 +10,7 @@ export interface NotificationSetting {mentioned:boolean;workPackageCommented:boolean;workPackageCreated:boolean;+ workPackageProcessed:boolean;all:boolean;}@@ -26,6 +27,7 @@ export function buildNotificationSetting(project:null|HalSourceLink, params:Partwatched: true,workPackageCommented: true,workPackageCreated: true,+ workPackageProcessed: true,all: false,channel: 'in_app',...params,diff --git a/lib/api/v3/user_preferences/notification_setting_representer.rb b/lib/api/v3/user_preferences/notification_setting_representer.rbindex d01bc72c2d8..5fa4662d2df 100644--- a/lib/api/v3/user_preferences/notification_setting_representer.rb+++ b/lib/api/v3/user_preferences/notification_setting_representer.rb@@ -38,9 +38,10 @@ module APIproperty :watchedproperty :involvedproperty :mentioned- property :all- property :work_package_commentedproperty :work_package_created+ property :work_package_commented+ property :work_package_processed+ property :allassociated_resource :project,skip_render: ->(*) { true },diff --git a/lib/open_project/notifiable.rb b/lib/open_project/notifiable.rbindex 2c03c5d6bc0..6d488b21bb8 100644--- a/lib/open_project/notifiable.rb+++ b/lib/open_project/notifiable.rb@@ -31,7 +31,6 @@module OpenProjectNOTIFIABLE = [%w(work_package_updated),- %w(status_updated work_package_updated),%w(work_package_priority_updated work_package_updated),%w(news_added),%w(news_comment_added),diff --git a/spec/factories/notification_setting_factory.rb b/spec/factories/notification_setting_factory.rbindex 25c390361bb..a06fdec8671 100644--- a/spec/factories/notification_setting_factory.rb+++ b/spec/factories/notification_setting_factory.rb@@ -7,6 +7,7 @@ FactoryBot.define dowatched { true }work_package_commented { false }work_package_created { false }+ work_package_processed { false }project { nil } # Default settingsuserdiff --git a/spec/features/notifications/digest_mail_spec.rb b/spec/features/notifications/digest_mail_spec.rbindex 311ebcefc63..d7ada016f6e 100644--- a/spec/features/notifications/digest_mail_spec.rb+++ b/spec/features/notifications/digest_mail_spec.rb@@ -20,6 +20,7 @@ describe "Digest email", type: :feature, js: true domentioned: false,work_package_commented: false,work_package_created: false,+ work_package_processed: false,all: false),FactoryBot.build(:in_app_notification_setting,involved: false,@@ -27,6 +28,7 @@ describe "Digest email", type: :feature, js: true domentioned: false,work_package_commented: false,work_package_created: false,+ work_package_processed: false,all: false),FactoryBot.build(:mail_digest_notification_setting,involved: true,@@ -34,6 +36,7 @@ describe "Digest email", type: :feature, js: true domentioned: true,work_package_commented: true,work_package_created: true,+ work_package_processed: true,all: false)]end@@ -57,6 +60,7 @@ describe "Digest email", type: :feature, js: true dowatched: true,work_package_commented: true,work_package_created: true,+ work_package_processed: true,all: falsenotification_settings_page.configure_channel :mail_digest,@@ -66,6 +70,7 @@ describe "Digest email", type: :feature, js: true dowatched: true,work_package_commented: false,work_package_created: false,+ work_package_processed: false,all: falsenotification_settings_page.add_row(mute_project)@@ -77,6 +82,7 @@ describe "Digest email", type: :feature, js: true dowatched: false,work_package_commented: false,work_package_created: false,+ work_package_processed: false,all: falsenotification_settings_page.savediff --git a/spec/features/users/notifications/shared_examples.rb b/spec/features/users/notifications/shared_examples.rbindex 15f385b7672..68285e6741f 100644--- a/spec/features/users/notifications/shared_examples.rb+++ b/spec/features/users/notifications/shared_examples.rb@@ -19,6 +19,7 @@ shared_examples 'notification settings workflow' dowatched: true,work_package_commented: true,work_package_created: true,+ work_package_processed: true,all: false# Set settings for project email@@ -29,6 +30,7 @@ shared_examples 'notification settings workflow' dowatched: false,work_package_commented: false,work_package_created: false,+ work_package_processed: false,all: false# Set settings for project email digest@@ -39,6 +41,7 @@ shared_examples 'notification settings workflow' dowatched: false,work_package_commented: true,work_package_created: true,+ work_package_processed: true,all: truesettings_page.save@@ -55,6 +58,7 @@ shared_examples 'notification settings workflow' doexpect(in_app.all).to be_falseyexpect(in_app.work_package_commented).to be_falseyexpect(in_app.work_package_created).to be_falsey+ expect(in_app.work_package_processed).to be_falseymail = notification_settings.find_by(project: project, channel: :mail)expect(mail.involved).to be_truthy@@ -63,6 +67,7 @@ shared_examples 'notification settings workflow' doexpect(mail.all).to be_falseyexpect(mail.work_package_commented).to be_truthyexpect(mail.work_package_created).to be_truthy+ expect(mail.work_package_processed).to be_truthymail_digest = notification_settings.find_by(project: project, channel: :mail_digest)expect(mail_digest.involved).to be_falsey@@ -71,6 +76,7 @@ shared_examples 'notification settings workflow' doexpect(mail_digest.all).to be_truthyexpect(mail_digest.work_package_commented).to be_truthyexpect(mail_digest.work_package_created).to be_truthy+ expect(mail_digest.work_package_processed).to be_truthy# Trying to add the same project again will not be possible (Regression #38072)click_button 'Add setting for project'diff --git a/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rb b/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rbindex 51b87d5f8e1..a874b5426ed 100644--- a/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rb+++ b/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rb@@ -96,6 +96,10 @@ describe ::API::V3::UserPreferences::NotificationSettingRepresenter, 'rendering'it_behaves_like 'property', :workPackageCreated dolet(:value) { notification_setting.work_package_created }end++ it_behaves_like 'property', :workPackageProcessed do+ let(:value) { notification_setting.work_package_processed }+ endenddescribe '_embedded' dodiff --git a/spec/lib/open_project/notifiable_spec.rb b/spec/lib/open_project/notifiable_spec.rbindex d6c8888a44c..db97125eaba 100644--- a/spec/lib/open_project/notifiable_spec.rb+++ b/spec/lib/open_project/notifiable_spec.rb@@ -32,7 +32,7 @@ require 'spec_helper'describe OpenProject::Notifiable dodescribe '#all' doit 'matches expected list' do- expected = %w(work_package_updated status_updated work_package_priority_updated news_added news_comment_added+ expected = %w(work_package_updated work_package_priority_updated news_added news_comment_addedfile_added message_posted wiki_content_added wiki_content_updated membership_added membership_updated)expect(described_class.all.map(&:name))diff --git a/spec/services/notifications/journal_wp_notification_service_spec.rb b/spec/services/notifications/journal_wp_notification_service_spec.rbindex 425d8ae53a4..f0313a82ea9 100644--- a/spec/services/notifications/journal_wp_notification_service_spec.rb+++ b/spec/services/notifications/journal_wp_notification_service_spec.rb@@ -57,6 +57,7 @@ describe Notifications::JournalWpNotificationService, with_settings: { journal_awatched: false,mentioned: false,work_package_commented: false,+ work_package_processed: false,work_package_created: false}end@@ -119,7 +120,7 @@ describe Notifications::JournalWpNotificationService, with_settings: { journal_aendlet(:send_notifications) { true }let(:notification_setting) do- %w(work_package_updated status_updated work_package_priority_updated)+ %w(work_package_updated work_package_priority_updated)enddef call@@ -765,7 +766,7 @@ describe Notifications::JournalWpNotificationService, with_settings: { journal_aendcontext 'when a work package is created' do- context 'when the user configured to be notified' do+ context 'when the user configured to be notified on work package creation' dolet(:recipient_notification_settings) do[FactoryBot.build(:mail_notification_setting, **notification_settings_all_false@@ -791,6 +792,21 @@ describe Notifications::JournalWpNotificationService, with_settings: { journal_aendend+ context 'when the user configured to be notified on work package status changes' do+ let(:recipient_notification_settings) do+ [+ FactoryBot.build(:mail_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true)),+ FactoryBot.build(:mail_digest_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true)),+ FactoryBot.build(:in_app_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true))+ ]+ end++ it_behaves_like 'creates no notification'+ end+context 'when the user did not configure to be notified' dolet(:recipient_notification_settings) do[@@ -867,46 +883,62 @@ describe Notifications::JournalWpNotificationService, with_settings: { journal_acontext 'when the journal has status update' dolet(:journal) { journal_2_with_status }- let(:user_property) { :assigned_to }-- context 'notification for work_package_updated and status_updated disabled' do- let(:notification_setting) { %w(work_package_priority_updated) }-- it_behaves_like 'creates no notification'- end- context 'notification for work_package_updated enabled' do- let(:notification_setting) { %w(work_package_updated) }+ context 'when the user has processed notifications activated' do+ let(:recipient_notification_settings) do+ [+ FactoryBot.build(:mail_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true)),+ FactoryBot.build(:in_app_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true)),+ FactoryBot.build(:mail_digest_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true))+ ]+ endit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{read_ian: false,- reason_ian: :involved,+ reason_ian: :processed,read_mail: false,- reason_mail: :involved,+ reason_mail: :processed,read_mail_digest: false,- reason_mail_digest: :involved+ reason_mail_digest: :processed}endendend- context 'notification for status_updated enabled' do- let(:notification_setting) { %w(status_updated) }+ context 'when the user has commented notifications deactivated' do+ let(:recipient_notification_settings) do+ [+ FactoryBot.build(:mail_notification_setting, **notification_settings_all_false),+ FactoryBot.build(:in_app_notification_setting, **notification_settings_all_false),+ FactoryBot.build(:mail_digest_notification_setting, **notification_settings_all_false)+ ]+ end- it_behaves_like 'creates notification' do- let(:notification_channel_reasons) do- {- read_ian: false,- reason_ian: :involved,- read_mail: false,- reason_mail: :involved,- read_mail_digest: false,- reason_mail_digest: :involved- }- end+ it_behaves_like 'creates no notification'+ end+ end++ context 'when the journal has no status update' do+ let(:journal) { journal_2_with_notes }++ context 'with the user having commented notifications activated' do+ let(:recipient_notification_settings) do+ [+ FactoryBot.build(:mail_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true)),+ FactoryBot.build(:in_app_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true)),+ FactoryBot.build(:mail_digest_notification_setting, **notification_settings_all_false+ .merge(work_package_processed: true))+ ]end++ it_behaves_like 'creates no notification'endend@@ -915,7 +947,7 @@ describe Notifications::JournalWpNotificationService, with_settings: { journal_alet(:user_property) { :assigned_to }context 'notification for work_package_updated and work_package_priority_updated disabled' do- let(:notification_setting) { %w(status_updated) }+ let(:notification_setting) { [] }it_behaves_like 'creates no notification'end