Commit Graph

8733 Commits

Author SHA1 Message Date
Aman Agrawal
4cca5652e3 slack_import: Pipe file processing error message to the user.
When the slack import fails due to invalid zip file being uploaded,
we take user back to the file upload page with an appropriate
error message.
2025-06-16 10:46:25 -07:00
whilstsomebody
26e5b916bc test_subs: Fix the incorrect syntax in 'test_unarchive_stream'.
This commit fixes the use of `/json/streams/...` by replacing
it with the correct `/api/v1/streams/...`. Also removes
unnecessary `login_user` call when using `api_patch`.
2025-06-16 09:14:03 -07:00
Anders Kaseorg
717cf60edf python: Use Django 5.2 reverse(…, query=…).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-06-12 09:32:38 -07:00
Sahil Batra
79c2972232 tests: Move test to check permission to update message retention setting.
This commit moves test to check permission to update message retention
setting of a stream to test_channel_permissions.py.
2025-06-11 15:41:50 -07:00
Sahil Batra
0dee5f4c0d tests: Move subscription properties test to new file.
This commit moves subscription properties test to
test_subscription_settings.py.
2025-06-11 15:41:50 -07:00
Sahil Batra
62579b5b24 tests: Move tests to get streams and subscriptions to test_channel_fetch. 2025-06-11 15:41:50 -07:00
Sahil Batra
679a8363cb tests: Move test for updating default stream to test_default_channels.
This commit moves test for add or removing a stream as default using
"/json/streams/{stream_id}" endpoint to test_default_channels.py.
2025-06-11 15:41:50 -07:00
Sahil Batra
5228c2c97c tests: Create new test_default_channels.py file.
This commit moves tests for default streams and default
stream groups to a new file.

This commit also moves test_guest_user_access_to_streams
test to a different class in test_subs.py since it was
present in DefaultStreamTest class before.
2025-06-11 15:41:50 -07:00
Shubham Padia
7eb9c9deef Groups: Can perform any join, leave, add, remove for deactivated group.
Fixes #33804.

We still do not allow permission settings to be set to deactivated
groups.
2025-06-11 14:58:14 -07:00
Lauryn Menard
c797c481b3 demo-orgs: Delete expired demo orgs in archive_messages cron job.
Adds delete_expired_demo_organizations to the archive_messages
management command, which is run as a cron job.

Adds "demo_expired" as a `RealmDeactivationReasonType` to be
used for this specific case of calling do_deactivate_realm.

The function loops through non-deactivated realms that have a
demo organization scheduled deletion datetime set that is less
than the current datetime.
2025-06-07 22:53:01 -07:00
theofficialvedantjoshi
cb07605e52 integrations: Prevent logging of MissingHTTPEventHeaderError.
Fixes #34623.
2025-06-06 18:06:06 -07:00
Mohammad Reza Kianifar
df00b68529 messages: Add unread 1:1/self DMs to pm_dict if DM group exists.
In get_raw_unread_data, 1:1 or self messages are added to pm_dict.
However, if a DirectMessageGroup is the recipient, the message is
added to huddle_dict by default.

To keep API compatibility, we override this behavior to populate
pm_dict for 1:1 and self DMs when a DirectMessageGroup exists.
This ensures clients relying on pm_dict continue to work during
and after the migration.

This PR fixes part of issue #25713.
2025-06-05 17:03:49 -07:00
Niloth P
2a2ca01cad integrations: Add FIXTURELESS_SCREENSHOT_CONFIG.
Created a `WEBHOOK_SCREENSHOT_CONFIG` to track those separately, by
renaming the existing `DOC_SCREENSHOT_CONFIG` which contained only the
configs for webhook integrations.

Tracking the screenshot configs separately allows us to generate
the screenshots of all fixtureless integrations in a single batch, and
all webhook integrations in their own separate batch.
2025-06-01 11:38:02 -07:00
Niloth P
0b8e042627 integrations: Split the getters for fixture_path and image_path.
This is in preparation of adding support for generating screenshots of
fixtureless integrations, which would need to get image_path, without
involving fixture_path.
2025-06-01 11:38:02 -07:00
Niloth P
94a5ced243 integrations: Rename ScreenshotConfig to WebhookScreenshotConfig.
This is in preparation to differentiate the current config dataclass
(used for webhooks) from the FixturelessScreenshotConfig that will be
added for non-webhook integrations in the following commits.
2025-06-01 11:38:02 -07:00
Niloth P
9f92ae710f integrations: Remove support for non-webhook example screenshots.
- Removed the BaseScreenshotConfig dataclass, and merge it with
ScreenshotConfig dataclass.
- Simplified get_fixture_and_image_paths.
- Simplified generate_screenshot_from_config in the screenshot script.
- Deleted send_bot_mock_message.
2025-06-01 11:38:02 -07:00
Sahil Batra
d8ae21a4f4 folders: Don't allow archiving a folder if it contains channels. 2025-05-29 15:39:03 -07:00
Sahil Batra
677390d3f6 channel_folders: Add tests for case-insensitive duplicate name check.
This commit adds tests for checking the requirement of folder
names to be unique case insensitively.
2025-05-29 15:39:03 -07:00
Sahil Batra
88b47be938 channel_folders: Pass realm as argument to check_add_channel_folder.
Passing realm explicitly to check_add_channel_folder instead of
using realm field from acting_user seems much cleaner and readable.
2025-05-29 15:39:03 -07:00
Sérgio Glórias
d817bd5faf email_mirror: Also strip "SV:" from subject.
Observed in emails from Nordic countries, the prefix SV: is used instead of RE:.
2025-05-29 10:55:18 -07:00
Lauryn Menard
fd16c2e2b0 templates: Update deactivated organization template for deleted data.
If a realm's data has been scrubbed, update the deactivated realm
to note the URL can be reused, but not that the realm can be
reactivated.

Updates the template for context variables that are no longer used.
2025-05-28 17:32:29 -07:00
Aman Agrawal
b57b783dd8 slack: Don't show error code to users.
We log the error internally and only show invalid token as the
error message.
2025-05-28 17:18:07 -07:00
Aman Agrawal
68372f8e03 slack: Change invalid token error message. 2025-05-28 17:18:07 -07:00
Sahil Batra
460c471a29 tests: Move channel access tests to test_channel_access. 2025-05-28 17:02:41 -07:00
Sahil Batra
bf7f567009 tests: Move stream permission tests to test_channel_permissions. 2025-05-28 17:02:41 -07:00
Sahil Batra
4b29d402c6 tests: Move channel creation tests to test_channel_creation. 2025-05-28 17:02:41 -07:00
Aditya Kumar Kasaudhan
c5f126c6ff navigation_views: Add backend for navigation views in left sidebar.
Fixes part of #32077.
2025-05-23 16:25:08 -07:00
PieterCK
0dfb709152 slack_data_import: Support converting integration bot messages.
Integration bot messages in Slack may include "blocks" and
"attachments," which are Slack's messaging features.
Currently, these messages aren't processed when converting
Slack export data.

This commit adds support for converting integration bot
messages, as well as other Slack messages containing "blocks"
and "attachments".

Message payload with the block type `rich_text` is skipped because all
messages sent by users have this format.

Fixes #31162.

[1]=https://docs.slack.dev/reference/block-kit/blocks/rich-text-block/
2025-05-23 14:27:31 -07:00
PieterCK
5b32fa7227 mattermost_import: Add message with faulty HTML to fixture.
This adds a new message sample with faulty HTML content that crashes
`html2text`. The previous test for this mocks a function that raises the
error that this fixture emulates.
2025-05-23 11:28:41 -07:00
Niklas Fiekas
e4d366d159 email_mirror: Also strip "Re[123]:" from subject.
Observed consecutively numbered replies from Outlook.
2025-05-23 11:27:22 -07:00
PieterCK
201a71b575 mattermost_import: Except error when converting messages HTML.
This adds a try-except block when running html2text when processing raw
messages from HTML to markdown.

convert_html_to_text is added mainly for testing convinience. We don't
have any sample of Mattermosts' problematic content that could trigger
this sort of error yet, so the test mocks convert_html_to_text to raise
error instead.
2025-05-21 16:08:30 -07:00
PieterCK
45b396393f mattermost_import: Log when processing messages.
This logs a line for every batch of messages processed by
process_list_in_batches.
2025-05-21 16:08:30 -07:00
Lauryn Menard
8830373c9e demo-orgs: Disable allowing users to join until owner email set.
Until a demo organization creator sets an email address, we want to
restrict other users from joining the organization. Therefore, we
disable changing the "invite_required" setting for the organization
until they set their email address. Otherwise, the owner could
share the demo organization URL with someone and they could create
an account via the homepage.

Checks the demo organization owner delivery email address state
on the server-side.

Disables updating the organization setting in the web app UI.
2025-05-21 15:52:38 -07:00
Lauryn Menard
c9592c62f8 demo-orgs: Check owner email state when changing subdomain.
Enforce checking the demo organization owner delivery email on
the server-side when converting the organization to a permanent
organization via changing the subdomain.
2025-05-21 15:52:38 -07:00
Lauryn Menard
2fac27afb9 demo-orgs: Check owner email for missed message emails.
It is possible that a demo organization owner will receive a direct
message from a bot when they haven't yet added an email to their
account, e.g., the Notification bot sends a reminder about watching
the intro to Zulip onboarding video.

Adds a check and early return in handle_missedmessage_emails for
this demo organization owner case.
2025-05-21 12:56:27 -07:00
Lauryn Menard
28b1a071fe demo-orgs: Schedule onboarding/welcome emails when owner adds email.
When a demo organization creator confirms their email change for
their account, we now schedule the series of onboarding emails
via enqueue_welcome_emails.

If a demo organization is deactivated/deleted before the emails
are sent, any scheduled emails are deleted as part of that process.

We use the current datetime for getting the onboarding schedule
for the onboarding emails in this case, instead of the datetime the
user joined/created the organization.
2025-05-20 16:25:51 -07:00
Sahil Batra
222ccac765 register: Include folder data for web public streams for spectators.
Spectators would only receive data for channel folders that have
at least one web-public stream.
2025-05-20 13:25:06 -07:00
Sahil Batra
2f34e6d24c streams: Add API support to update folder of a stream.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
ec96fc9659 streams: Allow adding newly created channels to folders.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
202bebda89 streams: Add folder foreign key to Stream table.
This commit also adds "folder_id" field in stream and subscription
objects.

Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
5de0f265bd channel_folders: Add support to update channel folders.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
e93667cc06 channel_folders: Add API endpoint to get all channel folders.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
332abd9e91 channel_folder: Add API to create a channel folder.
This commit also includes code to include channel_folders
data in register response.

Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
350f6a1fa1 streams: Add ChannelFolder table.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Aman Agrawal
f4e6f2f89b events: Add option to send partial data.
Server can now send partial data to the client to help in
developement. We don't want this to be widely used right now,
hence no documentation changes have been made.

This will likely be a check on client capability later.
2025-05-19 16:58:56 -07:00
Alex Vandiver
01e08f0e32 email_server: Attempt to reject unauth'd destinations at RCPT TO time.
This is done in a best-effort way -- we rely on the final ACL check
happening when the message is sent.  However, by then we will be in
the `email_mirror` worker, with no way to convey to the original SMTP
client that the sending failed; giving the client the information will
allow them to provide it back to the end-user, instead of merely being
swallowed up in the worker.
2025-05-19 16:39:44 -07:00
Alex Vandiver
c6e0f0b436 email-mirror: Remove HTTP interface. 2025-05-19 16:39:44 -07:00
Alex Vandiver
1f0cfd4662 email-mirror: Add a standalone server that processes incoming email.
Using postfix to handle the incoming email gateway complicates things
a great deal:

- It cannot verify that incoming email addresses exist in Zulip before
  accepting them; it thus accepts mail at the `RCPT TO` stage which it
  cannot handle, and thus must reject after the `DATA`.

- It is built to handle both incoming and outgoing email, which
  results in subtle errors (1c17583ad5, 79931051bd, a53092687e,
  #18600).

- Rate-limiting happens much too late to avoid denial of
  service (#12501).

- Mis-configurations of the HTTP endpoint can break incoming
  mail (#18105).

Provide a replacement SMTP server which accepts incoming email on port
25, verifies that Zulip can accept the address, and that no
rate-limits are being broken, and then adds it directly to the
relevant queue.

Removes an incorrect comment which implied that missed-message
addresses were only usable once.  We leave rate-limiting to only
channel email addresses, since missed-message addresses are unlikely
to be placed into automated systems, as channel email addresses are.

Also simplifies #7814 somewhat.
2025-05-19 16:39:44 -07:00
Mohammad Reza Kianifar
a0488715f3 direct_messages: Use DM groups for 1:1 or self DMs if present.
This is a preparatory refactor for migrating the internal structure of
Recipient objects for group DMs to use the DirectMessageGroup type,
not the legacy PERSONAL type. This step has the message-sending code
path check if a DirectMessageGroupe exists and prefer it if available.

It should have no effect in production other than doing a useless
database query for each outgoing DM, since we do not at present ever
create such DirectMessageGroup objects. (It will not add a marginal
database query once the migration is complete, just during this
transition).
2025-05-18 23:58:59 -07:00
Mateusz Mandera
a52bc4d71b slack: Handle integration bots with missing data.
We encountered the following two new cases with integration bots in
Slack imports:
1. Bots without the image_72 field in their data. Such bots should fall
   back to gravatar.
2. Bots whose bot_id is the sender of certain messages, but querying the
   bots.info endpoint returns bot_not_found error. We should create
   dummy accounts in place of such bots.
2025-05-16 13:06:28 -07:00