dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 096936c0fe79ebcb76b561acbbd94bd9704fe745
parent 36d4f0afa2dd37e2ea9638c86c106f5c5d185aad
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 12 Jun 2023 08:56:38 -0700

cleanup

Diffstat:
Mpkg/web/handlers/handlers.go | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -5244,7 +5244,7 @@ var ErrTooManyStreams = errors.New("too many streams") type UserStreamsMap map[string]int64 -func (m *UserStreamsMap) Count() (out int64) { +func (m *UserStreamsMap) count() (out int64) { for _, v := range *m { out += v } @@ -5268,12 +5268,12 @@ func (m *UsersStreamsManager) Add(userID database.UserID, chessKey string) error m.Lock() defer m.Unlock() tmp, found := m.m[userID] + if found && tmp.count() >= userMaxStream { + return ErrTooManyStreams + } if !found { tmp = make(UserStreamsMap) } - if tmp.Count() >= userMaxStream { - return ErrTooManyStreams - } tmp[chessKey]++ m.m[userID] = tmp return nil @@ -5303,7 +5303,7 @@ func (m *UsersStreamsManager) GetUsers() (out []database.UserID) { m.RLock() defer m.RUnlock() for userID, userMap := range m.m { - if userMap.Count() > 0 { + if userMap.count() > 0 { out = append(out, userID) } }