]> git.mxchange.org Git - friendica.git/blob - src/Model/PushSubscriber.php
2794a0b6121c73ee29cf5350a822eb4b582e62fd
[friendica.git] / src / Model / PushSubscriber.php
1 <?php
2 /**
3  * @file src/Model/PushSubscriber.php
4  */
5 namespace Friendica\Model;
6
7 use Friendica\Core\Worker;
8 use dba;
9
10 require_once 'include/dba.php';
11
12 class PushSubscriber
13 {
14         /**
15          * @param string $priority Priority for push workers
16          */
17         public static function publishFeed($priority = PRIORITY_HIGH)
18         {
19                 // We'll push to each subscriber that has push > 0,
20                 // i.e. there has been an update (set in notifier.php).
21                 $subscribers = dba::select('push_subscriber', ['id', 'callback_url'], ["`push` > 0 AND `next_try` < UTC_TIMESTAMP()"]);
22
23                 while ($subscriber = dba::fetch($subscribers)) {
24                         logger("Publish feed to " . $subscriber["callback_url"], LOGGER_DEBUG);
25                         Worker::add($priority, 'PubSubPublish', (int)$subscriber["id"]);
26                 }
27
28                 dba::close($subscribers);
29         }
30 }