Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultFirebasePushNotificationAndroidConfig(data map[string]string, notification *messaging.AndroidNotification) *messaging.AndroidConfig
- func DefaultFirebasePushNotificationIosConfig(headers map[string]string, payloadAps *messaging.Aps, ...) *messaging.APNSConfig
- func DefaultFirebasePushNotificationWebConfig(headers, data map[string]string, notification *messaging.WebpushNotification, ...) *messaging.WebpushConfig
- func ProcessMeta(ctx context.Context, contractABI *abi.ABI, eventData []byte, ...) (*types.NewProcessTx, error)
- type API
- type BasePushNotification
- type Data
- type FirebaseAdmin
- func (fa *FirebaseAdmin) Check(notification Notification) bool
- func (fa *FirebaseAdmin) CreateUser(userData User) (User, error)
- func (fa *FirebaseAdmin) DeleteUser(uid string) error
- func (fa *FirebaseAdmin) DeleteUserBulk(uids []string) (*auth.DeleteUsersResult, error)
- func (fa *FirebaseAdmin) GenerateToken(uid string) (string, error)
- func (fa *FirebaseAdmin) GetUser(uid string) (User, error)
- func (fa *FirebaseAdmin) GetUserByEmail(email string) (User, error)
- func (fa *FirebaseAdmin) HandleEthereum(ctx context.Context, event *ethtypes.Log, e *ethevents.EthereumEvents) error
- func (fa *FirebaseAdmin) HandleIPFS()
- func (fa *FirebaseAdmin) Init() (err error)
- func (fa *FirebaseAdmin) Send(pn Notification) error
- func (fa *FirebaseAdmin) Service() int
- func (fa *FirebaseAdmin) SubscribeTopic(tokens []string, topic string) error
- func (fa *FirebaseAdmin) UnsubscribeTopic(tokens []string, topic string) error
- func (fa *FirebaseAdmin) UpdateUser(uid string, userData User) (User, error)
- type FirebasePushNotification
- func (fpn *FirebasePushNotification) Action() string
- func (fpn *FirebasePushNotification) Body() string
- func (fpn *FirebasePushNotification) Data() Data
- func (fpn *FirebasePushNotification) Date() time.Time
- func (fpn *FirebasePushNotification) ID() string
- func (fpn *FirebasePushNotification) Image() string
- func (fpn *FirebasePushNotification) Message() Message
- func (fpn *FirebasePushNotification) Platform() int
- func (fpn *FirebasePushNotification) Priority() string
- func (fpn *FirebasePushNotification) Title() string
- func (fpn *FirebasePushNotification) Token() string
- func (fpn *FirebasePushNotification) Topic() string
- type FirebaseUser
- type IPFSFile
- type IPFSFileTracker
- type Message
- type Notification
- type PushNotifier
- type UpdatedFile
- type User
Constants ¶
const ( TopicMessage = iota + 1 ConditionMessage TokenMessage GroupMessage )
message types by receiver
const ( PlatformAndroid = iota + 1 PlatformIos PlatformWeb PlatformAll )
supported platforms
const ( RetrieveTimeout = 1 * time.Minute RefreshTime = 30 * time.Second )
RetrieveTimeout the maximum duration the import queue will wait for retreiving a remote file
const (
Firebase = iota + 1
)
supported Push notifications service
Variables ¶
var ( HashLogProcessCreated = crypto.Keccak256Hash(logProcessCreated) HashLogResultsPublished = crypto.Keccak256Hash(logResultsPublished) )
Functions ¶
func DefaultFirebasePushNotificationAndroidConfig ¶
func DefaultFirebasePushNotificationAndroidConfig( data map[string]string, notification *messaging.AndroidNotification) *messaging.AndroidConfig
DefaultFirebasePushNotificationAndroidConfig creates an android notification config with default config opts
func DefaultFirebasePushNotificationIosConfig ¶
func DefaultFirebasePushNotificationIosConfig( headers map[string]string, payloadAps *messaging.Aps, payloadCustom map[string]interface{}) *messaging.APNSConfig
DefaultFirebasePushNotificationIosConfig creates an ios notification config with default config opts
func DefaultFirebasePushNotificationWebConfig ¶
func DefaultFirebasePushNotificationWebConfig( headers, data map[string]string, notification *messaging.WebpushNotification, link string) *messaging.WebpushConfig
DefaultFirebasePushNotificationWebConfig creates a web notification config with default config opts
func ProcessMeta ¶
func ProcessMeta(ctx context.Context, contractABI *abi.ABI, eventData []byte, ph *chain.ProcessHandle) (*types.NewProcessTx, error)
ProcessMeta returns the info of a newly created process from the event raised and ethereum storage
Types ¶
type API ¶
type API struct { Router *router.Router PushNotifier PushNotifier MetricsAgent *metrics.Agent }
API wraps the push notifications API
func (*API) RegisterMethods ¶
RegisterMethods registers all registry methods behind the given path
type BasePushNotification ¶
type BasePushNotification struct { // this are the most common fields among many push notifications services ID string Action string Body string Data Data Date time.Time Image string Message Message Platform int Priority string Title string Token string Topic string }
BasePushNotification is a base notification wrapper
type FirebaseAdmin ¶
type FirebaseAdmin struct { *firebase.App Client *auth.Client Key string IPFS *IPFSFileTracker Routes [2]string // routes for each env }
FirebaseAdmin wraps the firebase admin SDK App struct and a reference to the IPFS file tracker
func NewFirebaseAdmin ¶
func NewFirebaseAdmin(key, env string, ft *IPFSFileTracker) *FirebaseAdmin
NewFirebaseAdmin returns a pointer to a fresh FirebaseAdmin
func (*FirebaseAdmin) Check ¶
func (fa *FirebaseAdmin) Check(notification Notification) bool
Check checks a firebase push notification format
func (*FirebaseAdmin) CreateUser ¶
func (fa *FirebaseAdmin) CreateUser(userData User) (User, error)
CreateUser creates a user with the given user info
func (*FirebaseAdmin) DeleteUser ¶
func (fa *FirebaseAdmin) DeleteUser(uid string) error
DeleteUser deletes a user with the given UID
func (*FirebaseAdmin) DeleteUserBulk ¶
func (fa *FirebaseAdmin) DeleteUserBulk(uids []string) (*auth.DeleteUsersResult, error)
DeleteUserBulk deletes a list of users giving its ids
func (*FirebaseAdmin) GenerateToken ¶
func (fa *FirebaseAdmin) GenerateToken(uid string) (string, error)
GenerateToken returns a custom Firebase FCM token given an UID
func (*FirebaseAdmin) GetUser ¶
func (fa *FirebaseAdmin) GetUser(uid string) (User, error)
GetUser retrieves user's data
func (*FirebaseAdmin) GetUserByEmail ¶
func (fa *FirebaseAdmin) GetUserByEmail(email string) (User, error)
GetUserByEmail returns user's data from the user matching the given email
func (*FirebaseAdmin) HandleEthereum ¶
func (fa *FirebaseAdmin) HandleEthereum(ctx context.Context, event *ethtypes.Log, e *ethevents.EthereumEvents) error
HandleEthereum handles an Ethereum event
func (*FirebaseAdmin) HandleIPFS ¶
func (fa *FirebaseAdmin) HandleIPFS()
HandleIPFS handles an IPFS file content change
func (*FirebaseAdmin) Init ¶
func (fa *FirebaseAdmin) Init() (err error)
Init initializes the Firebase Admin instance
func (*FirebaseAdmin) Send ¶
func (fa *FirebaseAdmin) Send(pn Notification) error
Send sends a push notification
func (*FirebaseAdmin) Service ¶
func (fa *FirebaseAdmin) Service() int
Service returns an integer representing the Firebase push notifications service
func (*FirebaseAdmin) SubscribeTopic ¶
func (fa *FirebaseAdmin) SubscribeTopic(tokens []string, topic string) error
SubscribeTopic subscribes a list of users to a given topic
func (*FirebaseAdmin) UnsubscribeTopic ¶
func (fa *FirebaseAdmin) UnsubscribeTopic(tokens []string, topic string) error
UnsubscribeTopic unsubscribes a list of users to a given topic
func (*FirebaseAdmin) UpdateUser ¶
func (fa *FirebaseAdmin) UpdateUser(uid string, userData User) (User, error)
UpdateUser updates a user given its UID and the info to update
type FirebasePushNotification ¶
type FirebasePushNotification struct { Upstream BasePushNotification FCM *messaging.Message }
FirebasePushNotification wraps a FCM notification
func NewFirebasePushNotification ¶
func NewFirebasePushNotification( data map[string]string, notification *messaging.Notification, androidConfig *messaging.AndroidConfig, iosConfig *messaging.APNSConfig, webpushConfig *messaging.WebpushConfig, FCMOpts *messaging.FCMOptions, token, topic, condition string) *FirebasePushNotification
NewFirebasePushNotification returns an initialized message struct with all its data filled
func (*FirebasePushNotification) Action ¶
func (fpn *FirebasePushNotification) Action() string
Action returns the base push notification action
func (*FirebasePushNotification) Body ¶
func (fpn *FirebasePushNotification) Body() string
Body returns the base push notification body
func (*FirebasePushNotification) Data ¶
func (fpn *FirebasePushNotification) Data() Data
Data returns the base push notification data
func (*FirebasePushNotification) Date ¶
func (fpn *FirebasePushNotification) Date() time.Time
Date returns the base push notification date
func (*FirebasePushNotification) ID ¶
func (fpn *FirebasePushNotification) ID() string
ID returns the base push notification id
func (*FirebasePushNotification) Image ¶
func (fpn *FirebasePushNotification) Image() string
Image returns the base push notification image
func (*FirebasePushNotification) Message ¶
func (fpn *FirebasePushNotification) Message() Message
Message returns the base push notification message
func (*FirebasePushNotification) Platform ¶
func (fpn *FirebasePushNotification) Platform() int
Platform returns the base push notification platform
func (*FirebasePushNotification) Priority ¶
func (fpn *FirebasePushNotification) Priority() string
Priority returns the base push notification priority
func (*FirebasePushNotification) Title ¶
func (fpn *FirebasePushNotification) Title() string
Title returns the base push notification title
func (*FirebasePushNotification) Token ¶
func (fpn *FirebasePushNotification) Token() string
Token returns the base push notification token
func (*FirebasePushNotification) Topic ¶
func (fpn *FirebasePushNotification) Topic() string
Topic returns the base push notification topic
type FirebaseUser ¶
type FirebaseUser struct { User *auth.UserRecord *auth.UserToCreate *auth.UserToUpdate *auth.DeleteUsersResult }
FirebaseUser wraps a firebase user
type IPFSFile ¶ added in v0.6.1
type IPFSFile struct { Hash string // used for fast comparation on the news feed // NewsFeed:map[default:ipfs://<hash>] OuterMap map[string]string // the news feed pointed content NewsFeed *types.NewsFeed }
IPFSFile holds the ipfs hash of the entity metadata and the relevant content
type IPFSFileTracker ¶ added in v0.6.1
type IPFSFileTracker struct { IPFS *data.IPFSHandle IPFSConfig *config.IPFSCfg FileContentList *sync.Map // [eID]IPFSFile UpdatedFilesQueue chan *UpdatedFile // read only receiver EntitiesTrackingStatus *sync.Map // contains filtered or unexported fields }
IPFSFileTracker contains all the components of a IPFSFileTracker
func NewIPFSFileTracker ¶ added in v0.6.1
func NewIPFSFileTracker(config *config.IPFSCfg, ma *metrics.Agent, db database.Database, ensRegistry, w3endpoint string) *IPFSFileTracker
NewIPFSFileTracker creates a new IPFSFileTracker
type Notification ¶
type Notification interface { ID() string Action() string Body() string Data() Data Date() time.Time Image() string Message() Message Platform() int Priority() string Title() string Token() string Topic() string }
Notification is the interface wrapping the methods that any Notification must implement
type PushNotifier ¶
type PushNotifier interface { // Service returns the push notifications selected service Service() int // topic subscription SubscribeTopic(tokens []string, topic string) error UnsubscribeTopic(tokens []string, topic string) error // messaging Check(notification Notification) bool Send(notification Notification) error // ethereum HandleEthereum(ctx context.Context, event *ethtypes.Log, e *ethevents.EthereumEvents) error // ipfs HandleIPFS() // user management GetUser(uid string) (User, error) CreateUser(userData User) (User, error) UpdateUser(uid string, userData User) (User, error) DeleteUser(uid string) error // tokens GenerateToken(uid string) (string, error) Init() error }
PushNotifier contains the methos that all push notification services should implement
type UpdatedFile ¶ added in v0.6.1
type UpdatedFile struct { *IPFSFile // contains filtered or unexported fields }
UpdatedFile wraps the IPFS updated file and the creator entity