Is there a way to disable reply notification emails?


(Michael - DiscourseHosting.com) #1

We’re currently using the API to do some large forum migrations.
Of course we have disabled all email sending during the import runs using

config.action_mailer.delivery_method = :test 

But still the import jobs sometimes hangs for 10 or 20 seconds, and it turns out that the system is busy creating the notification mails.

So is there a more high-level way of disabling email notifications? That would allow the system to stop wasting time on creating those mails, and it would also allow an API client to toggle the notifications instead of having to reconfigure (argh, currently outside of the multisite config!) and restart Discourse.

Maybe it’s already there, but we cannot find it.


Using Discourse without any email interaction
(Ben T) #2

It’s a per user setting so you can manipulate it on all users from the rails console.

cd /var/docker
./launcher ssh app
rails c

and run this short code, typing it in line by line.

User.exec_sql("UPDATE user_options SET email_direct = 'f' WHERE email_direct = 't'")

You’ll get a bunch of outputs but this will turn off the last option in the screenshot below for all users. You can also edit email_digests and email_private_messages this way.

Overall though a flag may help.


(Jeff Atwood) #3

I know @ben_lubar is also working on a PR in this area.


(James Figgle) #4

I tried this and got thrown an error:

[1] pry(main)> User.all.each do |u|
[1] pry(main)*   u.email_direct = false
[1] pry(main)*   u.save
[1] pry(main)* end
NoMethodError: undefined method `email_direct=' for #<User:0x0055682f8f0e70>
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activemodel-4.2.5.2/lib/active_model/attribute_methods.rb:433:in `method_missing'

Has this method changed?


(Régis Hanol) #5

This was recently (about a month ago) changed. Try this instead

User.exec_sql("UPDATE user_options SET email_direct = 'f' WHERE email_direct = 't'")