-
Notifications
You must be signed in to change notification settings - Fork 77
Update Teams service to support new webhook URL format with required extraId #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
serverleader
wants to merge
180
commits into
containrrr:main
Choose a base branch
from
serverleader:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chore: Configure Renovate
…om-mattn-go-colorable-0.x fix(deps): update module github.com/mattn/go-colorable to v0.1.14
…-httpmock-1.x fix(deps): update module github.com/jarcoal/httpmock to v1.3.1
…org-x-oauth2-0.x fix(deps): update module golang.org/x/oauth2 to v0.26.0
…ser-goreleaser-action-6.x chore(deps): update goreleaser/goreleaser-action action to v6
…-codecov-action-5.x chore(deps): update codecov/codecov-action action to v5
…ocker-login-2.x chore(deps): update azure/docker-login action to v2
chore(deps): update alpine docker tag to v3.21.3
…om-onsi-gomega-1.x fix(deps): update module github.com/onsi/gomega to v1.36.2
…com-spf13-viper-1.x fix(deps): update module github.com/spf13/viper to v1.19.0
…om-fatih-color-1.x fix(deps): update module github.com/fatih/color to v1.18.0
…om-onsi-ginkgo-v2-2.x fix(deps): update module github.com/onsi/ginkgo/v2 to v2.22.2
…org-x-net-0.x fix(deps): update module golang.org/x/net to v0.35.0
…om-spf13-cobra-1.x fix(deps): update module github.com/spf13/cobra to v1.9.1
- Changed repository references to nicholas-fedor/shoutrrr - Linted all files - Added additional test cases to increase test coverage - Updated deprecated code - Updated GitHub workflows - Added GolangCI lint configuration - Added Codacy and CircleCI configurations - Removed dot imports in favor of explicit imports
… tests (containrrr#53) * feat(mattermost): add DisableTLS param and preserve port in host Introduce `DisableTLS` query/param prop to toggle between HTTPS and HTTP in the Mattermost service, addressing self-hosted HTTP use cases (e.g., Containrrr/Watchtower issue #2089). Preserve port in `Host` by adopting Gotify-style handling, fixing port stripping. Enhance security with `MinVersion: tls.VersionTLS12`, refactor `setURL` for complexity (from 11 to 4, parsePath to 8, limit 8), and add comprehensive tests. - Add `DisableTLS` to `Config` (default "No") and update `buildURL` to switch schemes. - Change `setURL` to use `url.Host` instead of `Hostname()` for port retention. - Introduce `httpClient` with `GetHTTPClient()` in `Service` for mocking. - Set `MinVersion` in `TLSClientConfig` when `DisableTLS` is false. - Extract path parsing into `parsePath`, reducing complexity and fixing empty token validation. - Add tests for `DisableTLS` transport (`TLSClientConfig: nil`) and `Send` error handling (non-200 status). - Update dependencies with minor Go version increment. Resolves port and scheme issues (e.g., `mattermost://user@host:port/token?disabletls=yes`), ensuring compliance with security and complexity standards at 95.9% coverage.
…ontainrrr#52) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ontainrrr#54) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…nrrr#56) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
- Updated documentation to reflect the new Teams webhook URL format, which now requires the organization domain. - Removed support for legacy webhook formats. - Enhanced the configuration structure to include an additional `ExtraID` component. - Updated related functions and tests to accommodate the new URL structure and ensure proper validation of the webhook parts.
- Updated the documentation to emphasize the new Teams webhook URL format, including the organization domain. - Enhanced the explanation of the URL structure and its components for better clarity. - Changed the formatting of notes and examples for improved readability.
Defer to using latest version
…r#60) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…rrr#63) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ontainrrr#61) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
# Conflicts: # pkg/services/teams/teams.go # pkg/services/teams/teams_config.go # pkg/services/teams/teams_test.go # pkg/services/teams/teams_token.go
This commit updates the Teams service in this Shoutrrr fork to support the new Microsoft Teams webhook URL format, removing legacy support, and refactors the package to align with Go best practices. It builds on serverleader's initial PR (March 25, 2025) to standardize the implementation, adding robust validation, improved error handling, and updated documentation in `teams.md`. Tests in `router_suite_test.go` and `services_test.go` are updated to match the new format. Key changes: - Added support for the required `extraId` in webhook URLs. - Updated URL parsing to extract all components, including `extraId`. - Modified `Config` to include `extraId` as a required field. - Removed legacy host fallback (`outlook.office.com`), enforcing an organization-specific domain (e.g., `<org>.webhook.office.com`). - Enhanced parameter validation with specific error messages. - Improved error handling for missing components. - Updated tests to use the new format with `extraId` and `host` param. - Reorganized package into `teams_config.go`, `teams_service.go`, `teams_validation.go`, and `teams_message.go` for better modularity and clarity. - Renamed functions (`BuildWebhookURL`, `WebhookParts`) to follow Go naming conventions. - Updated `teams.md` to document the new format, optional `color` and `title` parameters, and modernized the Microsoft link. The new webhook format is: `https://<org>.webhook.office.com/webhookb2/<group>@<tenant>/IncomingWebhook/<altId>/<groupOwner>/<extraId>` Converted to: `teams://<group>@<tenant>/<altId>/<groupOwner>/<extraId>?host=<org>.webhook.office.com`
feat(teams): update Teams service for new webhook format and refactor
…r#67) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Address Codacy-reported complexity issues in the teams package by refactoring two methods exceeding the limit of 8: - `setURL` (complexity 9): Split into `setURL`, `parseURLParts`, and `setQueryParams`, reducing complexity to 3, 5, and 4, respectively. Extracted URL parsing and query handling into separate functions for better modularity and maintainability. - `verifyWebhookParts` (complexity 10): Refactored to use a loop over a spec slice, reducing complexity to 3. Consolidated repeated length checks into a single control structure. Added comments to new functions. All existing tests pass with no functional changes.
refactor: reduce cyclomatic complexity in teams package
Lint jobs failing due to updated config. Temporarily disabling to get latest Teams update pushed through, then will re-enable and update project to meet updated linting criteria.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR updates the Teams service to support the new webhook URL format and removes support for legacy formats.
Key changes:
The new webhook URL format has the form:
https://<organization>.webhook.office.com/webhookb2/<group>@<tenant>/IncomingWebhook/<altId>/<groupOwner>/<extraId>
Which gets converted to:
teams://<group>@<tenant>/<altId>/<groupOwner>/<extraId>?host=<organization>.webhook.office.com
All components including the extraId and organization-specific domain are now required.