actions: Fetch presence idle data for non-basic mentions.

Apparently, get_active_presence_idle_user_ids, which is carefully
optimized to only fetch data for users who might actually need
notification processing, was only considering PMs and direct mentions,
not wildcard mentions or alert words.

This caused some pretty weird failure modes when working on adding
support for broader mention notifications, because users who had one
of these types of notifications would be treated as never
presence-idle, which was just confusing.

This is part of adding support for notifications for wildcard mentions
and alert words; it's worth merging this as an early commit because
the consequence of not doing this are very difficult to debug.
This commit is contained in:
Tim Abbott 2019-08-25 19:53:02 -07:00
parent 4e65f1dd2b
commit 625eb53b08
1 changed files with 4 additions and 3 deletions

View File

@ -4760,7 +4760,7 @@ def get_active_presence_idle_user_ids(realm: Realm,
of those users who fit these criteria:
* They are likely to need notifications (either due
to mentions or being PM'ed).
to mentions, alert words, or being PM'ed).
* They are no longer "present" according to the
UserPresence table.
'''
@ -4773,9 +4773,10 @@ def get_active_presence_idle_user_ids(realm: Realm,
user_ids = set()
for user_id in active_user_ids:
flags = user_flags.get(user_id, []) # type: Iterable[str]
mentioned = 'mentioned' in flags
mentioned = 'mentioned' in flags or 'wildcard_mentioned' in flags
private_message = is_pm and user_id != sender_id
if mentioned or private_message:
alerted = 'has_alert_word' in flags
if mentioned or private_message or alerted:
user_ids.add(user_id)
return filter_presence_idle_user_ids(user_ids)