dkforest

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

commit 25508da69b6641e81badea4bca1c674df143d1ca
parent 4c5786d5e7eeb7d3ab9ba4dd914c4f97f451a489
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 26 Apr 2023 04:27:12 -0700

notify if pm is sent to someone who would not be able to pm back

Diffstat:
Mpkg/web/handlers/api/v1/slashInterceptor.go | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/api/v1/slashInterceptor.go b/pkg/web/handlers/api/v1/slashInterceptor.go @@ -840,6 +840,7 @@ func handleEditLastCmd(c *Command) (handled bool) { var ErrPMDenied = errors.New("you cannot pm/inbox this user") var Err20Msgs = errors.New("you need 20 public messages to unlock PMs/Inbox; or be whitelisted") +var ErrOther20Msgs = errors.New("dest user must be whitelisted or have 20 public messages") func canUserInboxOther(db *database.DkfDB, user, other database.User) error { doesNotMatter := false @@ -878,6 +879,17 @@ func canUserPmOther(db *database.DkfDB, user, other database.User, roomIsPrivate return false, errPMDenied } + if !other.CanSendPM() { + if db.IsUserPmWhitelisted(other.ID, user.ID) { + return true, nil + } + // In private rooms, can send PM but inboxes will be skipped if not enough public messages + if roomIsPrivate { + return true, nil + } + return false, ErrOther20Msgs + } + return false, nil }