Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion EntityManager/ThreadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,29 @@ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $
// build a regex like (term1|term2)
$regex = sprintf('/(%s)/', implode('|', explode(' ', $search)));

throw new \Exception('not yet implemented');
return $this->repository->createQueryBuilder('t')
->innerJoin('t.metadata', 'tm')
->innerJoin('tm.participant', 'p')
->innerJoin('t.messages', 'm')

// the participant is in the thread participants
->andWhere('p.id = :user_id')
->setParameter('user_id', $participant->getId())

->andWhere('m.body LIKE :search')
->setParameter('search', "%$search%")


// the thread is not deleted by this participant
->andWhere('tm.isDeleted = :isDeleted')
->setParameter('isDeleted', false, \PDO::PARAM_BOOL)

// there is at least one message written by this participant
->andWhere('tm.lastParticipantMessageDate IS NOT NULL')

// sort by date of last message written by this participant
->orderBy('tm.lastParticipantMessageDate', 'DESC')
;
}

/**
Expand Down