member

package
v0.8.17-search-ws Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ban added in v0.7.0

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

type BanStatus added in v0.7.0

type BanStatus struct {
	Status BanStatusType `json:"status" db:"status"`
}

BanStatus holds information about a ban It can apply to a member, device or IP address/range

type BanStatusType added in v0.7.0

type BanStatusType string

see https://vladimir.varank.in/notes/2023/09/compile-time-safety-for-enumerations-in-go/

const (
	Current   BanStatusType = "current"
	Expired   BanStatusType = "expired"
	Permanent BanStatusType = "permanent"
	None      BanStatusType = "none"
	Error     BanStatusType = "error"
)

type Device added in v0.7.0

type Device struct {
	FriendlyName sql.NullString `json:"friendlyName,omitempty" db:"friendly_name"`
	// KnownIPs is used to improve the security in case of logging in from unknown locations
	KnownIPs  []net.IP  `json:"knownIPs,omitempty" db:"known_ips"`
	LastLogin time.Time `json:"lastLogin,omitempty" db:"last_login"`
	BanStatus BanStatus `json:"banStatus,omitempty" db:"ban_status"`
	ID        uuid.UUID `json:"id" db:"id,unique,notnull"`
}

Member holds the core information about a member

type FollowRequest

type FollowRequest struct {
	ID        int64  `json:"id" db:"id"`
	ActorID   string `json:"actor_id" db:"actor_id"`
	FollowsID string `json:"follows_id" db:"follows_id"`
}

Member holds the core information about a member

type Follower

type Follower struct {
	ID       uint32 `json:"id" db:"id"`
	Follower uint32 `json:"follower" db:"follower"`
	Followee uint32 `json:"followee" db:"followee"`
}

Follower represents a follower-followee relationship

type Input

type Input struct {
	MemberName string `json:"membername"`
	Email      string `json:"email"`
	Password   string `json:"password"`
}

Input holds the information required to create a new member account

type Member

type Member struct {
	ID               int            `json:"-" db:"id"`
	UUID             uuid.UUID      `json:"uuid,omitempty" db:"uuid"`
	PassHash         string         `json:"-" db:"passhash"`
	MemberName       string         `json:"memberName" db:"nick,unique" validate:"required,alphanumunicode,min=3,max=30"`
	DisplayName      sql.NullString `json:"displayName,omitempty" db:"display_name"`
	Email            string         `json:"email" db:"email" validate:"required,email"`
	Bio              sql.NullString `json:"bio,omitempty" db:"bio"`
	Active           bool           `json:"active" db:"active"`
	Roles            pq.StringArray `json:"roles,omitempty" db:"roles"`
	RegTimestamp     time.Time      `json:"regdate" db:"reg_timestamp"`
	ProfilePicID     sql.NullInt64  `json:"-" db:"profilepic_id"`
	ProfilePicSource string         `json:"profile_pic,omitempty" db:"-"`
	Homepage         sql.NullString `json:"homepage,omitempty" db:"homepage"`
	IRC              sql.NullString `json:"irc,omitempty" db:"irc"`
	XMPP             sql.NullString `json:"xmpp,omitempty" db:"xmpp"`
	Matrix           sql.NullString `json:"matrix,omitempty" db:"matrix"`
	Visibility       string         `json:"visibility" db:"visibility"`
	FollowingURI     string         `json:"following_uri" db:"following_uri"` // URI for getting the following list of this account
	FollowersURI     string         `json:"followers_uri" db:"followers_uri"` // URI for getting the followers list of this account
	SessionTimeout   sql.NullInt64  `json:"-" db:"session_timeout"`
	PublicKeyPem     string         `jsonld:"publicKeyPem,omitempty" json:"-" db:"public_key_pem"`
}

Member holds the core information about a member

func (*Member) IsFollowing added in v0.7.0

func (m *Member) IsFollowing(ctx context.Context, memberID int) (bool, error)

type MemberStorer

type MemberStorer interface {
	Save(ctx context.Context, member *Member) error
	Read(ctx context.Context, key string, keyNames ...string) (*Member, error)
	// Check checks if a member with the given email or nickname already exists
	Check(ctx context.Context, email, nickname string) (bool, error)
	Update(ctx context.Context, member *Member) error
	Delete(ctx context.Context, member *Member) error
	GetID(ctx context.Context, key string) (int, error)
	GetPassHash(email, login string) (string, error)
	// GetSessionTimeout retrieves the preferred timeout until the session expires,
	// represented as number of seconds
	GetSessionTimeout(ctx context.Context, memberID int, deviceID uuid.UUID) (timeout int, err error)
	LookupDevice(ctx context.Context, deviceID uuid.UUID) error
	CreateSession(ctx context.Context, member *Member) (string, error)
	RequestFollow(ctx context.Context, fr *FollowRequest) error
}

Member holds the core information about a member

type PgMemberStorage

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

Member holds the core information about a member

func NewSQLStorage

func NewSQLStorage(client *sqlx.DB, log *zerolog.Logger, conf *cfg.Config) *PgMemberStorage

func (*PgMemberStorage) CacheNicknames

func (s *PgMemberStorage) CacheNicknames(ctx context.Context) error

func (*PgMemberStorage) Check added in v0.7.0

func (s *PgMemberStorage) Check(c context.Context, email, nickname string) (bool, error)

Check checks if a member with the given email or nickname already exists

func (*PgMemberStorage) CreateSession

func (s *PgMemberStorage) CreateSession(ctx context.Context, m *Member) (t string, err error)

CreateSession creates a JWT token for the member

func (*PgMemberStorage) Delete

func (s *PgMemberStorage) Delete(ctx context.Context, member *Member) error

func (*PgMemberStorage) GetID

func (s *PgMemberStorage) GetID(ctx context.Context, credential string) (id int, err error)

GetID retrieves the ID required for JWT on the basis of one of the credentials, i.e. email or login

func (*PgMemberStorage) GetNicknames

func (s *PgMemberStorage) GetNicknames() []string

func (*PgMemberStorage) GetPassHash

func (s *PgMemberStorage) GetPassHash(email, login string) (string, error)

GetPassHash retrieves the password hash required for JWT on the basis of one of the credentials, i.e. email or login

func (*PgMemberStorage) GetSessionTimeout added in v0.7.0

func (s *PgMemberStorage) GetSessionTimeout(
	ctx context.Context, memberID int, deviceID uuid.UUID,
) (timeout int, err error)

TODO: implement

func (*PgMemberStorage) LookupDevice added in v0.7.0

func (s *PgMemberStorage) LookupDevice(ctx context.Context, deviceID uuid.UUID) error

func (*PgMemberStorage) Read

func (s *PgMemberStorage) Read(ctx context.Context, value string, keyNames ...string) (*Member, error)

func (*PgMemberStorage) RequestFollow

func (s *PgMemberStorage) RequestFollow(ctx context.Context, fr *FollowRequest) error

RequestFollow creates a follow request in the local database upon the reception of a request into the inbox

func (*PgMemberStorage) Save

func (s *PgMemberStorage) Save(ctx context.Context, member *Member) error

func (*PgMemberStorage) Update

func (s *PgMemberStorage) Update(ctx context.Context, member *Member) error

Jump to

Keyboard shortcuts

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