def get_user_info_for_message_updates(message_id: int) -> MessageUpdateUserInfoResult:
    query = UserMessage.objects.filter(message=message_id, flags=(~ UserMessage.flags.historical)).values('user_profile_id', 'flags')
    rows = list(query)
    message_user_ids = {row['user_profile_id'] for row in rows}
    mask = (UserMessage.flags.mentioned | UserMessage.flags.wildcard_mentioned)
    mention_user_ids = {row['user_profile_id'] for row in rows if (int(row['flags']) & mask)}
    return dict(message_user_ids=message_user_ids, mention_user_ids=mention_user_ids)
def get_user_info_for_message_updates(message_id: int) -> MessageUpdateUserInfoResult:
    query = UserMessage.objects.filter(message=message_id, flags=(~ UserMessage.flags.historical)).values('user_profile_id', 'flags')
    rows = list(query)
    message_user_ids = {row['user_profile_id'] for row in rows}
    mask = (UserMessage.flags.mentioned | UserMessage.flags.wildcard_mentioned)
    mention_user_ids = {row['user_profile_id'] for row in rows if (int(row['flags']) & mask)}
    return dict(message_user_ids=message_user_ids, mention_user_ids=mention_user_ids)