logic

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: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIEndpoint            = "https://api.chanify.net"
	MockPusher  APNSPusher = nil

	ErrNoSupportMethod = errors.New("no support method")
	ErrNotFound        = errors.New("not found")
	ErrInvalidContent  = errors.New("invalid content")
	ErrSystemLimited   = errors.New("system limited")
)

variable define

Functions

This section is empty.

Types

type APNSPusher

type APNSPusher interface {
	Push(n *apns2.Notification) (*apns2.Response, error)
}

APNSPusher is the interface of APNS2

type Info

type Info struct {
	NodeID    string   `json:"nodeid"`
	Name      string   `json:"name,omitempty"`
	Version   string   `json:"version"`
	PublicKey string   `json:"pubkey"`
	Endpoint  string   `json:"endpoint,omitempty"`
	Features  []string `json:"features,omitempty"`
}

Info for node server

type Logic

type Logic struct {
	Name     string
	NodeID   string
	Version  string
	Endpoint string
	Features []string
	// contains filtered or unexported fields
}

Logic instance

func NewLogic

func NewLogic(opts *Options) (*Logic, error)

NewLogic with options

func (*Logic) BindDevice

func (l *Logic) BindDevice(uid string, uuid string, key string, devType int) error

BindDevice to user

func (*Logic) CanFileStore added in v1.0.5

func (l *Logic) CanFileStore() bool

CanFileStore return file stroage is available

func (*Logic) Close

func (l *Logic) Close()

Close and cleanup logic instance

func (*Logic) Decrypt added in v1.0.5

func (l *Logic) Decrypt(data []byte) ([]byte, error)

Decrypt data with node secret key

func (*Logic) GetDeviceKey added in v1.0.0

func (l *Logic) GetDeviceKey(uuid string) ([]byte, error)

GetDeviceKey return device key with device uuid

func (*Logic) GetDevices

func (l *Logic) GetDevices(uid string) ([]*model.Device, error)

GetDevices return all devices with user id

func (*Logic) GetInfo

func (l *Logic) GetInfo() ([]byte, string)

GetInfo return signed info data

func (*Logic) GetQRCode

func (l *Logic) GetQRCode() []byte

GetQRCode return QRCode png data

func (*Logic) GetUser

func (l *Logic) GetUser(uid string) (*model.User, error)

GetUser find user info with user id

func (*Logic) GetUserKey

func (l *Logic) GetUserKey(uid string) ([]byte, error)

GetUserKey find user key with user id

func (*Logic) GetWebhook added in v1.3.4

func (l *Logic) GetWebhook(name string) (*Webhook, error)

GetWebhook with name

func (*Logic) InitInfo added in v1.0.5

func (l *Logic) InitInfo()

InitInfo calc all info data for node

func (*Logic) LoadFile added in v1.0.6

func (l *Logic) LoadFile(tname string, name string) ([]byte, error)

LoadFile read with file type & data

func (*Logic) SaveFile added in v1.0.6

func (l *Logic) SaveFile(tname string, data []byte) (string, error)

SaveFile save with file type & data

func (*Logic) SendAPNS

func (l *Logic) SendAPNS(uid string, data []byte, devices []*model.Device, priority int, interruptionLevel string, isTimeline bool) (string, int)

SendAPNS send message to APNS

func (*Logic) UnbindDevice

func (l *Logic) UnbindDevice(uid string, uuid string) error

UnbindDevice from user

func (*Logic) UpdatePushToken

func (l *Logic) UpdatePushToken(uid string, uuid string, token string, sandbox bool) error

UpdatePushToken for APNS

func (*Logic) UpsertUser

func (l *Logic) UpsertUser(uid string, key string, serverless bool) (*model.User, error)

UpsertUser insert or update user info

func (*Logic) VerifyToken added in v1.0.0

func (l *Logic) VerifyToken(tk *model.Token) bool

VerifyToken chekc sender token

type Options

type Options struct {
	Name         string
	Version      string
	Endpoint     string
	DataPath     string
	FilePath     string
	PluginPath   string
	DBUrl        string
	Secret       string
	Registerable bool
	RegUsers     []string
	WebHooks     []map[string]interface{}
}

Options for init logic

type Webhook added in v1.3.4

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

Webhook item

func (*Webhook) DoCall added in v1.3.4

func (w *Webhook) DoCall(l *lua.LState) error

Jump to

Keyboard shortcuts

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