Documentation ¶
Index ¶
- Constants
- Variables
- func Init(db *gorm.DB) (err error)
- func IsErrNoDocument(err error) bool
- func Transaction(fun func(tx TX) error) error
- type EmailVerification
- type NotificationMethod
- type RunningState
- type Sentry
- type SentryImage
- type SystemSetting
- type TX
- func (t TX) CheckUserExistence(u string) (bool, error)
- func (t TX) CheckVerificationCode(u string, vc string) (bool, error)
- func (t TX) CreateEmailVerification(u string) (string, error)
- func (t TX) CreateSentry(s *Sentry) (int64, error)
- func (t TX) CreateUser(u string, pwd string, tz *time.Location, lang language.Tag) error
- func (t TX) DeleteSentry(id int64, uid int64) error
- func (t TX) GetImageHistory(id int64) (results []SentryImage, err error)
- func (t TX) GetNotification(id int64) (*NotificationMethod, error)
- func (t TX) GetSentry(id int64) (*Sentry, error)
- func (t TX) GetSentryName(id int64) (string, error)
- func (t TX) GetSentryNotification(id int64) (int64, error)
- func (t TX) GetUncheckedSentry() (*Sentry, *SentryImage, error)
- func (t TX) GetUserByID(id int64) (*User, error)
- func (t TX) GetUserSentries(userID int64) (results []Sentry, err error)
- func (t TX) IsLastVerificationCodeGeneratedTimeExceeded(u string) (bool, error)
- func (t TX) NotificationAddEmail(userID int64, email string, name string) (err error)
- func (t TX) NotificationAddServerChan(name string, userID int64, sckey string) (id int64, err error)
- func (t TX) NotificationList(userID int64) (results []NotificationMethod, err error)
- func (t TX) UpdateSentry(sid int64, uid int64, s *Sentry) error
- func (t TX) UpdateSentryAfterCheck(id int64, changed bool, newImage string) error
- func (t TX) UpdateUser(id int64, u User) error
- func (t TX) UserLogin(u, p string) (*int64, error)
- type Trigger
- type User
Constants ¶
View Source
const (
VerificationCodeLength = 6
)
Variables ¶
Functions ¶
func IsErrNoDocument ¶
func Transaction ¶
Types ¶
type EmailVerification ¶
type NotificationMethod ¶
type NotificationMethod struct { ID int64 `gorm:"primary_key;auto_increment:false"` // use snowflake for this ID Name string `gorm:"type:varchar(100)"` UserID int64 `gorm:"index"` // foreignkey: User.ID Type string `gorm:"type:varchar(16)"` Setting string // json CreatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
type RunningState ¶
type RunningState int64
const ( RSRunning RunningState = 1 RSPaused RunningState = -1 )
func (*RunningState) Scan ¶
func (p *RunningState) Scan(value interface{}) error
type Sentry ¶
type Sentry struct { ID int64 `gorm:"primary_key;auto_increment:false"` // use snowflake for this ID Name string `gorm:"type:varchar(100)"` UserID int64 `gorm:"index"` // foreignkey: User.ID RunningState RunningState NotificationID int64 // foreignkey: NotificationMethod.ID Trigger string // json LastCheckTime *time.Time NextCheckTime time.Time `gorm:"index"` Interval int CheckCount int NotifyCount int LatestImageID *uint // foreignkey: SentryImage.ID Task string // json CreatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
type SentryImage ¶
type SystemSetting ¶
type TX ¶
type TX struct {
// contains filtered or unexported fields
}
func (TX) CheckVerificationCode ¶
CheckVerificationCode checks if the given verification code is one of the non-expired verification existed in the db
func (TX) CreateEmailVerification ¶
CreateCreateEmailVerification create new verification code associated with an email address
func (TX) CreateUser ¶
CreateUser add a new user and the default notification method
func (TX) GetImageHistory ¶
func (t TX) GetImageHistory(id int64) (results []SentryImage, err error)
func (TX) GetNotification ¶
func (t TX) GetNotification(id int64) (*NotificationMethod, error)
func (TX) GetUncheckedSentry ¶
func (t TX) GetUncheckedSentry() (*Sentry, *SentryImage, error)
If there isn't an unchecked sentry, it returns (nil, nil, nil)
func (TX) GetUserByID ¶
GetUserByID get the user's information by his id, it takes a id, and a result structure
func (TX) IsLastVerificationCodeGeneratedTimeExceeded ¶
IsLastVerificationCodeGeneratedTimeExceeded checks if the current is within the duration allowed starting from when the latest verification code is created
func (TX) NotificationAddEmail ¶
func (TX) NotificationAddServerChan ¶
func (TX) NotificationList ¶
func (t TX) NotificationList(userID int64) (results []NotificationMethod, err error)
func (TX) UpdateSentryAfterCheck ¶
type Trigger ¶
type Trigger struct {
SimilarityThreshold float64 `json:"similarityThreshold"`
}
Stored as json string
type User ¶
type User struct { ID int64 `gorm:"primary_key;auto_increment:false"` // use snowflake for this ID Email string `gorm:"type:varchar(255);unique_index"` // lower case Password string `gorm:"type:char(60)"` // bcrypt Language string `gorm:"type:varchar(10)"` TimeZone string `gorm:"type:varchar(64)"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
Click to show internal directories.
Click to hide internal directories.