Commit Graph

1402 Commits

Author SHA1 Message Date
PieterCK
0a2d7eedf8 integrations: Use real replace_link in Slack webhook.
The real `replace_link` function is now available. This cleans up the
duplicate and switches it with the real one instead.
2025-05-07 12:45:27 -07:00
nirved.mishra.eee23@itbhu.ac.in
3fc63110ac incoming-webhooks: Add OpenProject integration.
Fixes #29944.

Co-authored-by: theofficialvedantjoshi <vedant.messi101@gmail.com>
Co-authored-by: Niloth P <20315308+Niloth-p@users.noreply.github.com>
2025-05-05 12:23:04 -07:00
PieterCK
a228699108 slack_incoming: Use Slack text reformatters from data import.
This commit updates the Slack incoming webhook endpoint to use the same
Slack reformatting functions (`convert_to_zulip_markdown` and
`replace_links`) that are used for Slack data import and cleaning up any
duplicative functions.

This was previously not possible because the Slack reformatting regex in
`slack_message_conversion.py` could not handle these cases:

- Formatting applied to non-ASCII characters (e.g., emoji).

- Formatted strings separated by exactly one character.

- Formatted strings appearing immediately after a new line.

Fixes part of #31162.
2025-04-28 20:49:10 -07:00
PieterCK
c018911c5b slack_regex: Fix overlapping capture groups.
The Slack text regexes match specific characters before and after the
formatted string to ensure that they only match at word boundaries.

However, because the capture groups consume each matching character,
including the characters used to determine word boundaries, two
formatted strings separated by a single matching character result in one
string not being matched, as the trailing whitespace is already
consumed and cannot also match as the leading pre-match whitespace for
the next character.

Switch to a look-ahead regex for the trailing word boundary
characters. This is zero-width, and as such the next match can still
also consume the same characters.

This also fixes Slack webhook integrations'
`test_message_with_complex_formatted_mentions` which was previously
expecting false output.

Fixes part of #30827.
2025-04-28 20:49:10 -07:00
PieterCK
8992435caf slack_regex: Update Slack regex handle multiline strings.
This prep commit modifies the Slack text regex in
`slack_message_conversion.py` to use the `re.MULTILINE` flag capture
formatted strings that are adjacent to newline or end of line.

These kinds of strings are likely not uncommon to be generated by Slack
exporter itself and our Slack message block and attachment formatters
(`render_blocks` and `render_attachments`) also produces them.

This also fixes Slack webhook integration's
`test_message_with_complex_formatted_texts` which was previously
expecting false output.

Fixes part of #30827.
2025-04-28 20:49:10 -07:00
Sumit Bhanushali
facbdf08fc integrations: Handle approval/unapproval for GitLab MRs.
Fixes: #34222
2025-04-28 20:26:29 -07:00
Varun-Kolanu
4f8263cd7f integrations: Update example screenshot for JotForm.
This commit updates the screenshot for the JotForm
integration to better demonstrate its utility
in enhancing business workflows for Zulip users.
2025-04-25 15:34:00 -07:00
Varun-Kolanu
e8364d8edd integrations: Fix jotform integration to receive files.
This supports receiving files through jotform.

Fixes #32460.
2025-04-25 15:34:00 -07:00
Niloth P
14173b757f github webhook: Support all actions on discussion events.
Previously, only the action value `created` was supported.
Now, all 16 are supported.

Fixes: #26064.
2025-04-22 13:20:14 -07:00
Niloth P
22c80117f5 integrations: Add OpenSearch incoming webhook integration.
Co-authored-by: merlinz01 <158784988+merlinz01@users.noreply.github.com>
2025-04-16 14:05:29 -07:00
Varun-Kolanu
59d5d29ed8 integrations: Add support for GitLab design comments.
Fixes #26199.

Co-authored-by: Barış <barisunsalhn@users.noreply.github.com>
Co-authored-by: Satyam Bansal <sbansal1999@gmail.com>
2025-04-07 11:54:37 -07:00
Niloth P
e76ace28d2 integration-docs: Rename Jira doc to avoid collision with Jira plugin.
The Jira plugin integration doc will be moved in the next commit, to
"static/generated/integrations/jira/doc.md", as the directory name of
the integration is "jira" in zulip/python-zulip-api.

- Jira integration doc (previously) - "zerver/webhooks/jira/doc.md"
- Jira plugin integration doc (next commit) -
"static/generated/integrations/jira/doc.md"

Both of these will use the same path "jira/doc.md" as their
integration.doc value, and the actual file is loaded based on the order
of template directories listed in computed_settings.py.

Hence, use a custom path for the Jira integration doc to avoid this
collision.
2025-03-26 11:19:31 -07:00
Alex Vandiver
7db1e79133 uptimerobot: Ensure we do not use body without it being defined. 2025-03-21 09:25:17 -07:00
Prakhar Pratyush
9a46104684 addressee: Rename "(no topic)" to empty string topic.
This commit renames "(no topic)" to "" when used as
topic name, while sending or scheduling messages.

This is particularly helpful for older clients where
sending messages with empty topic input box resulted
in messages being sent to "(no topic)" topic.

Now, it will be sent in empty string topic and will
appear in the "general chat" topic.

This helps older clients to somewhat align with the UX
of the clients supporting empty string topic.
2025-03-19 11:39:28 -07:00
Niloth P
c32e6f4940 integrations: Improve the branch filtering in Git-related integrations.
- Made the branch-filtering checks uniform across all the integrations,
by adding a helper function to git.py, and re-using it.
- Instead of checking if the name of the branch that generated the
event is a substring of the "branches" parameter, we now check if
there's an exact match.
For example, if there are two branches named "main" and
"release/v1.0-main", and the user wants to track pushes to only the
"release/v1.0-main" branch, they wouldn't have been able to
previously, it will always track pushes to both branches. There was no
way to filter out the smaller named branch when there were overlaps.
2025-03-05 10:39:13 -08:00
Niloth P
b7e79715cc integration-docs: Combine two macros that are always used together.
Edited the git-append-branches.md macro to match the previous
git-branches-additional-feature.md macro, and moved it inside the
webhook-url-with-bot-email.md macro, as it's only ever used
immediately after that macro.
2025-03-05 10:39:13 -08:00
Niloth P
8f564b2053 integration-docs: Update branch filtering instructions.
Updated the Git-related integrations that support branch filtering:
- Removed the branch-filtering configuration option, and its macro.
- Added a new macro that integrates the branch-filtering instruction
with the Generate-URL step.

The new macro `generate-webhook-url-with-branch-filtering` builds off of
the `generate-webhook-url-basic` macro, adding only the branch filtering
instruction. But, it does not re-use the macro, instead duplicates it,
to avoid the newline break that would be added otherwise.
2025-03-05 10:39:13 -08:00
Niloth P
0df3dcdde9 integration-docs: Remove unnecessary instruction from Wekan doc.
A branch filtering instruction that has nothing to do with Wekan has
been present in the Wekan doc since the addition of the integration.
2025-03-05 10:39:13 -08:00
Alya Abbott
61db2bc158 integrations: Update GitHub intergation for new configuration UI. 2025-02-28 13:04:42 -08:00
Aditya Kumar Kasaudhan
18d83534ff github: Include old issue number in transfer message for new repo.
This commit updates the GitHub webhook integration to include the
old issue number in the transfer message sent for the new repository,
alongside the old repository's full name.
2025-02-27 09:22:15 -08:00
Anders Kaseorg
d7556b4060 requirements: Migrate to uv.
https://docs.astral.sh/uv/

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-24 22:29:24 -08:00
Aditya Kumar Kasaudhan
9d08063208 webhooks/github: Added support for issue transferred events.
On transferring an issue to another repository, GitHub sends
- a "transferred" event to the old repository's webhook URL,
- and an "opened event", containing links to the old issue,
  to the new repository's webhook URL.

This commit adds support for both events independently.
Fixes: #33450.
2025-02-21 15:34:14 -08:00
Anders Kaseorg
778a45d41e slack_incoming: Fix slack_error_handler typing.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-18 22:04:43 -08:00
Alex Vandiver
a7d513e5ec users: Remove unnecessary get_api_key helper.
Using the column name is clearer.
2025-02-13 12:40:53 -08:00
Niloth P
51839a72b9 HomeAssistant: Convert image instructions to code blocks.
Renamed the example screenshot to default image name as well.
2025-02-01 15:38:46 -08:00
Niloth P
fa0ea2aa2d webhooks: Remove second example screenshot from Sentry and Teamcity. 2025-02-01 15:38:46 -08:00
Niloth P
74d730f464 webhooks: Rename example screenshot images to match the default name.
The integrations - GoSquared, Greenhouse, OpsGenie and Zendesk - have
been using `000.png` as their example screenshots, renamed them to
match the default name `001.png`, to avoid passing them as arguments.
2025-02-01 15:38:46 -08:00
Niloth P
636f4f457c integration-docs: Remove context property recommended_channel_name.
The context property was previously being used in the macro
`git-webhook-url-with-branches` which has been removed as it is not in
use any longer.

The context property was now being used only in 2 integration docs, both
of which used it only in a single location, and directly used their own
names as the channel name. Making the context property unnecessary.
2025-01-30 11:59:38 -08:00
Alya Abbott
93dfd3dc1e integrations: Retitle Slack integration docs.
The updated titles are anti-pattern, but are much clearer.
2025-01-27 18:02:06 -08:00
PieterCK
e25da08886 integrations: Edit pass on Slack integration doc.
- Add a step to update the bot's API key if using a generic bot
for bidirectional bridging.
- Clarify setup options for how Slack channels are mapped.
- Edit for clarity and succinctness.
2025-01-27 18:02:06 -08:00
Mateusz Mandera
f81e514d07 slack: Fetch workspace users from /users.list in the correct manner.
1. Fetching from the `/users.list` endpoint is supposed to use
   pagination. Slack will return at most 1000 results in a single
   request. This means that our Slack import system hasn't worked
   properly for workspaces with more than 1000 users. Users after the
   first 1000 would be considered by our tool as mirror dummies and thus
   created with is_active=False,is_mirror_dummy=True.
   Ref https://api.slack.com/methods/users.list

2. Workspaces with a lot of users, and therefore requiring the use of
   paginated requests to fetch them all, might also get us to run into
   Slack's rate limits, since we'll be doing repeating requests to the
   endpoint.
   Therefore, the API fetch needs to also handle rate limiting errors
   correctly.
   Per, https://api.slack.com/apis/rate-limits#headers, we can just read
   the retry-after header from the rsponse and wait the indicated number
   of seconds before repeating the requests. This is an easy approach to
   implement, so that's what we go with here.
2025-01-24 16:41:53 -08:00
Anders Kaseorg
653b0b0436 ruff: Partially reformat Python with Ruff 0.9 (2025 style).
These are the changes that are backwards compatible with the 2024
style.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-14 09:42:16 -08:00
PieterCK
f89881d843 integrations: Change Slack private channel mention string.
In Slack webhook integration setup, the only scenario where a message
payload contains a channel mention without the channels name is when the
user mentions a private channel.
  e.g <#C07AVLQ3AUQ|>

This commit updates the string we use for such mention to "private Slack
channel" for better clarity.
2025-01-08 13:52:12 -05:00
PieterCK
059782bb9f integrations: Improve Slack integrations setup notification.
Previously, the notification message only informed users that the
integration URL was registered with Slack's Event API. However, it might
be misleading to send an "integration is successful" message when this
happens because we didn't verify that the token has the required scopes
or if the Slack token is even added to the URL at all.

Now that the integration also verifies the `slack_app_token`'s scope,
it's now more appropriate to send a notification message like
`get_setup_webhook_message` to let the user know that the setup is
indeed successful.
2025-01-08 13:52:12 -05:00
Niloth P
b7763f71e5 webhooks/opsgenie: Refactor to reduce redundancy in payload extraction. 2025-01-04 19:10:04 -08:00
Niloth P
ff96efbef4 webhooks/appveyor: Refactor to reduce redundancy in payload extraction.
Also renamed local functions to simpler names.
2025-01-04 19:10:04 -08:00
Niloth P
09f47d5a0a webhooks/github: Suppress "comment edited" events when body is same.
GitHub generates spurious edited events on hiding/unhiding a comment,
and on clicking "edit"/"update" without any changes, when the
comment "body" contains certain specific characters.

Instead of sending a notification message, we suppress those edge cases
by comparing the "body" content of the comment and changes in the event
payload.

Fixes #31042, #26136.
2025-01-03 15:18:39 -08:00
Niloth P
7261898d89 integrations: Remove Desk.com integration.
Desk.com has been discontinued by Salesforce in March 2020.
2024-12-31 16:31:48 -08:00
PieterCK
c6fd0ba424 integrations: Clean up duplicate functions.
This commit makes the Slack incoming webhook use the original
`convert_slack_formatting` and `convert_slack_workspace_mentions` from
`slack_message_conversion.py`. Previously those were not refactored out
into two smaller functions yet.

Fixes part of #30827.
2024-12-18 16:14:20 -08:00
PieterCK
a194d62093 integration-doc: Fix typo/wrong in Slack token scope list.
This commit deletes the duplicate `users:read` token scope from the list
of token scopes.
2024-12-18 16:14:20 -08:00
PieterCK
f2599bf33d integrations: Do check_token_access only initially.
Previously the `check_token_access` is called for every request we get
from Slack webhook, this may introduce significant latency.

This commit moves `check_token_access` to the same condition for when we
need to handle Slack challenge handshake so that we only do API token
check once per URL registered.

Additionally, we now check for the specific scopes that we need to run
the Slack webhook integration (SLACK_INTEGRATION_TOKEN_SCOPES).

Fixes part of #30827.
2024-12-18 16:14:19 -08:00
PieterCK
a746be807f slack_import: Make check_token_access more flexible.
Previously, the `check_token_access` function had a hardcoded
`required_parameters` variable because it was only used in the Slack
data importer. This commit refactors `required_parameters` into a
function parameter, enabling the function to check a Slack token’s scope
for other purposes, such as Slack webhook integration.

Additionally, this commit changes the Slack API call in
`check_token_access` from `teams.info` to `api.test`. The endpoint is
better suited for this purpose since we're only checking a token’s scope
using the response header here.
2024-12-18 16:11:31 -08:00
Niloth P
0d14ae1acf integration-docs: Remove the second screenshot from CircleCI doc.
The file had already been deleted, leaving behind its entry in the doc.
2024-12-12 15:04:02 -08:00
PieterCK
82e0468071 slack-integration: Update Slack integration documentation.
The doc now shows instructions to setup the integration using
Slack's Events API instead of the legacy Outgoing webhook
service.

Co-authored-by: Alya Abbott <alya@zulip.com>
Co-authored-by: Lauryn Menard <lauryn@zulip.com>
2024-12-11 13:06:52 -08:00
PieterCK
42a22e6aaa slack-integration: Block requests from Slack retries.
A Slack fail condition occurs when we don't respond with HTTP 200 within
3 seconds after Slack calls our endpoint. If this happens, Slack will
retry sending the same payload. This is often triggered because we need
to perform callbacks when converting messages. To avoid sending the same
message multiple times, we block subsequent retry calls from Slack.

This commit returns early HTTP 200 response as soon as we get any retry
calls from Slack.

Part of #30465.
2024-12-11 13:06:52 -08:00
PieterCK
c54d90e5c7 slack-integration: Add callback function to Slack API.
Payloads from Slack's Events API don't include human-readbale
information for a Slack username and for Slack channels.

This commit makes the Slack integration callback to the relevant
Slack API endpoints for that information.

Fixes #30074.
2024-12-11 13:06:52 -08:00
PieterCK
1ebbe2fd99 slack-integration: Add test fixtures for extra Slack payloads.
This commit adds 4 new payload fixtures to the Slack
integration for messages we don't process properly yet:

- Messages with code blocks.
- Messages with overlapping text formatting (e.g, bold
  and italic).
- Messages with formatted mentions.
- Messages with quote blocks.

The follow-up plan to add support for these kind of
Slack messages is tracked in #30827.

Part of #30465.
2024-12-11 13:06:52 -08:00
PieterCK
f29312ce03 slack-integration: Update Slack integration to handle Events API.
This updates the Slack webhook integration to handle the Slack Events
API[1], while maintaining backwards compatibility with Slack's legacy
Outgoing Webhook service.

The Events API introduces the "challenge" handshake[2] to verify and
add a new webhook URL for them to call. This commit adds a handler for
the challenge handshake.

Additionally, this commit reformats incoming payloads using the Slack
text reformatter from `slack_message_conversion.py`. There is some
duplicative code here because of the difference in Slack export data
and Slack's webhook payload.

Part of #30465

[1]: https://api.slack.com/apis/events-api#using-events-api
[2]: https://api.slack.com/apis/events-api#handshake
2024-12-11 13:06:52 -08:00
Niloth P
e731fb9eba integrations: Fix Jotform integration by accepting form-data payloads.
This does not add support for files.

Fixes part of #32460.

Co-authored by: PieterCK <pieterceka123@gmail.com>
2024-12-02 18:08:58 -08:00
Niloth P
f99e1a5dba integrations: Improve message formatting for Jotform. 2024-12-02 18:08:58 -08:00