models

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxUint16 = 65535
	MaxUint32 = 4294967295
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Blacklist

type Blacklist struct {
	gorm.Model
	Pubkey string `json:"pubkey" gorm:"type:varchar(64)"`
}

func (Blacklist) TableName

func (Blacklist) TableName() string

type Event

type Event struct {
	ID         string     `json:"id" gorm:"primaryKey;type:varchar(64)"`
	CreatedAt  Timestamp  `json:"created_at" gorm:"type:integer"`
	UpdatedAt  *Timestamp `json:"-" gorm:"type:integer"`
	DeletedAt  *Timestamp `json:"-" gorm:"type:integer"`
	Pubkey     string     `json:"pubkey" gorm:"type:varchar(64)"`
	Kind       int        `json:"kind" gorm:"type:integer"`
	Content    string     `json:"content"`
	Tags       Tags       `json:"tags" gorm:"type:jsonb"`
	Sig        string     `json:"sig"`
	Tagvalues  []string   `json:"-" gorm:"-"`
	Expiration *Timestamp `json:"-" gorm:"type:integer"`
}

func (*Event) GetID

func (evt *Event) GetID() string

GetID get event id

func (*Event) Serialize

func (evt *Event) Serialize() string

Serialize serialize event data

func (Event) TableName

func (Event) TableName() string

func (*Event) VerifySignature

func (evt *Event) VerifySignature() (bool, error)

VerifySignature verify signature

type Filter

type Filter struct {
	IDs     []string   `json:"ids"`
	Kinds   []int      `json:"kinds"`
	Authors []string   `json:"authors"`
	Tags    TagMap     `json:"-"`
	Since   *Timestamp `json:"since"`
	Until   *Timestamp `json:"until"`
	Limit   int        `json:"limit"`
	Search  string     `json:"search"`
}

type Filters

type Filters []Filter

type Page

type Page struct {
	PageInformation *PageInformation `json:"page_information,omitempty"`
	Entities        interface{}      `json:"entities,omitempty"`
}

Page page model

func NewPage

func NewPage(pageInfo *PageInformation, entities interface{}) *Page

NewPage new page

func (*Page) GetEntities

func (p *Page) GetEntities() interface{}

GetEntities get entities

type PageForm

type PageForm struct {
	Page    int    `json:"page,omitempty" form:"page" query:"page"`
	Size    int    `json:"size,omitempty" form:"size" query:"size"`
	Query   string `json:"query,omitempty" form:"query" query:"query"`
	Sort    string `json:"sort,omitempty" form:"sort" query:"sort"`
	Reverse bool   `json:"reverse,omitempty" form:"reverse" query:"reverse"`
	OrderBy string `json:"-" form:"-"`
}

PageForm page form

func (*PageForm) GetOrderBy

func (f *PageForm) GetOrderBy() string

GetOrderBy get order by

func (*PageForm) GetPage

func (f *PageForm) GetPage() int

GetPage get page

func (*PageForm) GetQuery

func (f *PageForm) GetQuery() string

GetQuery get query

func (*PageForm) GetReverse

func (f *PageForm) GetReverse() bool

GetReverse get reverse

func (*PageForm) GetSize

func (f *PageForm) GetSize() int

GetSize get size

func (*PageForm) GetSort

func (f *PageForm) GetSort() string

GetSort get sort

type PageInformation

type PageInformation struct {
	Page     int   `json:"page,omitempty"`
	Size     int   `json:"size,omitempty"`
	Count    int64 `json:"count,omitempty"`
	LastPage int   `json:"last_page,omitempty"`
}

PageInformation page information

type RelayInformationDocument

type RelayInformationDocument struct {
	Name          string                   `json:"name"`
	Description   string                   `json:"description"`
	Pubkey        string                   `json:"pubkey"`
	Contact       string                   `json:"contact"`
	SupportedNIPs []int                    `json:"supported_nips"`
	Software      string                   `json:"software"`
	Version       string                   `json:"version"`
	Limitation    *RelayLimitationDocument `json:"limitation,omitempty"`
	Icon          string                   `json:"icon"`
}

type RelayLimitationDocument

type RelayLimitationDocument struct {
	MaxMessageLength int  `json:"max_message_length,omitempty"`
	MaxSubscriptions int  `json:"max_subscriptions,omitempty"`
	MaxFilters       int  `json:"max_filters,omitempty"`
	MaxLimit         int  `json:"max_limit,omitempty"`
	MaxSubidLength   int  `json:"max_subid_length,omitempty"`
	MaxEventTags     int  `json:"max_event_tags,omitempty"`
	MaxContentLength int  `json:"max_content_length,omitempty"`
	MinPowDifficulty int  `json:"min_pow_difficulty,omitempty"`
	AuthRequired     bool `json:"auth_required"`
	PaymentRequired  bool `json:"payment_required"`
	RestrictedWrites bool `json:"restricted_writes"`
}

type Subscription

type Subscription struct {
	ID      string
	Filters []Filter
}

type Tag

type Tag []string

func (*Tag) CheckKey

func (t *Tag) CheckKey(prefix string) bool

func (*Tag) Key

func (t *Tag) Key() string

func (*Tag) Value

func (t *Tag) Value() string

type TagMap

type TagMap map[string][]string

type Tags

type Tags []Tag

func (*Tags) FindAll

func (t *Tags) FindAll(prefix string) *Tags

func (*Tags) FindFirst

func (t *Tags) FindFirst(prefix string) *Tag

func (*Tags) FindKeyD

func (t *Tags) FindKeyD() string

func (*Tags) Scan

func (t *Tags) Scan(v interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*Tags) Serialize

func (t *Tags) Serialize() string

type Timestamp

type Timestamp int64

Jump to

Keyboard shortcuts

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