Skip to content

Commit

Permalink
Show message in spam folder to initiator. Show messages in spam if mo…
Browse files Browse the repository at this point in the history
…ved to spam on block word.
  • Loading branch information
thisismeonmounteverest committed Sep 9, 2024
1 parent 51bf68a commit 272a28b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Pagerfanta/AbstractConversationsAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public function getNbResults(): int
*/
public function getSlice(int $offset, int $length): iterable
{
$sql = 'SELECT * FROM (' . $this->getConversationsQuery() . ') m';
$sql = 'SELECT *, i.id, r.id, s.id FROM (' . $this->getConversationsQuery() . ') m';
$sql .= ' JOIN members i ON m.initiator_id = i.id';
$sql .= ' JOIN members r ON m.IdReceiver = r.id';
$sql .= ' JOIN members s ON m.IdSender = s.id';
$sql .= ' ORDER BY `m`.`created` DESC LIMIT ' . $length . ' OFFSET ' . $offset;

$query = $this->entityManager->createNativeQuery($sql, new MessageResultSetMapping())
Expand Down Expand Up @@ -121,7 +124,7 @@ protected function getInitiatorCondition(): string

protected function getNotSpamCondition(): string
{
return 'InFolder <> \'' . InFolderType::SPAM . '\'';
return '(m.initiator_id <> :memberId AND InFolder <> \'' . InFolderType::SPAM . '\')';
}

abstract protected function getConversationsQuery(): string;
Expand Down
2 changes: 1 addition & 1 deletion src/Pagerfanta/SpamAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ protected function getConversationsQuery(): string

private function getSpamCondition(): string
{
return 'SpamInfo LIKE \'%' . SpamInfoType::MEMBER_SAYS_SPAM . '%\' AND InFolder = \'' . InFolderType::SPAM . '\'';
return '(SpamInfo LIKE \'%' . SpamInfoType::MEMBER_SAYS_SPAM . '%\'SpamInfo LIKE \'%' . SpamInfoType::SPAM_BLOCKED_WORD . '%\') OR AND InFolder = \'' . InFolderType::SPAM . '\'';
}
}

0 comments on commit 272a28b

Please sign in to comment.