request retry must be small than max retry.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
7167ce8323
commit
81f37465b0
|
@ -329,6 +329,13 @@ func GetIOSNotification(req PushNotification) *apns.Notification {
|
||||||
func PushToIOS(req PushNotification) bool {
|
func PushToIOS(req PushNotification) bool {
|
||||||
LogAccess.Debug("Start push notification for iOS")
|
LogAccess.Debug("Start push notification for iOS")
|
||||||
|
|
||||||
|
var retryCount = 0
|
||||||
|
var maxRetry = PushConf.Ios.MaxRetry
|
||||||
|
|
||||||
|
if req.Retry > 0 && req.Retry < maxRetry {
|
||||||
|
maxRetry = req.Retry
|
||||||
|
}
|
||||||
|
|
||||||
Retry:
|
Retry:
|
||||||
var isError = false
|
var isError = false
|
||||||
var newTokens []string
|
var newTokens []string
|
||||||
|
@ -366,12 +373,11 @@ Retry:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isError == true && req.Retry < PushConf.Ios.MaxRetry {
|
if isError == true && retryCount < maxRetry {
|
||||||
req.Retry++
|
retryCount++
|
||||||
|
|
||||||
// reset to default
|
// resend fail token
|
||||||
req.Tokens = newTokens
|
req.Tokens = newTokens
|
||||||
isError = false
|
|
||||||
goto Retry
|
goto Retry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +435,12 @@ func PushToAndroid(req PushNotification) bool {
|
||||||
LogAccess.Debug("Start push notification for Android")
|
LogAccess.Debug("Start push notification for Android")
|
||||||
|
|
||||||
var APIKey string
|
var APIKey string
|
||||||
|
var retryCount = 0
|
||||||
|
var maxRetry = PushConf.Android.MaxRetry
|
||||||
|
|
||||||
|
if req.Retry > 0 && req.Retry < maxRetry {
|
||||||
|
maxRetry = req.Retry
|
||||||
|
}
|
||||||
|
|
||||||
// check message
|
// check message
|
||||||
err := CheckMessage(req)
|
err := CheckMessage(req)
|
||||||
|
@ -471,8 +483,8 @@ Retry:
|
||||||
LogPush(SucceededPush, req.Tokens[k], req, nil)
|
LogPush(SucceededPush, req.Tokens[k], req, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if isError == true && req.Retry < PushConf.Android.MaxRetry {
|
if isError == true && retryCount < maxRetry {
|
||||||
req.Retry++
|
retryCount++
|
||||||
|
|
||||||
// resend fail token
|
// resend fail token
|
||||||
req.Tokens = newTokens
|
req.Tokens = newTokens
|
||||||
|
|
Loading…
Reference in New Issue