Skip to content

Commit

Permalink
Remove notified events
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 27, 2021
1 parent 26014cd commit 6125721
Show file tree
Hide file tree
Showing 38 changed files with 84 additions and 505 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class NotificationsSettingsController < ::Admin::SettingsController
end

def show
@notifiables = OpenProject::Notifiable.all

respond_to :html
end

Expand Down
11 changes: 0 additions & 11 deletions app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,6 @@ def setting_block(setting, options = {}, &block)
setting_label(setting, options) + wrap_field_outer(options, &block)
end

# Renders a notification field for an OpenProject::Notifiable option
def notification_field(notifiable, options = {})
content_tag(:label, class: 'form--label-with-check-box') do
styled_check_box_tag('settings[notified_events][]',
notifiable.name,
Setting.notified_events.include?(notifiable.name),
options.merge(id: nil)) +
l_or_humanize(notifiable.name, prefix: 'label_')
end
end

private

def wrap_field_outer(options, &block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def self.supports_mail?
end

def self.subscribed_users(comment)
User.notified_globally notification_reason(comment)
User.notified_globally subscribed_notification_reason(comment)
end

def self.subscribed_notification_reason(_comment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def self.supports_mail?
end

def self.subscribed_users(journal)
User.notified_globally notification_reason(journal)
User.notified_globally subscribed_notification_reason(journal)
end

def self.subscribed_notification_reason(_journal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def self.supports_mail?

def self.subscribed_users(journal)
if journal.initial?
User.notified_globally notification_reason(journal)
User.notified_globally subscribed_notification_reason(journal)
else
# No notification on updating a news
User.none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def self.supports_mail?
end

def self.subscribed_users(journal)
User.notified_globally notification_reason(journal)
User.notified_globally subscribed_notification_reason(journal)
end

def self.subscribed_notification_reason(journal)
Expand Down
8 changes: 0 additions & 8 deletions app/services/notifications/mail_service/comment_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
module Notifications::MailService::CommentStrategy
class << self
def send_mail(notification)
return if notification_disabled?

UserMailer
.news_comment_added(
notification.recipient,
Expand All @@ -39,11 +37,5 @@ def send_mail(notification)
)
.deliver_later
end

private

def notification_disabled?
Setting.notified_events.exclude?('news_comment_added')
end
end
end
8 changes: 0 additions & 8 deletions app/services/notifications/mail_service/message_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
module Notifications::MailService::MessageStrategy
class << self
def send_mail(notification)
return if notification_disabled?

UserMailer
.message_posted(
notification.recipient,
Expand All @@ -39,11 +37,5 @@ def send_mail(notification)
)
.deliver_later
end

private

def notification_disabled?
Setting.notified_events.exclude?('message_posted')
end
end
end
8 changes: 1 addition & 7 deletions app/services/notifications/mail_service/news_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
module Notifications::MailService::NewsStrategy
class << self
def send_mail(notification)
return if notification_disabled? || !notification.journal.initial?
return unless notification.journal.initial?

UserMailer
.news_added(
Expand All @@ -39,11 +39,5 @@ def send_mail(notification)
)
.deliver_later
end

private

def notification_disabled?
Setting.notified_events.exclude?('news_added')
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class << self
def send_mail(notification)
method = mailer_method(notification)

return if notification_disabled?(method.to_s)

UserMailer
.send(method,
notification.recipient,
Expand All @@ -50,9 +48,5 @@ def mailer_method(notification)
:wiki_content_updated
end
end

def notification_disabled?(name)
Setting.notified_events.exclude?(name)
end
end
end
22 changes: 0 additions & 22 deletions app/views/admin/settings/notifications_settings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,5 @@ See COPYRIGHT and LICENSE files for more details.
</span>
</div>

<fieldset id="notified_events" class="form--fieldset">
<legend class="form--fieldset-legend">
<%= t(:text_select_notifications) %>
</legend>
<div class="form--toolbar">
<span class="form--toolbar-item">
(<%= check_all_links 'notified_events' %>)
</span>
</div>
<%= hidden_field_tag 'settings[notified_events][]', '' %>
<div class="form--field">
<div class="form--field-container -vertical">
<% @notifiables.each do |notifiable| %>
<%= notification_field notifiable %>
<% end %>
</div>
<span class="form--field-instructions -no-margin">
<%= t(:'settings.notifications.events_explanation') %>
</span>
</div>
</fieldset>

<%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %>
<% end %>
8 changes: 3 additions & 5 deletions app/views/wiki/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
</li>
<% end %>
<% if Setting.notified_events.include?("wiki_content_added") or Setting.notified_events.include?("wiki_content_updated") %>
<li class="toolbar-item hidden-for-mobile">
<%= watcher_link(@page, User.current) %>
</li>
<% end %>
<li class="toolbar-item hidden-for-mobile">
<%= watcher_link(@page, User.current) %>
</li>
<% if @content.version != @page.content.version %>
<li class="toolbar-item hidden-for-mobile">
<%= link_to(t(:label_history), {action: 'history', id: @page}, class: 'button icon-wiki') %>
Expand Down
10 changes: 0 additions & 10 deletions app/workers/mails/member_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,18 @@ def send_for_project_user(_current_user, _member, _message)
end

def send_updated_global(current_user, member, member_message)
return if sending_disabled?(:updated, member_message)

MemberMailer
.updated_global(current_user, member, member_message)
.deliver_now
end

def send_added_project(current_user, member, member_message)
return if sending_disabled?(:added, member_message)

MemberMailer
.added_project(current_user, member, member_message)
.deliver_now
end

def send_updated_project(current_user, member, member_message)
return if sending_disabled?(:updated, member_message)

MemberMailer
.updated_project(current_user, member, member_message)
.deliver_now
Expand All @@ -84,8 +78,4 @@ def every_group_user_member(member, &block)
.includes(:project, :principal, :roles, :member_roles)
.each(&block)
end

def sending_disabled?(setting, message)
message.blank? && !Setting.notified_events.include?("membership_#{setting}")
end
end
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,6 @@ en:
text_regexp_info: "eg. ^[A-Z0-9]+$"
text_regexp_multiline: 'The regex is applied in a multi-line mode. e.g., ^---\s+'
text_repository_usernames_mapping: "Select or update the OpenProject user mapped to each username found in the repository log.\nUsers with the same OpenProject and repository username or email are automatically mapped."
text_select_notifications: "Select actions for which notifications should be sent."
text_status_changed_by_changeset: "Applied in changeset %{value}."
text_table_difference_description: "In this table the single %{entries} are shown. You can view the difference between any two entries by first selecting the according checkboxes in the table. When clicking on the button below the table the differences are shown."
text_time_logged_by_changeset: "Applied in changeset %{value}."
Expand Down
10 changes: 0 additions & 10 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,6 @@ user_format:
cross_project_work_package_relations:
default: 1
format: boolean
notified_events:
serialized: true
default:
- news_added
- news_comment_added
- message_posted
- wiki_content_added
- wiki_content_updated
- membership_added
- membership_updated
mail_handler_body_delimiters:
default: ''
mail_handler_ignore_filenames:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from 'core-app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import {
distinctUntilChanged,
filter,
withLatestFrom,
} from 'rxjs/operators';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class ReminderSettingsDailyTimeComponent implements OnInit {
.get('times') as FormArray)
.valueChanges
.pipe(
startWith(() => this.form.get('times')?.value as FormArray),
map(() => {
const timesArray = this.form.get('times') as FormArray;
const activeTimes = timesArray.controls.map((c) => c.value as string);
Expand Down Expand Up @@ -191,6 +192,7 @@ export class ReminderSettingsDailyTimeComponent implements OnInit {
);
}

// eslint-disable-next-line class-methods-use-this
isDisabled(time:string, activeTimes:string[]):boolean {
return activeTimes.length === 0 || (activeTimes.length === 1 && activeTimes[0] === time);
}
Expand Down
54 changes: 0 additions & 54 deletions lib/open_project/notifiable.rb

This file was deleted.

2 changes: 1 addition & 1 deletion modules/documents/app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def add_attachment
model: @document,
args: document_params

if call.success? && Setting.notified_events.include?('document_added')
if call.success?
added = call.result
.attachments
.reject { |a| current_attachments.include?(a.id) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def self.supports_mail?
end

def self.subscribed_users(journal)
User.notified_globally notification_reason(journal)
User.notified_globally subscribed_notification_reason(journal)
end

def self.subscribed_notification_reason(_journal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
module Notifications::MailService::DocumentStrategy
class << self
def send_mail(notification)
return if notification_disabled? || !notification.journal.initial?
return unless notification.journal.initial?

DocumentsMailer
.document_added(
Expand All @@ -38,11 +38,5 @@ def send_mail(notification)
)
.deliver_later
end

private

def notification_disabled?
Setting.notified_events.exclude?('document_added')
end
end
end
1 change: 0 additions & 1 deletion modules/documents/lib/open_project/documents/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class Engine < ::Rails::Engine
activity_provider :documents, class_name: 'Activities::DocumentActivityProvider', default: false

patches %i[CustomFieldsHelper Project]
patch_with_namespace :OpenProject, :Notifiable

add_api_path :documents do
"#{root}/documents"
Expand Down
Loading

0 comments on commit 6125721

Please sign in to comment.