-
Notifications
You must be signed in to change notification settings - Fork 280
feat(xo-server-web-hooks): handle office 365 connector format #8498
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
base: master
Are you sure you want to change the base?
Conversation
Probably worth a highlight for the next release 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me apart from the typo
@@ -141,6 +173,11 @@ export const configurationSchema = ({ xo: { apiMethods } }) => ({ | |||
title: 'URL', | |||
type: 'string', | |||
}, | |||
isOfficeHook: { | |||
description: 'Enable if your URL require a payload that follow the office 365 connector format', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: 'Enable if your URL require a payload that follow the office 365 connector format', | |
description: 'Enable if your URL requires a payload that follow the office 365 connector format', |
@@ -163,6 +200,11 @@ export const testSchema = { | |||
type: 'string', | |||
description: 'The URL the test request will be sent to', | |||
}, | |||
isOfficeHook: { | |||
description: 'Enable if your URL require a payload that follow the office 365 connector format', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: 'Enable if your URL require a payload that follow the office 365 connector format', | |
description: 'Enable if your URL requires a payload that follow the office 365 connector format', |
function constructPayload(isOfficeHook, data, type) { | ||
if (isOfficeHook) { | ||
// https://learn.microsoft.com/en-us/outlook/actionable-messages/message-card-reference | ||
const facts = Object.keys(data).map(key => { | ||
const value = data[key] | ||
return { name: key, value: typeof value === 'string' ? value : JSON.stringify(value) } | ||
}) | ||
|
||
return { | ||
'@type': 'MessageCard', | ||
'@context': 'https://schema.org/extensions', | ||
themeColor: 'BE1621', | ||
summary: 'New notification from the Xen-Orchestra webhook plugin', | ||
sections: [{ title: `XO ${type.toUpperCase()} notification` }, { facts }], | ||
} | ||
} | ||
|
||
return { ...data, type } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we want to support multiple formats, we might want to:
- Use an enum in the configuration
- Return a string here instead of an object (to be able to support non-JSON formats in the future)
What do you think?
Description
Microsoft teams webhook require a payload in the office 365 connector format.
This PR add a toggle in the plugin configuration to handle URL that require payload in this format.
zammad#36742
Screenshots
Checklist
Fixes #007
,See xoa-support#42
,See https://...
)Introduced by
CHANGELOG.unreleased.md
Review process
Notes: