dkforest

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

commit bc96b2b89113fdb25fd0dbbb39cf866f68a00340
parent aa2304d752f3e9bfae07df77b1f9b92677551f5c
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 22 May 2023 22:09:22 -0700

delete msg for stream chat

Diffstat:
Mpkg/database/tableChatMessages.go | 1+
Mpkg/web/handlers/api/v1/handlers.go | 2++
Mpkg/web/handlers/handlers.go | 6++++++
3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/pkg/database/tableChatMessages.go b/pkg/database/tableChatMessages.go @@ -541,6 +541,7 @@ const ( CreateMsg PubSubMessageType = iota EditMsg ForceRefresh + DeleteMsg RefreshTopic string = "refresh" ) diff --git a/pkg/web/handlers/api/v1/handlers.go b/pkg/web/handlers/api/v1/handlers.go @@ -515,6 +515,8 @@ func ChatDeleteMessageHandler(c echo.Context) error { logrus.Error(err) } + database.MsgPubSub.Pub("room_"+msg.RoomID.String(), database.ChatMessageType{Typ: database.DeleteMsg, Msg: &msg}) + return c.Redirect(http.StatusFound, c.Request().Referer()) } diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -4989,6 +4989,12 @@ Loop: return nil } + if msgTyp.Typ == database.DeleteMsg { + _, _ = c.Response().Write([]byte(fmt.Sprintf(`<style>.msgidc-%s-%d{display:none;}</style>`, msgTyp.Msg.UUID, msgTyp.Msg.Rev))) + c.Response().Flush() + continue + } + i++ msg := msgTyp.Msg