mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-13 09:55:29 +02:00
feat: add mattermost notification provider
Add comprehensive Mattermost integration as a new notification provider: ## Backend Implementation: - Add `mattermost` to notificationType enum and database schema - Create mattermost table with webhookUrl, channel, username fields - Implement CRUD operations: createMattermostNotification, updateMattermostNotification - Add API routes: createMattermost, updateMattermost, testMattermostConnection - Add sendMattermostNotification utility with proper payload formatting ## Frontend Implementation: - Add MattermostIcon component with provided SVG logo - Extend notification form with Mattermost schema validation - Add webhook URL (required), channel and username (optional) form fields - Integrate test connection functionality - Add Mattermost to provider selection UI ## Notification Integration: - Integrate across all notification types: - Build success/error notifications - Database backup notifications - Docker cleanup notifications - Dokploy restart notifications - Server threshold alerts - Format messages using Markdown for Mattermost compatibility - Handle optional channel (#prefix) and username override - Graceful fallback for empty optional fields ## Features: - Webhook-based messaging to Mattermost channels - Optional channel targeting and custom username display - Consistent formatting with other notification providers - Full CRUD support with proper validation - Test connection capability Closes: Support for Mattermost team communication platform # Conflicts: # apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx # apps/dokploy/components/icons/notification-icons.tsx # apps/dokploy/server/api/routers/notification.ts # packages/server/src/db/schema/notification.ts # packages/server/src/services/notification.ts # packages/server/src/utils/notifications/build-error.ts # packages/server/src/utils/notifications/build-success.ts # packages/server/src/utils/notifications/database-backup.ts # packages/server/src/utils/notifications/docker-cleanup.ts # packages/server/src/utils/notifications/dokploy-restart.ts # packages/server/src/utils/notifications/server-threshold.ts # packages/server/src/utils/notifications/utils.ts
This commit is contained in:
@@ -3,6 +3,7 @@ import type {
|
||||
email,
|
||||
lark,
|
||||
gotify,
|
||||
mattermost,
|
||||
ntfy,
|
||||
slack,
|
||||
telegram,
|
||||
@@ -154,6 +155,28 @@ export const sendNtfyNotification = async (
|
||||
}
|
||||
};
|
||||
|
||||
export const sendMattermostNotification = async (
|
||||
connection: typeof mattermost.$inferInsert,
|
||||
message: any,
|
||||
) => {
|
||||
try {
|
||||
const payload = {
|
||||
...message,
|
||||
// Only include username if it's provided and not empty
|
||||
...(message.username && message.username.trim() && { username: message.username }),
|
||||
// Only include wchannel if it's provided and not empty
|
||||
...(message.channel && message.channel.trim() && { channel: `#${message.channel.replace('#', '')}` }),
|
||||
};
|
||||
|
||||
await fetch(connection.webhookUrl, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
export const sendLarkNotification = async (
|
||||
connection: typeof lark.$inferInsert,
|
||||
message: any,
|
||||
|
||||
Reference in New Issue
Block a user