Documentation
¶
Index ¶
- Variables
- type Config
- type GoRushRequest
- type GoRushRequestData
- type GoRushRequestNotification
- type Persistence
- type PushNotificationIDAndRegistration
- type RequestAndRegistration
- type SQLitePersistence
- func (p *SQLitePersistence) DeletePushNotificationRegistration(publicKey []byte, installationID string) error
- func (p *SQLitePersistence) GetIdentity() (*ecdsa.PrivateKey, error)
- func (p *SQLitePersistence) GetPushNotificationRegistrationByPublicKeyAndInstallationID(publicKey []byte, installationID string) (*protobuf.PushNotificationRegistration, error)
- func (p *SQLitePersistence) GetPushNotificationRegistrationByPublicKeys(publicKeys [][]byte) ([]*PushNotificationIDAndRegistration, error)
- func (p *SQLitePersistence) GetPushNotificationRegistrationPublicKeys() ([][]byte, error)
- func (p *SQLitePersistence) SaveIdentity(privateKey *ecdsa.PrivateKey) error
- func (p *SQLitePersistence) SavePushNotificationRegistration(publicKey []byte, registration *protobuf.PushNotificationRegistration) error
- type Server
- func (s *Server) HandlePushNotificationQuery(publicKey *ecdsa.PublicKey, messageID []byte, ...) error
- func (s *Server) HandlePushNotificationRegistration(publicKey *ecdsa.PublicKey, payload []byte) error
- func (s *Server) HandlePushNotificationRequest(publicKey *ecdsa.PublicKey, request protobuf.PushNotificationRequest) error
- func (s *Server) Start() error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCouldNotUnmarshalPushNotificationRegistration = errors.New("could not unmarshal preferences")
View Source
var ErrEmptyPushNotificationRegistrationPayload = errors.New("empty payload")
View Source
var ErrEmptyPushNotificationRegistrationPublicKey = errors.New("no public key")
View Source
var ErrInvalidPushNotificationRegistrationVersion = errors.New("invalid version")
View Source
var ErrMalformedPushNotificationRegistrationAccessToken = errors.New("invalid access token")
View Source
var ErrMalformedPushNotificationRegistrationDeviceToken = errors.New("invalid device token")
View Source
var ErrMalformedPushNotificationRegistrationGrant = errors.New("invalid grant")
View Source
var ErrMalformedPushNotificationRegistrationInstallationID = errors.New("invalid installationID")
View Source
var ErrUnknownPushNotificationRegistrationTokenType = errors.New("invalid token type")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Identity is our identity key Identity *ecdsa.PrivateKey // GorushUrl is the url for the gorush service GorushURL string Logger *zap.Logger }
type GoRushRequest ¶
type GoRushRequest struct {
Notifications []*GoRushRequestNotification `json:"notifications"`
}
func PushNotificationRegistrationToGoRushRequest ¶
func PushNotificationRegistrationToGoRushRequest(requestAndRegistrations []*RequestAndRegistration) *GoRushRequest
type GoRushRequestData ¶
type GoRushRequestNotification ¶
type GoRushRequestNotification struct { Tokens []string `json:"tokens"` Platform uint `json:"platform"` Message string `json:"message"` Data *GoRushRequestData `json:"data"` }
type Persistence ¶
type Persistence interface { // GetPushNotificationRegistrationByPublicKeyAndInstallationID retrieve a push notification registration from storage given a public key and installation id GetPushNotificationRegistrationByPublicKeyAndInstallationID(publicKey []byte, installationID string) (*protobuf.PushNotificationRegistration, error) // GetPushNotificationRegistrationByPublicKey retrieve all the push notification registrations from storage given a public key GetPushNotificationRegistrationByPublicKeys(publicKeys [][]byte) ([]*PushNotificationIDAndRegistration, error) //GetPushNotificationRegistrationPublicKeys return all the public keys stored GetPushNotificationRegistrationPublicKeys() ([][]byte, error) // DeletePushNotificationRegistration deletes a push notification registration from storage given a public key and installation id DeletePushNotificationRegistration(publicKey []byte, installationID string) error // SavePushNotificationRegistration saves a push notification option to the db SavePushNotificationRegistration(publicKey []byte, registration *protobuf.PushNotificationRegistration) error // GetIdentity returns the server identity key GetIdentity() (*ecdsa.PrivateKey, error) // SaveIdentity saves the server identity key SaveIdentity(*ecdsa.PrivateKey) error }
func NewSQLitePersistence ¶
func NewSQLitePersistence(db *sql.DB) Persistence
type PushNotificationIDAndRegistration ¶
type PushNotificationIDAndRegistration struct { ID []byte Registration *protobuf.PushNotificationRegistration }
type RequestAndRegistration ¶
type RequestAndRegistration struct { Request *protobuf.PushNotification Registration *protobuf.PushNotificationRegistration }
type SQLitePersistence ¶
type SQLitePersistence struct {
// contains filtered or unexported fields
}
func (*SQLitePersistence) DeletePushNotificationRegistration ¶
func (p *SQLitePersistence) DeletePushNotificationRegistration(publicKey []byte, installationID string) error
func (*SQLitePersistence) GetIdentity ¶
func (p *SQLitePersistence) GetIdentity() (*ecdsa.PrivateKey, error)
func (*SQLitePersistence) GetPushNotificationRegistrationByPublicKeyAndInstallationID ¶
func (p *SQLitePersistence) GetPushNotificationRegistrationByPublicKeyAndInstallationID(publicKey []byte, installationID string) (*protobuf.PushNotificationRegistration, error)
func (*SQLitePersistence) GetPushNotificationRegistrationByPublicKeys ¶
func (p *SQLitePersistence) GetPushNotificationRegistrationByPublicKeys(publicKeys [][]byte) ([]*PushNotificationIDAndRegistration, error)
func (*SQLitePersistence) GetPushNotificationRegistrationPublicKeys ¶
func (p *SQLitePersistence) GetPushNotificationRegistrationPublicKeys() ([][]byte, error)
func (*SQLitePersistence) SaveIdentity ¶
func (p *SQLitePersistence) SaveIdentity(privateKey *ecdsa.PrivateKey) error
func (*SQLitePersistence) SavePushNotificationRegistration ¶
func (p *SQLitePersistence) SavePushNotificationRegistration(publicKey []byte, registration *protobuf.PushNotificationRegistration) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *Config, persistence Persistence, messageProcessor *common.MessageProcessor) *Server
func (*Server) HandlePushNotificationQuery ¶
func (s *Server) HandlePushNotificationQuery(publicKey *ecdsa.PublicKey, messageID []byte, query protobuf.PushNotificationQuery) error
HandlePushNotificationQuery builds a response for the query and sends it back to the user
func (*Server) HandlePushNotificationRegistration ¶
func (s *Server) HandlePushNotificationRegistration(publicKey *ecdsa.PublicKey, payload []byte) error
HandlePushNotificationRegistration builds a response for the registration and sends it back to the user
func (*Server) HandlePushNotificationRequest ¶
func (s *Server) HandlePushNotificationRequest(publicKey *ecdsa.PublicKey, request protobuf.PushNotificationRequest) error
HandlePushNotificationRequest will send a gorush notification and send a response back to the user
Click to show internal directories.
Click to hide internal directories.