Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions common/types/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,24 @@ const (
LarkMessageReceiveIDTypeChatID LarkMessageReceiveIDType = "chat_id"
)

func (t LarkMessageReceiveIDType) String() string {
return string(t)
}

func (t LarkMessageReceiveIDType) IsValid() bool {
switch t {
case LarkMessageReceiveIDTypeOpenID, LarkMessageReceiveIDTypeChatID:
return true
default:
return false
}
}

type LarkReceiver struct {
Type LarkMessageReceiveIDType `json:"type"`
ID string `json:"id"`
}

type LarkMessage struct {
Priority LarkMessagePriority `json:"priority"`
MsgType LarkMessageType `json:"msg_type"`
Expand Down Expand Up @@ -327,3 +345,43 @@ type SMSReq struct {
TemplateCode string `json:"template_code"`
TemplateParam string `json:"template_param"`
}

type EmailInvoiceCreatedNotification struct {
ReceiverEmail string `json:"receiver_email"`
UserUUID string `json:"user_uuid"`
Amount string `json:"amount"`
}

// EmailGitlabIssueFeedbackNotification gitlab issue feedback email notification parameters
type EmailGitlabIssueFeedbackNotification struct {
UserEmail string `json:"user_email"`
UserName string `json:"user_name"`
Language string `json:"language"`
EventType string `json:"event_type"` // create, comment, close
IssueID string `json:"issue_id"`
IssueTitle string `json:"issue_title"`
Comment string `json:"comment"`
}

// ModelDatasetRecommendRequest model dataset recommend request
type ModelDatasetRecommendRequest struct {
Models []ModelRecommendInfo `json:"models" binding:"required"`
Datasets []DatasetRecommendInfo `json:"datasets" binding:"required"`
}

// ModelRecommendInfo model recommend info
type ModelRecommendInfo struct {
ID string `json:"id"`
Description string `json:"description"`
}

// DatasetRecommendInfo dataset recommend info
type DatasetRecommendInfo struct {
ID string `json:"id"`
Description string `json:"description"`
}

// ModelDatasetRecommendResponse model dataset recommend response
type ModelDatasetRecommendResponse struct {
MsgUUID string `json:"msg_uuid"`
}
177 changes: 177 additions & 0 deletions common/types/notification_scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,183 @@ const (
MessageScenarioOrgVerify MessageScenario = "org-verify"
MessageScenarioOrgMember MessageScenario = "org-member"
MessageScenarioDiscussion MessageScenario = "discussion"
MessageScenarioRecharge MessageScenario = "recharge"
MessageScenarioLowBalance MessageScenario = "low-balance"
MessageScenarioRechargeSuccess MessageScenario = "recharge-success"
MessageScenarioWeeklyRecharges MessageScenario = "weekly-recharges"
MessageScenarioDeployment MessageScenario = "deployment"
MessageScenarioNegativeBalance MessageScenario = "negative-balance"

// inviter pending award notification
// @Scenario inviter-pending-award
// @Channels internal-message, email
// @PayloadFields amount
// @Template {
// "email": {
// "en-US": {
// "title": "Receive an inviter pending award",
// "content": "You receive an pending inviter award ¥{{.amount}}, it will be awarded on the 5th of next month"
// },
// "zh-CN": {
// "title": "收到待发放的邀请奖励",
// "content": "你收到待发放的邀请奖励 ¥{{.amount}},将在下个月5号发放"
// },
// "zh-HK": {
// "title": "收到待發放的邀請獎勵",
// "content": "你收到待發放的邀請獎勵 ¥{{.amount}},將在下個月5號發放"
// },
// },
// }
// @BuildTags saas
MessageScenarioInviterPendingAward MessageScenario = "inviter-pending-award"

// inviter award notification
// @Scenario inviter-award
// @Channels internal-message, email
// @PayloadFields amount
// @Template {
// "email": {
// "en-US": {
// "title": "Receive an inviter award",
// "content": "You receive an inviter award ¥{{.amount}}"
// },
// "zh-CN": {
// "title": "收到邀请奖励",
// "content": "你收到邀请奖励¥{{.amount}}"
// },
// "zh-HK": {
// "title": "收到邀請獎勵",
// "content": "你收到邀請獎勵¥{{.amount}}"
// },
// },
// }
// @BuildTags saas
MessageScenarioInviterAward MessageScenario = "inviter-award"

// invitee award notification
// @Scenario invitee-award
// @Channels internal-message, email
// @PayloadFields amount
// @Template {
// "email": {
// "en-US": {
// "title": "Receive an invitee award",
// "content": "You receive an invitee award ¥{{.amount}}"
// },
// "zh-CN": {
// "title": "收到受邀奖励",
// "content": "你收到受邀奖励 ¥{{.amount}}"
// },
// "zh-HK": {
// "title": "收到受邀請獎勵",
// "content": "你收到受邀請獎勵 ¥{{.amount}}"
// },
// },
// }
// @BuildTags saas
MessageScenarioInviteeAward MessageScenario = "invitee-award"

// invitation award be cancelled notification
// @Scenario invitation-award-cancelled
// @Channels internal-message, email
// @PayloadFields amount
// @Template {
// "email": {
// "en-US": {
// "title": "Invitation award cancelled",
// "content": "Invitation award cancelled ¥{{.amount}}, since not used within 90 days"
// },
// "zh-CN": {
// "title": "邀请奖励已取消",
// "content": "邀请奖励已取消 ¥{{.amount}},因90天內未使用"
// },
// "zh-HK": {
// "title": "邀請獎勵已取消",
// "content": "邀請獎勵已取消 ¥{{.amount}},因90天內未使用"
// },
// },
// }
// @BuildTags saas
MessageScenarioInvitationAwardCancelled MessageScenario = "invitation-award-cancelled"

// agent instance updated notification
// @Scenario agent-instance-updated
// @Channels internal-message, email
// @PayloadFields instance_type, instance_name
// @Template {
// "email": {
// "en-US": {
// "title": "Agent Instance Updated",
// "content": "Your agent instance '{{.instance_name}}' [{{.instance_type}}] has been successfully updated."
// },
// "zh-CN": {
// "title": "Agent实例已更新",
// "content": "您的Agent实例 '{{.instance_name}}' [{{.instance_type}}] 已成功更新。"
// },
// "zh-HK": {
// "title": "Agent實例已更新",
// "content": "您的Agent實例 '{{.instance_name}}' [{{.instance_type}}] 已成功更新。"
// },
// },
// }
// @BuildTags ce
MessageScenarioAgentInstanceUpdated MessageScenario = "agent-instance-updated"

// agent instance deleted notification
// @Scenario agent-instance-deleted
// @Channels internal-message, email
// @PayloadFields instance_type, instance_name
// @Template {
// "email": {
// "en-US": {
// "title": "Agent Instance Deleted",
// "content": "Your agent instance '{{.instance_name}}' [{{.instance_type}}] has been successfully deleted."
// },
// "zh-CN": {
// "title": "Agent实例已删除",
// "content": "您的Agent实例 '{{.instance_name}}' [{{.instance_type}}] 已成功删除。"
// },
// "zh-HK": {
// "title": "Agent實例已刪除",
// "content": "您的Agent實例 '{{.instance_name}}' [{{.instance_type}}] 已成功刪除。"
// },
// },
// }
// @BuildTags ce
MessageScenarioAgentInstanceDeleted MessageScenario = "agent-instance-deleted"

// invoice created notification
// @Scenario invoice-created
// @Channels email
// @PayloadFields user_name, phone, amount
// @Template {
// "email": {
// "zh-CN": {
// "title": "用户申请发票",
// "content": "用户ID:{{.user_name}},手机号:{{.phone}},开票金额:¥{{.amount}}"
// },
// },
// }
// @BuildTags saas
MessageScenarioInvoiceCreated MessageScenario = "invoice-created"

// csgbot critical error notification
MessageScenarioCSGBotCriticalError MessageScenario = "csgbot-critical-error"

// agentichub feedback notification
MessageScenarioAgentichubFeedback MessageScenario = "agentichub-feedback"

// model dataset recommend notification
// @Scenario model-dataset-recommend
// @Channels email
// @PayloadFields model_ids, dataset_ids
// @Description send model dataset recommend email to all users
MessageScenarioModelDatasetRecommend MessageScenario = "model-dataset-recommend"

// gitlab issue feedback notification
// @Scenario gitlab-issue-feedback
// @Channels email
// @PayloadFields user_email, user_name, language, event_type, issue_id, issue_title, comment
// @BuildTags saas
MessageScenarioGitlabIssueFeedback MessageScenario = "gitlab-issue-feedback"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{/* title section */}}
{{if eq .event_type "create"}}Your CSGHub issue has been created{{else if eq .event_type "comment"}}New comment on your CSGHub issue #{{.issue_id}}{{else}}Your CSGHub issue has been resolved{{end}}
---
{{/* content section */}}
<html>
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
<p style="margin-bottom: 20px;">Hi{{if .user_name}} {{.user_name}}{{end}},</p>

{{if eq .event_type "create"}}
<h2 style="color: #1e90ff; margin-top: 0; font-size: 18px;">Your CSGHub issue has been created</h2>
<p style="margin-bottom: 16px;">Thank you for submitting your feedback. We have received your issue and will process it as soon as possible.</p>
<div style="margin: 24px 0; padding: 16px; background-color: #f5f9ff; border-left: 4px solid #1e90ff; border-radius: 4px;">
<p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">Issue #{{.issue_id}}</p>
<p style="margin: 0; font-weight: bold;">{{.issue_title}}</p>
</div>
{{else if eq .event_type "comment"}}
<h2 style="color: #1e90ff; margin-top: 0; font-size: 18px;">New comment on your CSGHub issue</h2>
<p style="margin-bottom: 16px;">Your issue has received a new comment.</p>
<div style="margin: 24px 0; padding: 16px; background-color: #f9f9f9; border-radius: 4px;">
<p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">Issue #{{.issue_id}} · {{.issue_title}}</p>
{{if .comment}}
<div style="margin-top: 12px; padding: 12px; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 4px;">
<p style="margin: 0; white-space: pre-wrap;">{{.comment}}</p>
</div>
{{end}}
</div>
{{else}}
<h2 style="color: #2e7d32; margin-top: 0; font-size: 18px;">Your CSGHub issue has been resolved</h2>
<p style="margin-bottom: 16px;">Thank you for your feedback. The following issue has been resolved:</p>
<div style="margin: 24px 0; padding: 16px; background-color: #f1f8e9; border-left: 4px solid #2e7d32; border-radius: 4px;">
<p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">Issue #{{.issue_id}}</p>
<p style="margin: 0; font-weight: bold;">{{.issue_title}}</p>
</div>
<p style="margin-top: 20px;">We appreciate your contribution to the CSGHub community.</p>
{{end}}

<p style="margin-top: 32px; padding-top: 16px; border-top: 1px solid #eee; font-size: 12px; color: #888;">CSGHub Team</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{/* title section */}}
{{if eq .event_type "create"}}您在 CSGHub 提交的问题已创建{{else if eq .event_type "comment"}}您提交的 CSGHub 问题 #{{.issue_id}} 收到新回复{{else}}您在 CSGHub 提交的问题已解决{{end}}
---
{{/* content section */}}
<html>
<body style="font-family: Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
<p style="margin-bottom: 20px;">您好{{if .user_name}},{{.user_name}}{{end}}:</p>

{{if eq .event_type "create"}}
<h2 style="color: #1e90ff; margin-top: 0; font-size: 18px;">您在 CSGHub 提交的问题已创建</h2>
<p style="margin-bottom: 16px;">感谢您的反馈,我们已收到您提交的问题,将尽快处理。</p>
<div style="margin: 24px 0; padding: 16px; background-color: #f5f9ff; border-left: 4px solid #1e90ff; border-radius: 4px;">
<p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">问题 #{{.issue_id}}</p>
<p style="margin: 0; font-weight: bold;">{{.issue_title}}</p>
</div>
{{else if eq .event_type "comment"}}
<h2 style="color: #1e90ff; margin-top: 0; font-size: 18px;">您提交的问题收到新回复</h2>
<p style="margin-bottom: 16px;">您提交的问题收到了新回复。</p>
<div style="margin: 24px 0; padding: 16px; background-color: #f9f9f9; border-radius: 4px;">
<p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">问题 #{{.issue_id}} · {{.issue_title}}</p>
{{if .comment}}
<div style="margin-top: 12px; padding: 12px; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 4px;">
<p style="margin: 0; white-space: pre-wrap;">{{.comment}}</p>
</div>
{{end}}
</div>
{{else}}
<h2 style="color: #2e7d32; margin-top: 0; font-size: 18px;">您在 CSGHub 提交的问题已解决</h2>
<p style="margin-bottom: 16px;">感谢您的反馈,以下问题已解决:</p>
<div style="margin: 24px 0; padding: 16px; background-color: #f1f8e9; border-left: 4px solid #2e7d32; border-radius: 4px;">
<p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">问题 #{{.issue_id}}</p>
<p style="margin: 0; font-weight: bold;">{{.issue_title}}</p>
</div>
<p style="margin-top: 20px;">感谢您对 CSGHub 社区的贡献。</p>
{{end}}

<p style="margin-top: 32px; padding-top: 16px; border-top: 1px solid #eee; font-size: 12px; color: #888;">CSGHub 团队</p>
</body>
</html>
Loading