Topic notifications emails are not being sent if adding a Staff Colour to the post

Currently running Discourse 3.5.0.beta7-dev (7562bc2b15)

Topic notifications emails are not being sent out when scheduling a post to publish under certain conditions.

We’ve come across a very unusual bug and while we are running latest, this has occurred a few times in recent months so the issue has been around for a while.

We have a category called #Announcements and every user is set to Watching First Post by default.

Our steps to replicate the issue:

  1. Compose a new topic in a hidden staff-only category
  2. Apply a staff colour to the first post in the new topic
  3. Set a topic timer, Schedule Publishing, set the category to #Announcements and set the time/date

What should happen:

  • The topic moves from #staff to #Announcements
  • Tens of thousands of emails get sent
  • Each user receives a notification

What does happen:

  • The topic moves from #staff to #Announcements
  • No emails get sent
  • Each user receives a notification

While waiting for the scheduled publishing time to arrive, I could see these two tasks pending (filtered by the Post ID):

Ten minutes later when the topic was published in to the #Announcements the tasks disappeared:

The notifications were sent, here’s what a test account received:

But still no emails went out.

Usually at this point we’d see tens of thousands of emails starting to queue up in Scheduled and gradually moving their way across to Enqueued, but nothing happens, zero emails are sent out.

There is also nothing in Discourse error logs.

The posts contained a poll, but I suspect the post content is irrelevant, however I’m mentioning it here just in case the poll also has any relevance.

Today’s failed test can be found here if it helps anyone: https://greyarro.ws/t/do-you-own-a-drone-thats-not-on-the-what-do-you-fly-list/98146.json

The key to this failure very much seems to be caused by the action of adding a staff colour to the first post in the topic that’s scheduled for publishing.

Every other scheduled publishing post emails out just fine, adding a staff colour makes it fail every single time.

3 Likes

I can repro this. :raised_hand:

My basic step by step:

  • Adjust email time window to 1 minute (optional, but speeds things up)
  • As admin, ensure test user is Watching First Post for a test category
  • As admin, create topic in #staff category
  • Use post wrench to add Staff Colour to the first(/only) post
  • Set topic timer to Schedule Publishing into the test category in 1 minute
  • Have a small day dream about ice cream and wait for topic to be published and for a further minute to elapse to cover the email window
  • As admin, check the test user’s notifications, and then check the site’s email logs

Expected Result: test user receives notification about the scheduled topic and an email log is present signifying an accompanying email notification has been sent

Actual Result: test user receives an onsite notification but no email is sent out

(Also performed this test without the staff colour step as a control. All working fine. Both onsite notification and email notification were sent)

Is it something to do with staff colour adjusting the post_type to ‘2’ (moderator_action) and this not being accounted for in the code?

4 Likes

I knew I’d forget one of the repro steps :rofl:

This is an interesting observation:

2 Likes

Yeah, once you turn a post to a staff post it becomes Post.types[:moderator_action] I think we should notify here, the omission seems to be a mistake.

Added a pri-medium (some time in the next 4 weeks) so the team can have a look.

2 Likes

Out of interest, does replying to a user and setting a staff colour on the reply also cause the email notification to not be sent to that user?