types

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TelegramMaxPhotoFileSize        int = 10 * 1024 * 1024
	TelegramMaxPhotoTotalSideLength int = 10000

	RegularPhotoSideLength int = 2560
	ThumbPhotoSideLength   int = 500
)

Variables

Functions

This section is empty.

Types

type AdapterOption added in v0.60.0

type AdapterOption struct {
	LoadTag          bool
	LoadArtist       bool
	LoadPicture      bool
	OnlyIndexPicture bool
}

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 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 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 CallbackDataModel struct {
	ID        primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Data      string             `bson:"data" json:"data"`
	CreatedAt primitive.DateTime `bson:"created_at" json:"created_at"`
}

type DeletedModel added in v0.60.0

type DeletedModel struct {
	ID        primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	ArtworkID primitive.ObjectID `bson:"artwork_id" json:"artwork_id"`
	SourceURL string             `bson:"source_url" json:"source_url"`
	DeletedAt primitive.DateTime `bson:"deleted_at" json:"deleted_at"`
}

type FavoriteModel added in v0.60.0

type FavoriteModel struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	ArtworkID primitive.ObjectID `bson:"artwork_id"`
	UserID    primitive.ObjectID `bson:"user_id"`
}

type LikeModel added in v0.60.0

type LikeModel struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	ArtworkID primitive.ObjectID `bson:"artwork_id"`
	UserID    primitive.ObjectID `bson:"user_id"`
	CreatedAt primitive.DateTime `bson:"created_at"`
}

type Permission

type Permission string
const (
	PermissionPostArtwork    Permission = "post_artwork"
	PermissionDeleteArtwork  Permission = "delete_artwork"
	PermissionFetchArtwork   Permission = "fetch_artwork"
	PermissionGetArtworkInfo Permission = "get_artwork_info"
	PermissionSearchPicture  Permission = "search_picture"
	PermissionEditArtwork    Permission = "edit_artwork"
)

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 R18Type

type R18Type int
const (
	R18TypeNone R18Type = 0
	R18TypeOnly R18Type = 1
	R18TypeAll  R18Type = 2
)

type Service added in v0.60.0

type Service interface {
	GetArtworkByURL(ctx context.Context, url string, opts ...*AdapterOption) (*Artwork, error)
}

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 TagModel added in v0.60.0

type TagModel struct {
	ID   primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	Name string             `bson:"name" json:"name"`
}

type TelegramInfo

type TelegramInfo struct {
	PhotoFileID    string `json:"photo_file_id" bson:"photo_file_id"`
	DocumentFileID string `json:"document_file_id" bson:"document_file_id"`
	MessageID      int    `json:"message_id" bson:"message_id"`
	MediaGroupID   string `json:"media_group_id" bson:"media_group_id"`
}

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

type UserSettings struct {
	Language string `bson:"language" json:"language"`
	Theme    string `bson:"theme" json:"theme"`
	R18      bool   `bson:"r18" json:"r18"`
}

Jump to

Keyboard shortcuts

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