Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2703 Reviewed-by: lewis <747342561@qq.com>tags/v1.22.8.1^2
@@ -66,6 +66,7 @@ type DefaultWechatTemplate struct { | |||||
Keyword1 TemplateValue `json:"keyword1"` | Keyword1 TemplateValue `json:"keyword1"` | ||||
Keyword2 TemplateValue `json:"keyword2"` | Keyword2 TemplateValue `json:"keyword2"` | ||||
Keyword3 TemplateValue `json:"keyword3"` | Keyword3 TemplateValue `json:"keyword3"` | ||||
Keyword4 TemplateValue `json:"keyword4"` | |||||
Remark TemplateValue `json:"remark"` | Remark TemplateValue `json:"remark"` | ||||
} | } | ||||
@@ -53,6 +53,10 @@ func (CloudbrainStartMsg) Url(ctx *TemplateContext) string { | |||||
return getCloudbrainTemplateUrl(*ctx.Cloudbrain, repo) | return getCloudbrainTemplateUrl(*ctx.Cloudbrain, repo) | ||||
} | } | ||||
func (CloudbrainStartMsg) TemplateId(ctx *TemplateContext) string { | |||||
return setting.CloudbrainStartedTemplateId | |||||
} | |||||
type CloudbrainStopMsg struct { | type CloudbrainStopMsg struct { | ||||
} | } | ||||
@@ -62,6 +66,7 @@ func (CloudbrainStopMsg) Data(ctx *TemplateContext) *DefaultWechatTemplate { | |||||
Keyword1: TemplateValue{Value: ctx.Cloudbrain.DisplayJobName}, | Keyword1: TemplateValue{Value: ctx.Cloudbrain.DisplayJobName}, | ||||
Keyword2: TemplateValue{Value: getJobTypeDisplayName(ctx.Cloudbrain.JobType)}, | Keyword2: TemplateValue{Value: getJobTypeDisplayName(ctx.Cloudbrain.JobType)}, | ||||
Keyword3: TemplateValue{Value: time.Unix(int64(ctx.Cloudbrain.CreatedUnix), 0).Format("2006-01-02 15:04:05")}, | Keyword3: TemplateValue{Value: time.Unix(int64(ctx.Cloudbrain.CreatedUnix), 0).Format("2006-01-02 15:04:05")}, | ||||
Keyword4: TemplateValue{Value: time.Unix(int64(ctx.Cloudbrain.EndTime), 0).Format("2006-01-02 15:04:05")}, | |||||
Remark: TemplateValue{Value: setting.CloudbrainStoppedRemark}, | Remark: TemplateValue{Value: setting.CloudbrainStoppedRemark}, | ||||
} | } | ||||
} | } | ||||
@@ -91,6 +96,10 @@ func (CloudbrainStopMsg) Url(ctx *TemplateContext) string { | |||||
return getCloudbrainTemplateUrl(*ctx.Cloudbrain, repo) | return getCloudbrainTemplateUrl(*ctx.Cloudbrain, repo) | ||||
} | } | ||||
func (CloudbrainStopMsg) TemplateId(ctx *TemplateContext) string { | |||||
return setting.CloudbrainStoppedTemplateId | |||||
} | |||||
var startMsg = &CloudbrainStartMsg{} | var startMsg = &CloudbrainStartMsg{} | ||||
var stopMsg = &CloudbrainStopMsg{} | var stopMsg = &CloudbrainStopMsg{} | ||||
@@ -3,7 +3,6 @@ package wechat | |||||
import ( | import ( | ||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
"errors" | "errors" | ||||
"fmt" | "fmt" | ||||
) | ) | ||||
@@ -13,6 +12,7 @@ type Template interface { | |||||
Data(ctx *TemplateContext) *DefaultWechatTemplate | Data(ctx *TemplateContext) *DefaultWechatTemplate | ||||
MsgId(ctx *TemplateContext) string | MsgId(ctx *TemplateContext) string | ||||
Url(ctx *TemplateContext) string | Url(ctx *TemplateContext) string | ||||
TemplateId(ctx *TemplateContext) string | |||||
} | } | ||||
type TemplateContext struct { | type TemplateContext struct { | ||||
@@ -36,7 +36,7 @@ func SendTemplateMsg(template Template, ctx *TemplateContext, userId int64) erro | |||||
} | } | ||||
req := TemplateMsgRequest{ | req := TemplateMsgRequest{ | ||||
ToUser: openId, | ToUser: openId, | ||||
TemplateId: setting.CloudbrainStartedTemplateId, | |||||
TemplateId: template.TemplateId(ctx), | |||||
Url: template.Url(ctx), | Url: template.Url(ctx), | ||||
ClientMsgId: template.MsgId(ctx), | ClientMsgId: template.MsgId(ctx), | ||||
Data: template.Data(ctx), | Data: template.Data(ctx), | ||||