diff --git a/app/services/journals/create_service.rb b/app/services/journals/create_service.rb index e5138b03a4..4a050e6458 100644 --- a/app/services/journals/create_service.rb +++ b/app/services/journals/create_service.rb @@ -614,23 +614,6 @@ module Journals predecessor.user_id == user.id end - # TODO: check if this can be removed - # also check for the event and what it effects - def notify_aggregation_destruction(predecessor, journal) - OpenProject::Notifications.send(OpenProject::Events::JOURNAL_AGGREGATE_BEFORE_DESTROY, - journal:, - predecessor:) - end - - # TODO: check if this can be removed - def take_over_journal_details(predecessor, journal) - if predecessor.notes.present? - journal.update_columns(notes: predecessor.notes, version: predecessor.version) - else - journal.update_columns(version: predecessor.version) - end - end - def log_journal_creation(predecessor) if predecessor Rails.logger.debug { "Aggregating journal #{predecessor.id} for #{journable_type} ##{journable.id}" } diff --git a/app/services/notifications/aggregated_journal_service.rb b/app/services/notifications/aggregated_journal_service.rb deleted file mode 100644 index c22c2dd798..0000000000 --- a/app/services/notifications/aggregated_journal_service.rb +++ /dev/null @@ -1,39 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2022 the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See COPYRIGHT and LICENSE files for more details. -#++ - -class Notifications::AggregatedJournalService - ## - # Move existing notifications for aggregated events over - # if they have an immediate response associated - def self.relocate_immediate(journal:, predecessor:) - Notification - .where(journal_id: predecessor.id) - .where(reason: :mentioned) - .update_all(journal_id: journal.id, read_ian: false) - end -end diff --git a/config/initializers/subscribe_listeners.rb b/config/initializers/subscribe_listeners.rb index 8b6f39138f..c37f7c7082 100644 --- a/config/initializers/subscribe_listeners.rb +++ b/config/initializers/subscribe_listeners.rb @@ -41,10 +41,6 @@ Rails.application.config.after_initialize do Journals::CompletedJob.schedule(payload[:journal], payload[:send_notification]) end - OpenProject::Notifications.subscribe(OpenProject::Events::JOURNAL_AGGREGATE_BEFORE_DESTROY) do |payload| - Notifications::AggregatedJournalService.relocate_immediate(**payload.slice(:journal, :predecessor)) - end - OpenProject::Notifications.subscribe(OpenProject::Events::WATCHER_ADDED) do |payload| next unless payload[:send_notifications] diff --git a/lib/open_project/events.rb b/lib/open_project/events.rb index de74e1611f..b4f842238c 100644 --- a/lib/open_project/events.rb +++ b/lib/open_project/events.rb @@ -45,7 +45,6 @@ module OpenProject ATTACHMENT_CREATED = 'attachment_created'.freeze JOURNAL_CREATED = 'journal_created'.freeze - JOURNAL_AGGREGATE_BEFORE_DESTROY = 'journal_aggregate_before_destroy'.freeze MEMBER_CREATED = 'member_created'.freeze MEMBER_UPDATED = 'member_updated'.freeze diff --git a/spec/services/notifications/aggregated_journal_service_integration_spec.rb b/spec/services/notifications/aggregated_journal_service_integration_spec.rb deleted file mode 100644 index 8366e0ff90..0000000000 --- a/spec/services/notifications/aggregated_journal_service_integration_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2022 the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See COPYRIGHT and LICENSE files for more details. -#++ - -require 'spec_helper' -require_relative './mentioned_journals_shared' - -describe Notifications::AggregatedJournalService, 'integration', type: :model do - include_context 'with a mentioned work package being updated again' - - it 'will relocate the notification to the newer journal' do - trigger_comment! - - expect(mentioned_notification).to be_present - journal = mentioned_notification.journal - - update_assignee! - - expect(mentioned_notification.reload).to be_present - expect(mentioned_notification.journal).to eq journal - expect(mentioned_notification.journal.updated_at).not_to eq journal.updated_at - - # Expect only one notification to be present - expect(Notification.where(recipient:, reason: :mentioned).count) - .to eq 1 - end -end