chore(notification): Support Bytes for message queue (#596)
This commit is contained in:
		
							parent
							
								
									f24f5239cc
								
							
						
					
					
						commit
						3e62681dab
					
				
							
								
								
									
										1
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										1
									
								
								go.mod
								
								
								
								
							| 
						 | 
				
			
			@ -15,6 +15,7 @@ require (
 | 
			
		|||
	github.com/go-redis/redis/v7 v7.4.0
 | 
			
		||||
	github.com/golang/protobuf v1.5.1
 | 
			
		||||
	github.com/google/flatbuffers v2.0.0+incompatible // indirect
 | 
			
		||||
	github.com/json-iterator/go v1.1.10
 | 
			
		||||
	github.com/mattn/go-isatty v0.0.12
 | 
			
		||||
	github.com/mitchellh/mapstructure v1.4.1
 | 
			
		||||
	github.com/msalihkarakasli/go-hms-push v0.0.0-20200616114002-91cd23dfeed4
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,6 @@ package gorush
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"net"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,9 +12,13 @@ import (
 | 
			
		|||
	"github.com/appleboy/gorush/config"
 | 
			
		||||
	"github.com/appleboy/gorush/core"
 | 
			
		||||
	"github.com/appleboy/gorush/logx"
 | 
			
		||||
 | 
			
		||||
	jsoniter "github.com/json-iterator/go"
 | 
			
		||||
	"github.com/msalihkarakasli/go-hms-push/push/model"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
 | 
			
		||||
 | 
			
		||||
// D provide string array
 | 
			
		||||
type D map[string]interface{}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -133,6 +137,15 @@ func (p *PushNotification) AddLog(log logx.LogPushEntry) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Bytes for queue message
 | 
			
		||||
func (p *PushNotification) Bytes() []byte {
 | 
			
		||||
	b, err := json.Marshal(p)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	return b
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsTopic check if message format is topic for FCM
 | 
			
		||||
// ref: https://firebase.google.com/docs/cloud-messaging/send-message#topic-http-post-request
 | 
			
		||||
func (p *PushNotification) IsTopic() bool {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
package gorush
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,6 @@ package gorush
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"sync"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue