db

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2019 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AboutRoom

type AboutRoom struct {
	Title string `json:"title"`
	Path  string `json:"path"`
	Play  string `json:"play"`
	Users string `json:"users"`
}

type BannedIps

type BannedIps struct {
	IP      string `json:"ip"`
	Expires int64
}

type BannedUsers

type BannedUsers struct {
	UUID    string `json:"uuid"`
	Expires int64
}

type Database

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

func Connect

func Connect(dbAddr string) *Database

Connect to the database and create collections if needed

func (Database) BanAddress

func (db Database) BanAddress(roomUUID, ipAddress string) error

BanAddress add a ipadress to ban list

func (Database) BanUser

func (db Database) BanUser(roomUUID, userUUID string) error

BanUser add a user to ban list

func (Database) CheckUserRole

func (db Database) CheckUserRole(userUUID, roomUUID string, level int) (bool, error)

CheckUserRole check user level role and return result

func (Database) Close

func (db Database) Close()

Close connections for the database

func (Database) CreateNewRoom

func (db Database) CreateNewRoom(title, path, userUUID, roomUUID, password string, hidden bool) error

CreateNewRoom create a new room

func (Database) CreateNewUser

func (db Database) CreateNewUser(name, uname, hash, email, uuid string) (bool, error)

func (Database) GetAllPermissions

func (db Database) GetAllPermissions(uuid string) (*Permissions, error)

GetAllPermissions return permissions rules for a room

func (Database) GetAllRoles

func (db Database) GetAllRoles(uuid string) ([]Role, error)

GetAllRoles return all roles in room

func (Database) GetAllRooms

func (db Database) GetAllRooms() ([]Room, error)

GetAllRooms return all rooms

func (Database) GetEmojiCount

func (db Database) GetEmojiCount(uuid string) (int, error)

GetEmojiCount return current emoji size in a room

func (Database) GetRoom

func (db Database) GetRoom(key, value string) (Room, error)

GetRoom return a room object

func (Database) GetUserByUUID

func (db Database) GetUserByUUID(uuid string) (*User, error)

GetUserByUUID find user by uuid and return user object

func (Database) GetUserByUname

func (db Database) GetUserByUname(value string) (*User, error)

GetUserByUname find user by username and return it

func (Database) GetUserImage

func (db Database) GetUserImage(userUUID string) (string, error)

GetUserImage find user and return him profile image path

func (Database) GetUserRoles

func (db Database) GetUserRoles(uuid string) ([]Room, error)

GetUserRoles return rooms list user roles in rooms

func (Database) IsAdmin

func (db Database) IsAdmin(uuid string) (bool, error)

IsAdmin return status is it admin or not

func (Database) RoomIsExists

func (db Database) RoomIsExists(key, value string) bool

RoomIsExists return true if found a room by a value with specified a key

func (Database) UnbanAddress

func (db Database) UnbanAddress(roomUUID, ipAddress string) error

UnbanAddress remove ipaddress from banlist

func (Database) UnbanUser

func (db Database) UnbanUser(roomUUID, userUUID string) error

UnbanUser remove user from ban list by uuid

func (Database) UpdateRoomValue

func (db Database) UpdateRoomValue(uuid, key string, value interface{}) error

UpdateRoomValue update specified key in a room

func (Database) UpdateUserValue

func (db Database) UpdateUserValue(uuid, key, value string) error

UpdateUserValue specified by key with value for a user with uuid

type Emoji

type Emoji struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

type Permissions

type Permissions struct {
	RoomUpdate    roomUpdate    `json:"room_update" bson:"room_update"`
	PlaylistEvent playlistEvent `json:"playlist_event" bson:"playlist_event"`
	PlayerEvent   playerEvent   `json:"player_event" bson:"player_event"`
	UserEvent     userEvent     `json:"user_event" bson:"user_event"`
}

func (Permissions) ToMap

func (p Permissions) ToMap() map[string]int

ToMap convert Permissions struct to a map. More usefull for checking

type Role

type Role struct {
	UUID        string `json:"UUID"`
	Permissions int    `json:"permissions"`
}

type Room

type Room struct {
	Title       string        `json:"title"`
	Path        string        `json:"path"`
	UUID        string        `json:"uuid"`
	Hidden      bool          `json:"hidden"`
	Password    string        `json:"passwd"`
	BannedUsers []BannedUsers `json:"banned_users" bson:"banned_users"`
	BannedIps   []BannedIps   `json:"banned_ips" bson:"banned_ips"`
	Roles       []Role        `json:"roles"`
	Permissions Permissions   `json:"permissions"`
	Emoji       []Emoji       `json:"emoji"`
}

type Rooms

type Rooms struct {
	Number int         `json:"number"`
	Body   []AboutRoom `json:"rooms"`
}

type User

type User struct {
	Name    string `json:"name"`
	Color   string `json:"color"`
	Image   string `json:"image"`
	IsAdmin bool   `json:"admin" bson:"is_admin"`
	Uname   string `json:"uname"`
	Hash    string `json:"hash"`
	Email   string `json:"email"`
	UUID    string `json:"uuid"`
}

type UserView

type UserView struct {
	Name     string `json:"name"`
	Username string `json:"username"`
	Color    string `json:"color"`
	Image    string `json:"image"`
	UUID     string `json:"uuid"`
}

Jump to

Keyboard shortcuts

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