chore: Empty string test can be improved
This commit is contained in:
		
							parent
							
								
									18cdf31e28
								
							
						
					
					
						commit
						56d0eb0e6a
					
				| 
						 | 
				
			
			@ -140,7 +140,7 @@ func typeForPlatForm(platform int) string {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func hideToken(token string, markLen int) string {
 | 
			
		||||
	if len(token) == 0 {
 | 
			
		||||
	if token == "" {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -147,13 +147,13 @@ func CheckMessage(req PushNotification) error {
 | 
			
		|||
	var msg string
 | 
			
		||||
 | 
			
		||||
	// 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"
 | 
			
		||||
		LogAccess.Debug(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"
 | 
			
		||||
		LogAccess.Debug(msg)
 | 
			
		||||
		return errors.New(msg)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -290,8 +290,8 @@ func GetIOSNotification(req PushNotification) *apns2.Notification {
 | 
			
		|||
 | 
			
		||||
	payload := payload.NewPayload()
 | 
			
		||||
 | 
			
		||||
	// add alert object if message length > 0 and title length == 0
 | 
			
		||||
	if len(req.Message) > 0 && len(req.Title) == 0 {
 | 
			
		||||
	// add alert object if message length > 0 and title is empty
 | 
			
		||||
	if len(req.Message) > 0 && req.Title == "" {
 | 
			
		||||
		payload.Alert(req.Message)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue