repo

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package repo consists of repositories, i.e. services which are a layer of abstraction over plain SQL queries.

Index

Constants

This section is empty.

Variables

View Source
var NoRowsWereAffected = errors.New("no rows were affected")

Functions

This section is empty.

Types

type ApprovalService

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

ApprovalService is a repository for the Approvals table.

func NewApprovalService

func NewApprovalService(appEnv *base.ApplicationEnv) *ApprovalService

func (*ApprovalService) Approve

func (service *ApprovalService) Approve(msg *dto.Message, approverUID int64) error

Approve creates a new approval in the database.

func (*ApprovalService) GetApprovers

func (service *ApprovalService) GetApprovers(msg *dto.Message) ([]string, error)

GetApprovers retrieves the list of all authors approved the message.

type SuggestionService

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

SuggestionService is a repository for the Suggestions table.

func NewSuggestionService

func NewSuggestionService(appEnv *base.ApplicationEnv) *SuggestionService

func (*SuggestionService) Create

func (service *SuggestionService) Create(msg *dto.Message, anonymously bool) error

Create a new suggestion with a reference to the message.

func (*SuggestionService) Get

func (service *SuggestionService) Get(msg *dto.Message) (*dto.Suggestion, error)

Get full information about the referenced message.

func (*SuggestionService) Publish

func (service *SuggestionService) Publish(msg *dto.Message) error

Publish updates the row. It returns an error if the suggestion was already revoked or published.

func (*SuggestionService) Revoke

func (service *SuggestionService) Revoke(msg *dto.Message) error

Revoke updates the row. It returns an error if the suggestion was already published or revoked.

type UserService

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

UserService is a repository for the Users table.

func NewUserService

func NewUserService(appEnv *base.ApplicationEnv) *UserService

func (*UserService) Ban

func (service *UserService) Ban(uid int64) error

func (*UserService) ChangeLanguage

func (service *UserService) ChangeLanguage(uid int64, lang settings.LangCode) error

func (*UserService) Create

func (service *UserService) Create(uid int64, name string) error

Create a new user in the database. The NoRowsWereAffected error will be returned if he already exists.

func (*UserService) FetchUserOptions

func (service *UserService) FetchUserOptions(uid int64, defaultLang string) (settings.LangCode, settings.UserOptions)

FetchUserOptions is the implementation of the settings.OptionsFetcher.FetchUserOptions method for this application.

func (*UserService) Get

func (service *UserService) Get(uid int64) (*dto.User, error)

func (*UserService) GetThemAll added in v0.1.3

func (service *UserService) GetThemAll(uids []int64) ([]*dto.User, error)

func (*UserService) Promote

func (service *UserService) Promote(uid int64, role dto.UserRole) error

Promote is the method to change the role of some user. If there is no such user, NoRowsWereAffected is returned.

func (*UserService) Unban

func (service *UserService) Unban(uid int64) error

func (*UserService) UpdateName

func (service *UserService) UpdateName(uid int64, name string) error

Jump to

Keyboard shortcuts

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