Documentation ¶
Index ¶
Constants ¶
const ( // MinPasswordLength specifies the minimiun password length MinPasswordLength = 6 // PasswordSaltLength specifies the length of salt used with hashing passwords PasswordSaltLength = 16 )
Variables ¶
This section is empty.
Functions ¶
func BackupForTesting ¶
func BackupForTesting()
BackupForTesting creates backup of current database before running tests.
func RestoreFromTesting ¶
func RestoreFromTesting()
RestoreFromTesting restores the database which was backedup before running tests.
func TokenExists ¶
TokenExists returns boolean indicating if specified token exists.
Types ¶
type GCMClient ¶
type GCMClient struct { ID int64 GCMId string `sql:"not null;unique" gorm:"column:gcm_id"` Token string `sql:"not null"` }
GCMClient is object mapped in database. Holds data of GoogleCloudMessaging clients registered by user
func GetGCMClient ¶
GetGCMClient returns GCMClient object if found with specified identifier.
func RegisterGCMClient ¶
RegisterGCMClient registers new GoogleCloudMessaging client associating with user through specfied token.
type PushData ¶
type PushData struct { // ID is the primary key used in databse ID int64 `json:"-"` // CreatedAt is the date when this user was created in database level CreatedAt time.Time `json:"-"` // DeletedAt is the date when user was /soft/ deleted in database level DeletedAt time.Time `json:"-"` // Accessed indicates if this data has already pooled by client (the one user design flaw lies in here) Accessed bool `json:"-"` // UinxTimeStamp is the timestamp which client can specify when sending data // Timestamp defaults to 0 if invalid UnixTimeStamp int64 Title string `sql:"not null"` Body string Token string `sql:"not null" json:"-"` // URL to open on client side // // URL is not validated URL string // Priority defines whether we send the data to all clients, do we make seound etc. // // Possible values: // 1*: Send to all clients // 2: Don't make sound on GCM clients if TCP client is listening // 3: Don't send to TCP client // * = default // // Invalid value defaults to 1 Priority int64 `json:"-"` Sound bool }
PushData is the object mapped on database. This is the object containing the data user may push through to other devices using this service.
func GetAllPushDatas ¶
func GetAllPushDatas() []PushData
GetAllPushDatas returns /all/ PushData objects in database.
func GetPushesForToken ¶
GetPushesForToken returns PushData objects linked to specified token.
func SavePushData ¶
func SavePushData(title, body, token, strurl string, timestamp, priority int64) (p *PushData, err error)
SavePushData saves push data to the database
func (*PushData) Delete ¶
func (p *PushData) Delete()
Delete is shortcut to delete data from database
func (*PushData) SetAccessed ¶
func (p *PushData) SetAccessed()
SetAccessed sets Accessed property to true and saves it to database
type User ¶
type User struct { // ID is the primary key used in databse ID int64 // CreatedAt is the date when this user was created in database level CreatedAt time.Time // ModifiedAt is the date when this user was last modified in database level ModifiedAt time.Time // DeletedAt is the date when user was /soft/ deleted in database level DeletedAt time.Time // Active is the flag indicating if the user is activated with email or not. // If user is not activated it cannot be used. Email activation can be skipped // within the server's configuration file Active bool // ActivateToken is used to securely activate the user with email. It is added // to the link sent in the activation email ActivateToken string // Email is the email user provoided when he/she registered to this service Email string `sql:"not null;unique"` // Password is the user's password Password string // Token is the token which is used to push/pool data Token string `sql:"unique"` // GCMClients are the clients registered with GoogleCloudMessaging service to this user GCMClients []GCMClient }
User is the user object mapped in database. Contains all relevant information about user.
func GetUserByToken ¶
GetUserByToken returns User object if found with specified token.
func (*User) Activate ¶
func (u *User) Activate()
Activate activates the user (sets User.Active to true and saves it to database)
func (*User) AfterFind ¶
func (u *User) AfterFind()
AfterFind is function rab by gorm library after database query is ran agains User table. In this case its used to load data to User object.
func (*User) BeforeCreate ¶
BeforeCreate is function ran by gorm library before the user is created.
func (*User) ValidatePassword ¶
ValidatePassword checks if specified password is the correct password for the user