internal

package
v0.0.0-...-a0d1ad3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: MIT, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArticleTable = "articles"
)

Variables

This section is empty.

Functions

func Run

func Run() error

Types

type Article

type Article interface {
	// Create is a method for creating an article.
	Create() (*Articles, error)

	// Get is a method for getting an article.
	Get() (*Articles, error)

	// GetArticles is a method for getting all articles by actor.
	GetArticles() ([]*Articles, error)

	Edit() error

	// Delete is a method for deleting an article.
	Delete() error

	// DeleteArticles is a method for deleting all articles by actor.
	DeleteArticles() error
}

type Articles

type Articles struct {
	gorm.Model

	ActorId uint   `gorm:"primaryKey;type:bigint;actor_id"`
	Title   string `gorm:"type:text;title"`
	Summary string `gorm:"type:text;summary"`

	// Article The content of the article or status,
	// it needs to store the text in html format,
	// but please be aware of XSS attacks.
	Article string `gorm:"type:text;article"`

	// Tags When the content is an article (status is false),
	// the tag of the article should be selected.
	Tags pq.StringArray `gorm:"type:text[];tags"`

	// Statuses sets whether the content is an article or a status.
	// Long text in HVXAHV means article, which will have to have title,
	// summary, and tags. Short articles are represented as statuses,
	// and statuses will not allow title summaries and tags to be added.
	Statuses bool `gorm:"type:boolean;statuses"`

	//// NSFW Sets whether the content of a post or status is NSFW.
	NSFW bool `gorm:"type:boolean;nsfw"`

	Attachments pq.StringArray `gorm:"type:text[];attachments"`

	// TO This field stores a slice of the recipient's address,
	// which can be multiple addresses or a single address.
	// If the slice is empty, it is sent to all followers.
	TO pq.StringArray `gorm:"type:text[];to"`

	// CC This field stores the sliced inbox address of the person being copied.
	CC pq.StringArray `gorm:"type:text[];cc"`

	BTO pq.StringArray `gorm:"type:text[];bto"`

	// Audience means the audience sent to the channel,
	// when submitting a post, if it needs to be synced to the channel,
	// the synced channel id will be sent to this field.
	Audience pq.Int64Array `gorm:"type:integer[];audience"`

	// Visibility setting for the article or status content, this field is
	// set to int type.
	// 0 is visible to everyone.
	// 1 is only visible to friends who follow each other.
	// 2 is only visible to yourself.
	Visibility int64 `gorm:"type:bigint;visibility"`
}

func NewArticlesActorId

func NewArticlesActorId(actorId uint) *Articles

NewArticlesActorId is a constructor for ArticlesActorId.

func NewArticlesDelete

func NewArticlesDelete(articleId, actorId uint) *Articles

func NewArticlesId

func NewArticlesId(articleId uint) *Articles

NewArticlesId is a constructor for ArticlesId.

func (*Articles) Create

func (a *Articles) Create() (*Articles, error)

func (*Articles) Delete

func (a *Articles) Delete() error

func (*Articles) DeleteArticles

func (a *Articles) DeleteArticles() error

func (*Articles) Edit

func (a *Articles) Edit() error

func (*Articles) EditArticle

func (a *Articles) EditArticle(article string) *Articles

func (*Articles) EditAttachments

func (a *Articles) EditAttachments(attachments []string) *Articles

func (*Articles) EditNSFW

func (a *Articles) EditNSFW(nsfw bool) *Articles

func (*Articles) EditSummary

func (a *Articles) EditSummary(summary string) *Articles

func (*Articles) EditTags

func (a *Articles) EditTags(tags []string) *Articles

func (*Articles) EditTitle

func (a *Articles) EditTitle(title string) *Articles

func (*Articles) EditVisibility

func (a *Articles) EditVisibility(visibility int64) *Articles

func (*Articles) Get

func (a *Articles) Get() (*Articles, error)

func (*Articles) GetArticles

func (a *Articles) GetArticles() ([]*Articles, error)

type Attachments

type Attachments struct {
	Attachment []struct {
		Type      string      `json:"type"`
		MediaType string      `json:"mediaType"`
		Url       string      `json:"url"`
		Name      interface{} `json:"name"`
		Blurhash  string      `json:"blurhash"`
		Width     int         `json:"width"`
		Height    int         `json:"height"`
	} `json:"attachment"`
}

type Editor

type Editor interface {
	// EditTitle is a method for editing the title of an article.
	EditTitle(title string) *Articles

	// EditSummary is a method for editing the summary of an article.
	EditSummary(summary string) *Articles

	// EditArticle is a method for editing the article of an article.
	EditArticle(article string) *Articles

	// EditTags is a method for editing the tags of an article.
	EditTags(tags []string) *Articles

	// EditAttachmentType is a method for editing the attachment article.
	EditAttachmentType(attachmentType string) *Articles

	// EditAttachments is a method for editing the attachments of an article.
	EditAttachments(attachments []string) *Articles

	// EditNSFW is a method for editing the nsfw of an article.
	EditNSFW(nsfw bool) *Articles

	// EditVisibility is a method for editing the visibility of an article.
	EditVisibility(visibility uint) *Articles
}

Jump to

Keyboard shortcuts

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