shared

package
v0.0.0-...-b289748 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Shared

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

func NewShared

func NewShared(sa SharedArgs) *Shared

func (*Shared) AddTags

func (s *Shared) AddTags(ctx context.Context, tx pgx.Tx, table, keyName string, keyVal any, tags []string, ignoreDups bool) error

func (*Shared) CredDel

func (s *Shared) CredDel(ctx context.Context, tx pgx.Tx, uid types.Uid, method, value string) error

CredDel deletes given validation method or all methods of the given user.

1. If user is being deleted, hard-delete all records (method == "")

2. If one value is being deleted:

2.1 Delete it if it's valiated or if there were no attempts at validation

(otherwise it could be used to circumvent the limit on validation attempts).

2.2 In that case mark it as soft-deleted.

func (*Shared) DecodeUidString

func (s *Shared) DecodeUidString(str string) int64

func (*Shared) DeviceDelete

func (s *Shared) DeviceDelete(ctx context.Context, tx pgx.Tx, uid types.Uid, deviceID string) error

func (*Shared) DeviceHasher

func (s *Shared) DeviceHasher(devID string) string

func (*Shared) ExpandQuery

func (s *Shared) ExpandQuery(query string, args ...any) (string, []any)

ExpandQuery() converts query strings like: 'where arg = ? AND arg2 = ? ...' to

a query that can be used with pgx library like: 'where arg = $1 AND arg2 = $2 ...'

func (*Shared) ExtractTags

func (s *Shared) ExtractTags(update map[string]any) []string

If Tags field is updated, get the tags so tags table cab be updated too.

func (*Shared) IsDupe

func (s *Shared) IsDupe(err error) bool

Check if Postgres error is an Error Code: 1062. Duplicate entry ... for key ...

func (*Shared) MessageDeleteList

func (s *Shared) MessageDeleteList(ctx context.Context, tx pgx.Tx, topic string, toDel *types.DelMessage) error

func (*Shared) SubDelForUser

func (s *Shared) SubDelForUser(ctx context.Context, tx pgx.Tx, uid types.Uid, hard bool) error

SubDelForUser marks user's subscriptions as deleted.

func (*Shared) UpdateByMap

func (s *Shared) UpdateByMap(update map[string]any) (cols []string, args []any)

Convert update to a list of columns and arguments.

type SharedArgs

type SharedArgs struct {
	Utils *utils.Utils
	UGen  *types.UidGenerator
}

Jump to

Keyboard shortcuts

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