FIX: skip notifications when topic is not found (#634)

Fixes a bug where the topic may already be deleted before the notification job runs, causing the job to fail.
This commit is contained in:
David Battersby 2025-02-18 12:02:59 +04:00 committed by GitHub
parent 77dc3abc12
commit db60986342
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -68,6 +68,7 @@ module DiscourseAssign
end
def call
return if topic.nil?
Assigner.publish_topic_tracking_state(topic, user.id)
unless mark_as_read?
PostAlerter.new(post).create_notification_alert(

View File

@ -24,6 +24,20 @@ RSpec.describe DiscourseAssign::CreateNotification do
create_notification
end
context "when topic is not found" do
before { assignment.topic = nil }
it "does not publish topic tracking state" do
Assigner.expects(:publish_topic_tracking_state).never
create_notification
end
it "does not create a notification alert" do
alerter.expects(:create_notification_alert).never
create_notification
end
end
context "when `mark_as_read` is false" do
let(:excerpt) do
I18n.t(