dkforest

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

commit 65e15ad4b6ff172337b33a232624a508fd07d8d5
parent 5ecb5a946843fe4aac022036f70ef9a5d24c3220
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat, 30 Dec 2023 15:18:03 -0500

add debugging helpers

Diffstat:
Mpkg/database/tableChatMessages.go | 2++
Mpkg/web/handlers/api/v1/chat.go | 9++++++++-
Mpkg/web/handlers/interceptors/slashInterceptor.go | 20++++++++++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/pkg/database/tableChatMessages.go b/pkg/database/tableChatMessages.go @@ -685,6 +685,8 @@ const ( DeleteMsg Wizz Redirect + Close + CloseMenu RefreshTopic string = "refresh" ) diff --git a/pkg/web/handlers/api/v1/chat.go b/pkg/web/handlers/api/v1/chat.go @@ -315,6 +315,10 @@ Loop: return nil } + if topic == selfRefreshTopic && msgTyp.Typ == database.Close { + return nil + } + if topic == selfRefreshTopic && msgTyp.Typ == database.Redirect { send(`<meta http-equiv="refresh" content="0; URL='` + msgTyp.NewURL + `'" />`) return nil @@ -474,7 +478,10 @@ Loop: select { case <-once.Now(): case <-time.After(5 * time.Second): - case <-sub.ReceiveCh(): + case p := <-sub.ReceiveCh(): + if p.Msg.Typ == database.CloseMenu { + return nil + } send(`<meta http-equiv="refresh" content="1" />`) return nil case <-streamItem.Quit: diff --git a/pkg/web/handlers/interceptors/slashInterceptor.go b/pkg/web/handlers/interceptors/slashInterceptor.go @@ -157,6 +157,8 @@ var adminCmdsMap = map[string]CmdHandler{ "/memerm": handleRemoveMeme, "/refresh": handleRefreshCmd, "/chips": handleChipsCmd, + "/close": handleCloseCmd, + "/closem": handleCloseMenuCmd, } func (i SlashInterceptor) InterceptMsg(c *command.Command) { @@ -2018,3 +2020,21 @@ func handleDistCmd(c *command.Command) (handled bool) { } return false } + +func handleCloseCmd(c *command.Command) (handled bool) { + if c.Message == "/close" { + database.MsgPubSub.Pub("refresh_"+string(c.AuthUser.Username), database.ChatMessageType{Typ: database.Close}) + c.Err = command.ErrRedirect + return true + } + return false +} + +func handleCloseMenuCmd(c *command.Command) (handled bool) { + if c.Message == "/closem" { + database.MsgPubSub.Pub("refresh_loading_icon_"+string(c.AuthUser.Username), database.ChatMessageType{Typ: database.CloseMenu}) + c.Err = command.ErrRedirect + return true + } + return false +}