chore: Empty string test can be improved

This commit is contained in:
Bo-Yi Wu 2021-01-23 09:48:58 +08:00
parent 18cdf31e28
commit 56d0eb0e6a
3 changed files with 5 additions and 5 deletions

View File

@ -140,7 +140,7 @@ func typeForPlatForm(platform int) string {
} }
func hideToken(token string, markLen int) string { func hideToken(token string, markLen int) string {
if len(token) == 0 { if token == "" {
return "" return ""
} }

View File

@ -147,13 +147,13 @@ func CheckMessage(req PushNotification) error {
var msg string var msg string
// ignore send topic mesaage from FCM // ignore send topic mesaage from FCM
if !req.IsTopic() && len(req.Tokens) == 0 && len(req.To) == 0 { if !req.IsTopic() && len(req.Tokens) == 0 && req.To == "" {
msg = "the message must specify at least one registration ID" msg = "the message must specify at least one registration ID"
LogAccess.Debug(msg) LogAccess.Debug(msg)
return errors.New(msg) return errors.New(msg)
} }
if len(req.Tokens) == PlatFormIos && len(req.Tokens[0]) == 0 { if len(req.Tokens) == PlatFormIos && req.Tokens[0] == "" {
msg = "the token must not be empty" msg = "the token must not be empty"
LogAccess.Debug(msg) LogAccess.Debug(msg)
return errors.New(msg) return errors.New(msg)

View File

@ -290,8 +290,8 @@ func GetIOSNotification(req PushNotification) *apns2.Notification {
payload := payload.NewPayload() payload := payload.NewPayload()
// add alert object if message length > 0 and title length == 0 // add alert object if message length > 0 and title is empty
if len(req.Message) > 0 && len(req.Title) == 0 { if len(req.Message) > 0 && req.Title == "" {
payload.Alert(req.Message) payload.Alert(req.Message)
} }