create empty client, add function of collecting user unread messages on channels
This commit is contained in:
+24
-13
@@ -27,19 +27,30 @@ func RandomRgba() Rgba {
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Mu sync.RWMutex `json:"-"`
|
||||
Name string `json:"name"`
|
||||
Pronouns string `json:"pronouns"`
|
||||
Description string `json:"description"`
|
||||
AvatarKey string `json:"avatarType"`
|
||||
ProfileBgKey string `json:"profileBackgroundType"`
|
||||
PasswordHash string `json:"-"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
WsConn *websocket.Conn `json:"-"`
|
||||
Id uuid.UUID `json:"-"`
|
||||
Connections map[uuid.UUID]*Connection `json:"-"`
|
||||
Hubs map[uuid.UUID]*Hub `json:"hubs-to-delete"`
|
||||
Color Rgba `json:"color"`
|
||||
Mu sync.RWMutex `json:"-"`
|
||||
Name string `json:"name"`
|
||||
Pronouns string `json:"pronouns"`
|
||||
Description string `json:"description"`
|
||||
AvatarKey string `json:"avatarType"`
|
||||
ProfileBgKey string `json:"profileBackgroundType"`
|
||||
PasswordHash string `json:"-"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
WsConn *websocket.Conn `json:"-"`
|
||||
Id uuid.UUID `json:"-"`
|
||||
Connections map[uuid.UUID]*Connection `json:"-"`
|
||||
Hubs map[uuid.UUID]*Hub `json:"hubs-to-delete"`
|
||||
ChannelUnreadMessage map[uuid.UUID]uint8 `json:"-"`
|
||||
Color Rgba `json:"color"`
|
||||
}
|
||||
|
||||
func (u *User) IncrementUnreadMessagesWithCap(channel uuid.UUID) {
|
||||
u.Mu.Lock()
|
||||
defer u.Mu.Unlock()
|
||||
|
||||
if u.ChannelUnreadMessage[channel] == uint8(math.MaxUint8) {
|
||||
return
|
||||
}
|
||||
u.ChannelUnreadMessage[channel]++
|
||||
}
|
||||
|
||||
type UserProfileUpdate struct {
|
||||
|
||||
Reference in New Issue
Block a user