getMessage(); if (strlen($summary) === 0) { // no message provided, display the number of attached files $attachmentsCount = count($message->getAttachments()); if ($attachmentsCount === 1) { // only one attachment $summary = JText::sprintf('VBO_CHAT_MESSAGE_WEBPUSH_NOTIFICATION_SUMMARY_N_FILES_1', $message->getSenderName()); } else { // multiple attachments $summary = JText::plural('VBO_CHAT_MESSAGE_WEBPUSH_NOTIFICATION_SUMMARY_N_FILES', $message->getSenderName(), $attachmentsCount); } } else { // message provided $summary = JText::sprintf('VBO_CHAT_MESSAGE_WEBPUSH_NOTIFICATION_SUMMARY', $message->getSenderName(), $summary); } try { /** @var VBOChatContext */ $context = $message->getContext(); // store the notification record VBOFactory::getNotificationCenter()->store([ [ 'sender' => $context->getAlias() === 'session' ? 'website' : 'operators', 'type' => 'chat.newmessage', 'title' => JText::sprintf('VBO_CHAT_MESSAGE_WEBPUSH_NOTIFICATION_TITLE', $context->getSubject()), 'summary' => $summary, 'label' => JText::translate('VBO_REPLY'), 'avatar' => $user->getAvatar(), 'widget' => $context->getAlias() === 'session' ? 'inquiries_chat' : 'operators_chat', 'widget_options' => [ 'context_alias' => $context->getAlias(), 'context_id' => $context->getID(), ], // always skip signature check, so that we can allow a duplicate insert '_signature' => md5(time()), ], ]); } catch (Exception $e) { // silently catch the error return false; } return true; } }