# Automated Responses to Flags not Generating Notification

**URL:** https://meta.discourse.org/t/automated-responses-to-flags-not-generating-notification/31151
**Category:** Bug
**Created:** [July 17, 2015, 11:53pm UTC](https://meta.discourse.org/t/automated-responses-to-flags-not-generating-notification/31151 "2015-07-17T23:53:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![anon25879736](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@anon25879736](https://meta.discourse.org/u/anon25879736)
#### Post date: [July 17, 2015, 11:53pm UTC](https://meta.discourse.org/t/automated-responses-to-flags-not-generating-notification/31151/1 "2015-07-17T23:53:51Z")

</div>

On WTDWTF, we’ve been getting reports that users are not being notified when a staff members agrees, disagrees, or defers their custom flags. The automated post is being added to the message that’s attached to the flag, but the user isn’t being notified of this. They don’t find out about the new post unless they visit the Messages page in their profile.

If a staff member manually replies in the message attached to the flag, the notification does get properly generated.

Because of another bug that causes the automatic post to not generate if the flag was created by a staff member, this bug requires a non-staff account to reproduce.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [July 18, 2015, 12:01am UTC](https://meta.discourse.org/t/automated-responses-to-flags-not-generating-notification/31151/2 "2015-07-18T00:01:33Z")

</div>

> [@abarker](#):
>
> Because of another bug that causes the automatic post to not generate if the flag was created by a staff member,

This part is not a bug, any response in the topic by a staff member, including _creation of the first post_, prevents automated reply.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [October 14, 2015, 10:26am UTC](https://meta.discourse.org/t/automated-responses-to-flags-not-generating-notification/31151/3 "2015-10-14T10:26:15Z")

</div>

I narrowed this down to a timing issue in `Jobs::PostAlert`. If I throw a sleep in there and query for the automated response post, it works fine. Otherwise, the first query fails to find the post.

Jobs are working fine for other posts that are enqueued though.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [October 15, 2015, 6:44am UTC](https://meta.discourse.org/t/automated-responses-to-flags-not-generating-notification/31151/4 "2015-10-15T06:44:54Z")

</div>

my first encounter of a race condition… 💣

[https://github.com/discourse/discourse/pull/3854](https://github.com/discourse/discourse/pull/3854)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [October 15, 2015, 10:46am UTC](https://meta.discourse.org/t/automated-responses-to-flags-not-generating-notification/31151/5 "2015-10-15T10:46:00Z")

</div>

PR merged 😄 Please flag if the patch didn’t fix it for you
