Documentation ¶
Index ¶
- func ToTSQuery(input string) string
- type NotificationStorage
- func (s *NotificationStorage) GetActiveNotifications() ([]*models.Notification, error)
- func (s *NotificationStorage) GetNotification(id int) (*models.Notification, error)
- func (s *NotificationStorage) Insert(user *models.User, title, link string, postID int) (*models.Notification, error)
- func (s *NotificationStorage) MarkAllAsRead() error
- func (s *NotificationStorage) MarkAsRead(id int) error
- func (s *NotificationStorage) SetCurrentTenant(tenant *models.Tenant)
- func (s *NotificationStorage) SetCurrentUser(user *models.User)
- func (s *NotificationStorage) TotalUnread() (int, error)
- type PostStorage
- func (s *PostStorage) Add(title, description string) (*models.Post, error)
- func (s *PostStorage) AddComment(post *models.Post, content string) (int, error)
- func (s *PostStorage) AddSubscriber(post *models.Post, user *models.User) error
- func (s *PostStorage) AddSupporter(post *models.Post, user *models.User) error
- func (s *PostStorage) CountPerStatus() (map[int]int, error)
- func (s *PostStorage) GetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error)
- func (s *PostStorage) GetAll() ([]*models.Post, error)
- func (s *PostStorage) GetByID(postID int) (*models.Post, error)
- func (s *PostStorage) GetByNumber(number int) (*models.Post, error)
- func (s *PostStorage) GetBySlug(slug string) (*models.Post, error)
- func (s *PostStorage) GetCommentByID(id int) (*models.Comment, error)
- func (s *PostStorage) GetCommentsByPost(post *models.Post) ([]*models.Comment, error)
- func (s *PostStorage) IsReferenced(post *models.Post) (bool, error)
- func (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post) error
- func (s *PostStorage) RemoveSubscriber(post *models.Post, user *models.User) error
- func (s *PostStorage) RemoveSupporter(post *models.Post, user *models.User) error
- func (s *PostStorage) Search(query, filter, limit string, tags []string) ([]*models.Post, error)
- func (s *PostStorage) SetCurrentTenant(tenant *models.Tenant)
- func (s *PostStorage) SetCurrentUser(user *models.User)
- func (s *PostStorage) SetResponse(post *models.Post, text string, status int) error
- func (s *PostStorage) SupportedBy() ([]int, error)
- func (s *PostStorage) Update(post *models.Post, title, description string) (*models.Post, error)
- func (s *PostStorage) UpdateComment(id int, content string) error
- type TagStorage
- func (s *TagStorage) Add(name, color string, isPublic bool) (*models.Tag, error)
- func (s *TagStorage) AssignTag(tag *models.Tag, post *models.Post) error
- func (s *TagStorage) Delete(tag *models.Tag) error
- func (s *TagStorage) GetAll() ([]*models.Tag, error)
- func (s *TagStorage) GetAssigned(post *models.Post) ([]*models.Tag, error)
- func (s *TagStorage) GetBySlug(slug string) (*models.Tag, error)
- func (s *TagStorage) SetCurrentTenant(tenant *models.Tenant)
- func (s *TagStorage) SetCurrentUser(user *models.User)
- func (s *TagStorage) UnassignTag(tag *models.Tag, post *models.Post) error
- func (s *TagStorage) Update(tag *models.Tag, name, color string, isPublic bool) (*models.Tag, error)
- type TenantStorage
- func (s *TenantStorage) Activate(id int) error
- func (s *TenantStorage) Add(name string, subdomain string, status int) (*models.Tenant, error)
- func (s *TenantStorage) FindVerificationByKey(kind models.EmailVerificationKind, key string) (*models.EmailVerification, error)
- func (s *TenantStorage) First() (*models.Tenant, error)
- func (s *TenantStorage) GetByDomain(domain string) (*models.Tenant, error)
- func (s *TenantStorage) GetOAuthConfigByProvider(provider string) (*models.OAuthConfig, error)
- func (s *TenantStorage) GetUpload(id int) (*models.Upload, error)
- func (s *TenantStorage) IsCNAMEAvailable(cname string) (bool, error)
- func (s *TenantStorage) IsSubdomainAvailable(subdomain string) (bool, error)
- func (s *TenantStorage) ListOAuthConfig() ([]*models.OAuthConfig, error)
- func (s *TenantStorage) SaveNewUpload(content []byte) (int, error)
- func (s *TenantStorage) SaveOAuthConfig(config *models.CreateEditOAuthConfig) error
- func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration, request models.NewEmailVerification) error
- func (s *TenantStorage) SetCurrentTenant(tenant *models.Tenant)
- func (s *TenantStorage) SetCurrentUser(user *models.User)
- func (s *TenantStorage) SetKeyAsVerified(key string) error
- func (s *TenantStorage) UpdateAdvancedSettings(settings *models.UpdateTenantAdvancedSettings) error
- func (s *TenantStorage) UpdatePrivacy(settings *models.UpdateTenantPrivacy) error
- func (s *TenantStorage) UpdateSettings(settings *models.UpdateTenantSettings) error
- type UserStorage
- func (s *UserStorage) ChangeEmail(userID int, email string) error
- func (s *UserStorage) ChangeRole(userID int, role models.Role) error
- func (s *UserStorage) Delete() error
- func (s *UserStorage) GetAll() ([]*models.User, error)
- func (s *UserStorage) GetByAPIKey(apiKey string) (*models.User, error)
- func (s *UserStorage) GetByEmail(email string) (*models.User, error)
- func (s *UserStorage) GetByID(userID int) (*models.User, error)
- func (s *UserStorage) GetByProvider(provider string, uid string) (*models.User, error)
- func (s *UserStorage) GetUserSettings() (map[string]string, error)
- func (s *UserStorage) HasSubscribedTo(postID int) (bool, error)
- func (s *UserStorage) RegenerateAPIKey() (string, error)
- func (s *UserStorage) Register(user *models.User) error
- func (s *UserStorage) RegisterProvider(userID int, provider *models.UserProvider) error
- func (s *UserStorage) SetCurrentTenant(tenant *models.Tenant)
- func (s *UserStorage) SetCurrentUser(user *models.User)
- func (s *UserStorage) Update(settings *models.UpdateUserSettings) error
- func (s *UserStorage) UpdateSettings(settings map[string]string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type NotificationStorage ¶ added in v0.10.0
type NotificationStorage struct {
// contains filtered or unexported fields
}
NotificationStorage contains read and write operations for notifications
func NewNotificationStorage ¶ added in v0.10.0
func NewNotificationStorage(trx *dbx.Trx) *NotificationStorage
NewNotificationStorage creates a new NotificationStorage
func (*NotificationStorage) GetActiveNotifications ¶ added in v0.10.0
func (s *NotificationStorage) GetActiveNotifications() ([]*models.Notification, error)
GetActiveNotifications returns all unread notifications and last 30 days of read notifications
func (*NotificationStorage) GetNotification ¶ added in v0.10.0
func (s *NotificationStorage) GetNotification(id int) (*models.Notification, error)
GetNotification returns notification by id
func (*NotificationStorage) Insert ¶ added in v0.10.0
func (s *NotificationStorage) Insert(user *models.User, title, link string, postID int) (*models.Notification, error)
Insert notification for given user
func (*NotificationStorage) MarkAllAsRead ¶ added in v0.10.0
func (s *NotificationStorage) MarkAllAsRead() error
MarkAllAsRead of current user
func (*NotificationStorage) MarkAsRead ¶ added in v0.10.0
func (s *NotificationStorage) MarkAsRead(id int) error
MarkAsRead given id of current user
func (*NotificationStorage) SetCurrentTenant ¶ added in v0.10.0
func (s *NotificationStorage) SetCurrentTenant(tenant *models.Tenant)
SetCurrentTenant to current context
func (*NotificationStorage) SetCurrentUser ¶ added in v0.10.0
func (s *NotificationStorage) SetCurrentUser(user *models.User)
SetCurrentUser to current context
func (*NotificationStorage) TotalUnread ¶ added in v0.10.0
func (s *NotificationStorage) TotalUnread() (int, error)
TotalUnread returns the number of unread notifications for current user
type PostStorage ¶ added in v0.15.0
type PostStorage struct {
// contains filtered or unexported fields
}
PostStorage contains read and write operations for posts
func NewPostStorage ¶ added in v0.15.0
func NewPostStorage(trx *dbx.Trx) *PostStorage
NewPostStorage creates a new PostStorage
func (*PostStorage) Add ¶ added in v0.15.0
func (s *PostStorage) Add(title, description string) (*models.Post, error)
Add a new post in the database
func (*PostStorage) AddComment ¶ added in v0.15.0
AddComment places a new comment on an post
func (*PostStorage) AddSubscriber ¶ added in v0.15.0
AddSubscriber adds user to the post list of subscribers
func (*PostStorage) AddSupporter ¶ added in v0.15.0
AddSupporter adds user to post list of supporters
func (*PostStorage) CountPerStatus ¶ added in v0.15.0
func (s *PostStorage) CountPerStatus() (map[int]int, error)
CountPerStatus returns total number of posts per status
func (*PostStorage) GetActiveSubscribers ¶ added in v0.15.0
func (s *PostStorage) GetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error)
GetActiveSubscribers based on input and settings
func (*PostStorage) GetAll ¶ added in v0.15.0
func (s *PostStorage) GetAll() ([]*models.Post, error)
GetAll returns all tenant posts
func (*PostStorage) GetByID ¶ added in v0.15.0
func (s *PostStorage) GetByID(postID int) (*models.Post, error)
GetByID returns post by given id
func (*PostStorage) GetByNumber ¶ added in v0.15.0
func (s *PostStorage) GetByNumber(number int) (*models.Post, error)
GetByNumber returns post by tenant and number
func (*PostStorage) GetBySlug ¶ added in v0.15.0
func (s *PostStorage) GetBySlug(slug string) (*models.Post, error)
GetBySlug returns post by tenant and slug
func (*PostStorage) GetCommentByID ¶ added in v0.15.0
func (s *PostStorage) GetCommentByID(id int) (*models.Comment, error)
GetCommentByID returns a comment by given ID
func (*PostStorage) GetCommentsByPost ¶ added in v0.15.0
GetCommentsByPost returns all comments from given post
func (*PostStorage) IsReferenced ¶ added in v0.15.0
func (s *PostStorage) IsReferenced(post *models.Post) (bool, error)
IsReferenced returns true if another post is referencing given post
func (*PostStorage) MarkAsDuplicate ¶ added in v0.15.0
MarkAsDuplicate set post as a duplicate of another post
func (*PostStorage) RemoveSubscriber ¶ added in v0.15.0
RemoveSubscriber removes user from post list of subscribers
func (*PostStorage) RemoveSupporter ¶ added in v0.15.0
RemoveSupporter removes user from post list of supporters
func (*PostStorage) SetCurrentTenant ¶ added in v0.15.0
func (s *PostStorage) SetCurrentTenant(tenant *models.Tenant)
SetCurrentTenant to current context
func (*PostStorage) SetCurrentUser ¶ added in v0.15.0
func (s *PostStorage) SetCurrentUser(user *models.User)
SetCurrentUser to current context
func (*PostStorage) SetResponse ¶ added in v0.15.0
SetResponse changes current post response
func (*PostStorage) SupportedBy ¶ added in v0.15.0
func (s *PostStorage) SupportedBy() ([]int, error)
SupportedBy returns a list of Post ID supported by given user
func (*PostStorage) UpdateComment ¶ added in v0.15.0
func (s *PostStorage) UpdateComment(id int, content string) error
UpdateComment with given ID and content
type TagStorage ¶ added in v0.8.0
type TagStorage struct {
// contains filtered or unexported fields
}
TagStorage contains read and write operations for tags
func NewTagStorage ¶ added in v0.8.0
func NewTagStorage(trx *dbx.Trx) *TagStorage
NewTagStorage creates a new TagStorage
func (*TagStorage) Delete ¶ added in v0.8.0
func (s *TagStorage) Delete(tag *models.Tag) error
Delete a tag by its id
func (*TagStorage) GetAll ¶ added in v0.8.0
func (s *TagStorage) GetAll() ([]*models.Tag, error)
GetAll returns all tags
func (*TagStorage) GetAssigned ¶ added in v0.8.0
GetAssigned returns all tags assigned to given post
func (*TagStorage) GetBySlug ¶ added in v0.8.0
func (s *TagStorage) GetBySlug(slug string) (*models.Tag, error)
GetBySlug returns tag by given slug
func (*TagStorage) SetCurrentTenant ¶ added in v0.8.0
func (s *TagStorage) SetCurrentTenant(tenant *models.Tenant)
SetCurrentTenant to current context
func (*TagStorage) SetCurrentUser ¶ added in v0.8.0
func (s *TagStorage) SetCurrentUser(user *models.User)
SetCurrentUser to current context
func (*TagStorage) UnassignTag ¶ added in v0.8.0
UnassignTag removes a tag from an post
type TenantStorage ¶
type TenantStorage struct {
// contains filtered or unexported fields
}
TenantStorage contains read and write operations for tenants
func NewTenantStorage ¶
func NewTenantStorage(trx *dbx.Trx) *TenantStorage
NewTenantStorage creates a new TenantStorage
func (*TenantStorage) Activate ¶ added in v0.6.0
func (s *TenantStorage) Activate(id int) error
Activate given tenant
func (*TenantStorage) FindVerificationByKey ¶ added in v0.6.0
func (s *TenantStorage) FindVerificationByKey(kind models.EmailVerificationKind, key string) (*models.EmailVerification, error)
FindVerificationByKey based on current tenant
func (*TenantStorage) First ¶
func (s *TenantStorage) First() (*models.Tenant, error)
First returns first tenant
func (*TenantStorage) GetByDomain ¶
func (s *TenantStorage) GetByDomain(domain string) (*models.Tenant, error)
GetByDomain returns a tenant based on its domain
func (*TenantStorage) GetOAuthConfigByProvider ¶ added in v0.15.0
func (s *TenantStorage) GetOAuthConfigByProvider(provider string) (*models.OAuthConfig, error)
GetOAuthConfigByProvider returns a custom OAuth configuration by provider name
func (*TenantStorage) GetUpload ¶ added in v0.15.0
func (s *TenantStorage) GetUpload(id int) (*models.Upload, error)
GetUpload returns upload by id
func (*TenantStorage) IsCNAMEAvailable ¶ added in v0.8.0
func (s *TenantStorage) IsCNAMEAvailable(cname string) (bool, error)
IsCNAMEAvailable returns true if cname is available to use
func (*TenantStorage) IsSubdomainAvailable ¶
func (s *TenantStorage) IsSubdomainAvailable(subdomain string) (bool, error)
IsSubdomainAvailable returns true if subdomain is available to use
func (*TenantStorage) ListOAuthConfig ¶ added in v0.15.0
func (s *TenantStorage) ListOAuthConfig() ([]*models.OAuthConfig, error)
ListOAuthConfig returns a list of all custom OAuth provider for current tenant
func (*TenantStorage) SaveNewUpload ¶ added in v0.15.0
func (s *TenantStorage) SaveNewUpload(content []byte) (int, error)
SaveNewUpload saves given content and return upload id
func (*TenantStorage) SaveOAuthConfig ¶ added in v0.15.0
func (s *TenantStorage) SaveOAuthConfig(config *models.CreateEditOAuthConfig) error
SaveOAuthConfig saves given config into database
func (*TenantStorage) SaveVerificationKey ¶ added in v0.6.0
func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration, request models.NewEmailVerification) error
SaveVerificationKey used by email verification process
func (*TenantStorage) SetCurrentTenant ¶ added in v0.6.0
func (s *TenantStorage) SetCurrentTenant(tenant *models.Tenant)
SetCurrentTenant to current context
func (*TenantStorage) SetCurrentUser ¶ added in v0.8.0
func (s *TenantStorage) SetCurrentUser(user *models.User)
SetCurrentUser to current context
func (*TenantStorage) SetKeyAsVerified ¶ added in v0.6.0
func (s *TenantStorage) SetKeyAsVerified(key string) error
SetKeyAsVerified so that it cannot be used anymore
func (*TenantStorage) UpdateAdvancedSettings ¶ added in v0.13.0
func (s *TenantStorage) UpdateAdvancedSettings(settings *models.UpdateTenantAdvancedSettings) error
UpdateAdvancedSettings of current tenant
func (*TenantStorage) UpdatePrivacy ¶ added in v0.12.0
func (s *TenantStorage) UpdatePrivacy(settings *models.UpdateTenantPrivacy) error
UpdatePrivacy settings of current tenant
func (*TenantStorage) UpdateSettings ¶ added in v0.4.0
func (s *TenantStorage) UpdateSettings(settings *models.UpdateTenantSettings) error
UpdateSettings of current tenant
type UserStorage ¶
type UserStorage struct {
// contains filtered or unexported fields
}
UserStorage is used for user operations using a Postgres database
func NewUserStorage ¶
func NewUserStorage(trx *dbx.Trx) *UserStorage
NewUserStorage creates a new UserStorage
func (*UserStorage) ChangeEmail ¶ added in v0.9.0
func (s *UserStorage) ChangeEmail(userID int, email string) error
ChangeEmail of given user
func (*UserStorage) ChangeRole ¶ added in v0.7.0
func (s *UserStorage) ChangeRole(userID int, role models.Role) error
ChangeRole of given user
func (*UserStorage) Delete ¶ added in v0.13.0
func (s *UserStorage) Delete() error
Delete removes current user personal data and mark it as deleted
func (*UserStorage) GetAll ¶ added in v0.7.0
func (s *UserStorage) GetAll() ([]*models.User, error)
GetAll return all users of current tenant
func (*UserStorage) GetByAPIKey ¶ added in v0.15.0
func (s *UserStorage) GetByAPIKey(apiKey string) (*models.User, error)
GetByAPIKey returns a user based on its API key
func (*UserStorage) GetByEmail ¶
func (s *UserStorage) GetByEmail(email string) (*models.User, error)
GetByEmail returns a user based on given email
func (*UserStorage) GetByID ¶
func (s *UserStorage) GetByID(userID int) (*models.User, error)
GetByID returns a user based on given id
func (*UserStorage) GetByProvider ¶ added in v0.4.0
GetByProvider returns a user based on provider details
func (*UserStorage) GetUserSettings ¶ added in v0.10.0
func (s *UserStorage) GetUserSettings() (map[string]string, error)
GetUserSettings returns current user's settings
func (*UserStorage) HasSubscribedTo ¶ added in v0.10.0
func (s *UserStorage) HasSubscribedTo(postID int) (bool, error)
HasSubscribedTo returns true if current user is receiving notification from specific post
func (*UserStorage) RegenerateAPIKey ¶ added in v0.15.0
func (s *UserStorage) RegenerateAPIKey() (string, error)
RegenerateAPIKey generates a new API Key and returns it
func (*UserStorage) Register ¶
func (s *UserStorage) Register(user *models.User) error
Register creates a new user based on given information
func (*UserStorage) RegisterProvider ¶
func (s *UserStorage) RegisterProvider(userID int, provider *models.UserProvider) error
RegisterProvider adds given provider to userID
func (*UserStorage) SetCurrentTenant ¶ added in v0.8.0
func (s *UserStorage) SetCurrentTenant(tenant *models.Tenant)
SetCurrentTenant to current context
func (*UserStorage) SetCurrentUser ¶ added in v0.8.0
func (s *UserStorage) SetCurrentUser(user *models.User)
SetCurrentUser to current context
func (*UserStorage) Update ¶ added in v0.6.0
func (s *UserStorage) Update(settings *models.UpdateUserSettings) error
Update user profile
func (*UserStorage) UpdateSettings ¶ added in v0.10.0
func (s *UserStorage) UpdateSettings(settings map[string]string) error
UpdateSettings of given user