model

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDriverNotFound   = errors.New("driver not found")
	ErrNotImplemented   = errors.New("not implemented")
	ErrInvalidDeviceID  = errors.New("invalid device id")
	ErrInvalidUserID    = errors.New("invalid user id")
	ErrInvalidPublicKey = errors.New("invalid public key")
	ErrInvalidToken     = errors.New("invalid token")
	ErrInvalidDSN       = errors.New("invalid dsn")
)

variable define

Functions

func CalcDeviceKey

func CalcDeviceKey(uuid string, key string) (*crypto.PublicKey, error)

CalcDeviceKey from device public key

func CalcUserKey

func CalcUserKey(uid string, key string) (*crypto.PublicKey, error)

CalcUserKey from user public key

func DecodePushToken

func DecodePushToken(token string) ([]byte, error)

DecodePushToken for APNS

func NewAESGCM added in v1.0.1

func NewAESGCM(key []byte) (cipher.AEAD, error)

NewAESGCM for aes-gcm chiper

Types

type DB

type DB interface {
	GetOption(key string, value interface{}) error
	SetOption(key string, value interface{}) error
	GetUser(uid string) (*User, error)
	UpsertUser(u *User) error
	BindDevice(uid string, uuid string, key []byte, devType int) error
	UnbindDevice(uid string, uuid string) error
	UpdatePushToken(uid string, uuid string, token []byte, sandbox bool) error
	GetDeviceKey(uuid string) ([]byte, error)
	GetDevices(uid string) ([]*Device, error)
	Close()
}

DB base interface

func InitDB

func InitDB(dsn string) (DB, error)

InitDB with DSN

type Device

type Device struct {
	Token   []byte
	Sandbox bool
	Type    int
}

Device of user

type Message added in v1.0.1

type Message struct {
	pb.Message
	// contains filtered or unexported fields
}

Message for notification

func NewMessage added in v1.0.1

func NewMessage(tk *Token) *Message

NewMessage with sender token

func (*Message) ActionContent added in v1.1.4

func (m *Message) ActionContent(text string, title string, actions []string) *Message

ActionContent set custom action notification

func (*Message) AudioContent added in v1.1.6

func (m *Message) AudioContent(path string, fname string, title string, duration uint64, size int) *Message

AudioContent set audio notification

func (*Message) DisableToken added in v1.0.1

func (m *Message) DisableToken() *Message

DisableToken clear token

func (*Message) EncryptContent added in v1.0.1

func (m *Message) EncryptContent(key []byte)

EncryptContent return encrypted content with key

func (*Message) EncryptData added in v1.0.1

func (m *Message) EncryptData(key []byte, ts uint64) []byte

EncryptData return encrypted body with key & timestamp

func (*Message) FileContent added in v1.0.6

func (m *Message) FileContent(path string, filename string, desc string, size int, actions []string) *Message

FileContent set file notification

func (*Message) ImageContent added in v1.0.2

func (m *Message) ImageContent(path string, t *Thumbnail, size int) *Message

ImageContent set image notification

func (*Message) IsTimeline added in v1.2.2

func (m *Message) IsTimeline() bool

IsTimeline return is timeline notification

func (*Message) LinkContent added in v1.0.5

func (m *Message) LinkContent(link string) *Message

LinkContent set link notification

func (*Message) Marshal added in v1.0.1

func (m *Message) Marshal() []byte

Marshal return binary data

func (*Message) SetInterruptionLevel added in v1.2.9

func (m *Message) SetInterruptionLevel(interruptionLevel string) *Message

SetInterruptionLevel set time sensitive notification

func (*Message) SetPriority added in v1.0.1

func (m *Message) SetPriority(priority int) *Message

SetPriority set notification priority

func (*Message) SetTimeline added in v1.2.2

func (m *Message) SetTimeline(timeline bool) *Message

SetTimeline set timeline notification

func (*Message) SoundName added in v1.0.1

func (m *Message) SoundName(sound string) *Message

SoundName set notification sound

func (*Message) TextContent added in v1.0.1

func (m *Message) TextContent(text string, title string, copytext string, autocopy string) *Message

TextContent set text notification

func (*Message) TextFileContent added in v1.0.10

func (m *Message) TextFileContent(path string, filename string, title string, desc string, size int, actions []string) *Message

TextFileContent set text file notification

func (*Message) TimelineContent added in v1.2.2

func (m *Message) TimelineContent(code string, title string, ts *time.Time, items []*MsgTimeItem) *Message

TimelineContent set timeline notification

type MsgTimeItem added in v1.2.2

type MsgTimeItem struct {
	Name  string
	Value interface{}
}

MsgTimeItem define data for timeline

type OpenDB

type OpenDB func(dsn string) (DB, error)

OpenDB is the function of creating DB instance

type Thumbnail added in v1.0.4

type Thumbnail struct {
	// contains filtered or unexported fields
}

Thumbnail for image

func NewThumbnail added in v1.0.4

func NewThumbnail(w int, h int) *Thumbnail

NewThumbnail from image width & height

type Token

type Token struct {
	// contains filtered or unexported fields
}

Token for sender

func ParseToken

func ParseToken(token string) (*Token, error)

ParseToken create token from base64 string

func (*Token) GetChannel

func (tk *Token) GetChannel() []byte

GetChannel return channel code

func (*Token) GetNodeID

func (tk *Token) GetNodeID() []byte

GetNodeID return node id

func (*Token) GetUserID

func (tk *Token) GetUserID() string

GetUserID return user id string

func (*Token) HashValue added in v1.1.7

func (tk *Token) HashValue() []byte

HashValue return sha1 with token raw value

func (*Token) IsExpires added in v1.0.0

func (tk *Token) IsExpires() bool

IsExpires check token expires timestamp(UTC)

func (*Token) RawToken

func (tk *Token) RawToken() string

RawToken return raw value

func (*Token) VerifyDataHash added in v1.0.2

func (tk *Token) VerifyDataHash(data []byte) bool

VerifyDataHash check the hash of uri limit

func (*Token) VerifySign added in v1.0.0

func (tk *Token) VerifySign(key []byte) bool

VerifySign check token sign

type User

type User struct {
	UID       string
	PublicKey []byte
	SecretKey []byte
	Flags     uint
}

User information

func (*User) GetPublicKeyString added in v1.0.0

func (u *User) GetPublicKeyString() string

GetPublicKeyString return the user public key

func (*User) IsServerless

func (u *User) IsServerless() bool

IsServerless for user configuration

func (*User) PublicKeyEncrypt

func (u *User) PublicKeyEncrypt(data []byte) []byte

PublicKeyEncrypt return encrypted public key

func (*User) SetServerless

func (u *User) SetServerless(s bool)

SetServerless for user configuration

Jump to

Keyboard shortcuts

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