Merge pull request #12544 from rainzm/notify/generate_name

fix(notify): be compatible with Chinese when generating names
This commit is contained in:
Zexi Li
2021-10-28 18:17:13 +08:00
committed by GitHub
+4 -3
View File
@@ -151,10 +151,11 @@ func (nm *SNotificationManager) ValidateCreateData(ctx context.Context, userCred
}
// hack
length := 10
if len(input.Topic) < 10 {
length = len(input.Topic)
topicRunes := []rune(input.Topic)
if len(topicRunes) < 10 {
length = len(topicRunes)
}
name := fmt.Sprintf("%s-%s-%s", input.Topic[:length], input.ContactType, nowStr)
name := fmt.Sprintf("%s-%s-%s", string(topicRunes[:length]), input.ContactType, nowStr)
var err error
input.Name, err = db.GenerateName(ctx, nm, ownerId, name)
if err != nil {