remove journal aggregate event

pull/10886/head
ulferts 2 years ago
parent f452b0b411
commit a7febaf6a0
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 17
      app/services/journals/create_service.rb
  2. 39
      app/services/notifications/aggregated_journal_service.rb
  3. 4
      config/initializers/subscribe_listeners.rb
  4. 1
      lib/open_project/events.rb
  5. 51
      spec/services/notifications/aggregated_journal_service_integration_spec.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}" }

@ -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

@ -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]

@ -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

@ -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
Loading…
Cancel
Save