Editing posts cause notification

So, imagine a post with 3 different group mentions. It’s edited and a fourth mention is added.

When saving the edit, we can use a query like this to find the current list of group mentions for that post.

-- [params]
-- text :post_id

select gm.group_id, g.name
from group_mentions gm
join groups g on (gm.group_id = g.id)
where post_id = :post_id

Then, by comparing the results of the query against the list of groups being mentioned in the post, we can find the new mention(s).

That doesn’t seem like too big of a calculation, but maybe I’m missing something obvious. This also seems like the sort of thing that could be done in a background task.

As far as the JIT banner about notifying the group(s), maybe this logic could be exposed by an API endpoint (/post/<id>/mentions.json) to get this data asynchronously.