def create_user_messages(message: Message, um_eligible_user_ids: AbstractSet[int], long_term_idle_user_ids: AbstractSet[int], stream_push_user_ids: AbstractSet[int], stream_email_user_ids: AbstractSet[int], mentioned_user_ids: AbstractSet[int], mark_as_read: Sequence[int]=[]) -> List[UserMessageLite]:
    ums_to_create = []
    for user_profile_id in um_eligible_user_ids:
        um = UserMessageLite(user_profile_id=user_profile_id, message_id=message.id, flags=0)
        ums_to_create.append(um)
    wildcard = message.mentions_wildcard
    ids_with_alert_words = message.user_ids_with_alert_words
    for um in ums_to_create:
        if (((um.user_profile_id == message.sender.id) and message.sent_by_human()) or (um.user_profile_id in mark_as_read)):
            um.flags |= UserMessage.flags.read
        if wildcard:
            um.flags |= UserMessage.flags.wildcard_mentioned
        if (um.user_profile_id in mentioned_user_ids):
            um.flags |= UserMessage.flags.mentioned
        if (um.user_profile_id in ids_with_alert_words):
            um.flags |= UserMessage.flags.has_alert_word
        if (message.recipient.type in [Recipient.HUDDLE, Recipient.PERSONAL]):
            um.flags |= UserMessage.flags.is_private
    user_messages = []
    for um in ums_to_create:
        if ((um.user_profile_id in long_term_idle_user_ids) and (um.user_profile_id not in stream_push_user_ids) and (um.user_profile_id not in stream_email_user_ids) and message.is_stream_message() and (int(um.flags) == 0)):
            continue
        user_messages.append(um)
    return user_messages
def create_user_messages(message: Message, um_eligible_user_ids: AbstractSet[int], long_term_idle_user_ids: AbstractSet[int], stream_push_user_ids: AbstractSet[int], stream_email_user_ids: AbstractSet[int], mentioned_user_ids: AbstractSet[int], mark_as_read: Sequence[int]=[]) -> List[UserMessageLite]:
    ums_to_create = []
    for user_profile_id in um_eligible_user_ids:
        um = UserMessageLite(user_profile_id=user_profile_id, message_id=message.id, flags=0)
        ums_to_create.append(um)
    wildcard = message.mentions_wildcard
    ids_with_alert_words = message.user_ids_with_alert_words
    for um in ums_to_create:
        if (((um.user_profile_id == message.sender.id) and message.sent_by_human()) or (um.user_profile_id in mark_as_read)):
            um.flags |= UserMessage.flags.read
        if wildcard:
            um.flags |= UserMessage.flags.wildcard_mentioned
        if (um.user_profile_id in mentioned_user_ids):
            um.flags |= UserMessage.flags.mentioned
        if (um.user_profile_id in ids_with_alert_words):
            um.flags |= UserMessage.flags.has_alert_word
        if (message.recipient.type in [Recipient.HUDDLE, Recipient.PERSONAL]):
            um.flags |= UserMessage.flags.is_private
    user_messages = []
    for um in ums_to_create:
        if ((um.user_profile_id in long_term_idle_user_ids) and (um.user_profile_id not in stream_push_user_ids) and (um.user_profile_id not in stream_email_user_ids) and message.is_stream_message() and (int(um.flags) == 0)):
            continue
        user_messages.append(um)
    return user_messages