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/go-redis/redis/v7 v7.4.0
|
||||||
github.com/golang/protobuf v1.5.1
|
github.com/golang/protobuf v1.5.1
|
||||||
github.com/google/flatbuffers v2.0.0+incompatible // indirect
|
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/mattn/go-isatty v0.0.12
|
||||||
github.com/mitchellh/mapstructure v1.4.1
|
github.com/mitchellh/mapstructure v1.4.1
|
||||||
github.com/msalihkarakasli/go-hms-push v0.0.0-20200616114002-91cd23dfeed4
|
github.com/msalihkarakasli/go-hms-push v0.0.0-20200616114002-91cd23dfeed4
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gorush
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
|
@ -12,9 +12,13 @@ import (
|
||||||
"github.com/appleboy/gorush/config"
|
"github.com/appleboy/gorush/config"
|
||||||
"github.com/appleboy/gorush/core"
|
"github.com/appleboy/gorush/core"
|
||||||
"github.com/appleboy/gorush/logx"
|
"github.com/appleboy/gorush/logx"
|
||||||
|
|
||||||
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/msalihkarakasli/go-hms-push/push/model"
|
"github.com/msalihkarakasli/go-hms-push/push/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||||
|
|
||||||
// D provide string array
|
// D provide string array
|
||||||
type D map[string]interface{}
|
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
|
// 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 {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package gorush
|
package gorush
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gorush
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue