From a95ad8a702918782cb429188510952bd4a0fbfb1 Mon Sep 17 00:00:00 2001 From: valentinkolb Date: Tue, 11 Jun 2024 23:30:56 +0200 Subject: [PATCH] fix(messages): don't send notification to sender of message --- messages/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/messages/main.go b/messages/main.go index 8196593..d432a29 100644 --- a/messages/main.go +++ b/messages/main.go @@ -14,6 +14,11 @@ import ( // sendEmailNotification sends an email notification to the user func sendEmailNotification(app *pocketbase.PocketBase, registry *template.Registry, user *models.Record, message *models.Record) { + // check if user and message are set and user is not the sender + if user == nil || message == nil || user.GetId() == message.GetString("sender") { + return + } + userEmail := user.GetString("email") // check if user has a valid email