dkforest

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

commit bd49189d7837e2ad5000a17dfe19751c4c84ce60
parent a4f54a37e6d4aa197c5364620bdafee80ea119d4
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 29 Dec 2023 00:47:16 -0500

increase initial messages load limit

Diffstat:
Mpkg/database/database.go | 2+-
Mpkg/database/tableChatMessages.go | 4++--
Mpkg/web/handlers/api/v1/chat.go | 4++--
Mpkg/web/handlers/api/v1/handlers.go | 4++--
4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/pkg/database/database.go b/pkg/database/database.go @@ -100,7 +100,7 @@ type IDkfDB interface { DoCreateSession(userID UserID, userAgent string, sessionDuration time.Duration) Session GetActiveUserSessions(userID UserID) (out []Session) GetCategories() (out []CategoriesResult, err error) - GetChatMessages(roomID RoomID, roomKey string, username Username, userID UserID, displayPms PmDisplayMode, mentionsOnly, displayHellbanned, displayIgnored, displayModerators, displayIgnoredMessages bool, minID1 int64) (out ChatMessages, err error) + GetChatMessages(roomID RoomID, roomKey string, username Username, userID UserID, displayPms PmDisplayMode, mentionsOnly, displayHellbanned, displayIgnored, displayModerators, displayIgnoredMessages bool, msgsLimit, minID1 int64) (out ChatMessages, err error) GetChatRoomByID(roomID RoomID) (out ChatRoom, err error) GetChatRoomByName(roomName string) (out ChatRoom, err error) GetChessSubscribers() (out []User, err error) diff --git a/pkg/database/tableChatMessages.go b/pkg/database/tableChatMessages.go @@ -378,7 +378,7 @@ const ( func (d *DkfDB) GetChatMessages(roomID RoomID, roomKey string, username Username, userID UserID, displayPms PmDisplayMode, mentionsOnly, displayHellbanned, displayIgnored, displayModerators, - displayIgnoredMessages bool, minID1 int64) (out ChatMessages, err error) { + displayIgnoredMessages bool, msgsLimit, minID1 int64) (out ChatMessages, err error) { cmp := func(t, t2 ChatMessage) bool { return t.ID > t2.ID } @@ -387,7 +387,7 @@ func (d *DkfDB) GetChatMessages(roomID RoomID, roomKey string, username Username Preload("ToUser"). Preload("Room"). Preload("Group"). - Limit(150). + Limit(msgsLimit). Where(`room_id = ?`, roomID) if minID1 > 0 { q = q.Where("id >= ?", minID1) diff --git a/pkg/web/handlers/api/v1/chat.go b/pkg/web/handlers/api/v1/chat.go @@ -160,7 +160,7 @@ func ChatStreamMessagesHandler(c echo.Context) error { displayHellbanned := authUser.DisplayHellbanned || authUser.IsHellbanned displayIgnoredMessages := false msgs, err := db.GetChatMessages(room.ID, roomKey, authUser.Username, authUser.ID, pmOnlyQuery, mentionsOnlyQuery, - displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators, displayIgnoredMessages, 0) + displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators, displayIgnoredMessages, 500, 0) if err != nil { return c.Redirect(http.StatusFound, "/") } @@ -318,7 +318,7 @@ Loop: // Get all messages for the user that were created after the edited one (included) msgs, err := db.GetChatMessages(room.ID, roomKey, authUser.Username, authUser.ID, pmOnlyQuery, mentionsOnlyQuery, displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators, - displayIgnoredMessages, msgTyp.Msg.ID) + displayIgnoredMessages, 150, msgTyp.Msg.ID) if err != nil { return c.Redirect(http.StatusFound, "/") } diff --git a/pkg/web/handlers/api/v1/handlers.go b/pkg/web/handlers/api/v1/handlers.go @@ -77,7 +77,7 @@ func chatMessages(c echo.Context) (status int, data ChatMessagesData) { displayHellbanned := authUser.DisplayHellbanned || authUser.IsHellbanned displayIgnoredMessages := false msgs, err := db.GetChatMessages(room.ID, roomKey, authUser.Username, authUser.ID, pmOnlyQuery, mentionsOnlyQuery, - displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators, displayIgnoredMessages, 0) + displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators, displayIgnoredMessages, 150, 0) if err != nil { return http.StatusInternalServerError, data } @@ -181,7 +181,7 @@ func RoomNotifierHandler(c echo.Context) error { mentionsOnly := false displayIgnoredMessages := false msgs, err := db.GetChatMessages(room.ID, roomKey, authUser.Username, authUser.ID, database.PmNoFilter, mentionsOnly, - displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators, displayIgnoredMessages, 0) + displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators, displayIgnoredMessages, 150, 0) if err != nil { return c.NoContent(http.StatusInternalServerError) }