Skip to content

Commit b201836

Browse files
authored
fix:create user info for notify_tpl (#2292)
1 parent b5eced1 commit b201836

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

center/router/router_notify_tpl.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,20 @@ func (rt *Router) notifyTplPreview(c *gin.Context) {
161161
func (rt *Router) notifyTplAdd(c *gin.Context) {
162162
var f models.NotifyTpl
163163
ginx.BindJSON(c, &f)
164-
f.Channel = strings.TrimSpace(f.Channel)
164+
165+
user := c.MustGet("user").(*models.User)
166+
f.CreateBy = user.Username
167+
168+
f.Channel = strings.TrimSpace(f.Channel)
165169
ginx.Dangerous(templateValidate(f))
166170

167171
count, err := models.Count(models.DB(rt.Ctx).Model(&models.NotifyTpl{}).Where("channel = ? or name = ?", f.Channel, f.Name))
168172
ginx.Dangerous(err)
169173
if count != 0 {
170174
ginx.Bomb(200, "Refuse to create duplicate channel(unique)")
171175
}
176+
177+
f.CreateAt = time.Now().Unix()
172178
ginx.NewRender(c).Message(f.Create(rt.Ctx))
173179
}
174180

0 commit comments

Comments
 (0)