models

package
v0.0.0-...-5c4fd57 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateEmail = errors.New("models: duplicate email")
View Source
var ErrDuplicateUsername = errors.New("models: duplicate username")
View Source
var ErrInvalidCredentials = errors.New("models: invalid credentials")
View Source
var ErrInvalidSession = errors.New("models: session token is invalid")
View Source
var ErrMaxFriends = errors.New("models: the user has reached the maximum number of friends")
View Source
var ErrNoSessionsFound = errors.New("models: no sessions matching the specified token or id where found")
View Source
var ErrNothingToUpdate = errors.New("models: nothing to update")
View Source
var ErrRecipientHasBlockedUser = errors.New("models: the recipient has blocked the client user")
View Source
var ErrRelationshipExists = errors.New("models: the users are already friends")
View Source
var ErrSameUser = errors.New("models: the user IDs are the same")
View Source
var ErrSessionExpired = errors.New("models: the session has expired")
View Source
var ErrUserNotFound = errors.New("models: user not found")
View Source
var RefreshTokenExpirationDelta time.Duration = time.Hour * 24 * 30

Functions

This section is empty.

Types

type BlockedUserDTO

type BlockedUserDTO struct {
	UserID            string     `json:"userID"`
	Username          string     `json:"username"`
	DisplayName       NullString `json:"displayName"`
	ProfilePictureURL NullString `json:"profilePictureURL"`
}

type Channel

type Channel struct {
	ChannelID   string
	ChannelName string
	OwnerID     string
	ChannelType string
	Description NullString
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type ChannelMember

type ChannelMember struct {
	ChannelID string
	UserID    string
	JoinedAt  time.Time
	IsAdmnin  bool
	Hidden    bool
}

type ChannelModel

type ChannelModel struct {
	DB *pgxpool.Pool
}

func (*ChannelModel) AddMember

func (m *ChannelModel) AddMember()

func (*ChannelModel) ChangeAdminPerms

func (m *ChannelModel) ChangeAdminPerms()

func (*ChannelModel) ChangeChannelHiddenState

func (m *ChannelModel) ChangeChannelHiddenState()

func (*ChannelModel) CreateChannel

func (m *ChannelModel) CreateChannel()

func (*ChannelModel) DeleteChannel

func (m *ChannelModel) DeleteChannel()

func (*ChannelModel) FetchChannel

func (m *ChannelModel) FetchChannel()

func (*ChannelModel) FetchChannels

func (m *ChannelModel) FetchChannels()

func (*ChannelModel) FetchMembers

func (m *ChannelModel) FetchMembers()

func (*ChannelModel) RemoveMember

func (m *ChannelModel) RemoveMember()

type NewSession

type NewSession struct {
	UserID       string
	SessionID    string
	RefreshToken string
}

type NullString

type NullString string

func (*NullString) Scan

func (ns *NullString) Scan(value interface{}) error

type PublicUserDTO

type PublicUserDTO struct {
	UserID            string     `json:"userID"`
	Username          string     `json:"username"`
	DisplayName       NullString `json:"displayName"`
	JoinedAt          time.Time  `json:"joinedAt"`
	CustomStatus      NullString `json:"customStatus"`
	Bio               NullString `json:"bio"`
	ProfilePictureURL NullString `json:"profilePictureURL"`
}

type Relationship

type Relationship struct {
	UserA  string
	UserB  string
	Status string
}

type RelationshipModel

type RelationshipModel struct {
	DB *pgxpool.Pool
}

func (*RelationshipModel) BlockUser

func (m *RelationshipModel) BlockUser(userA, userB string) error

func (*RelationshipModel) DeleteRelationship

func (m *RelationshipModel) DeleteRelationship(userA, userB string) error

func (*RelationshipModel) FetchBlockedUsers

func (m *RelationshipModel) FetchBlockedUsers(userID string) ([]BlockedUserDTO, error)

func (*RelationshipModel) FetchFriendRequests

func (m *RelationshipModel) FetchFriendRequests(userID string) ([]RelationshipUserDTO, error)

func (*RelationshipModel) FetchFriends

func (m *RelationshipModel) FetchFriends(userID string) ([]RelationshipUserDTO, error)

func (*RelationshipModel) SetRelationship

func (m *RelationshipModel) SetRelationship(userA, userB string) (string, error)

type RelationshipUserDTO

type RelationshipUserDTO struct {
	UserID            string     `json:"userID"`
	Username          string     `json:"username"`
	DisplayName       NullString `json:"displayName"`
	ProfilePictureURL NullString `json:"profilePictureURL"`
	Status            string     `json:"status"`
}

type Session

type Session struct {
	SessionID    string
	UserID       string
	RefreshToken string
	IpAddress    string
	Platform     string
	OS           string
	ExpiresAt    time.Time
	UpdatedAt    time.Time
}

type SessionsModel

type SessionsModel struct {
	DB *pgxpool.Pool
}

func (*SessionsModel) DeleteAllSessions

func (m *SessionsModel) DeleteAllSessions(userID string) error

func (*SessionsModel) DeleteSession

func (m *SessionsModel) DeleteSession(sessionID string) error

func (*SessionsModel) NewSession

func (m *SessionsModel) NewSession(userID, platform, os, ip string) (NewSession, error)

func (*SessionsModel) RevalidateSession

func (m *SessionsModel) RevalidateSession(sessionID string, refreshToken string) (NewSession, error)

type User

type User struct {
	UserID            string
	Username          string
	DisplayName       NullString
	Email             string
	Password          string
	JoinedAt          time.Time
	UpdatedAt         time.Time
	Verified          bool
	CustomStatus      NullString
	ProfilePictureURL NullString
	Bio               NullString
}

type UserDTO

type UserDTO struct {
	UserID            string     `json:"userID"`
	Username          string     `json:"username"`
	DisplayName       NullString `json:"displayName"`
	Email             string     `json:"email"`
	JoinedAt          time.Time  `json:"joinedAt"`
	UpdatedAt         time.Time  `json:"updatedAt"`
	CustomStatus      NullString `json:"customStatus"`
	ProfilePictureURL NullString `json:"profilePictureURL"`
	Bio               NullString `json:"bio"`
}

type UserModel

type UserModel struct {
	DB *pgxpool.Pool
}

func (*UserModel) Authenticate

func (m *UserModel) Authenticate(email, password string) (string, error)

func (*UserModel) FetchUser

func (m *UserModel) FetchUser(userID string) (UserDTO, error)

func (*UserModel) FetchUsersByUsername

func (m *UserModel) FetchUsersByUsername(username string) ([]PublicUserDTO, error)

func (*UserModel) InsertUser

func (m *UserModel) InsertUser(username, email, password string) (string, error)

func (*UserModel) UpdatePassword

func (m *UserModel) UpdatePassword(userID, oldPassword, newPassword string) error

func (*UserModel) UpdateProfileInfo

func (m *UserModel) UpdateProfileInfo(userID, displayName, bio string) (UserDTO, error)

Jump to

Keyboard shortcuts

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