Skip to content

Commit

Permalink
Format conversations before sending notifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismeonmounteverest committed Sep 3, 2024
1 parent 02877e7 commit 4ba0192
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/Controller/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Controller;

use App\Doctrine\MemberStatusType;
use App\Doctrine\SpamInfoType;
use App\Entity\Member;
use App\Entity\Message;
use App\Entity\Subject;
Expand Down Expand Up @@ -207,11 +208,13 @@ private function addMessageAndSendNotification(
$em->persist($message);
$em->flush();

$this->mailer->sendMessageNotificationEmail($sender, $receiver, 'message', [
'message' => $message,
'subject' => $subjectText,
'body' => $body,
]);
if (!strpos($message->getSpamInfo(), SpamInfoType::SPAM_BLOCKED_WORD)) {
$this->mailer->sendMessageNotificationEmail($sender, $receiver, 'message', [
'message' => $message,
'subject' => $subjectText,
'body' => $body,
]);
}

return $message;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Controller/RequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Doctrine\AccommodationType;
use App\Doctrine\MemberStatusType;
use App\Doctrine\SpamInfoType;
use App\Entity\HostingRequest;
use App\Entity\Member;
use App\Entity\Message;
Expand Down Expand Up @@ -326,7 +327,9 @@ private function sendInitialRequestNotification(Member $host, Member $guest, Mes
{
$subject = $request->getSubject()->getSubject();

$this->sendRequestNotification($guest, $host, $host, $request, $subject, 'request', false);
if (!strpos($request->getSpamInfo(), SpamInfoType::SPAM_BLOCKED_WORD)) {
$this->sendRequestNotification($guest, $host, $host, $request, $subject, 'request', false);
}
}

private function sendHostReplyNotification(
Expand Down
7 changes: 5 additions & 2 deletions src/Model/ConversationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Symfony\Contracts\Translation\TranslatorInterface;

class ConversationModel
{
private Mailer $mailer;
private EntityManagerInterface $entityManager;
private ConversationThread $conversationThread;
private TranslatorInterface $translator;

public function __construct(Mailer $mailer, EntityManagerInterface $entityManager)
public function __construct(Mailer $mailer, EntityManagerInterface $entityManager, TranslatorInterface $translator)
{
$this->mailer = $mailer;
$this->entityManager = $entityManager;
$this->conversationThread = new ConversationThread($entityManager);
$this->translator = $translator;
}

/**
Expand Down Expand Up @@ -292,7 +295,7 @@ public function formatConversation(Message $message): Message

if ($found != 0) {
$message->setSpamInfo(SpamInfoType::SPAM_BLOCKED_WORD);
$message->setMessage($messageText . '<p>This might be spam.</p>');
$message->setMessage($messageText);
}

return $message;
Expand Down

0 comments on commit 4ba0192

Please sign in to comment.