diff --git a/notify/feedback.go b/notify/feedback.go index 790404c..c4f873e 100644 --- a/notify/feedback.go +++ b/notify/feedback.go @@ -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) diff --git a/notify/notification.go b/notify/notification.go index d2f82c7..2233094 100644 --- a/notify/notification.go +++ b/notify/notification.go @@ -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 diff --git a/notify/notification_apns.go b/notify/notification_apns.go index 5b6c5d3..d1b2a9d 100644 --- a/notify/notification_apns.go +++ b/notify/notification_apns.go @@ -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) } diff --git a/notify/notification_apns_test.go b/notify/notification_apns_test.go index a69a587..2c76e11 100644 --- a/notify/notification_apns_test.go +++ b/notify/notification_apns_test.go @@ -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)