Documentation
¶
Index ¶
- Constants
- Variables
- func Configure(conf config.Config, database db.DB, downloadCache cache.Cache) error
- func Shutdown()
- type ArticleCreationOptions
- type Registry
- func (reg *Registry) AddJob(job job.Job)
- func (reg *Registry) CleanHistory(ctx context.Context) (int64, error)
- func (reg *Registry) CountCurrentUserArticles(ctx context.Context, req model.ArticlesPageRequest) (uint, error)
- func (reg *Registry) CountCurrentUserCategories(ctx context.Context) (uint, error)
- func (reg *Registry) CountCurrentUserDevices(ctx context.Context) (uint, error)
- func (reg *Registry) CountUserArticles(ctx context.Context, uid uint, req model.ArticlesPageRequest) (uint, error)
- func (reg *Registry) CreateArticle(ctx context.Context, form model.ArticleCreateForm, opts ArticleCreationOptions) (*model.Article, error)
- func (reg *Registry) CreateArticles(ctx context.Context, data []model.ArticleCreateForm) *model.CreatedArticlesResponse
- func (reg *Registry) CreateCategory(ctx context.Context, form model.CategoryCreateForm) (*model.Category, error)
- func (reg *Registry) CreateDevice(ctx context.Context, sub string) (*model.Device, error)
- func (reg *Registry) CreateIncomingWebhook(ctx context.Context, form model.IncomingWebhookCreateForm) (*model.IncomingWebhook, error)
- func (reg *Registry) CreateOutgoingWebhook(ctx context.Context, form model.OutgoingWebhookCreateForm) (*model.OutgoingWebhook, error)
- func (reg *Registry) DeleteAccount(ctx context.Context) (bool, error)
- func (reg *Registry) DeleteCategories(ctx context.Context, ids []uint) (int64, error)
- func (reg *Registry) DeleteCategory(ctx context.Context, id uint) (*model.Category, error)
- func (reg *Registry) DeleteDevice(ctx context.Context, id uint) (*model.Device, error)
- func (reg *Registry) DeleteDevices(ctx context.Context, ids []uint) (int64, error)
- func (reg *Registry) DeleteIncomingWebhook(ctx context.Context, id uint) (*model.IncomingWebhook, error)
- func (reg *Registry) DeleteIncomingWebhooks(ctx context.Context, ids []uint) (int64, error)
- func (reg *Registry) DeleteOutgoingWebhook(ctx context.Context, id uint) (*model.OutgoingWebhook, error)
- func (reg *Registry) DeleteOutgoingWebhooks(ctx context.Context, ids []uint) (int64, error)
- func (reg *Registry) DownloadArticle(ctx context.Context, idArticle uint, format string) (*downloader.WebAsset, error)
- func (reg *Registry) GetArticle(ctx context.Context, id uint) (*model.Article, error)
- func (reg *Registry) GetArticles(ctx context.Context, req model.ArticlesPageRequest) (*model.ArticlesPageResponse, error)
- func (reg *Registry) GetCategories(ctx context.Context) ([]model.Category, error)
- func (reg *Registry) GetCategory(ctx context.Context, id uint) (*model.Category, error)
- func (reg *Registry) GetConfig() config.Config
- func (reg *Registry) GetCurrentUser(ctx context.Context) (*model.User, error)
- func (reg *Registry) GetCurrentUserPlan(ctx context.Context) (*config.UserPlan, error)
- func (reg *Registry) GetDevice(ctx context.Context, id uint) (*model.Device, error)
- func (reg *Registry) GetDevices(ctx context.Context) (*[]model.Device, error)
- func (reg *Registry) GetIncomingWebhook(ctx context.Context, id uint) (*model.IncomingWebhook, error)
- func (reg *Registry) GetIncomingWebhookByAlias(ctx context.Context, alias string) (*model.IncomingWebhook, error)
- func (reg *Registry) GetIncomingWebhookByToken(token string) (*model.IncomingWebhook, error)
- func (reg *Registry) GetIncomingWebhooks(ctx context.Context) (*[]model.IncomingWebhook, error)
- func (reg *Registry) GetOrRegisterUser(ctx context.Context, username string) (*model.User, error)
- func (reg *Registry) GetOutgoingWebhook(ctx context.Context, id uint) (*model.OutgoingWebhook, error)
- func (reg *Registry) GetOutgoingWebhooks(ctx context.Context) (*[]model.OutgoingWebhook, error)
- func (reg *Registry) GetProperties() model.Properties
- func (reg *Registry) GetUserByHashID(ctx context.Context, hashid string) (*model.User, error)
- func (reg *Registry) GetUserByID(ctx context.Context, uid uint) (*model.User, error)
- func (reg *Registry) GetUserByUsername(ctx context.Context, username string) (*model.User, error)
- func (reg *Registry) GetUserHashID(uid uint) string
- func (reg *Registry) GetUserPlans() []config.UserPlan
- func (reg *Registry) MarkAllArticlesAsRead(ctx context.Context, status string, categoryID *uint) (int64, error)
- func (reg *Registry) NotifyDevices(ctx context.Context, payload *model.DeviceNotification) (int, error)
- func (reg *Registry) SendArticle(ctx context.Context, idArticle uint, alias *string) (*webhook.Result, error)
- func (reg *Registry) UpdateArticle(ctx context.Context, form model.ArticleUpdateForm) (*model.Article, error)
- func (reg *Registry) UpdateCategory(ctx context.Context, form model.CategoryUpdateForm) (*model.Category, error)
- func (reg *Registry) UpdateIncomingWebhook(ctx context.Context, form model.IncomingWebhookUpdateForm) (*model.IncomingWebhook, error)
- func (reg *Registry) UpdateOutgoingWebhook(ctx context.Context, form model.OutgoingWebhookUpdateForm) (*model.OutgoingWebhook, error)
- func (reg *Registry) UpdateUser(ctx context.Context, form model.UserForm) (*model.User, error)
Constants ¶
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" )
const ( // NoNotificationEventOption will disable global notification policy NoNotificationEventOption event.EventOption = 1 << iota // 1 )
Variables ¶
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 ¶
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 (*Registry) CleanHistory ¶
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 ¶
CountCurrentUserCategories get total categories of current user
func (*Registry) CountCurrentUserDevices ¶
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 ¶
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 ¶
DeleteAccount delete current user account
func (*Registry) DeleteCategories ¶
DeleteCategories delete categories of the current user
func (*Registry) DeleteCategory ¶
DeleteCategory delete a category of the current user
func (*Registry) DeleteDevice ¶
DeleteDevice delete a device of the current user
func (*Registry) DeleteDevices ¶
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 ¶
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 ¶
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 ¶
GetArticle get article
func (*Registry) GetArticles ¶
func (reg *Registry) GetArticles(ctx context.Context, req model.ArticlesPageRequest) (*model.ArticlesPageResponse, error)
GetArticles get articles
func (*Registry) GetCategories ¶
GetCategories get categories from current user
func (*Registry) GetCategory ¶
GetCategory get a category of the current user
func (*Registry) GetCurrentUser ¶
GetCurrentUser get current user
func (*Registry) GetCurrentUserPlan ¶
GetCurrentUserPlan get current user plan
func (*Registry) GetDevices ¶
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 ¶
GetIncomingWebhooks get incoming webhook from current user
func (*Registry) GetOrRegisterUser ¶
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 ¶
GetOutgoingWebhooks get outgoing webhooks from current user
func (*Registry) GetProperties ¶
func (reg *Registry) GetProperties() model.Properties
GetProperties retrieve service properties
func (*Registry) GetUserByHashID ¶
GetUserByHashID get user by hash ID
func (*Registry) GetUserByID ¶
GetUserByID get user by id
func (*Registry) GetUserByUsername ¶
GetUserByUsername get user by username
func (*Registry) GetUserHashID ¶
GetUserHashID returns user hashid
func (*Registry) GetUserPlans ¶
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