Documentation
¶
Index ¶
- Constants
- Variables
- type AdapterOption
- type AdminModel
- type ApiKeyModel
- type ApiKeyPermission
- type Artist
- type ArtistModel
- type Artwork
- type ArtworkModel
- type ArtworkSearchDocument
- type ArtworkStatus
- type AuthMethod
- type CachedArtworksModel
- type CallbackDataModel
- type DeletedModel
- type FavoriteModel
- type LikeModel
- type Permission
- type Picture
- type PictureModel
- type R18Type
- type Service
- type Source
- type SourceType
- type StorageDetail
- type StorageInfo
- type StorageType
- type TagModel
- type TelegramInfo
- type UnauthUserModel
- type UserModel
- type UserSettings
Constants ¶
View Source
const ( TelegramMaxPhotoFileSize int = 10 * 1024 * 1024 TelegramMaxPhotoTotalSideLength int = 10000 RegularPhotoSideLength int = 2560 ThumbPhotoSideLength int = 500 )
Variables ¶
View Source
var AllPermissions = []Permission{ PermissionPostArtwork, PermissionDeleteArtwork, PermissionGetArtworkInfo, PermissionEditArtwork, PermissionFetchArtwork, PermissionSearchPicture, }
View Source
var SourceTypes []SourceType = []SourceType{ SourceTypePixiv, SourceTypeTwitter, SourceTypeBilibili, SourceTypeDanbooru, SourceTypeKemono, SourceTypeYandere, SourceTypeNhentai, }
View Source
var StorageTypes []StorageType = []StorageType{ StorageTypeWebdav, StorageTypeLocal, StorageTypeAlist, }
View Source
var ValidApiKeyPermissions = []string{ string(ApiKeyPermissionFetchArtwork), }
Functions ¶
This section is empty.
Types ¶
type AdapterOption ¶ added in v0.60.0
func (*AdapterOption) WithLoadArtist ¶ added in v0.60.0
func (o *AdapterOption) WithLoadArtist() *AdapterOption
func (*AdapterOption) WithLoadPicture ¶ added in v0.60.0
func (o *AdapterOption) WithLoadPicture() *AdapterOption
func (*AdapterOption) WithLoadTag ¶ added in v0.60.0
func (o *AdapterOption) WithLoadTag() *AdapterOption
func (*AdapterOption) WithOnlyIndexPicture ¶ added in v0.60.0
func (o *AdapterOption) WithOnlyIndexPicture() *AdapterOption
type AdminModel ¶ added in v0.60.0
type AdminModel struct {
UserID int64 `bson:"user_id" json:"user_id"`
Permissions []Permission `bson:"permissions" json:"permissions"`
GrantBy int64 `bson:"grant_by" json:"grant_by"`
SuperAdmin bool `bson:"super_admin" json:"super_admin"`
}
func (*AdminModel) HasPermission ¶ added in v0.60.0
func (a *AdminModel) HasPermission(p Permission) bool
type ApiKeyModel ¶ added in v0.69.0
type ApiKeyModel struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
Key string `bson:"key"`
Quota int `bson:"quota"`
Used int `bson:"used"`
Permissions []ApiKeyPermission `bson:"permissions"`
Description string `bson:"description"`
}
func (*ApiKeyModel) HasPermission ¶ added in v0.69.0
func (apiKey *ApiKeyModel) HasPermission(permission ApiKeyPermission) bool
type ApiKeyPermission ¶ added in v0.69.0
type ApiKeyPermission string
const (
ApiKeyPermissionFetchArtwork ApiKeyPermission = "fetch_artwork"
)
type Artist ¶
type Artist struct {
ID string `json:"id" bson:"_id"`
Name string `json:"name" bson:"name"`
Type SourceType `json:"type" bson:"type"`
UID string `json:"uid" bson:"uid"`
Username string `json:"username" bson:"username"`
}
type ArtistModel ¶ added in v0.60.0
type ArtistModel struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Name string `bson:"name" json:"name"`
Type SourceType `bson:"type" json:"type"`
UID string `bson:"uid" json:"uid"`
Username string `bson:"username" json:"username"`
}
func (*ArtistModel) ToArtist ¶ added in v0.60.0
func (artist *ArtistModel) ToArtist() *Artist
type Artwork ¶
type Artwork struct {
ID string `json:"id" bson:"_id"`
Title string `json:"title" bson:"title"`
Description string `json:"description" bson:"description"`
R18 bool `json:"r18" bson:"r18"`
CreatedAt time.Time `json:"created_at" bson:"created_at"`
SourceType SourceType `json:"source_type" bson:"source_type"`
SourceURL string `json:"source_url" bson:"source_url"`
LikeCount uint `json:"like_count" bson:"like_count"`
Artist *Artist `json:"artist" bson:"artist"`
Tags []string `json:"tags" bson:"tags"`
Pictures []*Picture `json:"pictures" bson:"pictures"`
}
type ArtworkModel ¶ added in v0.60.0
type ArtworkModel struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Title string `bson:"title" json:"title"`
Description string `bson:"description" json:"description"`
R18 bool `bson:"r18" json:"r18"`
CreatedAt primitive.DateTime `bson:"created_at" json:"created_at"`
SourceType SourceType `bson:"source_type" json:"source_type"`
SourceURL string `bson:"source_url" json:"source_url"`
LikeCount uint `bson:"like_count" json:"like_count"`
ArtistID primitive.ObjectID `bson:"artist_id" json:"artist_id"`
Tags []primitive.ObjectID `bson:"tags" json:"tags"`
Pictures []primitive.ObjectID `bson:"pictures" json:"pictures"`
}
type ArtworkSearchDocument ¶ added in v0.72.0
type ArtworkStatus ¶
type ArtworkStatus string
const ( ArtworkStatusCached ArtworkStatus = "cached" ArtworkStatusPosting ArtworkStatus = "posting" ArtworkStatusPosted ArtworkStatus = "posted" )
type AuthMethod ¶
type AuthMethod string
const ( AuthMethodEmail AuthMethod = "email" AuthMethodTelegram AuthMethod = "telegram" )
type CachedArtworksModel ¶ added in v0.60.0
type CachedArtworksModel struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
SourceURL string `bson:"source_url" json:"source_url"`
CreatedAt primitive.DateTime `bson:"created_at" json:"created_at"`
Artwork *Artwork `bson:"artwork" json:"artwork"`
Status ArtworkStatus `bson:"status" json:"status"`
}
type CallbackDataModel ¶ added in v0.60.0
type DeletedModel ¶ added in v0.60.0
type FavoriteModel ¶ added in v0.60.0
type Permission ¶
type Permission string
const ( PermissionPostArtwork Permission = "post_artwork" PermissionDeleteArtwork Permission = "delete_artwork" PermissionGetArtworkInfo Permission = "get_artwork_info" PermissionEditArtwork Permission = "edit_artwork" // deprecated PermissionFetchArtwork Permission = "fetch_artwork" PermissionSearchPicture Permission = "search_picture" )
type Picture ¶
type Picture struct {
ID string `json:"id" bson:"_id"`
ArtworkID string `json:"artwork_id" bson:"artwork_id"`
Index uint `json:"index" bson:"index"`
Thumbnail string `json:"thumbnail" bson:"thumbnail"`
Original string `json:"original" bson:"original"`
Width uint `json:"width" bson:"width"`
Height uint `json:"height" bson:"height"`
Hash string `json:"hash" bson:"hash"`
TelegramInfo *TelegramInfo `json:"telegram_info" bson:"telegram_info"`
StorageInfo *StorageInfo `json:"storage_info" bson:"storage_info"`
}
type PictureModel ¶ added in v0.60.0
type PictureModel struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
ArtworkID primitive.ObjectID `bson:"artwork_id" json:"artwork_id"`
Index uint `bson:"index" json:"index"`
Thumbnail string `bson:"thumbnail" json:"thumbnail"`
Original string `bson:"original" json:"original"`
Width uint `bson:"width" json:"width"`
Height uint `bson:"height" json:"height"`
Hash string `bson:"hash" json:"hash"`
BlurScore float64 `bson:"blur_score" json:"blur_score"`
TelegramInfo *TelegramInfo `bson:"telegram_info" json:"telegram_info"`
StorageInfo *StorageInfo `bson:"storage_info" json:"storage_info"`
}
func (*PictureModel) ToPicture ¶ added in v0.60.0
func (picture *PictureModel) ToPicture() *Picture
type Source ¶ added in v0.61.0
type Source interface {
Init(service Service)
FetchNewArtworksWithCh(artworkCh chan *Artwork, limit int) error
FetchNewArtworks(limit int) ([]*Artwork, error)
GetArtworkInfo(sourceURL string) (*Artwork, error)
// GetPictureInfo(sourceURL string, index uint) (*Picture, error)
GetSourceURLRegexp() *regexp.Regexp
// CommonSourceURl should has prefix "https://"
GetCommonSourceURL(url string) string
// FileName 返回图片的用于存储和传输的文件名
GetFileName(artwork *Artwork, picture *Picture) string
Config() *config.SourceCommonConfig
}
type SourceType ¶
type SourceType string
const ( SourceTypePixiv SourceType = "pixiv" SourceTypeTwitter SourceType = "twitter" SourceTypeBilibili SourceType = "bilibili" SourceTypeDanbooru SourceType = "danbooru" SourceTypeKemono SourceType = "kemono" SourceTypeYandere SourceType = "yandere" SourceTypeNhentai SourceType = "nhentai" )
type StorageDetail ¶
type StorageDetail struct {
Type StorageType `json:"type" bson:"type"`
Path string `json:"path" bson:"path"`
}
func (*StorageDetail) String ¶ added in v0.60.0
func (detail *StorageDetail) String() string
type StorageInfo ¶
type StorageInfo struct {
Original *StorageDetail `json:"original" bson:"original"`
Regular *StorageDetail `json:"regular" bson:"regular"`
Thumb *StorageDetail `json:"thumb" bson:"thumb"`
}
type StorageType ¶
type StorageType string
const ( StorageTypeWebdav StorageType = "webdav" StorageTypeLocal StorageType = "local" StorageTypeAlist StorageType = "alist" )
type TelegramInfo ¶
type UnauthUserModel ¶ added in v0.60.0
type UnauthUserModel struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
Code string `bson:"code"` // 注册验证码
Username string `bson:"username"`
TelegramID int64 `bson:"telegram_id"`
Email string `bson:"email"`
AuthMethod AuthMethod `bson:"auth_method"`
CreatedAt primitive.DateTime `bson:"created_at"`
}
type UserModel ¶ added in v0.60.0
type UserModel struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
Username string `bson:"username"`
Password string `bson:"password"`
Email string `bson:"email"`
TelegramID int64 `bson:"telegram_id"`
Blocked bool `bson:"blocked"`
UpdatedAt primitive.DateTime `bson:"updated_at"`
DeletedAt primitive.DateTime `bson:"deleted_at,omitempty"`
// Settings
Settings *UserSettings `bson:"settings" json:"settings"`
}
type UserSettings ¶ added in v0.60.0
Click to show internal directories.
Click to hide internal directories.