dkforest

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

commit ea775f6936b6676d9f603cb2e3eb806ff5666c4c
parent f5e9fc53d7f79f89fe75b519c0cd626fdb6e3e6c
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 23 May 2023 16:16:23 -0700

reduce requests

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

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -4960,12 +4960,16 @@ Loop: msg := msgTyp.Msg - user, _ := db.GetUserByID(msg.UserID) - msg.User = user + if msg.User.ID == 0 { + msg.User, _ = db.GetUserByID(msg.UserID) + } if msg.ToUserID != nil { - toUser, _ := db.GetUserByID(*msg.ToUserID) - msg.ToUser = &toUser - if user.ID != authUser.ID && toUser.ID != authUser.ID { + if msg.ToUser == nil { + toUser, _ := db.GetUserByID(*msg.ToUserID) + msg.ToUser = &toUser + } + // Skip PMs that are not for the auth user + if msg.User.ID != authUser.ID && msg.ToUser.ID != authUser.ID { continue } }