system

package
v0.0.0-...-495e01f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountNotices

func CountNotices() int64

CountNotices returns number of notices.

func CreateNotice

func CreateNotice(ctx context.Context, tp NoticeType, desc string, args ...any) error

CreateNotice creates new system notice.

func CreateRepositoryNotice

func CreateRepositoryNotice(desc string, args ...any) error

CreateRepositoryNotice creates new system notice with type NoticeRepository.

func DeleteNotice

func DeleteNotice(ctx context.Context, id int64) error

DeleteNotice deletes a system notice by given ID.

func DeleteNotices

func DeleteNotices(ctx context.Context, start, end int64) error

DeleteNotices deletes all notices with ID from start to end (inclusive).

func DeleteNoticesByIDs

func DeleteNoticesByIDs(ctx context.Context, ids []int64) error

DeleteNoticesByIDs deletes notices by given IDs.

func DeleteOldSystemNotices

func DeleteOldSystemNotices(ctx context.Context, olderThan time.Duration) (err error)

DeleteOldSystemNotices deletes all old system notices from database.

func GetAllSettings

func GetAllSettings(ctx context.Context) (revision int, res map[string]string, err error)

func GetAppStateContent

func GetAppStateContent(key string) (content string, err error)

GetAppStateContent gets an app state from database

func GetRevision

func GetRevision(ctx context.Context) int

func NewDatabaseDynKeyGetter

func NewDatabaseDynKeyGetter() config.DynKeyGetter

func RemoveAllWithNotice

func RemoveAllWithNotice(ctx context.Context, title, path string)

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

func SaveAppStateContent(key, content string) error

SaveAppStateContent saves the app state item to database

func SetSettings

func SetSettings(ctx context.Context, settings map[string]string) error

Types

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 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.

func Notices

func Notices(ctx context.Context, page, pageSize int) ([]*Notice, error)

Notices returns notices in given page.

func (*Notice) TrStr

func (n *Notice) TrStr() string

TrStr returns a translation format string.

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"` // key should be lowercase
	SettingValue string             `xorm:"text"`
	Version      int                `xorm:"version"`
	Created      timeutil.TimeStamp `xorm:"created"`
	Updated      timeutil.TimeStamp `xorm:"updated"`
}

func (*Setting) TableName

func (s *Setting) TableName() string

TableName sets the table name for the settings struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL