Documentation ¶
Index ¶
- func CreateNullInt64(i int64) sql.NullInt64
- func CreateNullString(s string) sql.NullString
- func FormatComparator(field string, value string) string
- func FormatGif(gif string) string
- func FormatNsfw(isNfw string) string
- func FormatNsfwTags(isNsfw string, includedTags []string, parameters *[]any) string
- func FormatOrderBy(orderBy string, prefix string, randomEnabled bool) string
- func FormatOrientation(orientation string) string
- type Database
- func (database Database) DeleteImageFromFav(userId int64, imageId int64) error
- func (database Database) FetchImages(isNsfw string, includedTags []string, excludedTags []string, ...) (ImageRows, time.Duration, error)
- func (database Database) GetMissingPermissions(userId int64, targetUserId int64, permissions []string) ([]string, error)
- func (database Database) GetTags() ([]models.Tag, error)
- func (database Database) GetUserInformationFromId(userId int64) (models.User, error)
- func (database Database) GetUserInformationFromToken(token string) (models.User, error)
- func (database Database) InsertImageToFav(userId int64, imageId int64) error
- func (database Database) InsertUser(user ipc.User) error
- func (database Database) LogRequest(ip string, url string, userAgent string, userId int64, version string, ...)
- func (database Database) Report(userId int64, imageId int64, description *string) (ReportRes, error)
- func (database Database) ToggleImageInFav(userId int64, imageId int64) (string, error)
- type ImageRow
- type ImageRows
- type PermissionsInformation
- type ReportRes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNullInt64 ¶
func CreateNullString ¶
func CreateNullString(s string) sql.NullString
func FormatComparator ¶
func FormatNsfw ¶
func FormatNsfwTags ¶
func FormatOrientation ¶
Types ¶
type Database ¶
func InitDatabase ¶
func InitDatabase(config config.Configuration) Database
func (Database) DeleteImageFromFav ¶
func (Database) FetchImages ¶
func (database Database) FetchImages( isNsfw string, includedTags []string, excludedTags []string, includedFiles []string, excludedFiles []string, gif string, orderBy string, orientation string, many bool, full bool, width string, height string, byteSize string, userId int64, ) (ImageRows, time.Duration, error)
FetchImages this method is charged of generating the appropriate query based on the user query params (after binding) and querying the database
func (Database) GetMissingPermissions ¶
func (database Database) GetMissingPermissions(userId int64, targetUserId int64, permissions []string) ([]string, error)
GetMissingPermissions Provide a user id, an optional target user id, and permissions checks for all provided permissions that a user has the permissions globally or for the target if provided. Some might argue that performing a query for each permission might not be a good idea ,however fetching permissions position before might be a bit of a hassle and conduct to more query for the most command case : /fav , that only needs one permission. feel free to share your opinion if you have a better idea.
func (Database) GetUserInformationFromId ¶
func (Database) GetUserInformationFromToken ¶
func (Database) InsertImageToFav ¶
func (Database) LogRequest ¶
type ImageRow ¶
type ImageRow struct { Signature string `field:"signature" json:"signature"` Extension string `field:"extension" json:"extension"` ImageId int64 `field:"image_id" json:"image_id"` Favorites int64 `field:"favorites" json:"favorites"` DominantColor string `field:"dominant_color" json:"dominant_color"` Source *string `field:"source" json:"source"` UploadedAt string `field:"uploaded_at" json:"uploaded_at"` LikedAt *string `field:"liked_at" json:"liked_at"` IsNsfw bool `field:"is_nsfw" json:"is_nsfw"` Width int64 `field:"width" json:"width"` Height int64 `field:"height" json:"height"` ByteSize int64 `field:"byte_size" json:"byte_size"` TagId int64 `field:"tag_id" json:"tag_id"` TagName string `field:"tag_name" json:"tag_name"` TagDescription string `field:"tag_description" json:"tag_description"` TagIsNsfw bool `field:"tag_is_nsfw" json:"tag_is_nsfw"` ArtistId *int64 `field:"artist_id" json:"artist_id"` ArtistName *string `field:"artist_name" json:"artist_name"` ArtistPatreon *string `field:"artist_patreon" json:"artist_patreon"` ArtistTwitter *string `field:"artist_twitter" json:"artist_twitter"` ArtistDeviantArt *string `field:"artist_deviant_art" json:"artist_deviant_art"` ArtistPixiv *string `field:"artist_pixiv" json:"artist_pixiv"` }
ImageRow Represent a row when retrieving images (likedAt may not be present)
type ImageRows ¶
type ImageRows struct { Configuration config.Configuration Rows []ImageRow }
ImageRows Represent multiple rows
type PermissionsInformation ¶
PermissionsInformation a struct used to retrieve and a row from the database