service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventCreateUser is the create event on an user
	EventCreateUser = "user:create"
	// EventUpdateUser is the update event on an user
	EventUpdateUser = "user:update"
	// EventDeleteUser is the delete event on an user
	EventDeleteUser = "user:delete"
	// EventCreateArticle is the create event on an article
	EventCreateArticle = "article:create"
	// EventUpdateArticle is the update event on an article
	EventUpdateArticle = "article:update"
)
View Source
const (
	// NoNotificationEventOption will disable global notification policy
	NoNotificationEventOption event.EventOption = 1 << iota // 1
)

Variables

View Source
var (
	// ErrCategoryNotFound if a category is not found
	ErrCategoryNotFound = errors.New("category not found")
	// ErrIncomingWebhookNotFound if an incoming webhook service is not found
	ErrIncomingWebhookNotFound = errors.New("incoming webhook not found")
	// ErrOutgoingWebhookNotFound if an outgoing webhook service is not found
	ErrOutgoingWebhookNotFound = errors.New("outgoing webhook not found")
	// ErrDeviceNotFound if a device is not found
	ErrDeviceNotFound = errors.New("device not found")
	// ErrUserQuotaReached if an user reach its quota
	ErrUserQuotaReached = errors.New("user quota reached")
	// ErrOutgoingWebhookSend if an article can not be send to the outgoing webhook
	ErrOutgoingWebhookSend = errors.New("unable to send article to outgoing webhook")
	// ErrArticleDownload if an article can not be downloaded
	ErrArticleDownload = errors.New("unable to download article")
)

Functions

func Configure

func Configure(conf config.Config, database db.DB, downloadCache cache.Cache) error

Configure the global service registry

Types

type ArticleCreationOptions

type ArticleCreationOptions struct {
	IgnoreHydrateError bool
}

ArticleCreationOptions article creation options

type Registry

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

Registry is the structure definition of the service registry

func Lookup

func Lookup() *Registry

Lookup returns the global service registry

func (*Registry) CleanHistory

func (reg *Registry) CleanHistory(ctx context.Context) (int64, error)

CleanHistory remove all read articles

func (*Registry) CountCurrentUserArticles

func (reg *Registry) CountCurrentUserArticles(ctx context.Context, req model.ArticlesPageRequest) (uint, error)

CountCurrentUserArticles count current user articles

func (*Registry) CountCurrentUserCategories

func (reg *Registry) CountCurrentUserCategories(ctx context.Context) (uint, error)

CountCurrentUserCategories get total categories of current user

func (*Registry) CountCurrentUserDevices

func (reg *Registry) CountCurrentUserDevices(ctx context.Context) (uint, error)

CountCurrentUserDevices get total categories of current user

func (*Registry) CountUserArticles

func (reg *Registry) CountUserArticles(ctx context.Context, uid uint, req model.ArticlesPageRequest) (uint, error)

CountUserArticles count user articles

func (*Registry) CreateArticle

func (reg *Registry) CreateArticle(ctx context.Context, form model.ArticleCreateForm, opts ArticleCreationOptions) (*model.Article, error)

CreateArticle creates new article

func (*Registry) CreateArticles

func (reg *Registry) CreateArticles(ctx context.Context, data []model.ArticleCreateForm) *model.CreatedArticlesResponse

CreateArticles creates new articles

func (*Registry) CreateCategory

func (reg *Registry) CreateCategory(ctx context.Context, form model.CategoryCreateForm) (*model.Category, error)

CreateCategory create a category for current user

func (*Registry) CreateDevice

func (reg *Registry) CreateDevice(ctx context.Context, sub string) (*model.Device, error)

CreateDevice create or update a device for current user

func (*Registry) CreateIncomingWebhook

func (reg *Registry) CreateIncomingWebhook(ctx context.Context, form model.IncomingWebhookCreateForm) (*model.IncomingWebhook, error)

CreateIncomingWebhook create an incoming webhook for current user

func (*Registry) CreateOutgoingWebhook

func (reg *Registry) CreateOutgoingWebhook(ctx context.Context, form model.OutgoingWebhookCreateForm) (*model.OutgoingWebhook, error)

CreateOutgoingWebhook create an outgoing webhook for current user

func (*Registry) DeleteAccount

func (reg *Registry) DeleteAccount(ctx context.Context) (bool, error)

DeleteAccount delete current user account

func (*Registry) DeleteCategories

func (reg *Registry) DeleteCategories(ctx context.Context, ids []uint) (int64, error)

DeleteCategories delete categories of the current user

func (*Registry) DeleteCategory

func (reg *Registry) DeleteCategory(ctx context.Context, id uint) (*model.Category, error)

DeleteCategory delete a category of the current user

func (*Registry) DeleteDevice

func (reg *Registry) DeleteDevice(ctx context.Context, id uint) (*model.Device, error)

DeleteDevice delete a device of the current user

func (*Registry) DeleteDevices

func (reg *Registry) DeleteDevices(ctx context.Context, ids []uint) (int64, error)

DeleteDevices delete devices of the current user

func (*Registry) DeleteIncomingWebhook

func (reg *Registry) DeleteIncomingWebhook(ctx context.Context, id uint) (*model.IncomingWebhook, error)

DeleteIncomingWebhook delete an incoming webhook of the current user

func (*Registry) DeleteIncomingWebhooks

func (reg *Registry) DeleteIncomingWebhooks(ctx context.Context, ids []uint) (int64, error)

DeleteIncomingWebhooks delete incoming webhooks of the current user

func (*Registry) DeleteOutgoingWebhook

func (reg *Registry) DeleteOutgoingWebhook(ctx context.Context, id uint) (*model.OutgoingWebhook, error)

DeleteOutgoingWebhook delete an outgoing webhook of the current user

func (*Registry) DeleteOutgoingWebhooks

func (reg *Registry) DeleteOutgoingWebhooks(ctx context.Context, ids []uint) (int64, error)

DeleteOutgoingWebhooks delete outgoing webhooks of the current user

func (*Registry) DownloadArticle

func (reg *Registry) DownloadArticle(ctx context.Context, idArticle uint, format string) (*downloader.WebAsset, error)

DownloadArticle get article as a binary file

func (*Registry) GetArticle

func (reg *Registry) GetArticle(ctx context.Context, id uint) (*model.Article, error)

GetArticle get article

func (*Registry) GetArticles

GetArticles get articles

func (*Registry) GetCategories

func (reg *Registry) GetCategories(ctx context.Context) ([]model.Category, error)

GetCategories get categories from current user

func (*Registry) GetCategory

func (reg *Registry) GetCategory(ctx context.Context, id uint) (*model.Category, error)

GetCategory get a category of the current user

func (*Registry) GetCurrentUser

func (reg *Registry) GetCurrentUser(ctx context.Context) (*model.User, error)

GetCurrentUser get current user

func (*Registry) GetCurrentUserPlan

func (reg *Registry) GetCurrentUserPlan(ctx context.Context) (*config.UserPlan, error)

GetCurrentUserPlan get current user plan

func (*Registry) GetDevice

func (reg *Registry) GetDevice(ctx context.Context, id uint) (*model.Device, error)

GetDevice get a device of the current user

func (*Registry) GetDevices

func (reg *Registry) GetDevices(ctx context.Context) (*[]model.Device, error)

GetDevices get devices from current user

func (*Registry) GetIncomingWebhook

func (reg *Registry) GetIncomingWebhook(ctx context.Context, id uint) (*model.IncomingWebhook, error)

GetIncomingWebhook get an incoming webhook of the current user

func (*Registry) GetIncomingWebhookByAlias

func (reg *Registry) GetIncomingWebhookByAlias(ctx context.Context, alias string) (*model.IncomingWebhook, error)

GetIncomingWebhookByAlias get an incoming webhook of the current user

func (*Registry) GetIncomingWebhookByToken

func (reg *Registry) GetIncomingWebhookByToken(token string) (*model.IncomingWebhook, error)

GetIncomingWebhookByToken returns an incoming webhook by its token

func (*Registry) GetIncomingWebhooks

func (reg *Registry) GetIncomingWebhooks(ctx context.Context) (*[]model.IncomingWebhook, error)

GetIncomingWebhooks get incoming webhook from current user

func (*Registry) GetOrRegisterUser

func (reg *Registry) GetOrRegisterUser(ctx context.Context, username string) (*model.User, error)

GetOrRegisterUser get an existing user or creates new one

func (*Registry) GetOutgoingWebhook

func (reg *Registry) GetOutgoingWebhook(ctx context.Context, id uint) (*model.OutgoingWebhook, error)

GetOutgoingWebhook get an outgoing webhook of the current user

func (*Registry) GetOutgoingWebhooks

func (reg *Registry) GetOutgoingWebhooks(ctx context.Context) (*[]model.OutgoingWebhook, error)

GetOutgoingWebhooks get outgoing webhooks from current user

func (*Registry) GetProperties

func (reg *Registry) GetProperties() model.Properties

GetProperties retrieve service properties

func (*Registry) GetUserByHashID

func (reg *Registry) GetUserByHashID(ctx context.Context, hashid string) (*model.User, error)

GetUserByHashID get user by hash ID

func (*Registry) GetUserByID

func (reg *Registry) GetUserByID(ctx context.Context, uid uint) (*model.User, error)

GetUserByID get user by id

func (*Registry) GetUserByUsername

func (reg *Registry) GetUserByUsername(ctx context.Context, username string) (*model.User, error)

GetUserByUsername get user by username

func (*Registry) GetUserHashID

func (reg *Registry) GetUserHashID(uid uint) string

GetUserHashID returns user hashid

func (*Registry) GetUserPlans

func (reg *Registry) GetUserPlans() []config.UserPlan

GetUserPlans returns user plans

func (*Registry) MarkAllArticlesAsRead

func (reg *Registry) MarkAllArticlesAsRead(ctx context.Context, status string, categoryID *uint) (int64, error)

MarkAllArticlesAsRead set status to read for all user's articles of a specific status and category

func (*Registry) NotifyDevices

func (reg *Registry) NotifyDevices(ctx context.Context, payload *model.DeviceNotification) (int, error)

NotifyDevices send a notification to all user devices

func (*Registry) SendArticle

func (reg *Registry) SendArticle(ctx context.Context, idArticle uint, alias *string) (*webhook.Result, error)

SendArticle send an article to outgoing webhook

func (*Registry) UpdateArticle

func (reg *Registry) UpdateArticle(ctx context.Context, form model.ArticleUpdateForm) (*model.Article, error)

UpdateArticle update article

func (*Registry) UpdateCategory

func (reg *Registry) UpdateCategory(ctx context.Context, form model.CategoryUpdateForm) (*model.Category, error)

UpdateCategory update a category for current user

func (*Registry) UpdateIncomingWebhook

func (reg *Registry) UpdateIncomingWebhook(ctx context.Context, form model.IncomingWebhookUpdateForm) (*model.IncomingWebhook, error)

UpdateIncomingWebhook update an incoming webhook for current user

func (*Registry) UpdateOutgoingWebhook

func (reg *Registry) UpdateOutgoingWebhook(ctx context.Context, form model.OutgoingWebhookUpdateForm) (*model.OutgoingWebhook, error)

UpdateOutgoingWebhook update an outgoing webhook for current user

func (*Registry) UpdateUser

func (reg *Registry) UpdateUser(ctx context.Context, form model.UserForm) (*model.User, error)

UpdateUser update user account (required admin access)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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