mirror of
https://github.com/friendica/friendica
synced 2025-04-24 00:30:11 +00:00
Create constants for Mastodon notification types
This commit is contained in:
parent
ea6f7aba40
commit
3e6fea30f2
7 changed files with 59 additions and 49 deletions
|
@ -26,6 +26,7 @@ use Friendica\Core\System;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Subscription;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Object\Api\Mastodon\Notification;
|
||||
|
||||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/notifications/push/
|
||||
|
@ -44,18 +45,18 @@ class PushSubscription extends BaseApi
|
|||
]);
|
||||
|
||||
$subscription = [
|
||||
'application-id' => $application['id'],
|
||||
'uid' => $uid,
|
||||
'endpoint' => $request['subscription']['endpoint'] ?? '',
|
||||
'pubkey' => $request['subscription']['keys']['p256dh'] ?? '',
|
||||
'secret' => $request['subscription']['keys']['auth'] ?? '',
|
||||
'follow' => $request['data']['alerts']['follow'] ?? false,
|
||||
'favourite' => $request['data']['alerts']['favourite'] ?? false,
|
||||
'reblog' => $request['data']['alerts']['reblog'] ?? false,
|
||||
'mention' => $request['data']['alerts']['mention'] ?? false,
|
||||
'poll' => $request['data']['alerts']['poll'] ?? false,
|
||||
'follow_request' => $request['data']['alerts']['follow_request'] ?? false,
|
||||
'status' => $request['data']['alerts']['status'] ?? false,
|
||||
'application-id' => $application['id'],
|
||||
'uid' => $uid,
|
||||
'endpoint' => $request['subscription']['endpoint'] ?? '',
|
||||
'pubkey' => $request['subscription']['keys']['p256dh'] ?? '',
|
||||
'secret' => $request['subscription']['keys']['auth'] ?? '',
|
||||
Notification::TYPE_FOLLOW => $request['data']['alerts'][Notification::TYPE_FOLLOW] ?? false,
|
||||
Notification::TYPE_LIKE => $request['data']['alerts'][Notification::TYPE_LIKE] ?? false,
|
||||
Notification::TYPE_RESHARE => $request['data']['alerts'][Notification::TYPE_RESHARE] ?? false,
|
||||
Notification::TYPE_MENTION => $request['data']['alerts'][Notification::TYPE_MENTION] ?? false,
|
||||
Notification::TYPE_POLL => $request['data']['alerts'][Notification::TYPE_POLL] ?? false,
|
||||
Notification::TYPE_INTRODUCTION => $request['data']['alerts'][Notification::TYPE_INTRODUCTION] ?? false,
|
||||
Notification::TYPE_POST => $request['data']['alerts'][Notification::TYPE_POST] ?? false,
|
||||
];
|
||||
|
||||
$ret = Subscription::replace($subscription);
|
||||
|
@ -82,13 +83,13 @@ class PushSubscription extends BaseApi
|
|||
}
|
||||
|
||||
$fields = [
|
||||
'follow' => $request['data']['alerts']['follow'] ?? false,
|
||||
'favourite' => $request['data']['alerts']['favourite'] ?? false,
|
||||
'reblog' => $request['data']['alerts']['reblog'] ?? false,
|
||||
'mention' => $request['data']['alerts']['mention'] ?? false,
|
||||
'poll' => $request['data']['alerts']['poll'] ?? false,
|
||||
'follow_request' => $request['data']['alerts']['follow_request'] ?? false,
|
||||
'status' => $request['data']['alerts']['status'] ?? false,
|
||||
Notification::TYPE_FOLLOW => $request['data']['alerts'][Notification::TYPE_FOLLOW] ?? false,
|
||||
Notification::TYPE_LIKE => $request['data']['alerts'][Notification::TYPE_LIKE] ?? false,
|
||||
Notification::TYPE_RESHARE => $request['data']['alerts'][Notification::TYPE_RESHARE] ?? false,
|
||||
Notification::TYPE_MENTION => $request['data']['alerts'][Notification::TYPE_MENTION] ?? false,
|
||||
Notification::TYPE_POLL => $request['data']['alerts'][Notification::TYPE_POLL] ?? false,
|
||||
Notification::TYPE_INTRODUCTION => $request['data']['alerts'][Notification::TYPE_INTRODUCTION] ?? false,
|
||||
Notification::TYPE_POST => $request['data']['alerts'][Notification::TYPE_POST] ?? false,
|
||||
];
|
||||
|
||||
$ret = Subscription::update($application['id'], $uid, $fields);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue