settings

package
v0.0.0-...-31110fa Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TokenExpiration = 7 * 24 * time.Hour

Variables

View Source
var (
	ErrInvalidType    = errors.New("invalid type")
	ErrInvalidID      = errors.New("invalid id")
	ErrNoPendingEmail = errors.New("no pending email")
)

Functions

func PublicName deprecated

func PublicName(db prefixer.Prefixer) (string, error)

PublicName returns the settings' public name or a default one if missing

Deprecated: Use [Service.PublicName] instead.

func SettingsDocument deprecated

func SettingsDocument(inst prefixer.Prefixer) (*couchdb.JSONDoc, error)

SettingsDocument returns the document with the settings of this instance

Deprecated: Use [Service.GetInstanceSettings] instead.

Types

type CouchdbStorage

type CouchdbStorage struct {
}

CouchdbStorage handle all the settings data in couchdb.

func NewCouchdbStorage

func NewCouchdbStorage() *CouchdbStorage

NewCouchdbStorage instantiates a new CouchdbStorage.

type ExternalTies

type ExternalTies struct {
	HasBlockingSubscription bool                           `json:"has_blocking_subscription"`
	BlockingSubscription    *cloudery.BlockingSubscription `json:"blocking_subscription,omitempty"`
}

type Mock

type Mock struct {
	mock.Mock
}

Mock implementation of Service.

func NewServiceMock

func NewServiceMock(t *testing.T) *Mock

NewServiceMock instantiates a new Mock.

func (*Mock) CancelEmailUpdate

func (m *Mock) CancelEmailUpdate(inst *instance.Instance) error

CancelEmailUpdate mock method.

func (*Mock) ConfirmEmailUpdate

func (m *Mock) ConfirmEmailUpdate(inst *instance.Instance, tok string) error

ConfirmEmailUpdate mock method.

func (*Mock) GetExternalTies

func (m *Mock) GetExternalTies(inst *instance.Instance) (*ExternalTies, error)

func (*Mock) GetInstanceSettings

func (m *Mock) GetInstanceSettings(db prefixer.Prefixer) (*couchdb.JSONDoc, error)

GetInstanceSettings mock method.

func (*Mock) PublicName

func (m *Mock) PublicName(db prefixer.Prefixer) (string, error)

PublicName mock method.

func (*Mock) ResendEmailUpdate

func (m *Mock) ResendEmailUpdate(inst *instance.Instance) error

ResendEmailUpdate mock method.

func (*Mock) SetInstanceSettings

func (m *Mock) SetInstanceSettings(db prefixer.Prefixer, doc *couchdb.JSONDoc) error

SetInstanceSettings mock method.

func (*Mock) StartEmailUpdate

func (m *Mock) StartEmailUpdate(inst *instance.Instance, cmd *UpdateEmailCmd) error

StartEmailUpdate mock method.

type Service

type Service interface {
	PublicName(db prefixer.Prefixer) (string, error)
	GetInstanceSettings(inst prefixer.Prefixer) (*couchdb.JSONDoc, error)
	SetInstanceSettings(inst prefixer.Prefixer, doc *couchdb.JSONDoc) error
	StartEmailUpdate(inst *instance.Instance, cmd *UpdateEmailCmd) error
	ResendEmailUpdate(inst *instance.Instance) error
	ConfirmEmailUpdate(inst *instance.Instance, tok string) error
	CancelEmailUpdate(inst *instance.Instance) error
	GetExternalTies(inst *instance.Instance) (*ExternalTies, error)
}

type SettingsService

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

SettingsService handle the business logic around "settings".

This service handle 2 structured documents present in consts.Settings - The "instance settings" (consts.InstanceSettingsID) - The "bitwarden settings" (consts.BitwardenSettingsID) (#TODO)

func Init

func Init(
	emailer emailer.Emailer,
	instance instance.Service,
	token token.Service,
	cloudery cloudery.Service,
) *SettingsService

func NewService

func NewService(
	emailer emailer.Emailer,
	instance instance.Service,
	token token.Service,
	cloudery cloudery.Service,
	storage Storage,
) *SettingsService

NewService instantiates a new SettingsService.

func (*SettingsService) CancelEmailUpdate

func (s *SettingsService) CancelEmailUpdate(inst *instance.Instance) error

CancelEmailUpdate cancel any ongoing email update process

If no process is ongoin it's a no-op.

func (*SettingsService) ConfirmEmailUpdate

func (s *SettingsService) ConfirmEmailUpdate(inst *instance.Instance, tok string) error

ConfirmEmailUpdate is the second step to the email update process.

This step consiste to make the email change effectif and relay the change into the cloudery.

func (*SettingsService) GetExternalTies

func (s *SettingsService) GetExternalTies(inst *instance.Instance) (*ExternalTies, error)

func (*SettingsService) GetInstanceSettings

func (s *SettingsService) GetInstanceSettings(db prefixer.Prefixer) (*couchdb.JSONDoc, error)

GetInstanceSettings allows for fetch directly the consts.InstanceSettingsID couchdb document.

func (*SettingsService) PublicName

func (s *SettingsService) PublicName(db prefixer.Prefixer) (string, error)

PublicName returns the settings' public name or a default one if missing

func (*SettingsService) ResendEmailUpdate

func (s *SettingsService) ResendEmailUpdate(inst *instance.Instance) error

ResendEmailUpdate will resend the validation email.

func (*SettingsService) SetInstanceSettings

func (s *SettingsService) SetInstanceSettings(db prefixer.Prefixer, doc *couchdb.JSONDoc) error

SetInstanceSettings allows a set directly the consts.InstanceSettingsID couchdb document.

func (*SettingsService) StartEmailUpdate

func (s *SettingsService) StartEmailUpdate(inst *instance.Instance, cmd *UpdateEmailCmd) error

StartEmailUpdate will start the email updating process.

This process consists of validating the user with a password and sending a validation email to the new address with a validation link. This link will allow the user to confirm its email.

type Storage

type Storage interface {
	// contains filtered or unexported methods
}

Storage used to persiste and fetch settings data.

type UpdateEmailCmd

type UpdateEmailCmd struct {
	Passphrase []byte
	Email      string
}

Jump to

Keyboard shortcuts

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