Documentation
      ¶
    
    
  
    
  
    Index ¶
- type Ban
 - type BanStatus
 - type BanStatusType
 - type Device
 - type FollowRequest
 - type Follower
 - type Input
 - type Member
 - type MemberStorer
 - type PgMemberStorage
 - func (s *PgMemberStorage) CacheNicknames(ctx context.Context) error
 - func (s *PgMemberStorage) Check(c context.Context, email, nickname string) (bool, error)
 - func (s *PgMemberStorage) CreateSession(ctx context.Context, m *Member) (t string, err error)
 - func (s *PgMemberStorage) Delete(ctx context.Context, member *Member) error
 - func (s *PgMemberStorage) GetID(ctx context.Context, credential string) (id int, err error)
 - func (s *PgMemberStorage) GetNicknames() []string
 - func (s *PgMemberStorage) GetPassHash(email, login string) (string, error)
 - func (s *PgMemberStorage) GetSessionTimeout(ctx context.Context, memberID int, deviceID uuid.UUID) (timeout int, err error)
 - func (s *PgMemberStorage) LookupDevice(ctx context.Context, deviceID uuid.UUID) error
 - func (s *PgMemberStorage) Read(ctx context.Context, value string, keyNames ...string) (*Member, error)
 - func (s *PgMemberStorage) RequestFollow(ctx context.Context, fr *FollowRequest) error
 - func (s *PgMemberStorage) Save(ctx context.Context, member *Member) error
 - func (s *PgMemberStorage) Update(ctx context.Context, member *Member) error
 
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
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 (*PgMemberStorage) CacheNicknames ¶
func (s *PgMemberStorage) CacheNicknames(ctx context.Context) error
func (*PgMemberStorage) Check ¶ added in v0.7.0
Check checks if a member with the given email or nickname already exists
func (*PgMemberStorage) CreateSession ¶
CreateSession creates a JWT token for the member
func (*PgMemberStorage) Delete ¶
func (s *PgMemberStorage) Delete(ctx context.Context, member *Member) error
func (*PgMemberStorage) GetID ¶
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) 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