mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-05 09:30:24 +08:00
创建通知消息的时候限制内容长度不超过1024长度
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||||
|
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
@@ -154,19 +155,16 @@ func (this *MessageDAO) CreateNodeMessage(tx *dbs.Tx, role string, clusterId int
|
|||||||
|
|
||||||
// CreateMessage 创建普通消息
|
// CreateMessage 创建普通消息
|
||||||
func (this *MessageDAO) CreateMessage(tx *dbs.Tx, adminId int64, userId int64, messageType MessageType, level string, subject string, body string, paramsJSON []byte) error {
|
func (this *MessageDAO) CreateMessage(tx *dbs.Tx, adminId int64, userId int64, messageType MessageType, level string, subject string, body string, paramsJSON []byte) error {
|
||||||
|
body = utils.LimitString(subject, 100)
|
||||||
|
body = utils.LimitString(body, 1024)
|
||||||
|
|
||||||
var op = NewMessageOperator()
|
var op = NewMessageOperator()
|
||||||
op.AdminId = adminId
|
op.AdminId = adminId
|
||||||
op.UserId = userId
|
op.UserId = userId
|
||||||
op.Type = messageType
|
op.Type = messageType
|
||||||
op.Level = level
|
op.Level = level
|
||||||
|
|
||||||
subjectRunes := []rune(subject)
|
op.Subject = subject
|
||||||
if len(subjectRunes) > 100 {
|
|
||||||
op.Subject = string(subjectRunes[:100]) + "..."
|
|
||||||
} else {
|
|
||||||
op.Subject = subject
|
|
||||||
}
|
|
||||||
|
|
||||||
op.Body = body
|
op.Body = body
|
||||||
if len(paramsJSON) > 0 {
|
if len(paramsJSON) > 0 {
|
||||||
op.Params = paramsJSON
|
op.Params = paramsJSON
|
||||||
|
|||||||
Reference in New Issue
Block a user