How to disable mail for staged users?

Continuing the discussion from Description of various user states in Discourse (Admin / Moderator / Staff / Developer / Other ):

I’ve got a forum that includes a Google Groups import. For Reasons, the intention is that this will be a static archive of the Google Group. The Google Group will continue to function standalone and the forum will simply include its posts as static archived data. Right now, I’m doing that by periodically running the Google Import script, but think that I’ll soon instead configure incoming mail and subscribe the category to the Google Group list.

I have turned off enabled staged users. The users all show as active=false and staged=true.

If someone replies to a post, they get an email.

If someone PMs them, they get an email.

If I change the user’s staged status to false, they no longer get PMs, but they do still get notifications about replies to their messages. This seems like a fine behavior, and exactly what someone else was asking about just today, but this entity believes that they do not have permission to email these Google Groups users who have not created an account on the forum.

Maybe I can modify the import script and/or make a plugin that will do something like make all active=false users automatically set to staged=false? Maybe I set the archive category so that it cannot be watched (in a plugin, I guess)?

For the record, here’s how staged users are supposed to be treated:

2 Likes

Continuing the discussion from How to disable mail for staged users?:

Well, I didn’t figure out a way to keep staged users from getting email, so I guess I’ll do

def no_mail_for_staged_users
  staged=User.where(staged: true)
  staged.all.each do |user|
    o=UserOption.find_by(user_id: user.id)
    o.email_level = 2
    o.email_messages_level = 2
    o.email_digests = false
    o.save
  end
end

and modify the mbox script to similarly disable email for the staged users that it creates.

If anyone has any better ideas, I’d be interested to hear.

Are you on latest? There was a bug around staged users getting email that we fixed in the last week or two.

2 Likes

That would be good. I’ll check on Monday and see about undoing the user option changes.

1 Like