entity

package
v2.0.0-beta11 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SiteCollection = "sites"
View Source
const SysUserCollection = "sys_users"

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	ID        uuid.UUID `json:"id,omitempty" bson:"_id,omitempty"`
	Link      string    `json:"link,omitempty" bson:"link,omitempty"`
	SiteID    uuid.UUID `json:"site_id,omitempty" bson:"site_id,omitempty"`
	Source    Source    `json:"source,omitempty" bson:"source,omitempty"`
	Lang      string    `json:"lang,omitempty" bson:"lang,omitempty"`
	Title     string    `json:"title,omitempty" bson:"title,omitempty"`
	Desc      *string   `json:"desc,omitempty" bson:"short_desc,omitempty"`
	Media     *[]Media  `json:"media,omitempty" bson:"media,omitempty"`
	PubDate   time.Time `json:"pub_date,omitempty" bson:"pub_date,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty" bson:"updated_at,omitempty"`
}

func (*Article) Domain

func (e *Article) Domain() string

func (*Article) EntityID

func (e *Article) EntityID() uuid.UUID

func (*Article) FirstMedia

func (e *Article) FirstMedia(t MediaType) (m Media)

func (*Article) SetDesc

func (e *Article) SetDesc(desc string) *Article

func (*Article) SetMedia

func (e *Article) SetMedia(media []Media) *Article

func (*Article) Tags

func (e *Article) Tags() []string

type Chat

type Chat struct {
	ID         uuid.UUID    `json:"id,omitempty" bson:"_id,omitempty"`
	TelegramID int64        `json:"telegram_id,omitempty" bson:"telegram_id,omitempty"`
	Type       ChatType     `json:"type,omitempty" bson:"type,omitempty"`
	Title      string       `json:"title,omitempty" bson:"title,omitempty"`
	Username   string       `json:"username,omitempty" bson:"username,omitempty"`
	FirstName  string       `json:"first_name,omitempty" bson:"first_name,omitempty"`
	LastName   string       `json:"last_name,omitempty" bson:"last_name,omitempty"`
	Broadcast  *[]uuid.UUID `json:"broadcast,omitempty" bson:"broadcast,omitempty"`
	Rights     *ChatRights  `json:"rights,omitempty" bson:"rights,omitempty"`
	Blocked    *bool        `json:"blocked,omitempty" bson:"blocked,omitempty"`
	Deleted    *bool        `json:"deleted,omitempty" bson:"deleted,omitempty"`
	CreatedAt  time.Time    `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt  time.Time    `json:"updated_at,omitempty" bson:"updated_at,omitempty"`
}

func (*Chat) EntityID

func (e *Chat) EntityID() uuid.UUID

func (*Chat) IsBlocked

func (e *Chat) IsBlocked() bool

func (*Chat) IsDeleted

func (e *Chat) IsDeleted() bool

func (*Chat) SetBlocked

func (e *Chat) SetBlocked(blocked bool) *Chat

func (*Chat) SetBroadcast

func (e *Chat) SetBroadcast(broadcast []uuid.UUID) *Chat

func (*Chat) SetDeleted

func (e *Chat) SetDeleted(deleted bool) *Chat

func (*Chat) SetRights

func (e *Chat) SetRights(rights ChatRights) *Chat

func (*Chat) Tags

func (e *Chat) Tags() []string

type ChatRights

type ChatRights struct {
	Status                string `json:"status,omitempty" bson:"status,omitempty"`
	IsAnonymous           bool   `json:"is_anonymous,omitempty" bson:"is_anonymous,omitempty"`
	UntilDate             int64  `json:"until_date,omitempty" bson:"until_date,omitempty"`
	CanBeEdited           bool   `json:"can_be_edited,omitempty" bson:"can_be_edited,omitempty"`
	CanManageChat         bool   `json:"can_manage_chat,omitempty" bson:"can_manage_chat,omitempty"`
	CanPostMessages       bool   `json:"can_post_messages,omitempty" bson:"can_post_messages,omitempty"`
	CanEditMessages       bool   `json:"can_edit_messages,omitempty" bson:"can_edit_messages,omitempty"`
	CanDeleteMessages     bool   `json:"can_delete_messages,omitempty" bson:"can_delete_messages,omitempty"`
	CanRestrictMembers    bool   `json:"can_restrict_members,omitempty" bson:"can_restrict_members,omitempty"`
	CanPromoteMembers     bool   `json:"can_promote_members,omitempty" bson:"can_promote_members,omitempty"`
	CanChangeInfo         bool   `json:"can_change_info,omitempty" bson:"can_change_info,omitempty"`
	CanInviteUsers        bool   `json:"can_invite_users,omitempty" bson:"can_invite_users,omitempty"`
	CanPinMessages        bool   `json:"can_pin_messages,omitempty" bson:"can_pin_messages,omitempty"`
	IsMember              bool   `json:"is_member,omitempty" bson:"is_member,omitempty"`
	CanSendMessages       bool   `json:"can_send_messages,omitempty" bson:"can_send_messages,omitempty"`
	CanSendMediaMessages  bool   `json:"can_send_media_messages,omitempty" bson:"can_send_media_messages,omitempty"`
	CanSendPolls          bool   `json:"can_send_polls,omitempty" bson:"can_send_polls,omitempty"`
	CanSendOtherMessages  bool   `json:"can_send_other_messages,omitempty" bson:"can_send_other_messages,omitempty"`
	CanAddWebPagePreviews bool   `json:"can_add_web_page_previews,omitempty" bson:"can_add_web_page_previews,omitempty"`
}

func (ChatRights) HasLeft

func (chat ChatRights) HasLeft() bool

func (ChatRights) IsAdministrator

func (chat ChatRights) IsAdministrator() bool

func (ChatRights) IsCreator

func (chat ChatRights) IsCreator() bool

func (ChatRights) WasKicked

func (chat ChatRights) WasKicked() bool

type ChatType

type ChatType string
const (
	Private    ChatType = "private"
	Group      ChatType = "group"
	SuperGroup ChatType = "supergroup"
	Channel    ChatType = "channel"

	ChatCollection = "chats"
)

type FeedPayload

type FeedPayload struct {
	JobID  *uuid.UUID `json:"job_id,omitempty" bson:"-"`
	SiteID uuid.UUID  `json:"site_id,omitempty" bson:"site_id,omitempty"`
	Link   string     `json:"link,omitempty" bson:"link,omitempty"`
}

type Job

type Job struct {
	ID        uuid.UUID    `json:"id,omitempty" bson:"_id"`
	CronExpr  string       `json:"cron_expr,omitempty" bson:"cron_expr,omitempty"`
	Name      JobName      `json:"name,omitempty" bson:"name,omitempty"`
	Payload   any          `json:"payload,omitempty" bson:"payload,omitempty"`
	Options   *[]JobOption `json:"options,omitempty" bson:"options,omitempty"`
	Enabled   *bool        `json:"enabled,omitempty" bson:"enabled,omitempty"`
	CreatedAt time.Time    `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt time.Time    `json:"updated_at,omitempty" bson:"updated_at,omitempty"`
}

func (*Job) Active

func (e *Job) Active() bool

func (*Job) EntityID

func (e *Job) EntityID() uuid.UUID

func (*Job) HasOptions

func (e *Job) HasOptions() bool

func (*Job) SetEnabled

func (e *Job) SetEnabled(enabled bool) *Job

func (*Job) SetOptions

func (e *Job) SetOptions(options []JobOption) *Job

func (*Job) Tags

func (e *Job) Tags() []string

func (*Job) UnmarshalBSON

func (e *Job) UnmarshalBSON(data []byte) error

type JobName

type JobName string
const (
	JobFeed    JobName = "job:feed"
	JobSitemap JobName = "job:sitemap"

	JobCollection = "jobs"
)

type JobOption

type JobOption struct {
	Type  JobOptionType `json:"type" bson:"type"`
	Value string        `json:"value" bson:"value"`
}

type JobOptionType

type JobOptionType string
const (
	MaxRetryOpt  JobOptionType = "max-retry"
	QueueOpt     JobOptionType = "queue"
	TimeoutOpt   JobOptionType = "timeout"
	DeadlineOpt  JobOptionType = "deadline"
	UniqueOpt    JobOptionType = "unique"
	ProcessAtOpt JobOptionType = "process-at"
	ProcessInOpt JobOptionType = "process-in"
	TaskIDOpt    JobOptionType = "task-id"
	RetentionOpt JobOptionType = "retention"
	GroupOpt     JobOptionType = "group"
)

type Media

type Media struct {
	URL  string         `json:"url,omitempty" bson:"url,omitempty"`
	Type MediaType      `json:"type,omitempty" bson:"type,omitempty"`
	Meta map[string]any `json:"meta,omitempty" bson:"meta,omitempty"`
}

type MediaType

type MediaType string
const (
	ImageType MediaType = "image"
	VideoType MediaType = "video"
	AudioType MediaType = "audio"
)

type Site

type Site struct {
	ID        uuid.UUID `json:"id,omitempty" bson:"_id,omitempty"`
	Domain    string    `json:"domain,omitempty" bson:"domain,omitempty"`
	Favicon   string    `json:"favicon,omitempty" bson:"favicon,omitempty"`
	Languages []string  `json:"languages,omitempty" bson:"languages,omitempty"`
	Title     string    `json:"title,omitempty" bson:"title,omitempty"`
	Enabled   *bool     `json:"enabled,omitempty" bson:"enabled,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty" bson:"updated_at,omitempty"`
}

func (*Site) EntityID

func (e *Site) EntityID() uuid.UUID

func (*Site) SetEnabled

func (e *Site) SetEnabled(enabled bool) *Site

func (*Site) Tags

func (e *Site) Tags() []string

type SitemapPayload

type SitemapPayload struct {
	JobID      *uuid.UUID `json:"job_id,omitempty" bson:"-"`
	SiteID     uuid.UUID  `json:"site_id,omitempty" bson:"site_id,omitempty"`
	Link       string     `json:"link,omitempty" bson:"link,omitempty"`
	Lang       *string    `json:"lang,omitempty" bson:"lang,omitempty"`
	MatchLoc   *string    `json:"match_loc,omitempty" bson:"match_loc,omitempty"`
	SearchLoc  *string    `json:"search_loc,omitempty" bson:"search_loc,omitempty"`
	SearchLink *string    `json:"search_link,omitempty" bson:"search_link,omitempty"`
	Index      *bool      `json:"index,omitempty" bson:"index,omitempty"`
	StopOnDup  *bool      `json:"stop_on_dup,omitempty" bson:"stop_on_dup,omitempty"`
}

func (*SitemapPayload) IsIndex

func (p *SitemapPayload) IsIndex() bool

func (*SitemapPayload) SetIndex

func (p *SitemapPayload) SetIndex(index bool) *SitemapPayload

func (*SitemapPayload) SetLang

func (p *SitemapPayload) SetLang(lang string) *SitemapPayload

func (*SitemapPayload) SetMatchLoc

func (p *SitemapPayload) SetMatchLoc(matchLoc string) *SitemapPayload
func (p *SitemapPayload) SetSearchLink(searchLink string) *SitemapPayload

func (*SitemapPayload) SetSearchLoc

func (p *SitemapPayload) SetSearchLoc(searchLoc string) *SitemapPayload

func (*SitemapPayload) SetStopOnDup

func (p *SitemapPayload) SetStopOnDup(stopOnDup bool) *SitemapPayload

func (*SitemapPayload) StoppingOnDup

func (p *SitemapPayload) StoppingOnDup() bool

type Source

type Source string
const (
	FeedSource    Source = "feed"
	SitemapSource Source = "sitemap"

	ArticleCollection = "articles"
)

type SysUser

type SysUser struct {
	ID        uuid.UUID `json:"id,omitempty" bson:"_id,omitempty"`
	Username  string    `json:"username,omitempty" bson:"username,omitempty"`
	Email     string    `json:"email,omitempty" bson:"email,omitempty"`
	Password  string    `json:"-" bson:"password,omitempty"`
	OTPSecret []byte    `json:"-" bson:"otp_secret,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty" bson:"updated_at,omitempty"`
}

func (*SysUser) CheckPassword

func (e *SysUser) CheckPassword(password string) error

func (*SysUser) CheckTOTP

func (e *SysUser) CheckTOTP(password string) error

func (*SysUser) EntityID

func (e *SysUser) EntityID() uuid.UUID

func (*SysUser) GenerateOTPSecret

func (e *SysUser) GenerateOTPSecret(size uint) (err error)

func (*SysUser) GeneratePasswordHash

func (e *SysUser) GeneratePasswordHash() error

func (*SysUser) Secret

func (e *SysUser) Secret() string

func (*SysUser) Tags

func (e *SysUser) Tags() []string

Jump to

Keyboard shortcuts

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