dkforest

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

commit 0828f23c65c498e2cb770205e799419eb8f840d5
parent b3f01bdf0266415de1b7d96d5066215ae32b0729
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 27 Jun 2023 12:40:06 -0700

improve code

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

diff --git a/pkg/web/handlers/interceptors/slashInterceptor.go b/pkg/web/handlers/interceptors/slashInterceptor.go @@ -779,14 +779,18 @@ func handleAddGroupCmd(c *command.Command) (handled bool) { func handleWhitelistCmd(c *command.Command) (handled bool) { if c.Message == "/whitelist" || c.Message == "/wl" { + usernames := make([]string, 0) whitelistedUsers, _ := c.DB.GetWhitelistedUsers(c.Room.ID) + if c.Room.OwnerUserID != nil { + owner, _ := c.DB.GetUserByID(*c.Room.OwnerUserID) + usernames = append(usernames, owner.Username.AtStr()) + } + for _, whitelistedUser := range whitelistedUsers { + usernames = append(usernames, whitelistedUser.User.Username.AtStr()) + } + sort.Slice(usernames, func(i, j int) bool { return usernames[i] < usernames[j] }) var msg string if len(whitelistedUsers) > 0 { - usernames := make([]string, 0) - for _, whitelistedUser := range whitelistedUsers { - usernames = append(usernames, whitelistedUser.User.Username.AtStr()) - } - sort.Slice(usernames, func(i, j int) bool { return usernames[i] < usernames[j] }) msg = "whitelisted users: " + strings.Join(usernames, ", ") } else { msg = "no whitelisted user"