]> git.mxchange.org Git - friendica.git/commitdiff
Added logging, removed superfluous comments
authorMichael <heluecht@pirati.ca>
Mon, 16 Aug 2021 15:23:34 +0000 (15:23 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 16 Aug 2021 15:23:34 +0000 (15:23 +0000)
src/Model/Subscription.php
src/Worker/PushSubscription.php
static/defaults.config.php

index 5fb88911ac4dc903a28da7f03652ace6f07a19bb..e3bbadcbf00141320eadff15061e0e1acaa72df6 100644 (file)
  *
  */
 
- /**
-  * @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\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Util\Crypto;
 use Minishlink\WebPush\VAPID;
 
 class Subscription
index f3c3a4046faa687771d7c2efd1646ef7dfe257c1..f740410e03127399b45682a9a5afc7209564fe51 100644 (file)
@@ -34,8 +34,19 @@ class PushSubscription
 {
        public static function execute(int $sid, int $nid)
        {
+               Logger::info('Start', ['subscription' => $sid, 'notification' => $nid]);
+
                $subscription = DBA::selectFirst('subscription', [], ['id' => $sid]);
+               if (empty($subscription)) {
+                       Logger::info('Subscription not found', ['subscription' => $sid]);
+                       return;
+               }
+
                $notification = DBA::selectFirst('notification', [], ['id' => $nid]);
+               if (empty($notification)) {
+                       Logger::info('Notification not found', ['notification' => $nid]);
+                       return;
+               }
 
                if (!empty($notification['uri-id'])) {
                        $notify = DBA::selectFirst('notify', ['msg'], ['uri-id' => $notification['target-uri-id']]);
@@ -71,7 +82,7 @@ class PushSubscription
                        ],
                ];
 
-               $webPush = new WebPush($auth);
+               $webPush = new WebPush($auth, [], DI::config()->get('system', 'xrd_timeout'));
 
                $report = $webPush->sendOneNotification(
                        $push['subscription'],
@@ -81,9 +92,9 @@ class PushSubscription
                $endpoint = $report->getRequest()->getUri()->__toString();
 
                if ($report->isSuccess()) {
-                       Logger::info('Message sent successfully for subscription', ['endpoint' => $endpoint]);
+                       Logger::info('Message sent successfully for subscription', ['subscription' => $sid, 'notification' => $nid, 'endpoint' => $endpoint]);
                } else {
-                       Logger::info('Message failed to sent for subscription', ['endpoint' => $endpoint, 'reason' => $report->getReason()]);
+                       Logger::info('Message failed to sent for subscription', ['subscription' => $sid, 'notification' => $nid, 'endpoint' => $endpoint, 'reason' => $report->getReason()]);
                }
        }
 }
index 20f351ab0eb66abec63cbc69af9c3f8519f039ae..b405d5f5e4dd76489f0c9c5c1f72d04d701c8731 100644 (file)
@@ -568,7 +568,7 @@ return [
                'worker_defer_limit' => 15,
 
                // xrd_timeout (Integer)
-               // Timeout in seconds for fetching the XRD links.
+               // Timeout in seconds for fetching the XRD links and other requests with an expected shorter timeout
                'xrd_timeout' => 20,
        ],
        'experimental' => [