data

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserCache = cmn.NewCache[string, *User](100)

Functions

func LoadPostInfo

func LoadPostInfo(post *Post) error

Types

type DomainRecord

type DomainRecord struct {
	Domain       string
	Amount       *big.Int
	CurrentFrame int
	TilFrame     int
}

type HistoryRecord

type HistoryRecord struct {
	Contract  sql.NullString
	Domain    sql.NullString
	Type      sql.NullString
	FromAddr  sql.NullString
	ToAddr    sql.NullString
	Amount    *big.Int
	Token     sql.NullString
	SavvaCid  sql.NullString
	Locales   sql.NullString
	Info      sql.NullString
	TxHash    sql.NullString
	TimeStamp time.Time
}

func GetHistory

func GetHistory(address string, from, to *time.Time) ([]HistoryRecord, error)

type Post

type Post struct {
	SavvaCid      string
	ShortCid      sql.NullString
	AuthorAddr    string
	PosterAddr    sql.NullString
	Domain        string
	Guid          string
	Ipfs          string
	TimeStamp     time.Time
	EffectiveTime time.Time
	TotalChilds   int

	ThumbnailImg image.Image
	// contains filtered or unexported fields
}

func GetPostsByAuthor

func GetPostsByAuthor(address, sponsor string, from, to time.Time) ([]Post, error)

func (*Post) GetContent

func (p *Post) GetContent(locale string) (string, error)

func (*Post) GetImage

func (p *Post) GetImage(url string) (image.Image, error)

func (*Post) GetLocale

func (p *Post) GetLocale(locale string) (SavvaContent_v2_0_Locale, bool)

func (*Post) GetTitle

func (p *Post) GetTitle(locale string) string

func (*Post) LoadThumbnail

func (p *Post) LoadThumbnail() error

type Receipient_v2_0

type Receipient_v2_0 struct {
	Pass     string `yaml:"pass"`
	Modifier string `yaml:"modifier"`
}

type SavvaContent_v2_0

type SavvaContent_v2_0 struct {
	SpecVersion string `yaml:"savva_spec_version"` // "2.0" Savva Content Specification Version
	MimeType    string `yaml:"mime_type"`          //
	Data        string `yaml:"data"`               // embedded content data
	DataPath    string `yaml:"data_path"`          // path to the content data
	Thumbnail   string `yaml:"thumbnail"`          // embedded thumbnail data
	RootCID     string `yaml:"root_savva_cid"`     // root Savva CID
	ParentCID   string `yaml:"parent_savva_cid"`   // parent Savva CID
	NSFT        bool   `yaml:"nsfw"`               // Not Safe For Work
	Fundraiser  int64  `yaml:"fundraiser"`         // Fundraiser ID
	Encryption  struct {
		Type              string                     `yaml:"type"`
		KeyExchangeAlg    string                     `yaml:"key_exchange_alg"`
		KeyExchangePubKey string                     `yaml:"key_exchange_pub_key"`
		Receipients       map[string]Receipient_v2_0 `yaml:"receipients"`
	} `yaml:"encryption"`

	Locales map[string]SavvaContent_v2_0_Locale `yaml:"locales"`
}

type SavvaContent_v2_0_Locale

type SavvaContent_v2_0_Locale struct {
	Title       string                             `yaml:"title"`        //
	TextPreview string                             `yaml:"text_preview"` // short preview to show in the lists
	Categories  []string                           `yaml:"categories"`   //
	Tags        []string                           `yaml:"tags"`         //
	Data        string                             `yaml:"data"`         // embedded content data
	DataPath    string                             `yaml:"data_path"`    // path to the content data
	Chapters    []SavvaContent_v2_0_Locale_Chapter `yaml:"chapters"`
}

type SavvaContent_v2_0_Locale_Chapter

type SavvaContent_v2_0_Locale_Chapter struct {
	Title    string `yaml:"title"`     //
	Data     string `yaml:"data"`      // embedded content data
	DataPath string `yaml:"data_path"` // path to the content data
}
type Sponsored struct {
	Author       string
	Domain       string
	Member       string
	Domains      []DomainRecord
	TotalAmount  *big.Int
	TotalFromAll *big.Int
}

func GetSponsoredBy

func GetSponsoredBy(address string) ([]Sponsored, error)

type User

type User struct {
	Address    string
	Name       string
	AvatarCid  string
	AvatarData []byte // In-memory avatar image data
	AvatarImg  image.Image
	Staked     big.Int
	Profiles   map[string]UserProfile // domaion -> profile
}

func GetUser

func GetUser(address string) (*User, error)

func (*User) BestName

func (u *User) BestName() string

func (*User) GetDisplayName

func (u *User) GetDisplayName() string

type UserProfile

type UserProfile struct {
	About         string `json:"about"`
	DisplayName   string `json:"display_name"`
	SponsorValues []int  `json:"sponsor_values"`
	Name          string `json:"name"`
}

Jump to

Keyboard shortcuts

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