Documentation ¶
Index ¶
- Constants
- Variables
- func Close() error
- func CountAll(table interface{}) (int64, error)
- func CountAllGistsForkedByUser(fromUserId uint, currentUserId uint) (int64, error)
- func CountAllGistsFromUser(fromUserId uint, currentUserId uint) (int64, error)
- func CountAllGistsLikedByUser(fromUserId uint, currentUserId uint) (int64, error)
- func DeprecationDBFilename()
- func GetAllGistsVisibleByUser(userId uint) ([]uint, error)
- func GetAllWACredentialsForUser(userID uint) ([]webauthn.Credential, error)
- func GetSetting(key string) (string, error)
- func GetSettings() (map[string]string, error)
- func GetUsersFromEmails(emailsSet map[string]struct{}) (map[string]*User, error)
- func InvitationCodeExists(code string) (bool, error)
- func IsUniqueConstraintViolation(err error) bool
- func Ping() error
- func SSHKeyDoesExists(sshKeyContent string) (bool, error)
- func SSHKeyLastUsedNow(sshKeyContent string) error
- func Setup(dbUri string, sharedCache bool) error
- func TruncateDatabase() error
- func UpdateSetting(key string, value string) error
- func UserExists(username string) (bool, error)
- type AdminSetting
- type AuthInfo
- type CrendentialDTO
- type FileDTO
- type Gist
- func GetAllGists(offset int) ([]*Gist, error)
- func GetAllGistsByIds(ids []uint) ([]*Gist, error)
- func GetAllGistsForCurrentUser(currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsForkedByUser(fromUserId uint, currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsFromSearch(currentUserId uint, query string, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsFromUser(fromUserId uint, currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsLikedByUser(fromUserId uint, currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsRows() ([]*Gist, error)
- func GetGist(user string, gistUuid string) (*Gist, error)
- func GetGistByID(gistId string) (*Gist, error)
- func (gist *Gist) AddAndCommitFile(file *FileDTO) error
- func (gist *Gist) AddAndCommitFiles(files *[]FileDTO) error
- func (gist *Gist) AddInIndex()
- func (gist *Gist) AppendUserLike(user *User) error
- func (gist *Gist) BeforeDelete(tx *gorm.DB) error
- func (gist *Gist) CanWrite(user *User) bool
- func (gist *Gist) Create() error
- func (gist *Gist) CreateForked() error
- func (gist *Gist) Delete() error
- func (gist *Gist) DeleteRepository() error
- func (gist *Gist) File(revision string, filename string, truncate bool) (*git.File, error)
- func (gist *Gist) FileNames(revision string) ([]string, error)
- func (gist *Gist) Files(revision string, truncate bool) ([]*git.File, error)
- func (gist *Gist) ForkClone(username string, uuid string) error
- func (gist *Gist) GetForkParent(user *User) (*Gist, error)
- func (gist *Gist) GetForks(currentUserId uint, offset int) ([]*Gist, error)
- func (gist *Gist) GetLanguagesFromFiles() ([]string, error)
- func (gist *Gist) GetUsersLikes(offset int) ([]*User, error)
- func (gist *Gist) Identifier() string
- func (gist *Gist) IncrementForkCount() error
- func (gist *Gist) InitRepository() error
- func (gist *Gist) Log(skip int) ([]*git.Commit, error)
- func (gist *Gist) NbCommits() (string, error)
- func (gist *Gist) RPC(service string) ([]byte, error)
- func (gist *Gist) RemoveFromIndex()
- func (gist *Gist) RemoveUserLike(user *User) error
- func (gist *Gist) SetLastActiveNow() error
- func (gist *Gist) ToIndexedGist() (*index.Gist, error)
- func (gist *Gist) Update() error
- func (gist *Gist) UpdateNoTimestamps() error
- func (gist *Gist) UpdatePreviewAndCount(withTimestampUpdate bool) error
- func (gist *Gist) UpdateServerInfo() error
- func (gist *Gist) VisibilityStr() string
- type GistDTO
- type Invitation
- type Like
- type MigrationVersion
- type SSHKey
- type SSHKeyDTO
- type TOTP
- func (totp *TOTP) Create() error
- func (totp *TOTP) Delete() error
- func (totp *TOTP) GenerateRecoveryCodes() ([]string, error)
- func (totp *TOTP) StoreSecret(secret string) error
- func (totp *TOTP) ValidateCode(code string) (bool, error)
- func (totp *TOTP) ValidateRecoveryCode(code string) (bool, error)
- type TOTPDTO
- type User
- func GetAllUsers(offset int) ([]*User, error)
- func GetUserByCredentialID(credID binaryData) (*User, error)
- func GetUserById(userId uint) (*User, error)
- func GetUserByProvider(id string, provider string) (*User, error)
- func GetUserByUsername(username string) (*User, error)
- func GetUserFromSSHKey(sshKey string) (*User, error)
- func (user *User) BeforeDelete(tx *gorm.DB) error
- func (user *User) Create() error
- func (user *User) Delete() error
- func (user *User) DeleteProviderID(provider string) error
- func (user *User) HasLiked(gist *Gist) (bool, error)
- func (user *User) HasMFA() (bool, bool, error)
- func (user *User) SetAdmin() error
- func (user *User) Update() error
- type UserDTO
- type Visibility
- type VisibilityDTO
- type WebAuthnCredential
- func CreateFromCrendential(userID uint, name string, cred *webauthn.Credential) (*WebAuthnCredential, error)
- func GetAllCredentialsForUser(userID uint) ([]WebAuthnCredential, error)
- func GetCredentialByID(id binaryData) (*WebAuthnCredential, error)
- func GetCredentialByIDDB(id uint) (*WebAuthnCredential, error)
Constants ¶
View Source
const ( SettingDisableSignup = "disable-signup" SettingRequireLogin = "require-login" SettingAllowGistsWithoutLogin = "allow-gists-without-login" SettingDisableLoginForm = "disable-login-form" SettingDisableGravatar = "disable-gravatar" )
View Source
const ( SQLite databaseType = iota PostgreSQL MySQL )
Variables ¶
View Source
var DatabaseInfo *databaseInfo
Functions ¶
func CountAllGistsFromUser ¶
func DeprecationDBFilename ¶ added in v1.8.0
func DeprecationDBFilename()
func GetAllGistsVisibleByUser ¶ added in v1.6.0
func GetAllWACredentialsForUser ¶ added in v1.8.0
func GetAllWACredentialsForUser(userID uint) ([]webauthn.Credential, error)
func GetSetting ¶
func GetSettings ¶
func GetUsersFromEmails ¶
func InvitationCodeExists ¶ added in v1.7.0
func SSHKeyDoesExists ¶
func SSHKeyLastUsedNow ¶
func TruncateDatabase ¶ added in v1.8.0
func TruncateDatabase() error
func UpdateSetting ¶
func UserExists ¶
Types ¶
type AdminSetting ¶
type AuthInfo ¶ added in v1.8.0
type AuthInfo struct{}
func (AuthInfo) AllowGistsWithoutLogin ¶ added in v1.8.0
func (AuthInfo) RequireLogin ¶ added in v1.8.0
type CrendentialDTO ¶ added in v1.8.0
type CrendentialDTO struct {
PasskeyName string `json:"passkeyname" validate:"max=50"`
}
type Gist ¶
type Gist struct { ID uint `gorm:"primaryKey"` Uuid string Title string URL string Preview string PreviewFilename string Description string Private Visibility // 0: public, 1: unlisted, 2: private UserID uint User User NbFiles int NbLikes int NbForks int CreatedAt int64 UpdatedAt int64 Likes []User `gorm:"many2many:likes;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` Forked *Gist `gorm:"foreignKey:ForkedID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"` ForkedID uint }
func GetAllGists ¶
func GetAllGistsByIds ¶ added in v1.6.0
func GetAllGistsForkedByUser ¶
func GetAllGistsFromSearch ¶
func GetAllGistsFromUser ¶
func GetAllGistsLikedByUser ¶
func GetAllGistsRows ¶
func GetGistByID ¶
func (*Gist) AddAndCommitFile ¶ added in v1.6.0
func (*Gist) AddAndCommitFiles ¶
func (*Gist) AddInIndex ¶ added in v1.6.0
func (gist *Gist) AddInIndex()
func (*Gist) AppendUserLike ¶
func (*Gist) CreateForked ¶
func (*Gist) DeleteRepository ¶
func (*Gist) GetLanguagesFromFiles ¶ added in v1.6.0
func (*Gist) Identifier ¶ added in v1.6.0
func (*Gist) IncrementForkCount ¶
func (*Gist) InitRepository ¶
func (*Gist) RemoveFromIndex ¶ added in v1.6.0
func (gist *Gist) RemoveFromIndex()
func (*Gist) RemoveUserLike ¶
func (*Gist) SetLastActiveNow ¶
func (*Gist) UpdateNoTimestamps ¶ added in v1.6.0
func (*Gist) UpdatePreviewAndCount ¶
func (*Gist) UpdateServerInfo ¶
func (*Gist) VisibilityStr ¶ added in v1.6.0
type GistDTO ¶
type GistDTO struct { Title string `validate:"max=250" form:"title"` Description string `validate:"max=1000" form:"description"` URL string `validate:"max=32,alphanumdashorempty" form:"url"` Files []FileDTO `validate:"min=1,dive"` Name []string `form:"name"` Content []string `form:"content"` VisibilityDTO }
func (*GistDTO) ToExistingGist ¶
type Invitation ¶ added in v1.7.0
type Invitation struct { ID uint `gorm:"primaryKey"` Code string ExpiresAt int64 NbUsed uint NbMax uint }
func GetAllInvitations ¶ added in v1.7.0
func GetAllInvitations() ([]*Invitation, error)
func GetInvitationByCode ¶ added in v1.7.0
func GetInvitationByCode(code string) (*Invitation, error)
func GetInvitationByID ¶ added in v1.7.0
func GetInvitationByID(id uint) (*Invitation, error)
func (*Invitation) Create ¶ added in v1.7.0
func (i *Invitation) Create() error
func (*Invitation) Delete ¶ added in v1.7.0
func (i *Invitation) Delete() error
func (*Invitation) IsExpired ¶ added in v1.7.0
func (i *Invitation) IsExpired() bool
func (*Invitation) IsMaxedOut ¶ added in v1.7.0
func (i *Invitation) IsMaxedOut() bool
func (*Invitation) IsUsable ¶ added in v1.7.0
func (i *Invitation) IsUsable() bool
func (*Invitation) Update ¶ added in v1.7.0
func (i *Invitation) Update() error
func (*Invitation) Use ¶ added in v1.7.0
func (i *Invitation) Use() error
type MigrationVersion ¶
type SSHKey ¶
type SSHKey struct { ID uint `gorm:"primaryKey"` Title string Content string SHA string CreatedAt int64 LastUsedAt int64 UserID uint User User `validate:"-" ` }
func GetSSHKeyByID ¶
func GetSSHKeysByUserID ¶
type SSHKeyDTO ¶
type TOTP ¶ added in v1.8.0
type TOTP struct { ID uint `gorm:"primaryKey"` UserID uint `gorm:"uniqueIndex"` User User Secret string RecoveryCodes jsonData `gorm:"type:json"` CreatedAt int64 LastUsedAt int64 }
func GetTOTPByUserID ¶ added in v1.8.0
func (*TOTP) GenerateRecoveryCodes ¶ added in v1.8.0
func (*TOTP) StoreSecret ¶ added in v1.8.0
func (*TOTP) ValidateCode ¶ added in v1.8.0
type User ¶
type User struct { ID uint `gorm:"primaryKey"` Username string `gorm:"uniqueIndex,size:191"` Password string IsAdmin bool CreatedAt int64 Email string MD5Hash string // for gravatar, if no Email is specified, the value is random AvatarURL string GithubID string GitlabID string GiteaID string OIDCID string `gorm:"column:oidc_id"` Gists []Gist `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;foreignKey:UserID"` SSHKeys []SSHKey `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;foreignKey:UserID"` Liked []Gist `gorm:"many2many:likes;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` WebAuthnCredentials []WebAuthnCredential `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;foreignKey:UserID"` }
func GetAllUsers ¶
func GetUserByCredentialID ¶ added in v1.8.0
func GetUserById ¶
func GetUserByUsername ¶
func GetUserFromSSHKey ¶ added in v1.7.3
func (*User) DeleteProviderID ¶
type UserDTO ¶
type Visibility ¶ added in v1.6.0
type Visibility int
const ( PublicVisibility Visibility = iota UnlistedVisibility PrivateVisibility )
func ParseVisibility ¶ added in v1.6.0
func ParseVisibility[T string | int](v T) (Visibility, error)
func (Visibility) Next ¶ added in v1.6.0
func (v Visibility) Next() Visibility
func (Visibility) String ¶ added in v1.7.3
func (v Visibility) String() string
type VisibilityDTO ¶ added in v1.7.3
type VisibilityDTO struct {
Private Visibility `validate:"number,min=0,max=2" form:"private"`
}
type WebAuthnCredential ¶ added in v1.8.0
type WebAuthnCredential struct { ID uint `gorm:"primaryKey"` Name string UserID uint User User CredentialID binaryData `gorm:"type:binary_data"` PublicKey binaryData `gorm:"type:binary_data"` AttestationType string AAGUID binaryData `gorm:"type:binary_data"` SignCount uint32 CloneWarning bool FlagUserPresent bool FlagUserVerified bool FlagBackupEligible bool FlagBackupState bool CreatedAt int64 LastUsedAt int64 }
func CreateFromCrendential ¶ added in v1.8.0
func CreateFromCrendential(userID uint, name string, cred *webauthn.Credential) (*WebAuthnCredential, error)
func GetAllCredentialsForUser ¶ added in v1.8.0
func GetAllCredentialsForUser(userID uint) ([]WebAuthnCredential, error)
func GetCredentialByID ¶ added in v1.8.0
func GetCredentialByID(id binaryData) (*WebAuthnCredential, error)
func GetCredentialByIDDB ¶ added in v1.8.0
func GetCredentialByIDDB(id uint) (*WebAuthnCredential, error)
func (*WebAuthnCredential) Delete ¶ added in v1.8.0
func (w *WebAuthnCredential) Delete() error
func (*WebAuthnCredential) TableName ¶ added in v1.8.0
func (*WebAuthnCredential) TableName() string
func (*WebAuthnCredential) UpdateLastUsedAt ¶ added in v1.8.0
func (w *WebAuthnCredential) UpdateLastUsedAt() error
func (*WebAuthnCredential) UpdateSignCount ¶ added in v1.8.0
func (w *WebAuthnCredential) UpdateSignCount() error
Click to show internal directories.
Click to hide internal directories.