action

package
v0.0.0-...-e039532 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Limit = 100
View Source
const Url = "https://fcm.googleapis.com/fcm/send"

Variables

View Source
var CONNECTED_TIME = "connectedTime"
View Source
var DeviceRegistrationDB = &sdk.DBModel2{
	ColName:        "firebase_registration",
	TemplateObject: &DeviceRegistration{},
}
View Source
var FirebaseMessageQueueDB = sdk.DBQueue2{
	ColName: "firebase_message_queue",
}
View Source
var USER_CON_ID = "userConId"
View Source
var USER_ID = "userId"

Functions

func AuthorizeV2

func AuthorizeV2(connId bson.ObjectId, userId, userAgent, IP string) *sdk.APIResponse

func CreateNewMessage

func CreateNewMessage(topic enum.TopicEnumValue, toUserId string, content *model.Content) *sdk.APIResponse

func DecryptMsg

func DecryptMsg(msg []byte, key *rsa.PrivateKey) string

func FirebaseMessageQueueDBConsumer

func FirebaseMessageQueueDBConsumer(item *sdk.QueueItem) error

func GetActiveConnectionOfUser

func GetActiveConnectionOfUser(userId string) *sdk.APIResponse

func GetReceiverId

func GetReceiverId(users []string, sender string) string

func InitDeviceRegistrationDB

func InitDeviceRegistrationDB(dbSession *sdk.DBSession, dbName string)

func InitFirebaseMessageQueueDB

func InitFirebaseMessageQueueDB(dbSession *sdk.DBSession, dbName string)

func IsExist

func IsExist(arr []string, e string) bool

func IsValidTopic

func IsValidTopic(input enum.TopicEnumValue) bool

func PushMessageToDevice

func PushMessageToDevice(conn *websocket.Connection, message string, messageId *bson.ObjectId) error

func QueueConsume

func QueueConsume(item *sdk.SortedQueueItem) error

func RemoveUser

func RemoveUser(arr []string, e string) []string

func TryToCleanConnection

func TryToCleanConnection()

Types

type ConQuery

type ConQuery struct {
	Status          enum.ConStatusEnumValue `bson:"status"`
	LastMessageTime map[string]*time.Time   `bson:"last_message_time"`
}

type DeviceRegistration

type DeviceRegistration struct {
	UserId         string `bson:"user_id,omitempty" json:"userId,omitempty"`
	RegistrationId string `bson:"registration_id,omitempty" json:"registrationId,omitempty"`
	DeviceName     string `bson:"device_name,omitempty" json:"deviceName,omitempty"`
}

type FirebaseClient

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

func GetDefaultFirebaseClient

func GetDefaultFirebaseClient() (*FirebaseClient, error)

func NewClient

func NewClient(apiKey, endPoint string, timeout time.Duration) (*FirebaseClient, error)

func NewClientDefault

func NewClientDefault(apiKey string) (*FirebaseClient, error)

func (*FirebaseClient) Send

Send is func client send msg to server

func (*FirebaseClient) WithCollapseKey

func (c *FirebaseClient) WithCollapseKey(k string) FirebaseMessages

func (*FirebaseClient) WithCondition

func (c *FirebaseClient) WithCondition(cd string) FirebaseMessages

func (*FirebaseClient) WithContentAvailable

func (c *FirebaseClient) WithContentAvailable(b bool) FirebaseMessages

func (*FirebaseClient) WithData

func (c *FirebaseClient) WithData(d map[string]interface{}) FirebaseMessages

func (*FirebaseClient) WithDelay

func (c *FirebaseClient) WithDelay(b bool) FirebaseMessages

func (*FirebaseClient) WithDeliveryReceiptRequested

func (c *FirebaseClient) WithDeliveryReceiptRequested(b bool) FirebaseMessages

func (*FirebaseClient) WithDryRun

func (c *FirebaseClient) WithDryRun(b bool) FirebaseMessages

func (*FirebaseClient) WithMutableContent

func (c *FirebaseClient) WithMutableContent(b bool) FirebaseMessages

func (*FirebaseClient) WithNotification

func (c *FirebaseClient) WithNotification(nf *FirebaseNotification) FirebaseMessages

func (*FirebaseClient) WithPriority

func (c *FirebaseClient) WithPriority(p string) FirebaseMessages

func (*FirebaseClient) WithRegistrationIDs

func (c *FirebaseClient) WithRegistrationIDs(ids []string) FirebaseMessages

func (*FirebaseClient) WithRestrictedPackageName

func (c *FirebaseClient) WithRestrictedPackageName(r string) FirebaseMessages

func (*FirebaseClient) WithTimeToLive

func (c *FirebaseClient) WithTimeToLive(t time.Duration) FirebaseMessages

func (*FirebaseClient) WithToken

func (c *FirebaseClient) WithToken(t string) FirebaseMessages

type FirebaseMessages

type FirebaseMessages interface {
	// contains filtered or unexported methods
}

type FirebaseNotification

type FirebaseNotification struct {
	Title       string `json:"title,omitempty"`
	Body        string `json:"body,omitempty"`
	ChannelID   string `json:"android_channel_id,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Sound       string `json:"sound,omitempty"`
	Badge       string `json:"badge,omitempty"`
	Tag         string `json:"tag,omitempty"`
	Color       string `json:"color,omitempty"`
	ClickAction string `json:"click_action,omitempty"`
}

type FirebaseResponse

type FirebaseResponse struct {
	MulticastID  int64    `json:"multicast_id"`
	Success      int      `json:"success"`
	Failure      int      `json:"failure"`
	CanonicalIDs int      `json:"canonical_ids"`
	Results      []Result `json:"results"`

	// Device Group HTTP Response
	FailedRegistrationIDs []string `json:"failed_registration_ids"`

	// Topic HTTP response
	MessageID int64 `json:"message_id"`
	Error     error `json:"error"`
}

type Result

type Result struct {
	MessageID      string `json:"message_id"`
	RegistrationID string `json:"registration_id"`
	Error          string `json:"error"`
}

Jump to

Keyboard shortcuts

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