dkforest

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

commit b55923814ffdfcc9ce4231fca3ed51c63dd05316
parent da9b6725800472c3534b8a739b9a9ef5556aab6a
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 18 Feb 2025 15:04:54 -0800

cleanup

Diffstat:
Mpkg/database/tableChatMessages.go | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/pkg/database/tableChatMessages.go b/pkg/database/tableChatMessages.go @@ -648,8 +648,16 @@ func (d *DkfDB) CreateOrEditMessage( editMsg.UploadID = &upload.ID } } + + addFullscreenLinkToCodeBlocks(editMsg) + editMsg.DoSave(d) + MsgPubSub.Pub("room_"+roomID.String(), ChatMessageType{Typ: typ, Msg: *editMsg}) + return editMsg.ID, nil +} + +func addFullscreenLinkToCodeBlocks(editMsg *ChatMessage) { i := 0 rgx := regexp.MustCompile(`</pre>`) editMsg.Message = rgx.ReplaceAllStringFunc(editMsg.Message, func(s string) string { @@ -657,12 +665,6 @@ func (d *DkfDB) CreateOrEditMessage( return fmt.Sprintf(`</pre><a href="/chat-code/%s/%d" title="Open in fullscreen" rel="noopener noreferrer" target="_blank" class=fullscreen>&#9974;</a>`, editMsg.UUID, i-1) }) - if i > 0 { - editMsg.DoSave(d) - } - - MsgPubSub.Pub("room_"+roomID.String(), ChatMessageType{Typ: typ, Msg: *editMsg}) - return editMsg.ID, nil } func encryptWithRoomKey(txt, raw string, roomKey string) (string, string, error) {