Documentation
¶
Index ¶
- func Run(ctx context.Context, opt *Option) error
- type ApiKey
- type Artist
- type Artwork
- type ArtworkStatus
- type CachedArtist
- type CachedArtwork
- type CachedArtworkData
- type CachedPicture
- type CachedUgoiraMeta
- type DeletedRecord
- type MongoUUID
- type Option
- type Picture
- type SourceType
- type StorageDetail
- type StorageInfo
- type StorageType
- type Tag
- type TagAlias
- type TelegramInfo
- func (t *TelegramInfo) ClearFileIDs()
- func (t TelegramInfo) DocumentFileID(botID int64) string
- func (t TelegramInfo) FileID(botID int64, mediaType TelegramMediaType) string
- func (t TelegramInfo) IsZero() bool
- func (t *TelegramInfo) MergeFrom(other *TelegramInfo)
- func (t TelegramInfo) MessageID(chatID int64) int
- func (t TelegramInfo) PhotoFileID(botID int64) string
- func (t *TelegramInfo) SetFileID(botID int64, mediaType TelegramMediaType, fileID string)
- func (t *TelegramInfo) SetMessage(chatID int64, messageID int, mediaGroupID string)
- func (t TelegramInfo) VideoFileID(botID int64) string
- type TelegramMediaType
- type TelegramMessage
- type UgoiraFrame
- type UgoiraMeta
- type UgoiraMetaData
- type User
- type UserSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiKey ¶
type ApiKey struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
Key string `gorm:"type:text;not null;uniqueIndex" json:"key"`
Quota int `gorm:"not null;default:0" json:"quota"`
Used int `gorm:"not null;default:0" json:"used"`
Permissions datatypes.JSONSlice[string] `gorm:"type:json" json:"permissions"`
Description string `gorm:"type:text" json:"description"`
}
type Artist ¶
type Artist struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
Name string `gorm:"type:text;not null;index" json:"name"`
Type SourceType `gorm:"type:text;not null;index" json:"type"`
UID string `gorm:"type:text;not null;index" json:"uid"`
Username string `gorm:"type:text;not null;index" json:"username"`
// reverse relation
Artworks []*Artwork `gorm:"foreignKey:ArtistID" json:"artworks"`
}
----- Artist -----
type Artwork ¶
type Artwork struct {
// keep ObjectID as 24-hex string
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
Title string `gorm:"type:text;not null;index:idx_artwork_title,sort:asc" json:"title"`
Description string `gorm:"type:text" json:"description"`
R18 bool `gorm:"not null;default:false" json:"r18"`
CreatedAt time.Time `gorm:"not null;autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"not null;autoUpdateTime" json:"updated_at"`
SourceType SourceType `gorm:"type:text;not null" json:"source_type"`
SourceURL string `gorm:"type:text;not null;uniqueIndex" json:"source_url"`
LikeCount uint `gorm:"not null;default:0" json:"like_count"`
ArtistID MongoUUID `gorm:"type:uuid;index" json:"artist_id"`
Artist *Artist `gorm:"foreignKey:ArtistID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL" json:"artist"`
// many2many relationship with tags
Tags []*Tag `gorm:"many2many:artwork_tags;constraint:OnDelete:CASCADE" json:"tags"`
// one-to-many pictures
Pictures []*Picture `gorm:"foreignKey:ArtworkID;constraint:OnDelete:CASCADE" json:"pictures"`
}
----- Artwork -----
type ArtworkStatus ¶
type ArtworkStatus string
const ( ArtworkStatusCached ArtworkStatus = "cached" ArtworkStatusPosting ArtworkStatus = "posting" ArtworkStatusPosted ArtworkStatus = "posted" )
type CachedArtist ¶
type CachedArtist struct {
ID string `json:"id"`
Name string `json:"name"`
Type SourceType `json:"type"`
UID string `json:"uid"`
Username string `json:"username"`
}
type CachedArtwork ¶
type CachedArtwork struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
SourceURL string `gorm:"type:text;uniqueIndex" json:"source_url"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
Artwork datatypes.JSONType[*CachedArtworkData] `gorm:"type:json" json:"artwork"`
Status ArtworkStatus `gorm:"type:text;index" json:"status"`
}
----- Cached Artworks -----
type CachedArtworkData ¶
type CachedArtworkData struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
R18 bool `json:"r18"`
SourceType SourceType `json:"source_type"`
SourceURL string `json:"source_url"`
Artist *CachedArtist `json:"artist"`
Tags []string `json:"tags"`
Pictures []*CachedPicture `json:"pictures"`
UgoiraMetas []*CachedUgoiraMeta `json:"ugoira_metas,omitempty"`
Version int `json:"version"` // for future schema changes
}
type CachedPicture ¶
type CachedPicture struct {
ID string `json:"id"`
ArtworkID string `json:"artwork_id"`
OrderIndex uint `json:"index"`
Thumbnail string `json:"thumbnail"`
Original string `json:"original"`
Hidden bool `json:"hidden"` // don't post when true
Width uint `json:"width"`
Height uint `json:"height"`
Phash string `json:"phash"` // phash
ThumbHash string `json:"thumb_hash"` // thumbhash
StorageInfo StorageInfo `json:"storage_info"`
TelegramInfo TelegramInfo `json:"telegram_info"`
}
type CachedUgoiraMeta ¶ added in v0.92.0
type CachedUgoiraMeta struct {
ID string `json:"id"`
ArtworkID string `json:"artwork_id"`
OrderIndex uint `json:"index"`
MetaData UgoiraMetaData `json:"data"`
OriginalStorage StorageDetail `json:"original_storage"`
TelegramInfo TelegramInfo `json:"telegram_info"`
}
type DeletedRecord ¶
type DeletedRecord struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
ArtworkID MongoUUID `gorm:"type:uuid;uniqueIndex" json:"artwork_id"`
SourceURL string `gorm:"type:text;not null;uniqueIndex" json:"source_url"`
DeletedAt time.Time `gorm:"not null;autoCreateTime" json:"deleted_at"`
}
func (*DeletedRecord) BeforeCreate ¶
func (d *DeletedRecord) BeforeCreate(tx *gorm.DB) (err error)
type MongoUUID ¶
MongoUUID will transform MongoDB's ObjectID (12 bytes) into UUID format (16 bytes). The last 4 bytes are always zero.
func FromObjectID ¶
FromObjectID converts MongoDB's ObjectID to MongoUUID
func NewMongoUUID ¶
func NewMongoUUID() MongoUUID
func (MongoUUID) ToObjectID ¶
ToObjectID converts MongoUUID back to MongoDB's ObjectID
type Picture ¶
type Picture struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
ArtworkID MongoUUID `gorm:"type:uuid;index" json:"artwork_id"`
Artwork *Artwork `gorm:"foreignKey:ArtworkID;references:ID;constraint:OnDelete:CASCADE" json:"-"`
OrderIndex uint `gorm:"column:order_index;not null;default:0;index:idx_picture_artwork_index,priority:1" json:"index"`
Thumbnail string `gorm:"type:text" json:"thumbnail"`
Original string `gorm:"type:text;index" json:"original"`
Width uint `json:"width"`
Height uint `json:"height"`
Phash string `gorm:"type:text;index" json:"phash"` // phash
ThumbHash string `gorm:"type:text" json:"thumb_hash"` // thumbhash
TelegramInfo datatypes.JSONType[TelegramInfo] `gorm:"type:json" json:"telegram_info"` // original TelegramInfo struct as JSON
StorageInfo datatypes.JSONType[StorageInfo] `gorm:"type:json" json:"storage_info"` // StorageInfo as JSON
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
----- Picture -----
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"`
Mime string `json:"mime" bson:"mime"`
}
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" StorageTypeTelegram StorageType = "telegram" )
type Tag ¶
type Tag struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
Name string `gorm:"type:text;not null;uniqueIndex" json:"name"`
Alias []*TagAlias `gorm:"foreignKey:TagID;constraint:OnDelete:CASCADE" json:"alias"`
// reverse relation via many2many
Artworks []*Artwork `gorm:"many2many:artwork_tags" json:"artworks"`
}
----- Tag -----
type TelegramInfo ¶
type TelegramInfo struct {
// {bot_id:{"photo": file_id, "document": file_id}}
FileIDs map[int64]map[TelegramMediaType]string `json:"file_ids"` // (file_id is bot specific)
Messages map[int64]TelegramMessage `json:"messages"` // key: chat id
}
func (*TelegramInfo) ClearFileIDs ¶ added in v0.93.0
func (t *TelegramInfo) ClearFileIDs()
func (TelegramInfo) DocumentFileID ¶
func (t TelegramInfo) DocumentFileID(botID int64) string
func (TelegramInfo) FileID ¶ added in v0.93.0
func (t TelegramInfo) FileID(botID int64, mediaType TelegramMediaType) string
func (TelegramInfo) IsZero ¶ added in v0.93.0
func (t TelegramInfo) IsZero() bool
func (*TelegramInfo) MergeFrom ¶ added in v0.93.0
func (t *TelegramInfo) MergeFrom(other *TelegramInfo)
func (TelegramInfo) MessageID ¶
func (t TelegramInfo) MessageID(chatID int64) int
func (TelegramInfo) PhotoFileID ¶
func (t TelegramInfo) PhotoFileID(botID int64) string
func (*TelegramInfo) SetFileID ¶ added in v0.93.0
func (t *TelegramInfo) SetFileID(botID int64, mediaType TelegramMediaType, fileID string)
func (*TelegramInfo) SetMessage ¶ added in v0.93.0
func (t *TelegramInfo) SetMessage(chatID int64, messageID int, mediaGroupID string)
func (TelegramInfo) VideoFileID ¶ added in v0.93.0
func (t TelegramInfo) VideoFileID(botID int64) string
type TelegramMediaType ¶ added in v0.93.0
type TelegramMediaType string
const ( // TelegramMediaTypePhoto is a TelegramMediaType of type photo. TelegramMediaTypePhoto TelegramMediaType = "photo" // TelegramMediaTypeDocument is a TelegramMediaType of type document. TelegramMediaTypeDocument TelegramMediaType = "document" // TelegramMediaTypeVideo is a TelegramMediaType of type video. TelegramMediaTypeVideo TelegramMediaType = "video" )
type TelegramMessage ¶ added in v0.93.0
type UgoiraFrame ¶ added in v0.92.0
type UgoiraMeta ¶ added in v0.92.0
type UgoiraMeta struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
ArtworkID MongoUUID `gorm:"type:uuid;index" json:"artwork_id"`
Artwork *Artwork `gorm:"foreignKey:ArtworkID;references:ID;constraint:OnDelete:CASCADE" json:"-"`
OrderIndex uint `gorm:"column:order_index;not null;default:0;index:idx_ugoira_artwork_index,priority:1" json:"index"`
Data datatypes.JSONType[UgoiraMetaData] `json:"data"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
OriginalStorage datatypes.JSONType[StorageDetail] `json:"original_storage"`
TelegramInfo datatypes.JSONType[TelegramInfo] `json:"telegram_info"`
}
func (*UgoiraMeta) BeforeCreate ¶ added in v0.92.0
func (u *UgoiraMeta) BeforeCreate(tx *gorm.DB) (err error)
type UgoiraMetaData ¶ added in v0.92.0
type UgoiraMetaData struct {
PosterOriginal string `json:"poster_original"`
PosterThumb string `json:"poster_thumb"`
OriginalZip string `json:"original_zip"`
ThumbZip string `json:"thumb_zip"`
MimeType string `json:"mime_type"`
Width int `json:"width"`
Height int `json:"height"`
Frames []UgoiraFrame `json:"frames"`
}
type User ¶
type User struct {
ID MongoUUID `gorm:"primaryKey;type:uuid" json:"id"`
Username string `gorm:"type:text;uniqueIndex" json:"username"`
Password string `gorm:"type:text;not null" json:"password"`
Email *string `gorm:"type:text;uniqueIndex" json:"email"`
TelegramID *int64 `gorm:"type:bigint;uniqueIndex" json:"telegram_id"`
Blocked bool `gorm:"not null;default:false;index" json:"blocked"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Favorites []*Artwork `gorm:"many2many:user_favorites;constraint:OnDelete:CASCADE" json:"favorites"`
Settings datatypes.JSONType[*UserSettings] `gorm:"type:json" json:"settings"`
}
type UserSettings ¶
Click to show internal directories.
Click to hide internal directories.