# User's posts go to approval queue due to incorrect user post count

**URL:** https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263
**Category:** Bug
**Created:** [June 30, 2018, 1:33pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263 "2018-06-30T13:33:08Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [June 30, 2018, 1:33pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/1 "2018-06-30T13:33:08Z")

</div>

On one of my self-hosted installs, I have a user whose posts go to the approval queue, and I cannot figure out why. Here’s what I know:

- The staff action log does not mention the post being sent to the queue, just the approvals that follow.
- This posts appear to be innocent, no links, for example just a quote and text.
- The user isn’t silenced, so I don’t think this is caused by a `min first post typing time` violation.
- We have not modified any setting that matches `approve`, e.g. `approve post count` and `approve unless trust level` are both 0.
- The user is not staged.
- It appears that three of four topics / posts the user has created have been affected.

Is there any reason left for why the posts go to approval?

---

<div class="post-metadata">

### Author: ![Logan\_Devine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/logan_devine/32/119800_2.png) [@Logan\_Devine](https://meta.discourse.org/u/Logan_Devine)
#### Post date: [June 30, 2018, 2:13pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/2 "2018-06-30T14:13:24Z")

</div>

I think it has to do with `first_post_typing_time` as that sometimes mutes and sometimes does not.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [June 30, 2018, 2:52pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/3 "2018-06-30T14:52:56Z")

</div>

The user says that she’s definitely typing more than three seconds, and not pasting in text typed somewhere else.  
Either way, I set `min first post typing time` to `0`, maybe that’ll help.

---

<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: [June 30, 2018, 2:54pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/4 "2018-06-30T14:54:04Z")

</div>

Rogue browser setup would be my guess? Remember the detailed first post checks mostly only apply to trust level 0 users.

Have this user try in a different web browser and on their phone versus computer.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [June 30, 2018, 2:54pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/5 "2018-06-30T14:54:35Z")

</div>

Than that shouldn’t be it as that user is TL1 🤔

---

<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: [June 30, 2018, 2:59pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/6 "2018-06-30T14:59:58Z")

</div>

I’m not sure. Do you have any Watched Words that force posts into approval?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [June 30, 2018, 3:00pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/7 "2018-06-30T15:00:42Z")

</div>

No, there are no watched words at all.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [June 30, 2018, 3:05pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/8 "2018-06-30T15:05:36Z")

</div>

The user has just noticed that the post counter in her profile is off – it’s currently at zero, but has been negative before.

I think this explains what has been happening – even if `approve post count` is 0, if a users post count is off, he can run into this check:

> <https://github.com/discourse/discourse/blob/b87205831bf3d6c6226f628bc91dfa6d04534630/lib/new_post_manager.rb#L79>

---

<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: [June 30, 2018, 3:08pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/9 "2018-06-30T15:08:59Z")

</div>

Did this person have a lot of pms that got deleted or posts that got deleted somehow? Your theory makes sense.

We should add protection here @neil in some form.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [June 30, 2018, 3:11pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/10 "2018-06-30T15:11:25Z")

</div>

There was some post deletion.

The story is that that user sent me a PM, asking a question of which she was not sure whether she was allowed to ask that in public. I answered, and then asked her whether she was OK with making that public. She agreed, I deleted the discussion about turning the message public, and then used the feature to turn the message into a normal, public topic.

~~Apart from this, nothing fancy happened to the account, I think.~~

Also, there was another conversation before that that was converted from a public topic to a message before I replied.

Apart from this, nothing fancy happened to the account, I think. (Again.)

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [July 4, 2018, 6:45pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/12 "2018-07-04T18:45:25Z")

</div>

I confirmed there was a problem with post counting in personal messages and made a fix.

Deleting a post in personal message would subtract from the user’s post count stat, but they aren’t counted when they’re created. So post counts can become negative. Changing topics from personal to/from public was adjusting counts correctly.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 4, 2018, 7:12pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/13 "2018-07-04T19:12:25Z")

</div>

How can we fix this for existing accounts? Is there a way to trigger a re-count?

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [July 4, 2018, 8:27pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/14 "2018-07-04T20:27:35Z")

</div>

We don’t have a way to do a recount, but I’m building a task to do it.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 5, 2018, 10:23am UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/15 "2018-07-05T10:23:51Z")

</div>

That sounds perfect 👍

(I’d love it if it also recalculated other counters, specifically the number of topics per category, as we also have a – likely unrelated – weirdness there.)

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [July 5, 2018, 2:44pm UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/16 "2018-07-05T14:44:04Z")

</div>

I added `rake users:recalculate_post_counts`.

> [@fefrei](#):
>
> recalculated other counters, specifically the number of topics per category

[We already do that once per day](https://github.com/discourse/discourse/blob/master/app/jobs/scheduled/category_stats.rb). Open a new topic about it with details.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 27, 2018, 8:06am UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/17 "2018-07-27T08:06:43Z")

</div>

Since this has now landed in `beta`, I can confirm `rake users:recalculate_post_counts` did its job and the problem is solved 👍

Thanks! ❤

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 27, 2018, 8:06am UTC](https://meta.discourse.org/t/users-posts-go-to-approval-queue-due-to-incorrect-user-post-count/91263/18 "2018-07-27T08:06:47Z")

</div>


