/**
  * Update the dates of last message written by other participants
  */
 protected function doDatesOfLastMessageWrittenByOtherParticipant(ThreadInterface $thread)
 {
     foreach ($thread->getAllMetadata() as $meta) {
         $participantId = $meta->getParticipant()->getId();
         $timestamp = 0;
         foreach ($thread->getMessages() as $message) {
             if ($participantId != $message->getSender()->getId()) {
                 $timestamp = max($timestamp, $message->getTimestamp());
             }
         }
         if ($timestamp) {
             $date = new \DateTime();
             $date->setTimestamp($timestamp);
             $meta->setLastMessageDate($date);
         }
     }
 }
 /**
  * Marks all messages of this thread as read by this participant
  *
  * @param ThreadInterface $thread
  * @param ParticipantInterface $participant
  * @param boolean $isRead
  */
 public function markIsReadByThreadAndParticipant(ThreadInterface $thread, ParticipantInterface $participant, $isRead)
 {
     foreach ($thread->getMessages() as $message) {
         $this->markIsReadByParticipant($message, $participant, $isRead);
     }
 }