chore: fix some lint (#626)
* chore: fix some lint Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * update Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
b219e0adc7
commit
c81a316047
|
@ -13,7 +13,7 @@ import (
|
|||
// DispatchFeedback sends a feedback to the configured gateway.
|
||||
func DispatchFeedback(log logx.LogPushEntry, url string, timeout int64) error {
|
||||
if url == "" {
|
||||
return errors.New("The url can't be empty")
|
||||
return errors.New("url can't be empty")
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(log)
|
||||
|
|
|
@ -197,12 +197,12 @@ func SetProxy(proxy string) error {
|
|||
// CheckPushConf provide check your yml config.
|
||||
func CheckPushConf(cfg *config.ConfYaml) error {
|
||||
if !cfg.Ios.Enabled && !cfg.Android.Enabled && !cfg.Huawei.Enabled {
|
||||
return errors.New("Please enable iOS, Android or Huawei config in yml config")
|
||||
return errors.New("please enable iOS, Android or Huawei config in yml config")
|
||||
}
|
||||
|
||||
if cfg.Ios.Enabled {
|
||||
if cfg.Ios.KeyPath == "" && cfg.Ios.KeyBase64 == "" {
|
||||
return errors.New("Missing iOS certificate key")
|
||||
return errors.New("missing iOS certificate key")
|
||||
}
|
||||
|
||||
// check certificate file exist
|
||||
|
|
|
@ -286,8 +286,8 @@ func iosAlertDictionary(payload *payload.Payload, req *PushNotification) *payloa
|
|||
}
|
||||
|
||||
// GetIOSNotification use for define iOS notification.
|
||||
// The iOS Notification Payload
|
||||
// ref: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1
|
||||
// The iOS Notification Payload (Payload Key Reference)
|
||||
// Ref: https://apple.co/2VtH6Iu
|
||||
func GetIOSNotification(req *PushNotification) *apns2.Notification {
|
||||
notification := &apns2.Notification{
|
||||
ApnsID: req.ApnsID,
|
||||
|
@ -372,17 +372,19 @@ func GetIOSNotification(req *PushNotification) *apns2.Notification {
|
|||
}
|
||||
|
||||
func getApnsClient(cfg *config.ConfYaml, req *PushNotification) (client *apns2.Client) {
|
||||
if req.Production {
|
||||
switch {
|
||||
case req.Production:
|
||||
client = ApnsClient.Production()
|
||||
} else if req.Development {
|
||||
case req.Development:
|
||||
client = ApnsClient.Development()
|
||||
} else {
|
||||
default:
|
||||
if cfg.Ios.Production {
|
||||
client = ApnsClient.Production()
|
||||
} else {
|
||||
client = ApnsClient.Development()
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -430,7 +432,7 @@ Retry:
|
|||
|
||||
status.StatStorage.AddIosError(1)
|
||||
// We should retry only "retryable" statuses. More info about response:
|
||||
// https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns
|
||||
// See https://apple.co/3AdNane (Handling Notification Responses from APNs)
|
||||
if res != nil && res.StatusCode >= http.StatusInternalServerError {
|
||||
newTokens = append(newTokens, token)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestDisabledAndroidIosConf(t *testing.T) {
|
|||
err := CheckPushConf(cfg)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "Please enable iOS, Android or Huawei config in yml config", err.Error())
|
||||
assert.Equal(t, "please enable iOS, Android or Huawei config in yml config", err.Error())
|
||||
}
|
||||
|
||||
func TestMissingIOSCertificate(t *testing.T) {
|
||||
|
@ -42,7 +42,7 @@ func TestMissingIOSCertificate(t *testing.T) {
|
|||
err := CheckPushConf(cfg)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "Missing iOS certificate key", err.Error())
|
||||
assert.Equal(t, "missing iOS certificate key", err.Error())
|
||||
|
||||
cfg.Ios.KeyPath = "test.pem"
|
||||
err = CheckPushConf(cfg)
|
||||
|
|
Loading…
Reference in New Issue