Create constants for Mastodon notification types

This commit is contained in:
Hypolite Petovan 2021-09-17 23:15:23 -04:00
parent ea6f7aba40
commit 3e6fea30f2
7 changed files with 59 additions and 49 deletions

View file

@ -33,9 +33,26 @@ use Friendica\Util\DateTimeFormat;
*/
class Notification extends BaseDataTransferObject
{
/* From the Mastodon documentation:
* - follow = Someone followed you
* - follow_request = Someone requested to follow you
* - mention = Someone mentioned you in their status
* - reblog = Someone boosted one of your statuses
* - favourite = Someone favourited one of your statuses
* - poll = A poll you have voted in or created has ended
* - status = Someone you enabled notifications for has posted a status
*/
public const TYPE_FOLLOW = 'follow';
public const TYPE_INTRODUCTION = 'follow_request';
public const TYPE_MENTION = 'mention';
public const TYPE_RESHARE = 'reblog';
public const TYPE_LIKE = 'favourite';
public const TYPE_POLL = 'poll';
public const TYPE_POST = 'status';
/** @var string */
protected $id;
/** @var string (Enumerable oneOf) */
/** @var string One of the TYPE_* constant values */
protected $type;
/** @var string (Datetime) */
protected $created_at;

View file

@ -42,20 +42,19 @@ class Subscription extends BaseDataTransferObject
/**
* Creates a subscription record from an item record.
*
* @param array $subscription
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @param array $subscription
* @param string $vapid
*/
public function __construct(array $subscription, string $vapid)
{
$this->id = (string)$subscription['id'];
$this->endpoint = $subscription['endpoint'];
$this->alerts = [
'follow' => $subscription['follow'],
'favourite' => $subscription['favourite'],
'reblog' => $subscription['reblog'],
'mention' => $subscription['mention'],
'mention' => $subscription['mention'],
'poll' => $subscription['poll'],
Notification::TYPE_FOLLOW => $subscription[Notification::TYPE_FOLLOW],
Notification::TYPE_LIKE => $subscription[Notification::TYPE_LIKE],
Notification::TYPE_RESHARE => $subscription[Notification::TYPE_RESHARE],
Notification::TYPE_MENTION => $subscription[Notification::TYPE_MENTION],
Notification::TYPE_POLL => $subscription[Notification::TYPE_POLL],
];
$this->server_key = $vapid;