[UTIL][Notification] Remove deprecated code

This commit is contained in:
Diogo Peralta Cordeiro 2022-03-05 14:25:01 +00:00
parent 1a0c9e720f
commit d629976322
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 0 additions and 208 deletions

View File

@ -1,107 +0,0 @@
<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
/**
* Base class for Transports
*
* @package GNUsocial
* @category Util
*
* @author Hugo Sales <hugo@hsal.es>
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Notification;
use function App\Core\I18n\_m;
use InvalidArgumentException;
/**
* @codeCoverageIgnore
*/
abstract class AbstractTransport
{
/**
* Get the display name of this transport
*/
abstract public function getName(): string;
/**
* Get the identifier used in code for this transport
*/
abstract public function getIdentifier(): string;
/**
* Send a given Notification through this transport
*/
abstract public function send(Notification $n): bool;
/**
* Get the display help message for one of the Notification-constants type
*/
public function getHelpMessage(int $t): string
{
switch ($t) {
case Notification::NOTICE_BY_SUBSCRIBED:
return _m('Send me alerts of mentions by those I subscribe through {name}', ['{name}' => $this->getName()]);
case Notification::MENTION:
return _m('Send me alerts of mentions through {name}', ['{name}' => $this->getName()]);
case Notification::REPLY:
return _m('Send me alerts of replies to my notice through {name}', ['{name}' => $this->getName()]);
case Notification::SUBSCRIPTION:
return _m('Send me alerts of new subscriptions through {name}', ['{name}' => $this->getName()]);
case Notification::FAVORITE:
return _m('Send me alerts of new favorites on my notices through {name}', ['{name}' => $this->getName()]);
case Notification::NUDGE:
return _m('Send me alerts when someone calls for my attention through {name}', ['{name}' => $this->getName()]);
case Notification::DM:
return _m('Send me alerts of new direct messages through {name}', ['{name}' => $this->getName()]);
default:
throw new InvalidArgumentException('Given an invalid Notification constant value');
}
}
/**
* Get the display label message for one of the Notification-constants type
*/
public function getLabelMessage(int $t): string
{
switch ($t) {
case Notification::NOTICE_BY_SUBSCRIBED:
return _m('Notify me of new notices');
case Notification::MENTION:
return _m('Notify me of mentions');
case Notification::REPLY:
return _m('Notify me of replies');
case Notification::SUBSCRIPTION:
return _m('Notify me of new subscriptions');
case Notification::FAVORITE:
return _m('Notify me of new favorites');
case Notification::NUDGE:
return _m('Notify me when nudged');
case Notification::DM:
return _m('Notify of new DMs');
default:
throw new InvalidArgumentException('Given an invalid Notification constant value');
}
}
}

View File

@ -1,64 +0,0 @@
<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
/**
* Common utility functions
*
* @package GNUsocial
* @category Util
*
* @author Hugo Sales <hugo@hsal.es>
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Notification;
use App\Entity\Actor;
class Notification
{
public const NOTICE_BY_SUBSCRIBED = 1;
public const MENTION = 2;
public const REPLY = 3;
public const SUBSCRIPTION = 4;
public const FAVORITE = 5;
public const NUDGE = 6;
public const DM = 7;
/**
* @param int $type One of the above constants
* @param Actor $actor Who caused this notification
*/
public function __construct(private int $type, private Actor $actor)
{
}
public function getType(): int
{
return $this->type;
}
public function getActor(): Actor
{
return $this->actor;
}
}

View File

@ -1,37 +0,0 @@
<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace App\Tests\Util\Notification;
use App\Entity\Actor;
use App\Util\Notification\Notification;
use Jchook\AssertThrows\AssertThrows;
use PHPUnit\Framework\TestCase;
class NotificationTest extends TestCase
{
use AssertThrows;
public function testNotificationBitmap()
{
static::assertTrue((new Notification(Notification::DM, new Actor())) instanceof Notification);
}
}