From a5104663e8fafed9909802b244be39631ebe64ce Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Wed, 17 Jul 2024 17:39:07 +0800 Subject: [PATCH] refactor: Add description, provider, and settings fields to NotificationChannelV2 model --- .../models/v2/notification_channel_v2.go | 11 ++++++++ core/notification/constants.go | 28 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core/models/models/v2/notification_channel_v2.go b/core/models/models/v2/notification_channel_v2.go index 250d6e6cc..035baeb0d 100644 --- a/core/models/models/v2/notification_channel_v2.go +++ b/core/models/models/v2/notification_channel_v2.go @@ -4,5 +4,16 @@ type NotificationChannelV2 struct { any `collection:"notification_channels"` BaseModelV2[NotificationChannelV2] `bson:",inline"` Name string `json:"name" bson:"name"` + Description string `json:"description" bson:"description"` Type string `json:"type" bson:"type"` + Provider string `json:"provider" bson:"provider"` + MailSettings struct { + SMTPServer string `json:"smtp_server" bson:"smtp_server"` + SMTPPort string `json:"smtp_port" bson:"smtp_port"` + SMTPFromEmailAddress string `json:"smtp_from_email_address" bson:"smtp_from_email_address"` + SMTPFromEmailPassword string `json:"smtp_from_email_password" bson:"smtp_from_email_password"` + } `json:"mail_settings,omitempty" bson:"mail_settings,omitempty"` + IMSettings struct { + Webhook string `json:"webhook" bson:"webhook"` + } `json:"im_settings,omitempty" bson:"im_settings,omitempty"` } diff --git a/core/notification/constants.go b/core/notification/constants.go index d3f56b721..a69491c3a 100644 --- a/core/notification/constants.go +++ b/core/notification/constants.go @@ -6,5 +6,31 @@ const ( ) const ( - SettingsColName = "notification_settings" + ChannelMailProviderGmail = "gmail" + ChannelMailProviderOutlook = "outlook" + ChannelMailProviderYahoo = "yahoo" + ChannelMailProviderHotmail = "hotmail" + ChannelMailProviderAol = "aol" + ChannelMailProviderZoho = "zoho" + ChannelMailProviderYandex = "yandex" + ChannelMailProviderICloud = "icloud" + ChannelMailProviderQQMailProvider = "qq" + ChannelMailProvider163 = "163" + ChannelMailProvider126 = "126" + ChannelMailProviderSina = "sina" + ChannelMailProviderSohu = "sohu" + ChannelMailProvider21CN = "21cn" + ChannelMailProviderTencent = "tencent" + ChannelMailProviderHuawei = "huawei" + ChannelMailProviderAliyun = "aliyun" + + ChannelIMProviderSlack = "slack" // https://api.slack.com/messaging/webhooks + ChannelIMProviderMSTeams = "ms_teams" // https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=newteams%2Cjavascript + ChannelIMProviderTelegram = "telegram" // https://core.telegram.org/bots/api + ChannelIMProviderDiscord = "discord" // https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks + ChannelIMProviderWhatsappBusiness = "whatsapp_business" // https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages + ChannelIMProviderFacebookMessenger = "facebook_messenger" // https://developers.facebook.com/docs/messenger-platform/send-messages + ChannelIMProviderWechatWork = "wechat_work" // https://developer.work.weixin.qq.com/document/path/91770 + ChannelIMProviderDingtalk = "dingtalk" // https://open.dingtalk.com/document/orgapp/custom-robot-access + ChannelIMProviderLark = "lark" // https://www.larksuite.com/hc/en-US/articles/099698615114-use-webhook-triggers )