mirror of
https://github.com/friendica/friendica
synced 2025-04-26 12:30:11 +00:00
Preparation for creating push notification
This commit is contained in:
parent
5056376902
commit
19f3cad56c
4 changed files with 74 additions and 22 deletions
|
@ -23,8 +23,10 @@
|
|||
* @see https://github.com/web-push-libs/web-push-php
|
||||
* Possibly we should simply use this.
|
||||
*/
|
||||
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Crypto;
|
||||
|
@ -110,4 +112,25 @@ class Subscription
|
|||
}
|
||||
return $keypair['vapid-public'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare push notification
|
||||
*
|
||||
* @param int $nid
|
||||
* @return void
|
||||
*/
|
||||
public static function pushByNotificationId(int $nid)
|
||||
{
|
||||
$notification = DBA::selectFirst('notification', [], ['id' => $nid]);
|
||||
$type = Notification::getType($notification);
|
||||
if (empty($type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$subscriptions = DBA::select('subscription', [], ['uid' => $notification['uid'], $type => true]);
|
||||
while ($subscription = DBA::fetch($subscriptions)) {
|
||||
Logger::info('Push notification', ['id' => $subscription['id'], 'uid' => $subscription['uid'], 'type' => $type]);
|
||||
}
|
||||
DBA::close($subscriptions);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue