chore(style): fix format by gofumpt
This commit is contained in:
		
							parent
							
								
									d32ca7f015
								
							
						
					
					
						commit
						d77e7fe4f2
					
				| 
						 | 
					@ -253,7 +253,6 @@ func LoadConf(confPath string) (ConfYaml, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if confPath != "" {
 | 
						if confPath != "" {
 | 
				
			||||||
		content, err := ioutil.ReadFile(confPath)
 | 
							content, err := ioutil.ReadFile(confPath)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return conf, err
 | 
								return conf, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,13 +11,11 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DispatchFeedback sends a feedback to the configured gateway.
 | 
					// DispatchFeedback sends a feedback to the configured gateway.
 | 
				
			||||||
func DispatchFeedback(log LogPushEntry, url string, timeout int64) error {
 | 
					func DispatchFeedback(log LogPushEntry, url string, timeout int64) error {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if url == "" {
 | 
						if url == "" {
 | 
				
			||||||
		return errors.New("The url can't be empty")
 | 
							return errors.New("The url can't be empty")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	payload, err := json.Marshal(log)
 | 
						payload, err := json.Marshal(log)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -29,13 +27,13 @@ func DispatchFeedback(log LogPushEntry, url string, timeout int64) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req.Header.Set("Content-Type", "application/json; charset=utf-8")
 | 
						req.Header.Set("Content-Type", "application/json; charset=utf-8")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var transport = &http.Transport{
 | 
						transport := &http.Transport{
 | 
				
			||||||
		Dial: (&net.Dialer{
 | 
							Dial: (&net.Dialer{
 | 
				
			||||||
			Timeout: 5 * time.Second,
 | 
								Timeout: 5 * time.Second,
 | 
				
			||||||
		}).Dial,
 | 
							}).Dial,
 | 
				
			||||||
		TLSHandshakeTimeout: 5 * time.Second,
 | 
							TLSHandshakeTimeout: 5 * time.Second,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var client = &http.Client{
 | 
						client := &http.Client{
 | 
				
			||||||
		Timeout:   time.Duration(timeout) * time.Second,
 | 
							Timeout:   time.Duration(timeout) * time.Second,
 | 
				
			||||||
		Transport: transport,
 | 
							Transport: transport,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,14 +43,12 @@ func TestHTTPErrorInFeedbackCall(t *testing.T) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestSuccessfulFeedbackCall(t *testing.T) {
 | 
					func TestSuccessfulFeedbackCall(t *testing.T) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Mock http server
 | 
						// Mock http server
 | 
				
			||||||
	httpMock := httptest.NewServer(
 | 
						httpMock := httptest.NewServer(
 | 
				
			||||||
		http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
							http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
			if r.URL.Path == "/dispatch" {
 | 
								if r.URL.Path == "/dispatch" {
 | 
				
			||||||
				w.Header().Add("Content-Type", "application/json")
 | 
									w.Header().Add("Content-Type", "application/json")
 | 
				
			||||||
				_, err := w.Write([]byte(`{}`))
 | 
									_, err := w.Write([]byte(`{}`))
 | 
				
			||||||
 | 
					 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					log.Println(err)
 | 
										log.Println(err)
 | 
				
			||||||
					panic(err)
 | 
										panic(err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,6 @@ func init() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InitLog use for initial log module
 | 
					// InitLog use for initial log module
 | 
				
			||||||
func InitLog() error {
 | 
					func InitLog() error {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// init logger
 | 
						// init logger
 | 
				
			||||||
| 
						 | 
					@ -90,8 +89,7 @@ func SetLogOut(log *logrus.Logger, outString string) error {
 | 
				
			||||||
	case "stderr":
 | 
						case "stderr":
 | 
				
			||||||
		log.Out = os.Stderr
 | 
							log.Out = os.Stderr
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		f, err := os.OpenFile(outString, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
 | 
							f, err := os.OpenFile(outString, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o600)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -106,7 +104,6 @@ func SetLogOut(log *logrus.Logger, outString string) error {
 | 
				
			||||||
// log level: panic, fatal, error, warn, info and debug
 | 
					// log level: panic, fatal, error, warn, info and debug
 | 
				
			||||||
func SetLogLevel(log *logrus.Logger, levelString string) error {
 | 
					func SetLogLevel(log *logrus.Logger, levelString string) error {
 | 
				
			||||||
	level, err := logrus.ParseLevel(levelString)
 | 
						level, err := logrus.ParseLevel(levelString)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,6 @@ type Metrics struct {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewMetrics returns a new Metrics with all prometheus.Desc initialized
 | 
					// NewMetrics returns a new Metrics with all prometheus.Desc initialized
 | 
				
			||||||
func NewMetrics() Metrics {
 | 
					func NewMetrics() Metrics {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	return Metrics{
 | 
						return Metrics{
 | 
				
			||||||
		TotalPushCount: prometheus.NewDesc(
 | 
							TotalPushCount: prometheus.NewDesc(
 | 
				
			||||||
			namespace+"total_push_count",
 | 
								namespace+"total_push_count",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,7 +131,6 @@ func (p *PushNotification) AddLog(log LogPushEntry) {
 | 
				
			||||||
// IsTopic check if message format is topic for FCM
 | 
					// IsTopic check if message format is topic for FCM
 | 
				
			||||||
// ref: https://firebase.google.com/docs/cloud-messaging/send-message#topic-http-post-request
 | 
					// ref: https://firebase.google.com/docs/cloud-messaging/send-message#topic-http-post-request
 | 
				
			||||||
func (p *PushNotification) IsTopic() bool {
 | 
					func (p *PushNotification) IsTopic() bool {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if p.Platform == PlatFormAndroid {
 | 
						if p.Platform == PlatFormAndroid {
 | 
				
			||||||
		return p.To != "" && strings.HasPrefix(p.To, "/topics/") || p.Condition != ""
 | 
							return p.To != "" && strings.HasPrefix(p.To, "/topics/") || p.Condition != ""
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -185,9 +184,7 @@ func CheckMessage(req PushNotification) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SetProxy only working for FCM server.
 | 
					// SetProxy only working for FCM server.
 | 
				
			||||||
func SetProxy(proxy string) error {
 | 
					func SetProxy(proxy string) error {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	proxyURL, err := url.ParseRequestURI(proxy)
 | 
						proxyURL, err := url.ParseRequestURI(proxy)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -377,9 +377,7 @@ func PushToIOS(req PushNotification) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Retry:
 | 
					Retry:
 | 
				
			||||||
	var (
 | 
						var newTokens []string
 | 
				
			||||||
		newTokens []string
 | 
					 | 
				
			||||||
	)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	notification := GetIOSNotification(req)
 | 
						notification := GetIOSNotification(req)
 | 
				
			||||||
	client := getApnsClient(req)
 | 
						client := getApnsClient(req)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,9 +52,10 @@ func TestMissingIOSCertificate(t *testing.T) {
 | 
				
			||||||
	assert.Error(t, err)
 | 
						assert.Error(t, err)
 | 
				
			||||||
	assert.Equal(t, "certificate file does not exist", err.Error())
 | 
						assert.Equal(t, "certificate file does not exist", err.Error())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestIOSNotificationStructure(t *testing.T) {
 | 
					func TestIOSNotificationStructure(t *testing.T) {
 | 
				
			||||||
	var dat map[string]interface{}
 | 
						var dat map[string]interface{}
 | 
				
			||||||
	var unix = time.Now().Unix()
 | 
						unix := time.Now().Unix()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	test := "test"
 | 
						test := "test"
 | 
				
			||||||
	expectBadge := 0
 | 
						expectBadge := 0
 | 
				
			||||||
| 
						 | 
					@ -579,7 +580,7 @@ func TestDisabledIosNotifications(t *testing.T) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req := RequestPush{
 | 
						req := RequestPush{
 | 
				
			||||||
		Notifications: []PushNotification{
 | 
							Notifications: []PushNotification{
 | 
				
			||||||
			//ios
 | 
								// ios
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
									Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
				
			||||||
				Platform: PlatFormIos,
 | 
									Platform: PlatFormIos,
 | 
				
			||||||
| 
						 | 
					@ -667,7 +668,7 @@ func TestAPNSClientInvaildToken(t *testing.T) {
 | 
				
			||||||
	err = InitAPNSClient()
 | 
						err = InitAPNSClient()
 | 
				
			||||||
	assert.Error(t, err)
 | 
						assert.Error(t, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//empty key-id or team-id
 | 
						// empty key-id or team-id
 | 
				
			||||||
	PushConf.Ios.Enabled = true
 | 
						PushConf.Ios.Enabled = true
 | 
				
			||||||
	PushConf.Ios.KeyPath = "../certificate/authkey-valid.p8"
 | 
						PushConf.Ios.KeyPath = "../certificate/authkey-valid.p8"
 | 
				
			||||||
	err = InitAPNSClient()
 | 
						err = InitAPNSClient()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -116,7 +116,6 @@ func PushToAndroid(req PushNotification) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// check message
 | 
						// check message
 | 
				
			||||||
	err := CheckMessage(req)
 | 
						err := CheckMessage(req)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		LogError.Error("request error: " + err.Error())
 | 
							LogError.Error("request error: " + err.Error())
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,7 @@ func TestMissingAndroidAPIKey(t *testing.T) {
 | 
				
			||||||
	assert.Error(t, err)
 | 
						assert.Error(t, err)
 | 
				
			||||||
	assert.Equal(t, "Missing Android API Key", err.Error())
 | 
						assert.Equal(t, "Missing Android API Key", err.Error())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestMissingKeyForInitFCMClient(t *testing.T) {
 | 
					func TestMissingKeyForInitFCMClient(t *testing.T) {
 | 
				
			||||||
	client, err := InitFCMClient("")
 | 
						client, err := InitFCMClient("")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -220,7 +221,6 @@ func TestCheckAndroidMessage(t *testing.T) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestAndroidNotificationStructure(t *testing.T) {
 | 
					func TestAndroidNotificationStructure(t *testing.T) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	test := "test"
 | 
						test := "test"
 | 
				
			||||||
	timeToLive := uint(100)
 | 
						timeToLive := uint(100)
 | 
				
			||||||
	req := PushNotification{
 | 
						req := PushNotification{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,6 @@ func GetPushClient(conf *config.Config) (*core.HMSClient, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InitHMSClient use for initialize HMS Client.
 | 
					// InitHMSClient use for initialize HMS Client.
 | 
				
			||||||
func InitHMSClient(apiKey string, appID string) (*core.HMSClient, error) {
 | 
					func InitHMSClient(apiKey string, appID string) (*core.HMSClient, error) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if apiKey == "" {
 | 
						if apiKey == "" {
 | 
				
			||||||
		return nil, errors.New("Missing Huawei API Key")
 | 
							return nil, errors.New("Missing Huawei API Key")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -42,7 +41,7 @@ func InitHMSClient(apiKey string, appID string) (*core.HMSClient, error) {
 | 
				
			||||||
		return nil, errors.New("Missing Huawei APP Id")
 | 
							return nil, errors.New("Missing Huawei APP Id")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var conf = &config.Config{
 | 
						conf := &config.Config{
 | 
				
			||||||
		AppId:     appID,
 | 
							AppId:     appID,
 | 
				
			||||||
		AppSecret: apiKey,
 | 
							AppSecret: apiKey,
 | 
				
			||||||
		AuthUrl:   "https://login.cloud.huawei.com/oauth2/v2/token",
 | 
							AuthUrl:   "https://login.cloud.huawei.com/oauth2/v2/token",
 | 
				
			||||||
| 
						 | 
					@ -64,7 +63,6 @@ func InitHMSClient(apiKey string, appID string) (*core.HMSClient, error) {
 | 
				
			||||||
// HTTP Connection Server Reference for HMS
 | 
					// HTTP Connection Server Reference for HMS
 | 
				
			||||||
// https://developer.huawei.com/consumer/en/doc/development/HMS-References/push-sendapi
 | 
					// https://developer.huawei.com/consumer/en/doc/development/HMS-References/push-sendapi
 | 
				
			||||||
func GetHuaweiNotification(req PushNotification) (*model.MessageRequest, error) {
 | 
					func GetHuaweiNotification(req PushNotification) (*model.MessageRequest, error) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	msgRequest := model.NewNotificationMsgRequest()
 | 
						msgRequest := model.NewNotificationMsgRequest()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	msgRequest.Message.Android = model.GetDefaultAndroid()
 | 
						msgRequest.Message.Android = model.GetDefaultAndroid()
 | 
				
			||||||
| 
						 | 
					@ -89,7 +87,7 @@ func GetHuaweiNotification(req PushNotification) (*model.MessageRequest, error)
 | 
				
			||||||
		msgRequest.Message.Android.Urgency = "HIGH"
 | 
							msgRequest.Message.Android.Urgency = "HIGH"
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//if req.HuaweiCollapseKey != nil {
 | 
						// if req.HuaweiCollapseKey != nil {
 | 
				
			||||||
	msgRequest.Message.Android.CollapseKey = req.HuaweiCollapseKey
 | 
						msgRequest.Message.Android.CollapseKey = req.HuaweiCollapseKey
 | 
				
			||||||
	//}
 | 
						//}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -107,11 +105,11 @@ func GetHuaweiNotification(req PushNotification) (*model.MessageRequest, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	msgRequest.Message.Android.FastAppTarget = req.FastAppTarget
 | 
						msgRequest.Message.Android.FastAppTarget = req.FastAppTarget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//Add data fields
 | 
						// Add data fields
 | 
				
			||||||
	if len(req.HuaweiData) > 0 {
 | 
						if len(req.HuaweiData) > 0 {
 | 
				
			||||||
		msgRequest.Message.Data = req.HuaweiData
 | 
							msgRequest.Message.Data = req.HuaweiData
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		//Notification Message
 | 
							// Notification Message
 | 
				
			||||||
		msgRequest.Message.Android.Notification = model.GetDefaultAndroidNotification()
 | 
							msgRequest.Message.Android.Notification = model.GetDefaultAndroidNotification()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		n := msgRequest.Message.Android.Notification
 | 
							n := msgRequest.Message.Android.Notification
 | 
				
			||||||
| 
						 | 
					@ -179,14 +177,13 @@ func PushToHuawei(req PushNotification) bool {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// check message
 | 
						// check message
 | 
				
			||||||
	err := CheckMessage(req)
 | 
						err := CheckMessage(req)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		LogError.Error("request error: " + err.Error())
 | 
							LogError.Error("request error: " + err.Error())
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Retry:
 | 
					Retry:
 | 
				
			||||||
	var isError = false
 | 
						isError := false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	notification, _ := GetHuaweiNotification(req)
 | 
						notification, _ := GetHuaweiNotification(req)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ func TestSenMultipleNotifications(t *testing.T) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req := RequestPush{
 | 
						req := RequestPush{
 | 
				
			||||||
		Notifications: []PushNotification{
 | 
							Notifications: []PushNotification{
 | 
				
			||||||
			//ios
 | 
								// ios
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
									Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
				
			||||||
				Platform: PlatFormIos,
 | 
									Platform: PlatFormIos,
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,7 @@ func TestDisabledAndroidNotifications(t *testing.T) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req := RequestPush{
 | 
						req := RequestPush{
 | 
				
			||||||
		Notifications: []PushNotification{
 | 
							Notifications: []PushNotification{
 | 
				
			||||||
			//ios
 | 
								// ios
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
									Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
				
			||||||
				Platform: PlatFormIos,
 | 
									Platform: PlatFormIos,
 | 
				
			||||||
| 
						 | 
					@ -114,7 +114,7 @@ func TestSyncModeForNotifications(t *testing.T) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req := RequestPush{
 | 
						req := RequestPush{
 | 
				
			||||||
		Notifications: []PushNotification{
 | 
							Notifications: []PushNotification{
 | 
				
			||||||
			//ios
 | 
								// ios
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
									Tokens:   []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},
 | 
				
			||||||
				Platform: PlatFormIos,
 | 
									Platform: PlatFormIos,
 | 
				
			||||||
| 
						 | 
					@ -205,7 +205,6 @@ func TestSyncModeForDeviceGroupNotification(t *testing.T) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestSetProxyURL(t *testing.T) {
 | 
					func TestSetProxyURL(t *testing.T) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	err := SetProxy("87.236.233.92:8080")
 | 
						err := SetProxy("87.236.233.92:8080")
 | 
				
			||||||
	assert.Error(t, err)
 | 
						assert.Error(t, err)
 | 
				
			||||||
	assert.Equal(t, "parse \"87.236.233.92:8080\": invalid URI for request", err.Error())
 | 
						assert.Equal(t, "parse \"87.236.233.92:8080\": invalid URI for request", err.Error())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,9 +19,7 @@ import (
 | 
				
			||||||
	"golang.org/x/crypto/acme/autocert"
 | 
						"golang.org/x/crypto/acme/autocert"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var rxURL = regexp.MustCompile(`^/healthz$`)
 | 
				
			||||||
	rxURL = regexp.MustCompile(`^/healthz$`)
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	// Support metrics
 | 
						// Support metrics
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,8 +92,8 @@ func TestRunTLSServer(t *testing.T) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestRunTLSBase64Server(t *testing.T) {
 | 
					func TestRunTLSBase64Server(t *testing.T) {
 | 
				
			||||||
	var cert = `LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMrekNDQWVPZ0F3SUJBZ0lKQUxiWkVEdlVRckZLTUEwR0NTcUdTSWIzRFFFQkJRVUFNQlF4RWpBUUJnTlYKQkFNTUNXeHZZMkZzYUc5emREQWVGdzB4TmpBek1qZ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||
| 
						 | 
					@ -224,7 +224,6 @@ func TestMissingNotificationsParameter(t *testing.T) {
 | 
				
			||||||
	// missing notifications parameter.
 | 
						// missing notifications parameter.
 | 
				
			||||||
	r.POST("/api/push").
 | 
						r.POST("/api/push").
 | 
				
			||||||
		Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
							Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			assert.Equal(t, http.StatusBadRequest, r.Code)
 | 
								assert.Equal(t, http.StatusBadRequest, r.Code)
 | 
				
			||||||
			assert.Equal(t, "application/json; charset=utf-8", r.HeaderMap.Get("Content-Type"))
 | 
								assert.Equal(t, "application/json; charset=utf-8", r.HeaderMap.Get("Content-Type"))
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
| 
						 | 
					@ -241,7 +240,6 @@ func TestEmptyNotifications(t *testing.T) {
 | 
				
			||||||
			"notifications": []PushNotification{},
 | 
								"notifications": []PushNotification{},
 | 
				
			||||||
		}).
 | 
							}).
 | 
				
			||||||
		Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
							Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			assert.Equal(t, http.StatusBadRequest, r.Code)
 | 
								assert.Equal(t, http.StatusBadRequest, r.Code)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -299,7 +297,6 @@ func TestOutOfRangeMaxNotifications(t *testing.T) {
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}).
 | 
							}).
 | 
				
			||||||
		Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
							Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			assert.Equal(t, http.StatusBadRequest, r.Code)
 | 
								assert.Equal(t, http.StatusBadRequest, r.Code)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -326,7 +323,6 @@ func TestSuccessPushHandler(t *testing.T) {
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}).
 | 
							}).
 | 
				
			||||||
		Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
							Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			assert.Equal(t, http.StatusOK, r.Code)
 | 
								assert.Equal(t, http.StatusOK, r.Code)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -391,6 +387,7 @@ func TestVersionHandler(t *testing.T) {
 | 
				
			||||||
			assert.Equal(t, "3.0.0", value)
 | 
								assert.Equal(t, "3.0.0", value)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestDisabledHTTPServer(t *testing.T) {
 | 
					func TestDisabledHTTPServer(t *testing.T) {
 | 
				
			||||||
	initTest()
 | 
						initTest()
 | 
				
			||||||
	PushConf.Core.Enabled = false
 | 
						PushConf.Core.Enabled = false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										7
									
								
								main.go
								
								
								
								
							
							
						
						
									
										7
									
								
								main.go
								
								
								
								
							| 
						 | 
					@ -201,7 +201,6 @@ func main() {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		err := gorush.CheckMessage(req)
 | 
							err := gorush.CheckMessage(req)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			gorush.LogError.Fatal(err)
 | 
								gorush.LogError.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -235,7 +234,6 @@ func main() {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		err := gorush.CheckMessage(req)
 | 
							err := gorush.CheckMessage(req)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			gorush.LogError.Fatal(err)
 | 
								gorush.LogError.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -273,7 +271,6 @@ func main() {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		err := gorush.CheckMessage(req)
 | 
							err := gorush.CheckMessage(req)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			gorush.LogError.Fatal(err)
 | 
								gorush.LogError.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -415,13 +412,13 @@ func usage() {
 | 
				
			||||||
// handles pinging the endpoint and returns an error if the
 | 
					// handles pinging the endpoint and returns an error if the
 | 
				
			||||||
// agent is in an unhealthy state.
 | 
					// agent is in an unhealthy state.
 | 
				
			||||||
func pinger() error {
 | 
					func pinger() error {
 | 
				
			||||||
	var transport = &http.Transport{
 | 
						transport := &http.Transport{
 | 
				
			||||||
		Dial: (&net.Dialer{
 | 
							Dial: (&net.Dialer{
 | 
				
			||||||
			Timeout: 5 * time.Second,
 | 
								Timeout: 5 * time.Second,
 | 
				
			||||||
		}).Dial,
 | 
							}).Dial,
 | 
				
			||||||
		TLSHandshakeTimeout: 5 * time.Second,
 | 
							TLSHandshakeTimeout: 5 * time.Second,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var client = &http.Client{
 | 
						client := &http.Client{
 | 
				
			||||||
		Timeout:   time.Second * 10,
 | 
							Timeout:   time.Second * 10,
 | 
				
			||||||
		Transport: transport,
 | 
							Transport: transport,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,9 @@ package proto
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	context "context"
 | 
						context "context"
 | 
				
			||||||
 | 
						reflect "reflect"
 | 
				
			||||||
 | 
						sync "sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	proto "github.com/golang/protobuf/proto"
 | 
						proto "github.com/golang/protobuf/proto"
 | 
				
			||||||
	_struct "github.com/golang/protobuf/ptypes/struct"
 | 
						_struct "github.com/golang/protobuf/ptypes/struct"
 | 
				
			||||||
	grpc "google.golang.org/grpc"
 | 
						grpc "google.golang.org/grpc"
 | 
				
			||||||
| 
						 | 
					@ -15,8 +18,6 @@ import (
 | 
				
			||||||
	status "google.golang.org/grpc/status"
 | 
						status "google.golang.org/grpc/status"
 | 
				
			||||||
	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 | 
						protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 | 
				
			||||||
	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 | 
						protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 | 
				
			||||||
	reflect "reflect"
 | 
					 | 
				
			||||||
	sync "sync"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
| 
						 | 
					@ -659,18 +660,21 @@ func file_gorush_proto_rawDescGZIP() []byte {
 | 
				
			||||||
	return file_gorush_proto_rawDescData
 | 
						return file_gorush_proto_rawDescData
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var file_gorush_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
 | 
					var (
 | 
				
			||||||
var file_gorush_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
 | 
						file_gorush_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
 | 
				
			||||||
var file_gorush_proto_goTypes = []interface{}{
 | 
						file_gorush_proto_msgTypes  = make([]protoimpl.MessageInfo, 5)
 | 
				
			||||||
	(Priority)(0),                          // 0: proto.Priority
 | 
						file_gorush_proto_goTypes   = []interface{}{
 | 
				
			||||||
	(HealthCheckResponse_ServingStatus)(0), // 1: proto.HealthCheckResponse.ServingStatus
 | 
							(Priority)(0),                          // 0: proto.Priority
 | 
				
			||||||
	(*Alert)(nil),                          // 2: proto.Alert
 | 
							(HealthCheckResponse_ServingStatus)(0), // 1: proto.HealthCheckResponse.ServingStatus
 | 
				
			||||||
	(*NotificationRequest)(nil),            // 3: proto.NotificationRequest
 | 
							(*Alert)(nil),                          // 2: proto.Alert
 | 
				
			||||||
	(*NotificationReply)(nil),              // 4: proto.NotificationReply
 | 
							(*NotificationRequest)(nil),            // 3: proto.NotificationRequest
 | 
				
			||||||
	(*HealthCheckRequest)(nil),             // 5: proto.HealthCheckRequest
 | 
							(*NotificationReply)(nil),              // 4: proto.NotificationReply
 | 
				
			||||||
	(*HealthCheckResponse)(nil),            // 6: proto.HealthCheckResponse
 | 
							(*HealthCheckRequest)(nil),             // 5: proto.HealthCheckRequest
 | 
				
			||||||
	(*_struct.Struct)(nil),                 // 7: google.protobuf.Struct
 | 
							(*HealthCheckResponse)(nil),            // 6: proto.HealthCheckResponse
 | 
				
			||||||
}
 | 
							(*_struct.Struct)(nil),                 // 7: google.protobuf.Struct
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var file_gorush_proto_depIdxs = []int32{
 | 
					var file_gorush_proto_depIdxs = []int32{
 | 
				
			||||||
	2, // 0: proto.NotificationRequest.alert:type_name -> proto.Alert
 | 
						2, // 0: proto.NotificationRequest.alert:type_name -> proto.Alert
 | 
				
			||||||
	7, // 1: proto.NotificationRequest.data:type_name -> google.protobuf.Struct
 | 
						7, // 1: proto.NotificationRequest.data:type_name -> google.protobuf.Struct
 | 
				
			||||||
| 
						 | 
					@ -776,8 +780,10 @@ func file_gorush_proto_init() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Reference imports to suppress errors if they are not otherwise used.
 | 
					// Reference imports to suppress errors if they are not otherwise used.
 | 
				
			||||||
var _ context.Context
 | 
					var (
 | 
				
			||||||
var _ grpc.ClientConnInterface
 | 
						_ context.Context
 | 
				
			||||||
 | 
						_ grpc.ClientConnInterface
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This is a compile-time assertion to ensure that this generated file
 | 
					// This is a compile-time assertion to ensure that this generated file
 | 
				
			||||||
// is compatible with the grpc package it is being compiled against.
 | 
					// is compatible with the grpc package it is being compiled against.
 | 
				
			||||||
| 
						 | 
					@ -813,8 +819,7 @@ type GorushServer interface {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UnimplementedGorushServer can be embedded to have forward compatible implementations.
 | 
					// UnimplementedGorushServer can be embedded to have forward compatible implementations.
 | 
				
			||||||
type UnimplementedGorushServer struct {
 | 
					type UnimplementedGorushServer struct{}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (*UnimplementedGorushServer) Send(context.Context, *NotificationRequest) (*NotificationReply, error) {
 | 
					func (*UnimplementedGorushServer) Send(context.Context, *NotificationRequest) (*NotificationReply, error) {
 | 
				
			||||||
	return nil, status.Errorf(codes.Unimplemented, "method Send not implemented")
 | 
						return nil, status.Errorf(codes.Unimplemented, "method Send not implemented")
 | 
				
			||||||
| 
						 | 
					@ -885,8 +890,7 @@ type HealthServer interface {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UnimplementedHealthServer can be embedded to have forward compatible implementations.
 | 
					// UnimplementedHealthServer can be embedded to have forward compatible implementations.
 | 
				
			||||||
type UnimplementedHealthServer struct {
 | 
					type UnimplementedHealthServer struct{}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (*UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
 | 
					func (*UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
 | 
				
			||||||
	return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
 | 
						return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ func (s *Server) Check(ctx context.Context, in *proto.HealthCheckRequest) (*prot
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Send implements helloworld.GreeterServer
 | 
					// Send implements helloworld.GreeterServer
 | 
				
			||||||
func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*proto.NotificationReply, error) {
 | 
					func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*proto.NotificationReply, error) {
 | 
				
			||||||
	var badge = int(in.Badge)
 | 
						badge := int(in.Badge)
 | 
				
			||||||
	notification := gorush.PushNotification{
 | 
						notification := gorush.PushNotification{
 | 
				
			||||||
		Platform:         int(in.Platform),
 | 
							Platform:         int(in.Platform),
 | 
				
			||||||
		Tokens:           in.Tokens,
 | 
							Tokens:           in.Tokens,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,6 @@ func (s *Storage) setBadger(key string, count int64) {
 | 
				
			||||||
		value := convert.ToString(count).(string)
 | 
							value := convert.ToString(count).(string)
 | 
				
			||||||
		return txn.Set([]byte(key), []byte(value))
 | 
							return txn.Set([]byte(key), []byte(value))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Println(s.name, "update error:", err.Error())
 | 
							log.Println(s.name, "update error:", err.Error())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -95,7 +94,6 @@ func (s *Storage) getBadger(key string, count *int64) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Println(s.name, "get error:", err.Error())
 | 
							log.Println(s.name, "get error:", err.Error())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,6 @@ func (s *Storage) setBuntDB(key string, count int64) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Println("BuntDB update error:", err.Error())
 | 
							log.Println("BuntDB update error:", err.Error())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -70,7 +69,6 @@ func (s *Storage) getBuntDB(key string, count *int64) {
 | 
				
			||||||
		*count, _ = strconv.ParseInt(val, 10, 64)
 | 
							*count, _ = strconv.ParseInt(val, 10, 64)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Println("BuntDB get error:", err.Error())
 | 
							log.Println("BuntDB get error:", err.Error())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue