The Slack text regexes match specific characters before and after the
formatted string to prevent cases like reformatting already formatted
text and test like `invlaid_bold_test` in
`slack_message_conversion.json`.
However, because the capture groups consume each matching character, two
formatted strings separated by a single matching character result in one
string not being matched, as the character is used to match the other
string.
e.g., (`*abc*b*def*` → **abc**b*def*) in this case, "b" is consumed to
match *abc*.
This prep commit modifies the Slack text regex in
`slack_message_conversion.py` to use a non-greedy quantifier for the
last capture group.
This prep commit to make `slack_incoming` use the same Slack
reformatting functions as the Slack import. Currently the Slack
regex at `slack_message_conversion.py` couldn't capture formatted
strings containing emojis in it. This commit reworks the main
capture group for formatted strings in Slack text regex in
`slack_message_conversion.py`.
Previously, the regex used multiple capture groups designed to
include everything except the formatting prefix and suffix
(`*`, `~`, `_`). This approach is replaced with a single capture
group that explicitly excludes these formatting characters,
simplifying the logic.
This prep commit modifies the Slack text regex in
`slack_message_conversion.py` to include the newline character (`\n`) as
part of the first and last capture groups.
Previously, the regex in `slack_message_conversion.py` couldn't capture
and reformat strings surrounded by newlines, such as "\n*ABC*\n". This
kind of string is likely not uncommon to be generated by both the Slack
exporter itself or by our Slack message block and attachment formatters
(`render_blocks` and `render_attachments`).
This prep commit introduces the `replace_links` function to convert
Slack-formatted links into Zulip-friendly format. This function uses the
same reformatting functions used in the Slack importer, and is intended
to replace an existing function of the same name in the Slack incoming
webhook, eliminating duplicate code.
Further refactors are needed before this function can be fully
integrated into the Slack incoming webhook.
This prep commit extracts the logic for converting Slack formatted text
into Zulip friendly markdown from `convert_to_zulip_markdown` into a new
helper function, `convert_slack_formatting`.
This is done to make reformating logic be reusable else where such as in
the Slack webhook or Slack incoming webhook.
This prep commit extracts the logic for reformatting Slack mentions into
Zulip mentions from `convert_to_zulip_markdown` into a new helper
function, `convert_slack_workspace_mentions`.
This is done to make the logic reformatting logic be reusable else where
such as in the Slack webhook or Slack incoming webhook.
This prep commit moves the helper function `convert_mailto_format` to
appear before its primary usage in `convert_to_zulip_markdown`. This
adjustment aligns with code style conventions, improving readability.
The change is also part of the refactor to make Slack text reformatting
functions reusable in the Slack incoming webhook.
This prep commit moves the helper function `convert_link_format` to
appear before its primary usage in `convert_to_zulip_markdown`. This
adjustment aligns with code style conventions, improving readability.
The change is also part of the refactor to make Slack text reformatting
functions reusable in the Slack incoming webhook.
This prep commit moves the helper function `convert_markdown_syntax` to
appear before its primary usage in `convert_to_zulip_markdown`. This
adjustment aligns with code style conventions, improving readability.
The change is also part of the refactor to make Slack text reformatting
functions reusable in the Slack incoming webhook.
This prep commit moves the helper function get_user_mentions to appear
before its primary usage in `convert_to_zulip_markdown`. This adjustment
aligns with code style conventions, improving readability.
The change also prepares the codebase for reusing Slack text
reformatting logic in the Slack incoming webhook.
Removed `invite_to_realm_policy` property, as the permission
to invite other users to the organization is now controlled by
`can_invite_users_group` setting.
This commit fixes the code to pass AnonymousSettingGroupDict
value instead of group ID when the setting is set to anonymous
groups in never subscribred streams subscription dicts.
Updates text of generate-webhook-url-basic.md to replace the use of
the "Create the channel" step.
Removes {!create-channel.md!} from all the integrations docs that
also include {!generate-webhook-url-basic.md!}.
Fixes#32269.
This change improves error handling in `do_import_realm` by replacing
the use of a generic Exception with CommandError. The updated approach
provides clearer, user-friendly error messages when there is a version
mismatch between the exported data and the Zulip server.
Fixes#32292.
This commit updates code to optimize code for computing stream
objects to be sent with stream creation event and in response
for 'GET /streams/{stream_id}' endpoint by optimizing number
of queries while computing values for group permission settings.
This change does not benefit much currently as we only have one
stream group permission setting, but is important before we add
more stream permission settings.
There are a couple of places left where we can still optimize
the code and that would be done in further commits.
This commit adds a new function to compute setting group
values for a list of streams, so we can avoid having duplicate
code for computing setting group IDs from streams.
This commit updates code to compute the values for group permission
settings in send_stream_creation_events_for_previously_inaccessible_streams
only when we need to send the events. This helps us in avoiding
unnecessary DB queries.
There is no need to call "locals()" inside the loop for
stream permission settings. It should just be called once
to get values of all the settings passed to the endpoint.
It was fine as we only had one group permission setting
for stream, but is a good fix before we add more settings.
This commit refactors code to create subscription dicts so
that we can efficiently compute can_remove_subscribers_group
setting when we add support to set the setting to anonymous
groups.
The initial implementation for this feature used the issue UUID
to create the topics, as some of the webhook events only provide
this and it is the only way to group sub-issues with parents.
However, if we sacrifice this and allow sub-issues to be
their own topic then we can avoid using the UUID as the topic name.
I think the quality of life improvement to topics here warrants this change,
as UUID topic names can be come unruly very quickly.
Part of #23118.
The in:home narrow filter is used to filter messages that appear
in the home view, i.e., messages that are not muted. Conversely,
`-in:home` should filter messages that are not in the home view,
i.e., muted messages. However, `-in:home` did not work as expected
because this filter lacked negation support, unlike similar code
paths.
This commit adds negation support for the in:home filter.
For more information, see:
<https://chat.zulip.org/#narrow/channel/378-api-design/topic/mark.20muted-topic.20messages.20as.20read/near/1980534>.
orjson’s use of Unicode is more consistent with what we get from
Transifex. (We could alternatively use json’s ensure_ascii=False
flag.)
Signed-off-by: Anders Kaseorg <anders@zulip.com>
If we don't revoke sessions, this can lead to issues when we import a
realm (e.g. from Slack) into the original subdomain for the same
organization. Because then, users who already had sessions before the
move end up stuck:
- when they try to open Zulip on the original subdomain, which now has
the imported instance, they get redirected to the moved subdomain due to
their pre-existing session cookie.
- they can't even log out to get rid of the bugged cookie, because the
account they're logged into in that session is now on the moved
subdomain.
Otherwise, these tests fail if ZULIP_VERSION is different locally from
what's hard-coded. Use a placeholder instead and replace dynamically in
a helper function.
This commit updates all third-party importer tools (Slack, Mattermost,
and Rocket Chat) in the `zerver/data_import` directory to also output a
migration_status.json file in their output tarball.
This is required because all importable tarball will be checked for
migration compatibility during import.
Fixes#28443.
When transferring a realm to a server that has a different set of
applied migrations (different Zulip versions), there is a chance that
the imported data formats appear to be compatible but data invariants
could still be violated.
This commit adds an assertion during the import process to verify
that both the exported realm and the importing server have matching
Zulip versions and have a compatible set of migrations.
This commit updates the export process to write the migration status of
the realm as a JSON file to be included in the export tarball.
This is a preparatory step for adding an assertion to ensure that the
importing and exporting realms have a compatible set of applied
migrations.
Newrelic has introduced a new update. This commit
updates the exisiting integration by adding support
for new types of payloads and cleaning up legacy
codes and fixtures.
Fixes#29729.
Co-authored-by: Pieter CK <pieterceka123@gmail.com>
Co-authored-by: Lauryn Menard <lauryn@zulip.com>
For resizing the icon.png files, we use resize_avatar, not resize_logo.
This is pretty confusing - sure, for icons we use the same function as
for avatars, but we should have a proper name for the function called in
the icon context. So this commit also adds resize_realm_icon, and
changes the calls to resize_avatar in icon contexts to
resize_realm_icon.
This commit refactors `render_attachment` and `render_block`
out of slack_incoming.py to promote reusability.
The primary motivation for this refactor is to add support for
converting integration bots messages in Slack exports, which could use
the same functions.
Part of #31311.
Previously, the GoCD integration relied on GoCD's integration with bug
tracking and monitoring tools through the users' Config XML file [1].
However, this feature no longer works as expected, as it cannot send
HTTPS payloads to an external endpoint.
This commit updates our GoCD integration to use Sentry's WebHook
notifier GoCD plugin [2] to send webhook payloads from users GoCD server
to Zulip. We are using an older version of the plugin—v0.0.6—because the
newer version—v0.0.9—doesn't work at this time.
Additionally, this change reformats the notifications to include more
details on the GoCD event, such as lists of passed and failed jobs.
Fixes#21224.
Co-authored-by: Pieter CK <pieterceka123@gmail.com>
[1]:
https://docs.gocd.org/current/integration/#integration-with-bug-tracking-and-story-management-tools
[2]:
https://github.com/getsentry/gocd-webhook-notification-plugin/releases/tag/v0.0.6
'do_deactivate_user' is used inside an outer db transaction
created in 'sync_user_from_ldap'.
`transaction.atomic()` block in 'do_deactivate_user' resulted
in savepoint creation.
This commit adds `savepoint=False` to avoid that.
'bulk_remove_subscriptions' is used inside an outer db transaction
created in 'do_change_bot_owner'.
`transaction.atomic()` block in 'bulk_remove_subscriptions'
resulted in savepoint creation.
This commit adds `savepoint=False` to avoid that.
'do_activate_mirror_dummy_user' is used inside an outer db
transaction created in 'registration_helper'.
`transaction.atomic()` block in 'do_activate_mirror_dummy_user'
resulted in savepoint creation.
This commit adds `savepoint=False` to avoid that.
'get_or_create_direct_message_group' is used inside an outer
db transaction created in 'edit_scheduled_message'.
`transaction.atomic()` block in 'get_or_create_direct_message_group'
resulted in savepoint creation.
This commit adds `savepoint=False` to avoid that.
'compose_views' is used inside an outer db transaction created in
'update_user_group_backend'.
`transaction.atomic()` block in 'compose_views' resulted in
savepoint creation.
This commit adds `savepoint=False` to avoid that.