Earlier, we were using `all_messages_data.first()` for the oldest
message ID we have in cache, which is incorrect.
`all_messages_data.first_including_muted()` returns the oldest ID.
This commit fixes the bug.
Previously, if `get_server_history()` was called while a request
for the stream was already pending, the provided `on_success`
callback was ignored.
This commit fixes that by queuing all `on_success` callbacks per
stream_id when a request is already in flight. Once the request
completes, all queued callbacks are executed.
This commit updates code to use "\x07" as value for
"subject" field of Message objects for DMs and group
DMs, so that we have a unique value for DMs and group
DMs which cannot be used for channel messages.
This helps in avoiding having an empty string value as
topic for DMs, which is also used for "general chat"
channel messages, as large number of DMs in the realm
resulted in PostgreSQL query planner thinking that there
are too many "general chat" messages and thus generated
bad query plans for operations like fetching
"general chat" messages in a stream or moving messages
to and from "general chat" topic.
This change as done for ArchivedMessage and
ScheduledMessage objects as well.
Note that the clients still get "subject" value as
an empty string "".
This commit also adds tests for checking that "\x07"
cannot be used as topic for channel messages.
Fixes#34360.
Slackbot should be correctly marked as a bot rather than a regular user
- otherwise, it confusingly appears on the Users list and in the realm
creation from Slack import flow, in the dropdown for choosing the
organization owner account.
Closes#34649
When selecting the realm owner is not needed in the realm creation from
Slack flow, we don't set need_select_realm_owner value on the
preregistration_realm object. Thus, this codepath cannot expect to
always find the key - and instead should use .get(), defaulting to False.
When a realm is a placeholder realm due, i.e., the realm redirects
to another URL due to previously changing the realm's subdomain,
we only show the redirect information.
There is a copy link that for the redirect URL that can be pasted
into the search bar to get to the support view for the actual
realm.
For confirmation objects that do not show realm details, but have
a realm object, format the header information to match what we do
show in the realm details page and show the realm's subdomain.
Creating a demo organization will not require the user to
set either an email or password, so explicitly set the
password field to not be required for that case.
Updates the form submitted in the dev environment to create
a new demo organization to not send a password value.
This prevents the case when we have text like `[abcd](url)`
in the compose box and the "url" part is selected, and we paste
a link copied from message actions popover.
Though the frontend module generated correct urls for
empty topics, it would sometime generate incorrect
link text in the fallback md link syntax. (eg, if
empty string was provided as the topic name).
This commit fixes that.
To maintain API compatibility during and after the migration to use
DirectMessageGroup for 1:1 messages, we need to build the existing
report message format for 1:1 DMs using DirectMessageGroup.
To maintain API compatibility during migration to DirectMessageGroup
for 1:1 DMs, generate notification payloads for such messages in the
same format as those sent to a Personal recipient.
Fixes: part of issue #25713.
This commit adds a test for the grouping logic of the
`do_delete_messages` function, which now groups public and private
messages based on their streams and topics.
This refactor updates `do_delete_messages` to categorize messages by
recipient and topic using a `defaultdict`. Messages are grouped into
batches where each batch corresponds to a unique recipient and topic
combination. For each group, a separate delete event is created and
processed, ensuring compliance with API requirements that mandate one
event per topic.
Co-authored-by: Mateusz Mandera <mateusz.mandera@zulip.com>