Documentation ¶
Index ¶
- Constants
- Variables
- func CountNotices() int64
- func CreateNotice(ctx context.Context, tp NoticeType, desc string, args ...interface{}) error
- func CreateRepositoryNotice(desc string, args ...interface{}) error
- func DeleteNotice(id int64) error
- func DeleteNotices(start, end int64) error
- func DeleteNoticesByIDs(ids []int64) error
- func DeleteOldSystemNotices(olderThan time.Duration) (err error)
- func DeleteSetting(ctx context.Context, setting *Setting) error
- func GetAppStateContent(key string) (content string, err error)
- func GetSettingBool(ctx context.Context, key string) bool
- func GetSettingWithCache(ctx context.Context, key string) (string, error)
- func GetSettingWithCacheBool(ctx context.Context, key string) bool
- func GetSettings(ctx context.Context, keys []string) (map[string]*Setting, error)
- func Init(ctx context.Context) error
- func IsErrDataExpired(err error) bool
- func IsErrSettingIsNotExist(err error) bool
- func RemoveAllWithNotice(ctx context.Context, title, path string)
- func RemoveStorageWithNotice(ctx context.Context, bucket storage.ObjectStorage, title, path string)
- func SaveAppStateContent(key, content string) error
- func SetSetting(ctx context.Context, setting *Setting) error
- func SetSettingNoVersion(ctx context.Context, key, value string) error
- type AllSettings
- type AppState
- type ErrDataExpired
- type ErrSettingIsNotExist
- type Notice
- type NoticeType
- type Setting
Constants ¶
const ( KeyPictureDisableGravatar = "picture.disable_gravatar" KeyPictureEnableFederatedAvatar = "picture.enable_federated_avatar" )
enumerate all system setting keys
Variables ¶
var ( GravatarSourceURL *url.URL LibravatarService *libravatar.Libravatar )
Functions ¶
func CreateNotice ¶
func CreateNotice(ctx context.Context, tp NoticeType, desc string, args ...interface{}) error
CreateNotice creates new system notice.
func CreateRepositoryNotice ¶
CreateRepositoryNotice creates new system notice with type NoticeRepository.
func DeleteNotice ¶
DeleteNotice deletes a system notice by given ID.
func DeleteNotices ¶
DeleteNotices deletes all notices with ID from start to end (inclusive).
func DeleteNoticesByIDs ¶
DeleteNoticesByIDs deletes notices by given IDs.
func DeleteOldSystemNotices ¶
DeleteOldSystemNotices deletes all old system notices from database.
func DeleteSetting ¶
DeleteSetting deletes a specific setting for a user
func GetAppStateContent ¶
GetAppStateContent gets an app state from database
func GetSettingBool ¶
GetSettingBool return bool value of setting, none existing keys and errors are ignored and result in false
func GetSettingWithCache ¶ added in v1.19.0
GetSettingWithCache returns the setting value via the key
func GetSettingWithCacheBool ¶ added in v1.19.0
func GetSettings ¶
GetSettings returns specific settings
func IsErrDataExpired ¶
IsErrDataExpired return true if err is ErrDataExpired
func IsErrSettingIsNotExist ¶
IsErrSettingIsNotExist return true if err is ErrSettingIsNotExist
func RemoveAllWithNotice ¶
RemoveAllWithNotice removes all directories in given path and creates a system notice when error occurs.
func RemoveStorageWithNotice ¶
func RemoveStorageWithNotice(ctx context.Context, bucket storage.ObjectStorage, title, path string)
RemoveStorageWithNotice removes a file from the storage and creates a system notice when error occurs.
func SaveAppStateContent ¶
SaveAppStateContent saves the app state item to database
func SetSetting ¶
SetSetting updates a users' setting for a specific key
Types ¶
type AllSettings ¶
func GetAllSettings ¶
func GetAllSettings(ctx context.Context) (AllSettings, error)
GetAllSettings returns all settings from user
func (AllSettings) Get ¶
func (settings AllSettings) Get(key string) Setting
func (AllSettings) GetBool ¶
func (settings AllSettings) GetBool(key string) bool
func (AllSettings) GetVersion ¶
func (settings AllSettings) GetVersion(key string) int
type AppState ¶
type AppState struct { ID string `xorm:"pk varchar(200)"` Revision int64 Content string `xorm:"LONGTEXT"` }
AppState represents a state record in database if one day we would make Gitea run as a cluster, we can introduce a new field `Scope` here to store different states for different nodes
type ErrDataExpired ¶
type ErrDataExpired struct {
Key string
}
ErrDataExpired represents an error that update a record which has been updated by another thread
type ErrSettingIsNotExist ¶
type ErrSettingIsNotExist struct {
Key string
}
ErrSettingIsNotExist represents an error that a setting is not exist with special key
func (ErrSettingIsNotExist) Error ¶
func (err ErrSettingIsNotExist) Error() string
Error implements error
type Notice ¶
type Notice struct { ID int64 `xorm:"pk autoincr"` Type NoticeType Description string `xorm:"TEXT"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` }
Notice represents a system notice for admin.
type NoticeType ¶
type NoticeType int
NoticeType describes the notice type
const ( // NoticeRepository type NoticeRepository NoticeType = iota + 1 // NoticeTask type NoticeTask )
type Setting ¶
type Setting struct { ID int64 `xorm:"pk autoincr"` SettingKey string `xorm:"varchar(255) unique"` // ensure key is always lowercase SettingValue string `xorm:"text"` Version int `xorm:"version"` // prevent to override Created timeutil.TimeStamp `xorm:"created"` Updated timeutil.TimeStamp `xorm:"updated"` }
Setting is a key value store of user settings
func GetSetting ¶
GetSetting returns specific setting without using the cache