mirror of https://github.com/zulip/zulip.git
Ignore inactive users in get_recipient_info().
We were mostly excluding inactive users before this fix, but now we completely ignore them. This potentially changes some of the data we return from get_recipient_info(), but the extra user ids before this fix were effectively ignored by the caller.
This commit is contained in:
parent
1759137e4f
commit
51d4f16fe0
|
@ -789,7 +789,8 @@ def get_recipient_info(recipient, sender_id):
|
|||
raise ValueError('Bad recipient type')
|
||||
|
||||
query = UserProfile.objects.filter(
|
||||
id__in=user_ids
|
||||
id__in=user_ids,
|
||||
is_active=True,
|
||||
).values(
|
||||
'id',
|
||||
'enable_online_push_notifications',
|
||||
|
@ -800,6 +801,11 @@ def get_recipient_info(recipient, sender_id):
|
|||
)
|
||||
rows = list(query)
|
||||
|
||||
active_user_ids = {
|
||||
row['id']
|
||||
for row in rows
|
||||
}
|
||||
|
||||
def get_ids_for(f):
|
||||
# type: (Callable[[Dict[str, Any]], bool]) -> Set[int]
|
||||
return {
|
||||
|
@ -812,18 +818,13 @@ def get_recipient_info(recipient, sender_id):
|
|||
# type: (Dict[str, Any]) -> bool
|
||||
return row['is_bot'] and (row['bot_type'] in UserProfile.SERVICE_BOT_TYPES)
|
||||
|
||||
# Only deliver the message to active user recipients
|
||||
active_user_ids = get_ids_for(
|
||||
lambda r: r['is_active']
|
||||
)
|
||||
|
||||
push_notify_user_ids = get_ids_for(
|
||||
lambda r: r['is_active'] and r['enable_online_push_notifications']
|
||||
lambda r: r['enable_online_push_notifications']
|
||||
)
|
||||
|
||||
# Service bots don't get UserMessage rows.
|
||||
um_eligible_user_ids = get_ids_for(
|
||||
lambda r: r['is_active'] and (not is_service_bot(r))
|
||||
lambda r: not is_service_bot(r)
|
||||
)
|
||||
|
||||
long_term_idle_user_ids = get_ids_for(
|
||||
|
@ -833,7 +834,7 @@ def get_recipient_info(recipient, sender_id):
|
|||
service_bot_tuples = [
|
||||
(row['id'], row['bot_type'])
|
||||
for row in rows
|
||||
if row['is_active'] and is_service_bot(row)
|
||||
if is_service_bot(row)
|
||||
]
|
||||
|
||||
info = dict(
|
||||
|
|
Loading…
Reference in New Issue