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