member

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

This file contains the implementation of the MemberStorage interface for Neo4j.

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"
)

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:"id" 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:"profilePic,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:"sessionTimeout,omitempty" db:"session_timeout"`
	PublicKeyPem     string         `jsonld:"publicKeyPem,omitempty" json:"publicKeyPem,omitempty" 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 Neo4jMemberStorage

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

Member holds the core information about a member

func NewNeo4jStorage

func NewNeo4jStorage(client neo4j.DriverWithContext, log *zerolog.Logger, conf *cfg.Config) Neo4jMemberStorage

func (Neo4jMemberStorage) Check added in v0.7.0

func (s Neo4jMemberStorage) Check(ctx context.Context, email, nick string) (bool, error)

func (Neo4jMemberStorage) Close

func (s Neo4jMemberStorage) Close() error

func (Neo4jMemberStorage) CreateSession

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

func (Neo4jMemberStorage) Delete

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

func (Neo4jMemberStorage) GetID

func (s Neo4jMemberStorage) GetID(ctx context.Context, key string) (int, error)

func (Neo4jMemberStorage) GetPassHash

func (s Neo4jMemberStorage) GetPassHash(email, login string) (string, error)

func (Neo4jMemberStorage) GetSessionTimeout added in v0.7.0

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

func (Neo4jMemberStorage) LookupDevice added in v0.7.0

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

func (Neo4jMemberStorage) Read

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

func (Neo4jMemberStorage) RequestFollow

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

func (Neo4jMemberStorage) Save

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

Save stores a new member in the database.

func (Neo4jMemberStorage) Update

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

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