core

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Unlicense Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMimeType    = errors.New("invalid mime type")
	ErrMimeTypeNotAllowed = errors.New("mime/content type not allowed")
)
View Source
var (
	ErrBlobNotFound = errors.New("blob not found")
)
View Source
var (
	ErrFileSizeLimit = errors.New("file size is greater than allowed")
)

Functions

This section is empty.

Types

type ACR

type ACR struct {
	Action   ACRAction
	Pubkey   string
	Resource ACRResource
}

func NewACR

func NewACR(action ACRAction, pubkey string, resource ACRResource) *ACR

type ACRAction

type ACRAction string
const (
	ACRActionAllow ACRAction = "ALLOW"
	ACRActionDeny  ACRAction = "DENY"
)

type ACRResource

type ACRResource string
const (
	ResourceUpload ACRResource = "UPLOAD"
	ResourceGet    ACRResource = "GET"
	ResourceDelete ACRResource = "DELETE"
	ResourceList   ACRResource = "LIST"
	ResourceMirror ACRResource = "MIRROR"
)

type ACRStorage

type ACRStorage interface {
	Validate(
		ctx context.Context,
		pubkey string,
		resource ACRResource,
	) error
}

type Blob

type Blob struct {
	Pubkey   string
	Url      string
	Sha256   string
	Size     int64
	Type     string
	Blob     []byte
	Uploaded int64
	NIP94    *NIP94FileMetadata
}

type BlobStorage

type BlobStorage interface {
	Save(
		ctx context.Context,
		pubkey string,
		sha256 string,
		url string,
		size int64,
		mimeType string,
		blob []byte,
		created int64,
	) (*Blob, error)
	Exists(ctx context.Context, sha256 string) (bool, error)
	GetFromHash(ctx context.Context, sha256 string) (*Blob, error)
	GetFromPubkey(ctx context.Context, pubkey string) ([]*Blob, error)
	GetFromPubkeyPaginated(ctx context.Context, pubkey string, since int64, until int64) ([]*Blob, error)
	GetAllPaginated(ctx context.Context, since int64, until int64) ([]*Blob, error)
	DeleteFromHash(ctx context.Context, sha256 string) error
}

type MimeType

type MimeType struct {
	Extension string
	MimeType  string
}

type MimeTypeService

type MimeTypeService interface {
	Get(
		ctx context.Context,
		mimeType string,
	) (*MimeType, error)
	IsAllowed(
		ctx context.Context,
		mimeType string,
	) error
}

type NIP94FileMetadata

type NIP94FileMetadata struct {
	Url            string
	MimeType       string
	Sha256         string
	OriginalSha256 string
	Size           *int64
	Dimension      *string
	Magnet         *string
	Infohash       *string
	Blurhash       *string
	ThumbnailUrl   *string
	ImageUrl       *string
	Summary        *string
	Alt            *string
	Fallback       *string
	Service        *string
}

type Services

type Services interface {
	Init(context.Context) error
	Blob() BlobStorage
	ACR() ACRStorage
	Mime() MimeTypeService
	Settings() SettingService
	Stats() StatService
}

type Setting

type Setting struct {
	Key   string
	Value string
}

type SettingService

type SettingService interface {
	ValidateFileSizeMaxBytes(
		ctx context.Context,
		sizeBytes int,
	) error
}

type StatService

type StatService interface {
	Get(ctx context.Context) (*Stats, error)
}

type Stats

type Stats struct {
	BytesStored int
	BlobCount   int
	PubkeyCount int
}

Jump to

Keyboard shortcuts

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