mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
create_user: Create historical UserMessage rows with bulk_create.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
ee2cb855f0
commit
fef365248b
@@ -59,8 +59,10 @@ ONBOARDING_TOTAL_MESSAGES = 1000
|
||||
ONBOARDING_UNREAD_MESSAGES = 20
|
||||
ONBOARDING_RECENT_TIMEDELTA = datetime.timedelta(weeks=1)
|
||||
|
||||
DEFAULT_HISTORICAL_FLAGS = UserMessage.flags.historical | UserMessage.flags.read
|
||||
|
||||
def create_historical_user_messages(*, user_id: int, message_ids: List[int]) -> None:
|
||||
|
||||
def create_historical_user_messages(*, user_id: int, message_ids: Iterable[int]) -> None:
|
||||
# Users can see and interact with messages sent to streams with
|
||||
# public history for which they do not have a UserMessage because
|
||||
# they were not a subscriber at the time the message was sent.
|
||||
@@ -68,12 +70,10 @@ def create_historical_user_messages(*, user_id: int, message_ids: List[int]) ->
|
||||
# those messages, we create UserMessage objects for those messages;
|
||||
# these have the special historical flag which keeps track of the
|
||||
# fact that the user did not receive the message at the time it was sent.
|
||||
for message_id in message_ids:
|
||||
UserMessage.objects.create(
|
||||
user_profile_id=user_id,
|
||||
message_id=message_id,
|
||||
flags=UserMessage.flags.historical | UserMessage.flags.read,
|
||||
)
|
||||
UserMessage.objects.bulk_create(
|
||||
UserMessage(user_profile_id=user_id, message_id=message_id, flags=DEFAULT_HISTORICAL_FLAGS)
|
||||
for message_id in message_ids
|
||||
)
|
||||
|
||||
|
||||
def send_message_to_signup_notification_stream(
|
||||
|
||||
Reference in New Issue
Block a user