Suspension emails fail with 'undefined method 'topic', other emails work fine

Hi @omarfilip,

I don’t have a solution for you, but I wanted to confirm I was able to replicate this experience on an installation of Discourse that does not have many plugins.

Steps taken to replicate:

  1. Select a user from /admin/users/list/active and manually suspend with the suspend button.

image

  1. Add text in the “Email message” field.

  1. Click the suspend button and confirm the user is now suspended.

image

Result: No email is sent, and there is a Job Exception in the error logs.

Message (3 copies reported)

Job exception: undefined method `topic' for nil:NilClass


Backtrace

/var/www/discourse/app/jobs/regular/user_email.rb:116:in `message_for_email'
/var/www/discourse/app/jobs/regular/user_email.rb:76:in `send_user_email'
/var/www/discourse/app/jobs/regular/user_email.rb:39:in `execute'
/var/www/discourse/plugins/chat/lib/chat/user_email_extension.rb:6:in `execute'
/var/www/discourse/app/jobs/regular/critical_user_email.rb:12:in `execute'
/var/www/discourse/app/jobs/base.rb:249:in `block (2 levels) in perform'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in `with_connection'
/var/www/discourse/app/jobs/base.rb:236:in `block in perform'
/var/www/discourse/app/jobs/base.rb:232:in `each'
/var/www/discourse/app/jobs/base.rb:232:in `perform'
5 Likes