services

package
v0.5.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithWriter

func WithWriter(ctx context.Context) context.Context

Types

type ArchivePeriod

type ArchivePeriod struct {
	Year  int
	Month int
	Day   int
	Date  string
	Count int
}

type CommentQuery

type CommentQuery struct {
	COID     int64
	Status   string
	Keywords string
	CID      int64
	Type     string
	AuthorID int64
	OwnerID  int64
	Mail     string
	IP       string
	Limit    int
	Offset   int
}

type CommentService

type CommentService struct {
	// contains filtered or unexported fields
}

func NewCommentService

func NewCommentService(db DB) *CommentService

func (*CommentService) ByID

func (s *CommentService) ByID(ctx context.Context, id int64) (models.Comment, error)

func (*CommentService) ClearSpam

func (s *CommentService) ClearSpam(ctx context.Context) error

func (*CommentService) CountFiltered

func (s *CommentService) CountFiltered(ctx context.Context, query CommentQuery) (int64, error)

func (*CommentService) CountForContent

func (s *CommentService) CountForContent(ctx context.Context, cid int64) (int64, error)

func (*CommentService) CountRecentByIP

func (s *CommentService) CountRecentByIP(ctx context.Context, ip string, since int64) (int64, error)

func (*CommentService) CountRecentByIPForContent

func (s *CommentService) CountRecentByIPForContent(ctx context.Context, cid int64, ip string, since int64) (int64, error)

func (*CommentService) Delete

func (s *CommentService) Delete(ctx context.Context, id int64) error

func (*CommentService) DeleteMany

func (s *CommentService) DeleteMany(ctx context.Context, ids []int64) error

func (*CommentService) ExistsByURLType

func (s *CommentService) ExistsByURLType(ctx context.Context, cid int64, commentURL, typ string) (bool, error)

func (*CommentService) HasApprovedAuthor

func (s *CommentService) HasApprovedAuthor(ctx context.Context, author, mail string) (bool, error)

func (*CommentService) List

func (s *CommentService) List(ctx context.Context, status, keywords string, cid int64) ([]models.Comment, error)

func (*CommentService) ListCommentsPlugin

func (s *CommentService) ListCommentsPlugin(ctx context.Context, query plugin.PublicCommentQuery) ([]plugin.PublicComment, int64, error)

func (*CommentService) ListFiltered

func (s *CommentService) ListFiltered(ctx context.Context, status, keywords string, cid int64, typ string) ([]models.Comment, error)

func (*CommentService) ListForContent

func (s *CommentService) ListForContent(ctx context.Context, cid int64, order string, limit, offset int) ([]models.Comment, error)

func (*CommentService) ListForContentViewer

func (s *CommentService) ListForContentViewer(ctx context.Context, cid int64, order string, limit, offset int, viewerAuthorID int64, visibleWaitingIDs []int64) ([]models.Comment, error)

func (*CommentService) ListPage

func (s *CommentService) ListPage(ctx context.Context, query CommentQuery) ([]models.Comment, error)

func (*CommentService) Mark

func (s *CommentService) Mark(ctx context.Context, id int64, status string) error

func (*CommentService) MarkMany

func (s *CommentService) MarkMany(ctx context.Context, ids []int64, status string) error

func (*CommentService) NormalizeParent

func (s *CommentService) NormalizeParent(ctx context.Context, cid, parent int64, maxDepth int) (int64, error)

func (*CommentService) ParentDepth

func (s *CommentService) ParentDepth(ctx context.Context, cid, parent int64) (int, error)

func (*CommentService) Save

func (s *CommentService) Save(ctx context.Context, input SaveCommentInput, id int64) error

func (*CommentService) SaveReturningID

func (s *CommentService) SaveReturningID(ctx context.Context, input SaveCommentInput, id int64) (int64, error)

type ContentQuery

type ContentQuery struct {
	CID           int64
	Slug          string
	SlugID        int64
	Type          string
	Status        string
	Keywords      string
	Category      int64
	Tag           int64
	AuthorID      int64
	Parent        int64
	Year          int
	Month         int
	Day           int
	ExcludeFuture bool
	IncludeDrafts bool
	Limit         int
	Offset        int
}

type ContentService

type ContentService struct {
	// contains filtered or unexported fields
}

func NewContentService

func NewContentService(db DB) *ContentService

func (*ContentService) Adjacent

func (s *ContentService) Adjacent(ctx context.Context, c models.Content) (prev, next models.Content, err error)

func (*ContentService) AllFields

func (s *ContentService) AllFields(ctx context.Context) ([]models.Field, error)

func (*ContentService) AllRelationships

func (s *ContentService) AllRelationships(ctx context.Context) ([]models.Relationship, error)

func (*ContentService) ArchiveMonths

func (s *ContentService) ArchiveMonths(ctx context.Context, loc *time.Location, limit int) ([]ArchivePeriod, error)

func (*ContentService) AttachmentBySlug

func (s *ContentService) AttachmentBySlug(ctx context.Context, attachSlug string) (models.Content, error)

func (*ContentService) ByID

func (s *ContentService) ByID(ctx context.Context, id int64) (models.Content, error)

func (*ContentService) BySlug

func (s *ContentService) BySlug(ctx context.Context, postSlug string) (models.Content, error)

func (*ContentService) CategoriesForContentIDs

func (s *ContentService) CategoriesForContentIDs(ctx context.Context, cid int64) ([]int64, error)

CategoriesForContentIDs returns category IDs for a content item.

func (*ContentService) Count

func (s *ContentService) Count(ctx context.Context) (int64, error)

func (*ContentService) CountList

func (s *ContentService) CountList(ctx context.Context, q ContentQuery) (int64, error)

func (*ContentService) Create

func (s *ContentService) Create(ctx context.Context, input SaveContentInput, authorID int64) (int64, error)

func (*ContentService) CreateAttachment

func (s *ContentService) CreateAttachment(ctx context.Context, title, slugValue, filePath string, authorID, parent int64) (int64, error)

func (*ContentService) CreateAttachmentMeta

func (s *ContentService) CreateAttachmentMeta(ctx context.Context, title, slugValue, text string, authorID, parent int64) (int64, error)

func (*ContentService) DB

func (s *ContentService) DB() *sql.DB

func (*ContentService) Delete

func (s *ContentService) Delete(ctx context.Context, id int64) error

func (*ContentService) DeleteDraft

func (s *ContentService) DeleteDraft(ctx context.Context, draftID int64) error

DeleteDraft deletes an editing draft (draftOf > 0) without affecting the published content.

func (*ContentService) DeleteField

func (s *ContentService) DeleteField(ctx context.Context, cid int64, name string) error

func (*ContentService) DeleteRevision

func (s *ContentService) DeleteRevision(ctx context.Context, cid, rid int64) error

func (*ContentService) Dialect

func (s *ContentService) Dialect() models.Dialect

func (*ContentService) DraftForContent

func (s *ContentService) DraftForContent(ctx context.Context, contentID int64) (models.Content, error)

DraftForContent returns the editing draft for a given published content ID. Returns sql.ErrNoRows if no draft exists.

func (*ContentService) DraftMapForContents

func (s *ContentService) DraftMapForContents(ctx context.Context, contentIDs []int64) (map[int64]bool, error)

DraftMapForContents returns a map of contentID -> true for published contents that have editing drafts.

func (*ContentService) FieldMap

func (s *ContentService) FieldMap(ctx context.Context, cid int64) (map[string]any, error)

func (*ContentService) FieldMapsForContents

func (s *ContentService) FieldMapsForContents(ctx context.Context, cids []int64) (map[int64]map[string]any, error)

func (*ContentService) FieldsForContent

func (s *ContentService) FieldsForContent(ctx context.Context, cid int64) ([]models.Field, error)

func (*ContentService) IncrementFieldInt

func (s *ContentService) IncrementFieldInt(ctx context.Context, cid int64, name string, delta int64) (int64, error)

func (*ContentService) List

func (*ContentService) ListAll

func (s *ContentService) ListAll(ctx context.Context, limit, offset int) ([]models.Content, error)

func (*ContentService) ListContentsPlugin

func (s *ContentService) ListContentsPlugin(ctx context.Context, query plugin.PublicContentQuery) ([]plugin.PublicContent, int64, error)

func (*ContentService) ListPublished

func (s *ContentService) ListPublished(ctx context.Context, limit, offset int) ([]models.Content, error)

func (*ContentService) MarkStatus

func (s *ContentService) MarkStatus(ctx context.Context, id int64, status string) error

func (*ContentService) MetaIDsForContent

func (s *ContentService) MetaIDsForContent(ctx context.Context, cid int64) ([]int64, error)

func (*ContentService) PageBySlug

func (s *ContentService) PageBySlug(ctx context.Context, pageSlug string) (models.Content, error)

func (*ContentService) PrivateBySlugForAuthor

func (s *ContentService) PrivateBySlugForAuthor(ctx context.Context, contentSlug, typ string, authorID int64) (models.Content, error)

func (*ContentService) PruneEditingDrafts

func (s *ContentService) PruneEditingDrafts(ctx context.Context, publishedID, keepID int64) error

func (*ContentService) PublishDraft

func (s *ContentService) PublishDraft(ctx context.Context, draftID int64) error

PublishDraft merges the editing draft content into the published article and deletes the draft.

func (*ContentService) RepairOrphanEditingDrafts

func (s *ContentService) RepairOrphanEditingDrafts(ctx context.Context) error

func (*ContentService) RestoreRevision

func (s *ContentService) RestoreRevision(ctx context.Context, cid, rid int64) (int64, error)

func (*ContentService) RevisionByID

func (s *ContentService) RevisionByID(ctx context.Context, rid int64) (models.Revision, error)

func (*ContentService) Revisions

func (s *ContentService) Revisions(ctx context.Context, cid int64) ([]models.Revision, error)

func (*ContentService) SaveEditingDraft

func (s *ContentService) SaveEditingDraft(ctx context.Context, publishedID int64, input SaveContentInput, authorID int64) (int64, error)

func (*ContentService) SaveFields

func (s *ContentService) SaveFields(ctx context.Context, cid int64, fields []SaveFieldInput) error

func (*ContentService) SaveRevision

func (s *ContentService) SaveRevision(ctx context.Context, c models.Content) error

func (*ContentService) SetField

func (s *ContentService) SetField(ctx context.Context, cid int64, field SaveFieldInput) error

func (*ContentService) SetRevisionConfig

func (s *ContentService) SetRevisionConfig(enabled bool, limit int)

func (*ContentService) SetRevisionLimit

func (s *ContentService) SetRevisionLimit(limit int)

func (*ContentService) Stats

func (s *ContentService) Stats(ctx context.Context) (models.Stats, error)

func (*ContentService) TagsForContentNames

func (s *ContentService) TagsForContentNames(ctx context.Context, cid int64) ([]string, error)

TagsForContentNames returns tag names for a content item.

func (*ContentService) Update

func (s *ContentService) Update(ctx context.Context, id int64, input SaveContentInput) error

func (*ContentService) UpdateAttachmentMeta

func (s *ContentService) UpdateAttachmentMeta(ctx context.Context, id int64, title, slugValue, text string, parent int64) error

type DB

type DB interface {
	QueryContext(context.Context, string, ...any) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...any) *sql.Row
	ExecContext(context.Context, string, ...any) (sql.Result, error)
	BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
	PingContext(context.Context) error
	Dialect() models.Dialect
	RawWriter() *sql.DB
}

type DBRouter

type DBRouter struct {
	Writer *sql.DB
	Reader *sql.DB
	// contains filtered or unexported fields
}

func NewDBRouter

func NewDBRouter(writer, reader *sql.DB, driver ...string) *DBRouter

func (*DBRouter) BeginTx

func (r *DBRouter) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

func (*DBRouter) Dialect

func (r *DBRouter) Dialect() models.Dialect

func (*DBRouter) ExecContext

func (r *DBRouter) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*DBRouter) PingContext

func (r *DBRouter) PingContext(ctx context.Context) error

func (*DBRouter) QueryContext

func (r *DBRouter) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

func (*DBRouter) QueryRowContext

func (r *DBRouter) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

func (*DBRouter) RawWriter

func (r *DBRouter) RawWriter() *sql.DB

type MetaService

type MetaService struct {
	// contains filtered or unexported fields
}

func NewMetaService

func NewMetaService(db DB) *MetaService

func (*MetaService) ByID

func (s *MetaService) ByID(ctx context.Context, id int64) (models.Meta, error)

func (*MetaService) BySlug

func (s *MetaService) BySlug(ctx context.Context, typ, slug string) (models.Meta, error)

func (*MetaService) CategoriesForContent

func (s *MetaService) CategoriesForContent(ctx context.Context, cid int64) ([]models.Meta, error)

func (*MetaService) CleanOrphanTags

func (s *MetaService) CleanOrphanTags(ctx context.Context) (int64, error)

func (*MetaService) CountFiltered

func (s *MetaService) CountFiltered(ctx context.Context, query plugin.PublicMetaQuery) (int64, error)

func (*MetaService) Delete

func (s *MetaService) Delete(ctx context.Context, id int64) error

func (*MetaService) EnsureDefaultCategory

func (s *MetaService) EnsureDefaultCategory(ctx context.Context) error

func (*MetaService) List

func (s *MetaService) List(ctx context.Context, typ string) ([]models.Meta, error)

func (*MetaService) ListCloud

func (s *MetaService) ListCloud(ctx context.Context, typ string, limit int) ([]models.Meta, error)

func (*MetaService) ListFiltered

func (s *MetaService) ListFiltered(ctx context.Context, query plugin.PublicMetaQuery) ([]models.Meta, error)

func (*MetaService) ListMetasPlugin

func (s *MetaService) ListMetasPlugin(ctx context.Context, query plugin.PublicMetaQuery) ([]plugin.PublicMeta, int64, error)

func (*MetaService) Merge

func (s *MetaService) Merge(ctx context.Context, targetID int64, sourceIDs []int64, typ string) error

func (*MetaService) Move

func (s *MetaService) Move(ctx context.Context, id int64, direction string) error

func (*MetaService) RefreshCount

func (s *MetaService) RefreshCount(ctx context.Context, id int64) error

func (*MetaService) RefreshCounts

func (s *MetaService) RefreshCounts(ctx context.Context) error

func (*MetaService) Save

func (s *MetaService) Save(ctx context.Context, input SaveMetaInput, id int64) (int64, error)

func (*MetaService) SetDefaultCategory

func (s *MetaService) SetDefaultCategory(ctx context.Context, mid int64, options *OptionService) error

func (*MetaService) TagsForContent

func (s *MetaService) TagsForContent(ctx context.Context, cid int64) ([]models.Meta, error)

type OptionService

type OptionService struct {
	// contains filtered or unexported fields
}

func NewOptionService

func NewOptionService(db DB) *OptionService

func (*OptionService) All

func (s *OptionService) All(ctx context.Context) (map[string]string, error)

func (*OptionService) EnsureDefaults

func (s *OptionService) EnsureDefaults(ctx context.Context) error

func (*OptionService) Get

func (s *OptionService) Get(ctx context.Context, name string) (string, error)

func (*OptionService) GetForUser

func (s *OptionService) GetForUser(ctx context.Context, name string, userID int64) (string, error)

func (*OptionService) Set

func (s *OptionService) Set(ctx context.Context, name, value string) error

func (*OptionService) SetForUser

func (s *OptionService) SetForUser(ctx context.Context, name, value string, userID int64) error

type SQLDB

type SQLDB struct {
	// contains filtered or unexported fields
}

func NewSQLDB

func NewSQLDB(db *sql.DB, driver string) *SQLDB

func (*SQLDB) BeginTx

func (d *SQLDB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

func (*SQLDB) Dialect

func (d *SQLDB) Dialect() models.Dialect

func (*SQLDB) ExecContext

func (d *SQLDB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*SQLDB) PingContext

func (d *SQLDB) PingContext(ctx context.Context) error

func (*SQLDB) QueryContext

func (d *SQLDB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

func (*SQLDB) QueryRowContext

func (d *SQLDB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

func (*SQLDB) RawWriter

func (d *SQLDB) RawWriter() *sql.DB

type SaveCommentInput

type SaveCommentInput struct {
	CID      int64
	Author   string
	AuthorID int64
	OwnerID  int64
	Mail     string
	URL      string
	Text     string
	Status   string
	Parent   int64
	IP       string
	Agent    string
	Type     string
}

type SaveContentInput

type SaveContentInput struct {
	Title        string
	Slug         string
	SlugID       int64
	Text         string
	Type         string
	Status       string
	Password     string
	Created      int64
	SortOrder    int64
	Template     string
	Parent       int64
	AllowComment bool
	AllowPing    bool
	AllowFeed    bool
	CategoryIDs  []int64
	Tags         []string
	Fields       []SaveFieldInput
	DraftOf      int64
}

type SaveFieldInput

type SaveFieldInput struct {
	Name       string
	Type       string
	StrValue   string
	IntValue   int64
	FloatValue float64
}

type SaveMetaInput

type SaveMetaInput struct {
	Name        string
	Slug        string
	Type        string
	Description string
	Parent      int64
}

type SaveUserInput

type SaveUserInput struct {
	Name       string
	Password   string
	Mail       string
	URL        string
	ScreenName string
	Role       string
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(db DB) *UserService

func (*UserService) Authenticate

func (s *UserService) Authenticate(ctx context.Context, name, password string) (models.User, error)

func (*UserService) ByID

func (s *UserService) ByID(ctx context.Context, id int64) (models.User, error)

func (*UserService) ByMail

func (s *UserService) ByMail(ctx context.Context, mail string) (models.User, error)

func (*UserService) ByName

func (s *UserService) ByName(ctx context.Context, name string) (models.User, error)

func (*UserService) ChangePassword

func (s *UserService) ChangePassword(ctx context.Context, id int64, password string) error

func (*UserService) Count

func (s *UserService) Count(ctx context.Context) (int, error)

func (*UserService) CountFiltered

func (s *UserService) CountFiltered(ctx context.Context, query plugin.PublicUserQuery) (int64, error)

func (*UserService) Delete

func (s *UserService) Delete(ctx context.Context, id int64) error

func (*UserService) EnsureDefaultAdmin

func (s *UserService) EnsureDefaultAdmin(ctx context.Context, name, password, mail string) error

func (*UserService) ExistsMail

func (s *UserService) ExistsMail(ctx context.Context, mail string, exceptID int64) (bool, error)

func (*UserService) ExistsName

func (s *UserService) ExistsName(ctx context.Context, name string, exceptID int64) (bool, error)

func (*UserService) List

func (s *UserService) List(ctx context.Context, keywords string) ([]models.User, error)

func (*UserService) ListFiltered

func (s *UserService) ListFiltered(ctx context.Context, query plugin.PublicUserQuery) ([]models.User, error)

func (*UserService) ListUsersPlugin

func (s *UserService) ListUsersPlugin(ctx context.Context, query plugin.PublicUserQuery) ([]plugin.PublicUser, int64, error)

func (*UserService) RevokeSessions

func (s *UserService) RevokeSessions(ctx context.Context, id int64) error

func (*UserService) Save

func (s *UserService) Save(ctx context.Context, input SaveUserInput, id int64) (int64, error)

func (*UserService) TouchLogged

func (s *UserService) TouchLogged(ctx context.Context, id int64) error

Jump to

Keyboard shortcuts

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