script to renew websub subscriptions
[phinde.git] / bin / subscribe.php
index 768ee102a0182967c2fd8856de9f6a460d2b45b4..411fa8671cb86dfde43ec9c56eb9494e0f7be122 100755 (executable)
@@ -43,12 +43,16 @@ if ($topic != $url) {
 }
 
 $sub = $subDb->get($topic);
-if ($sub !== false) {
-    Log::error('Topic exists already in subscription table');
-    Log::info('Current status: ' . $sub->sub_status);
-    exit(3);
+if ($sub === false) {
+    $subDb->create($topic);
+} else {
+    Log::info(
+        'Topic exists already in subscription table with status '
+        . $sub->sub_status
+    );
+    Log::info('Renewing subscription...');
+    $subDb->renew($sub->sub_id);
 }
-$subDb->create($topic);
 $sub = $subDb->get($topic);
 
 $callbackUrl = $GLOBALS['phinde']['baseurl'] . 'push-subscription.php'