Skip to content

Commit 4ba0192

Browse files
Format conversations before sending notifications.
1 parent 02877e7 commit 4ba0192

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/Controller/MessageController.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Controller;
44

55
use App\Doctrine\MemberStatusType;
6+
use App\Doctrine\SpamInfoType;
67
use App\Entity\Member;
78
use App\Entity\Message;
89
use App\Entity\Subject;
@@ -207,11 +208,13 @@ private function addMessageAndSendNotification(
207208
$em->persist($message);
208209
$em->flush();
209210

210-
$this->mailer->sendMessageNotificationEmail($sender, $receiver, 'message', [
211-
'message' => $message,
212-
'subject' => $subjectText,
213-
'body' => $body,
214-
]);
211+
if (!strpos($message->getSpamInfo(), SpamInfoType::SPAM_BLOCKED_WORD)) {
212+
$this->mailer->sendMessageNotificationEmail($sender, $receiver, 'message', [
213+
'message' => $message,
214+
'subject' => $subjectText,
215+
'body' => $body,
216+
]);
217+
}
215218

216219
return $message;
217220
}

src/Controller/RequestController.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Doctrine\AccommodationType;
66
use App\Doctrine\MemberStatusType;
7+
use App\Doctrine\SpamInfoType;
78
use App\Entity\HostingRequest;
89
use App\Entity\Member;
910
use App\Entity\Message;
@@ -326,7 +327,9 @@ private function sendInitialRequestNotification(Member $host, Member $guest, Mes
326327
{
327328
$subject = $request->getSubject()->getSubject();
328329

329-
$this->sendRequestNotification($guest, $host, $host, $request, $subject, 'request', false);
330+
if (!strpos($request->getSpamInfo(), SpamInfoType::SPAM_BLOCKED_WORD)) {
331+
$this->sendRequestNotification($guest, $host, $host, $request, $subject, 'request', false);
332+
}
330333
}
331334

332335
private function sendHostReplyNotification(

src/Model/ConversationModel.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@
1414
use DateTime;
1515
use Doctrine\ORM\EntityManagerInterface;
1616
use Exception;
17+
use Symfony\Contracts\Translation\TranslatorInterface;
1718

1819
class ConversationModel
1920
{
2021
private Mailer $mailer;
2122
private EntityManagerInterface $entityManager;
2223
private ConversationThread $conversationThread;
24+
private TranslatorInterface $translator;
2325

24-
public function __construct(Mailer $mailer, EntityManagerInterface $entityManager)
26+
public function __construct(Mailer $mailer, EntityManagerInterface $entityManager, TranslatorInterface $translator)
2527
{
2628
$this->mailer = $mailer;
2729
$this->entityManager = $entityManager;
2830
$this->conversationThread = new ConversationThread($entityManager);
31+
$this->translator = $translator;
2932
}
3033

3134
/**
@@ -292,7 +295,7 @@ public function formatConversation(Message $message): Message
292295

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

298301
return $message;

0 commit comments

Comments
 (0)