Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: support new teams webhook (#19204)
ecmadao83f77d5e5b9f
diff --git a/backend/plugin/webhook/teams/teams.go b/backend/plugin/webhook/teams/teams.goindex 91184d983f..e85953d658 100644--- a/backend/plugin/webhook/teams/teams.go+++ b/backend/plugin/webhook/teams/teams.go@@ -1,8 +1,8 @@// Package teams implements Microsoft Teams webhook and direct message integration.//// Documentation:-// - Teams Webhooks (Incoming Webhook): https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook-// - MessageCard Format: https://learn.microsoft.com/en-us/outlook/actionable-messages/message-card-reference+// - Power Automate Workflows: https://learn.microsoft.com/en-us/power-automate/overview-cloud+// - Legacy Office 365 Connectors (deprecated): https://learn.microsoft.com/en-us/outlook/actionable-messages/message-card-reference// - Adaptive Cards: https://learn.microsoft.com/en-us/adaptive-cards/// - Proactive Messaging: https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages// - Graph API App Installation: https://learn.microsoft.com/en-us/microsoftteams/platform/graph-api/proactive-bots-and-messages/graph-proactive-bots-and-messages@@ -16,6 +16,8 @@ import ("io""log/slog""net/http"+ "net/url"+ "strings""github.com/pkg/errors""go.uber.org/multierr"@@ -95,9 +97,68 @@ func (*Receiver) Post(context webhook.Context) error {return nil}}+ if isPowerAutomateURL(context.URL) {+ return postPowerAutomateMessage(context)+ }return postMessage(context)}+// isPowerAutomateURL returns true if the webhook URL is a Power Automate Workflow URL+// (*.powerplatform.com or legacy *.logic.azure.com) rather than a legacy Office 365 Connector URL.+func isPowerAutomateURL(webhookURL string) bool {+ u, err := url.Parse(webhookURL)+ if err != nil {+ return false+ }+ hostname := strings.ToLower(u.Hostname())+ return strings.HasSuffix(hostname, ".powerplatform.com") || strings.HasSuffix(hostname, ".logic.azure.com")+}++// postPowerAutomateMessage sends a webhook message to a Power Automate Workflow URL+// using the Adaptive Card format wrapped in a message envelope.+func postPowerAutomateMessage(context webhook.Context) error {+ card := getAdaptiveCard(context)+ msg := activity{+ Type: "message",+ Attachments: []attachment{+ {+ ContentType: "application/vnd.microsoft.card.adaptive",+ Content: card,+ },+ },+ }++ body, err := json.Marshal(msg)+ if err != nil {+ return errors.Wrapf(err, "failed to marshal webhook POST request to %s", context.URL)+ }+ req, err := http.NewRequest("POST", context.URL, bytes.NewBuffer(body))+ if err != nil {+ return errors.Wrapf(err, "failed to construct webhook POST request to %s", context.URL)+ }++ req.Header.Set("Content-Type", "application/json")+ client := &http.Client{+ Timeout: webhook.Timeout,+ }+ resp, err := client.Do(req)+ if err != nil {+ return errors.Wrapf(err, "failed to POST webhook to %s", context.URL)+ }++ b, err := io.ReadAll(resp.Body)+ if err != nil {+ return errors.Wrapf(err, "failed to read POST webhook response from %s", context.URL)+ }+ defer resp.Body.Close()++ if resp.StatusCode < 200 || resp.StatusCode >= 300 {+ return errors.Errorf("failed to POST webhook %s, status code: %d, response body: %s", context.URL, resp.StatusCode, b)+ }++ return nil+}+func postDirectMessage(webhookCtx webhook.Context) bool {teams := getTeamsConfig(webhookCtx.IMSetting)if teams == nil {diff --git a/backend/plugin/webhook/validator.go b/backend/plugin/webhook/validator.goindex c3dd8d37ae..a47c9fda93 100644--- a/backend/plugin/webhook/validator.go+++ b/backend/plugin/webhook/validator.go@@ -21,8 +21,16 @@ var ("discordapp.com",},storepb.WebhookType_TEAMS: {- ".office.com", // Matches *.office.com- ".office365.com", // Matches *.office365.com+ // Power Automate Workflows (recommended):+ // https://learn.microsoft.com/en-us/power-automate/how-tos-bulk-update-trigger-urls+ ".powerplatform.com",+ // Legacy Power Automate URLs (deprecated, retired Nov 2025):+ // https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/+ ".logic.azure.com",+ // Legacy Office 365 Connectors (deprecated, retiring Mar 2026):+ // https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/+ ".office.com",+ ".office365.com",},storepb.WebhookType_DINGTALK: {"oapi.dingtalk.com",diff --git a/backend/plugin/webhook/validator_test.go b/backend/plugin/webhook/validator_test.goindex d3a56d87d7..98473e904f 100644--- a/backend/plugin/webhook/validator_test.go+++ b/backend/plugin/webhook/validator_test.go@@ -83,6 +83,18 @@ func TestValidateWebhookURL(t *testing.T) {webhookURL: "https://example.office.com/webhook/xxx",wantErr: false,},+ {+ name: "valid teams Power Automate URL",+ webhookType: storepb.WebhookType_TEAMS,+ webhookURL: "https://prod-03.westus.logic.azure.com:443/workflows/abc123/triggers/manual/paths/invoke?api-version=2016-06-01",+ wantErr: false,+ },+ {+ name: "valid teams Power Automate powerplatform URL",+ webhookType: storepb.WebhookType_TEAMS,+ webhookURL: "https://default1234.aa.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/abc123/triggers/manual/paths/invoke",+ wantErr: false,+ },{name: "invalid teams domain",webhookType: storepb.WebhookType_TEAMS,diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vueindex cf264d7fba..b0a42c1151 100644--- a/frontend/src/components/ProjectWebhookForm.vue+++ b/frontend/src/components/ProjectWebhookForm.vue@@ -193,7 +193,11 @@</div></div><div class="mt-4">- <NButton @click.prevent="testWebhook">+ <NButton+ :loading="state.loading"+ :disabled="!state.webhook.url"+ @click.prevent="testWebhook"+ >{{ $t("project.webhook.test-webhook") }}</NButton></div>@@ -212,7 +216,8 @@<NButtonv-if="create"type="primary"- :disabled="!allowCreate"+ :loading="state.loading"+ :disabled="!allowCreate || state.loading"@click.prevent="createWebhook">{{ $t("common.create") }}@@ -220,8 +225,9 @@<NButtonv-elsetype="primary"+ :loading="state.loading":disabled="- !valueChanged || state.webhook.notificationTypes.length === 0+ state.loading || !valueChanged || state.webhook.notificationTypes.length === 0"@click.prevent="updateWebhook">@@ -264,7 +270,6 @@ import {import { WORKSPACE_ROUTE_IM } from "@/router/dashboard/workspaceRoutes";import {pushNotification,- useGracefulRequest,useProjectV1Store,useProjectWebhookV1Store,useSettingV1Store,@@ -284,6 +289,7 @@ import WebhookTypeIcon from "./Project/WebhookTypeIcon.vue";interface LocalState {webhook: Webhook;+ loading: boolean;}const props = withDefaults(@@ -315,6 +321,7 @@ onMounted(async () => {const state = reactive<LocalState>({webhook: cloneDeep(props.webhook),+ loading: false,});watch(@@ -375,8 +382,13 @@ const imApp = computed(() => {);});+const isPowerAutomateURL = computed(() => {+ const url = state.webhook.url.toLowerCase();+ return url.includes(".powerplatform.com") || url.includes(".logic.azure.com");+});+const webhookSupportDirectMessage = computed(- () => selectedWebhook.value?.supportDirectMessage+ () => selectedWebhook.value?.supportDirectMessage && !isPowerAutomateURL.value);const activitySupportDirectMessage = computed(() => {@@ -407,6 +419,7 @@ const dropdownOptions = computed((): DropdownOption[] => {{key: "delete",label: t("common.delete"),+ disabled: state.loading,},];});@@ -433,6 +446,19 @@ const cancel = () => {});};+// biome-ignore format: ESLint requires trailing comma for generic type parameter+const useGracefulRequest = async <T,>(+ fn: () => Promise<T>+): Promise<T | void> => {+ state.loading = true;+ try {+ const result = await fn();+ return result;+ } finally {+ state.loading = false;+ }+};+const createWebhook = () => {useGracefulRequest(async () => {const { webhook } = state;@@ -528,7 +554,7 @@ const deleteWebhook = () => {const testWebhook = () => {useGracefulRequest(async () => {- const result = await useProjectWebhookV1Store().testProjectWebhook(+ const result = await projectWebhookV1Store.testProjectWebhook(props.project,state.webhook);diff --git a/frontend/src/types/v1/projectWebhook.ts b/frontend/src/types/v1/projectWebhook.tsindex a606a4e3f5..752fb95104 100644--- a/frontend/src/types/v1/projectWebhook.ts+++ b/frontend/src/types/v1/projectWebhook.ts@@ -45,9 +45,10 @@ export const projectWebhookV1TypeItemList = (): ProjectWebhookV1TypeItem[] => {type: WebhookType.TEAMS,name: t("common.teams"),urlPrefix: "",- urlPlaceholder: "https://acme123.webhook.office.com/webhookb2/...",+ urlPlaceholder:+ "https://xxx.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/...",docUrl:- "https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook",+ "https://support.microsoft.com/en-us/office/create-incoming-webhooks-with-workflows-for-microsoft-teams-8ae491c7-0394-4861-ba59-055e33f75498",supportDirectMessage: true,},{