Skip to content

Commit

Permalink
Fix messages not shown to sender if receiver moved to spam.
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismeonmounteverest committed Sep 14, 2024
1 parent 272a28b commit 103c47a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/Pagerfanta/AbstractConversationsAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ public function getNbResults(): int
*/
public function getSlice(int $offset, int $length): iterable
{
$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 = 'SELECT * FROM (' . $this->getConversationsQuery() . ') m';
$sql .= ' ORDER BY `m`.`created` DESC LIMIT ' . $length . ' OFFSET ' . $offset;

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

protected function getNotSpamCondition(): string
{
return '(m.initiator_id <> :memberId AND InFolder <> \'' . InFolderType::SPAM . '\')';
return '(m.initiator_id = :memberId or 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 . '%\'SpamInfo LIKE \'%' . SpamInfoType::SPAM_BLOCKED_WORD . '%\') OR AND InFolder = \'' . InFolderType::SPAM . '\'';
return '(SpamInfo LIKE \'%' . SpamInfoType::MEMBER_SAYS_SPAM . '%\' OR SpamInfo LIKE \'%' . SpamInfoType::SPAM_BLOCKED_WORD . '%\') AND InFolder = \'' . InFolderType::SPAM . '\'';
}
}
5 changes: 5 additions & 0 deletions templates/admin/checker/messages.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
<div class="float-left">
{{ pagerfanta( reported, 'rox_default') }}
</div>
<div class="row">
<div class="col-12 text-right">
<button type="submit" class="btn btn-primary">{{ 'button.update' | trans }}</button>
</div>
</div>
{% endif %}
<table class="table table-striped table-hover">

Expand Down

0 comments on commit 103c47a

Please sign in to comment.