mirror of
https://github.com/friendica/friendica
synced 2025-04-29 03:04:22 +02:00
Add exception when message is empty in FormatteNavNotification::createFromNotification
- Filter out message less notifications in Ping
This commit is contained in:
parent
ee60c96269
commit
73c7b88fb2
4 changed files with 54 additions and 5 deletions
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2022, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Navigation\Notifications\Exception;
|
||||
|
||||
class NoMessageException extends \Exception
|
||||
{
|
||||
}
|
|
@ -25,6 +25,7 @@ use Friendica\BaseFactory;
|
|||
use Friendica\Core\Renderer;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Navigation\Notifications\Entity;
|
||||
use Friendica\Navigation\Notifications\Exception\NoMessageException;
|
||||
use Friendica\Navigation\Notifications\ValueObject;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Proxy;
|
||||
|
@ -94,10 +95,22 @@ class FormattedNavNotification extends BaseFactory
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entity\Notification $notification
|
||||
* @return ValueObject\FormattedNavNotification
|
||||
* @throws NoMessageException
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \Friendica\Network\HTTPException\NotFoundException
|
||||
* @throws \Friendica\Network\HTTPException\ServiceUnavailableException
|
||||
*/
|
||||
public function createFromNotification(Entity\Notification $notification): ValueObject\FormattedNavNotification
|
||||
{
|
||||
$message = $this->notification->getMessageFromNotification($notification);
|
||||
|
||||
if (empty($message)) {
|
||||
throw new NoMessageException();
|
||||
}
|
||||
|
||||
if (!isset(self::$contacts[$notification->actorId])) {
|
||||
self::$contacts[$notification->actorId] = Contact::getById($notification->actorId, ['name', 'url']);
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
|
||||
namespace Friendica\Navigation\Notifications\ValueObject;
|
||||
|
||||
use Friendica\BaseDataTransferObject;
|
||||
use Friendica\BaseEntity;
|
||||
|
||||
/**
|
||||
* A view-only object for printing item notifications to the frontend
|
||||
*/
|
||||
class FormattedNavNotification extends BaseDataTransferObject
|
||||
class FormattedNavNotification extends BaseEntity
|
||||
{
|
||||
/** @var array */
|
||||
protected $contact;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue