model

package
v0.0.0-...-98550de Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ADMIN_ROLE = "admin"
	USER_ROLE  = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Id        uuid.UUID `db:"id"`
	UserId    uuid.UUID `db:"user_id"`
	RoomId    uuid.UUID `db:"room_id"`
	Text      string    `db:"text"`
	CreatedAt time.Time `db:"created_at"`
}

func NewMessage

func NewMessage(userId, roomId uuid.UUID, text string) *Message

func (*Message) ToPbMessage

func (m *Message) ToPbMessage() *pb.Message

type RefreshToken

type RefreshToken struct {
	Token     uuid.UUID `db:"token"`
	UserId    uuid.UUID `db:"user_id"`
	ExpiresAt time.Time `db:"expires_at"`
	IssuedAt  time.Time `db:"issued_at"`
}

type Room

type Room struct {
	Id              uuid.UUID   `db:"id"`
	Name            string      `db:"name"`
	CreatedAt       time.Time   `db:"created_at"`
	UserIds         []uuid.UUID `db:"-"`
	DialogRoom      bool        `db:"dialog_room"`
	LastMessageTime time.Time   `db:"last_message_time"`
}

func NewRoom

func NewRoom(name string, dialogRoom bool, users ...uuid.UUID) *Room

func (*Room) PbRoom

func (r *Room) PbRoom() *pb.Room

type Session

type Session struct {
	Id         uuid.UUID
	Connection pb.MessageService_GetMessagesServer
	Expires    time.Duration
	Done       chan<- error
}

type TokenPair

type TokenPair struct {
	JwtToken     string
	RefreshToken *RefreshToken
}

type User

type User struct {
	Id           uuid.UUID `db:"id"`
	Username     string    `db:"username"`
	PasswordHash string    `db:"password_hash"`
	Role         string    `db:"role"`
}

func NewUser

func NewUser(username, password, role string) (*User, error)

func (*User) Clone

func (u *User) Clone() *User

func (*User) IsCorrectPassword

func (u *User) IsCorrectPassword(password string) bool

type UserClaims

type UserClaims struct {
	jwt.StandardClaims

	Username string `json:"username"`
	Role     string `json:"role"`
}

Jump to

Keyboard shortcuts

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