interfaces

package
v0.0.0-...-e21c0d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delivery

type Delivery interface {
	CanDeliver(req SendRequest) bool
	Send(ctx context.Context, req SendRequest) error
}

Pluggable interface for sending push notifications

type DeliveryMechanism

type DeliveryMechanism struct {
	Kind      DeliveryMechanismKind `json:"kind"`
	Token     string                `json:"token"`
	UpdatedAt time.Time             `json:"-"`
}

type DeliveryMechanismKind

type DeliveryMechanismKind string
const (
	APNS DeliveryMechanismKind = "apns"
	FCM  DeliveryMechanismKind = "fcm"
)

type HmacKey

type HmacKey struct {
	ThirtyDayPeriodsSinceEpoch int
	Key                        []byte
}

type HmacUpdates

type HmacUpdates map[string][]HmacKey

type Installation

type Installation struct {
	Id                string            `json:"id"`
	DeliveryMechanism DeliveryMechanism `json:"delivery_mechanism"`
}

* An installation represents an app installed on a device. If the app is reinstalled, or installed onto a new device it is expected to generate a fresh installation_id.

type Installations

type Installations interface {
	Register(ctx context.Context, installation Installation) (*RegisterResponse, error)
	Delete(ctx context.Context, installationId string) error
	GetInstallations(ctx context.Context, installationIds []string) ([]Installation, error)
}

Pluggable Installation Service interface

type MessageContext

type MessageContext struct {
	MessageType topics.MessageType `json:"message_type"`
	ShouldPush  *bool              `json:"should_push,omitempty"`
	HmacInputs  *[]byte            `json:"-"`
	SenderHmac  *[]byte            `json:"-"`
}

func (MessageContext) IsSender

func (m MessageContext) IsSender(hmacKey []byte) bool

type RegisterResponse

type RegisterResponse struct {
	InstallationId string
	ValidUntil     time.Time
}

type SendRequest

type SendRequest struct {
	IdempotencyKey string         `json:"idempotency_key"`
	Message        *v1.Envelope   `json:"message"`
	MessageContext MessageContext `json:"message_context"`
	Installation   Installation   `json:"installation"`
	Subscription   Subscription   `json:"subscription"`
}

type Subscription

type Subscription struct {
	Id             int64     `json:"-"`
	CreatedAt      time.Time `json:"created_at"`
	InstallationId string    `json:"-"`
	Topic          string    `json:"topic"`
	IsActive       bool      `json:"-"`
	IsSilent       bool      `json:"is_silent"`
	HmacKey        *HmacKey  `json:"-"`
}

type SubscriptionInput

type SubscriptionInput struct {
	Topic    string
	IsSilent bool
	HmacKeys []HmacKey
}

type Subscriptions

type Subscriptions interface {
	Subscribe(ctx context.Context, installationId string, topics []string) error
	Unsubscribe(ctx context.Context, installationId string, topics []string) error
	GetSubscriptions(ctx context.Context, topic string, thirtyDayPeriod int) ([]Subscription, error)
	SubscribeWithMetadata(ctx context.Context, installationId string, subscriptions []SubscriptionInput) error
}

This interface is not expected to be pluggable

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL