api

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrInvalidOp   = `invalid patch op: "%s"`
	ErrInvalidPath = `invalid patch path: "%s"`
)
View Source
const MagicUIDKey string = "_magic_uid_key_"
View Source
const Version = "v0.18.2"

Variables

View Source
var (
	ErrOpenAPINotExist = errors.New("webhook/api: OpenAPI does not exist")

	ErrAuthNotExist   = errors.New("webhook/api: Authorization does not exist")
	ErrBlogNotExist   = errors.New("webhook/api: blog does not exist")
	ErrUserNotExist   = errors.New("webhook/api: user does not exist")
	ErrTaskNotExist   = errors.New("webhook/api: task does not exist")
	ErrFilterNotExist = errors.New("webhook/api: filter does not exist")

	ErrExpired    = errors.New("webhook/api: token is expired")
	ErrPermDenied = errors.New("webhook/api: permission denied")

	ErrUserRegistered = errors.New("webhook/api: user registered")
	ErrIncorrectPwd   = errors.New("webhook/api: incorrect password")
	ErrBanned         = errors.New("webhook/api: user has been banned")
)
View Source
var AutoDownload bool

开启自动下载会极大的占用带宽 建议发送完所有 hook 请求后再下载

View Source
var BaseURL string = ""
View Source
var JWTSecretKey []byte
View Source
var UserDB, BlogDB *gorm.DB

Functions

func CloseDB added in v0.15.0

func CloseDB() error

func DeleteTaskID added in v0.15.0

func DeleteTaskID(ctx *gin.Context) (any, error)

移除任务

func DownloadAssets added in v0.18.0

func DownloadAssets(blog *model.Blog)

下载资源

func Error added in v0.10.0

func Error(ctx *gin.Context, err error)

func FindBlogs added in v0.18.2

func FindBlogs(f Filter, dest any) error

func Get added in v0.15.0

func Get(ctx *gin.Context) (any, error)

获取自身信息

func GetBlogID added in v0.15.0

func GetBlogID(ctx *gin.Context) (any, error)

查询单条博文

func GetBlogs added in v0.15.0

func GetBlogs(ctx *gin.Context) (any, error)

查询博文

func GetExecute added in v0.17.0

func GetExecute(ctx *gin.Context) (any, error)

func GetOnline added in v0.14.0

func GetOnline(ctx *gin.Context) (any, error)

获取当前在线状态

func GetPing added in v0.14.0

func GetPing(ctx *gin.Context) (any, error)

更新在线时间

func GetRssID added in v0.18.2

func GetRssID(ctx *gin.Context) (any, error)

func GetShutdown added in v0.15.0

func GetShutdown(ctx *gin.Context) (any, error)

func GetTaskID added in v0.15.0

func GetTaskID(ctx *gin.Context) (any, error)

获取任务

func GetToken

func GetToken(ctx *gin.Context) (data any, err error)

获取 Token

func GetUID added in v0.15.0

func GetUID(ctx *gin.Context) string

func GetUUID added in v0.15.0

func GetUUID(ctx *gin.Context) (any, error)

获取用户信息

func GetUserInfo added in v0.18.2

func GetUserInfo(item *Item) string

func GetUserUID added in v0.15.0

func GetUserUID(ctx *gin.Context) (any, error)

func GetValid added in v0.16.0

func GetValid(ctx *gin.Context) (any, error)

检验鉴权码是否有效

func GetVersion added in v0.14.0

func GetVersion(ctx *gin.Context) (any, error)

当前版本号

func Index added in v0.18.0

func Index(ctx *gin.Context)

func Info added in v0.15.0

func Info(ctx *gin.Context)

func IsAdmin added in v0.14.0

func IsAdmin(ctx *gin.Context)

func IsOwner added in v0.15.0

func IsOwner(ctx *gin.Context)

func IsUser added in v0.15.0

func IsUser(ctx *gin.Context)

func JWTAuth added in v0.15.0

func JWTAuth(ctx *gin.Context) (uid string, err error)

func JWTSecretKeyFn added in v0.18.2

func JWTSecretKeyFn(*jwt.Token) (any, error)

func JWTUser added in v0.15.0

func JWTUser(ctx *gin.Context) (user *model.User, err error)

func LoadDir added in v0.18.0

func LoadDir(root, path string) error

func LoadFile added in v0.18.0

func LoadFile(root, file string)

func LogMiddleware added in v0.15.0

func LogMiddleware(ctx *gin.Context)

func PatchTaskID added in v0.15.0

func PatchTaskID(ctx *gin.Context) (any, error)

修改任务

func PatchUser added in v0.15.0

func PatchUser(ctx *gin.Context) (any, error)

修改用户信息

func PatchUserBan added in v0.15.0

func PatchUserBan(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PatchUserName added in v0.15.0

func PatchUserName(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PatchUserNickname added in v0.15.0

func PatchUserNickname(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PatchUserRole added in v0.15.0

func PatchUserRole(ctx *gin.Context, me, user *model.User, patch PatchBody) error

func PostBlog added in v0.15.0

func PostBlog(ctx *gin.Context) (any, error)

提交博文

func PostFilter added in v0.17.0

func PostFilter(ctx *gin.Context) (any, error)

筛选查询

func PostRegister added in v0.15.0

func PostRegister(ctx *gin.Context) (any, error)

新建用户

func PostTask added in v0.15.0

func PostTask(ctx *gin.Context) (any, error)

新增任务

func PostTest added in v0.15.0

func PostTest(ctx *gin.Context) (any, error)

测试单个任务

func PostTests added in v0.15.0

func PostTests(ctx *gin.Context) (any, error)

测试已有任务

func PostUpload added in v0.18.0

func PostUpload(ctx *gin.Context) (any, error)

上传文件

Types

type Asset added in v0.18.2

type Asset struct {
	URL    string `xml:"url,attr"`
	Length int64  `xml:"length,attr"`
	Type   string `xml:"type,attr"`
}

func NewAsset added in v0.18.2

func NewAsset(url string) (a Asset)

type Assets added in v0.18.2

type Assets []Asset

func (*Assets) Scan added in v0.18.2

func (a *Assets) Scan(src any) error

type Channel added in v0.18.2

type Channel struct {
	Title     string  `xml:"title" gorm:"column:name"`
	Link      string  `xml:"link" gorm:"-"`
	Desc      string  `xml:"description" gorm:"column:README"`
	Language  string  `xml:"language" gorm:"-"`
	Copyright string  `xml:"copyright" gorm:"-"`
	Generator string  `xml:"generator" gorm:"-"`
	Items     []*Item `xml:"item" gorm:"-"`

	ID        uint64         `xml:"-"`
	CreatedAt time.Time      `xml:"-"`
	UserID    string         `xml:"-"`                          // 外键
	Filters   []model.Filter `xml:"-" gorm:"foreignKey:TaskID"` // 筛选条件
}

func (*Channel) AfterFind added in v0.18.2

func (c *Channel) AfterFind(tx *gorm.DB) error

http://127.0.0.1:9000/rss/1

type Filter added in v0.18.2

type Filter struct {
	Filters  []model.Filter `json:"filters"`
	Reply    bool           `json:"reply"`
	Comments bool           `json:"comments"`
	Order    string         `json:"order"`
	Limit    int            `json:"limit"`
	Offset   int            `json:"offset"`
	Conds    []string       `json:"conds"`
}

type GUID added in v0.18.2

type GUID uint64

func (GUID) MarshalXML added in v0.18.2

func (id GUID) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Item added in v0.18.2

type Item struct {
	Title       string  `xml:"title"`                          // 文章标题
	Link        string  `xml:"link" gorm:"column:url"`         // 博文网址
	Desc        string  `xml:"description" gorm:"column:text"` // 文本内容
	Author      string  `xml:"author" gorm:"column:name"`      // 账户昵称
	Assets      Assets  `xml:"enclosure" gorm:"type:text[]"`   // 博文附件
	GUID        GUID    `xml:"guid" gorm:"column:id"`          // 固定链接
	PubDate     PubDate `xml:"pubDate" gorm:"column:time"`     // 发送时间
	Source      string  `xml:"source"`                         // 博文来源
	Avatar      string  `xml:"-"`
	Description string  `xml:"-"`
}

type OpenAPI added in v0.18.2

type OpenAPI struct {
	*gin.Engine
}

func (*OpenAPI) Initial added in v0.18.2

func (o *OpenAPI) Initial(cfg *webhook.Config) error

type PatchBody added in v0.15.0

type PatchBody struct {
	Op    string `json:"op"` // [replace, add, remove, move, copy, test]
	Path  string `json:"path"`
	Value string `json:"value,omitempty"`
	From  string `json:"from,omitempty"`
}

type PubDate added in v0.18.2

type PubDate time.Time

func (PubDate) MarshalXML added in v0.18.2

func (t PubDate) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type UserClaims added in v0.15.0

type UserClaims struct {
	UID      string `json:"uid" gorm:"primaryKey"`
	IssuedAt int64  `json:"iat"`
}

func (UserClaims) TableName added in v0.17.3

func (UserClaims) TableName() string

func (UserClaims) Token added in v0.15.0

func (c UserClaims) Token(update bool) (string, error)

func (UserClaims) Valid added in v0.15.0

func (c UserClaims) Valid() error

Jump to

Keyboard shortcuts

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