Skip to content

Cleanup approval alerts after approvals#7529

Merged
sbulen merged 3 commits intoSimpleMachines:release-2.1from
sbulen:cleanup_moderation_alerts
Oct 18, 2022
Merged

Cleanup approval alerts after approvals#7529
sbulen merged 3 commits intoSimpleMachines:release-2.1from
sbulen:cleanup_moderation_alerts

Conversation

@sbulen
Copy link
Copy Markdown
Contributor

@sbulen sbulen commented Jul 22, 2022

Fixes #7423 (last one)

Cleanup alerts that posts need approval after posts have been approved.

The wrinkle here was that the post alerts were not identified by msg ids, but by topic ids, which made it impossible to identify the specific alerts to delete for that message. This required changing the content of the alert a bit, which in turn, required changing the key of the language string, as it is dynamically built.

sbulen added 3 commits July 20, 2022 19:27
Signed by Shawn Bulen, bulens@pacbell.net
Signed by Shawn Bulen, bulens@pacbell.net
Signed by Shawn Bulen, bulens@pacbell.net
Comment thread Sources/tasks/ApprovePost-Notify.php
@sbulen sbulen added this to the 2.1.3 milestone Jul 24, 2022
@Sesquipedalian
Copy link
Copy Markdown
Member

My comment here also applies to this PR, I'm afraid. 🙁

@sbulen
Copy link
Copy Markdown
Contributor Author

sbulen commented Aug 17, 2022

As in the others - this cannot attempt a delete before the alert exists - because it's driven by a query of existing alerts.

@Sesquipedalian
Copy link
Copy Markdown
Member

See #7516 (comment) 🙂

@sbulen
Copy link
Copy Markdown
Contributor Author

sbulen commented Aug 17, 2022

Yes, it is conceivable that the cleanup is attempted before the alert is posted (mainly if you're having system issues & cron isn't functioning). But that is such a narrow possibility, and the downside of that happening is so negligible, that I think we should stay with what we have here.

I modeled these PRs after pre-existing logic used elsewhere in SMF for cleaning up alerts, e.g., the cleanup after quote/mention removal logic.

You wrote that logic, emulated here.

For moderation activity and approvals, there will be sufficient time between those actions this gap should be virtually non-existent (again, unless there are system issues). For likes, especially if someone sits there twiddling the like link incessantly, there may be a discrepancy. But, it should be noted, that there was, in fact, a like performed. It's not inaccurate.

For 0.01% of the time, a once valid alert may remain after the fact. But the truth remains it was once valid.

This is not an accounting application with millions of transactions & critical sequencing. If so, I agree a rewrite of all of these functions would be necessary.

Now is not the time for a redesign. It is unnecessary.

These PRs had extensive testing before they were submitted, and have been executing in an active production environment for months after that with no issues.

@Sesquipedalian
Copy link
Copy Markdown
Member

Why the change to content_type for unapproved replies? I agree that it would make better sense for it to be msg rather than topic in such cases, but changing this part of the current behaviour doesn't seem strictly necessary to make this code work. Am I missing something?

@Sesquipedalian
Copy link
Copy Markdown
Member

I ask because I'd rather not force the translators to redo the $txt string if we can avoid it.

@sbulen
Copy link
Copy Markdown
Contributor Author

sbulen commented Aug 19, 2022

It's necessary to properly identify the alert. A "topic reply" that only ids the topic isn't specific enough to uniquely the message that was approved.

Suzie might have 2 unapproved posts in topic 555. George may have approved post 1 and Randy approved post 2. Both posts just put alerts out there for topic 555 - nothing message specific.

It's conceivable to find the alert by doing a preg match against the url stuffed in there... But that's a hackish workaround.

In all other alerts, the content ids uniquely id the record. Here, he messages are flagged as topic replies.

Note I only fixed the ones I had to here. There are other alerts that use the wrong content identifiers. All post & post approval related. Sometimes the content points to topics vs messages; sometimes it labeled as a board when the id is a topic id, etc. But I only cleaned up what I absolutely had to for this task.

So... Existing alerts at the time this goes in may not be cleaned properly, since they are not uniquely identified.

The "Mark read" link fixes everything, and resets the counters. It's magic....

@Sesquipedalian
Copy link
Copy Markdown
Member

Makes sense. Thanks.

@sbulen sbulen self-assigned this Sep 25, 2022
@sbulen
Copy link
Copy Markdown
Contributor Author

sbulen commented Oct 15, 2022

I believe this one is ready now.

@sbulen sbulen merged commit 61d113c into SimpleMachines:release-2.1 Oct 18, 2022
@pr-triage pr-triage Bot added the PR: merged label Oct 18, 2022
@sbulen sbulen deleted the cleanup_moderation_alerts branch October 18, 2022 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unread alerts should be deleted when relevant content no longer exists.

3 participants