]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Don't try to replace http with https if https already exists
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 14 Jan 2016 12:06:37 +0000 (13:06 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 14 Jan 2016 12:06:37 +0000 (13:06 +0100)
plugins/OStatus/classes/HubSub.php
plugins/OStatus/lib/huboutqueuehandler.php

index 6499e1b4cf081307375b1626ea3d1c7a7cc03f63..732ef33743dd83ac11079dcb20cd5795fef9a45d 100644 (file)
@@ -306,10 +306,13 @@ class HubSub extends Managed_DataObject
         if ('http' === parse_url($this->callback, PHP_URL_SCHEME)) {
             // Test if the feed callback for this node has migrated to HTTPS
             $httpscallback = preg_replace('/^http/', 'https', $this->callback, 1);
-            if ($httpscallback === $this->callback) {
-                throw new ServerException('Trying to preg_replace http to https on '._ve($this->callback).' failed and resulted in an identical string: '._ve($httpscallback).'.');
+            $alreadyreplaced = self::getByHashKey(self::hashkey($this->getTopic(), $httpscallback));
+            if ($alreadyreplaced instanceof HubSub) {
+                $this->delete();
+                throw new AlreadyFulfilledException('The remote side has already established an HTTPS callback, deleting the legacy HTTP entry.');
             }
-            common_debug('PuSH callback to '._ve($this->callback).' for '._ve($this->getTopic()).' testing with HTTPS callback: '._ve($httpscallback));
+
+            common_debug('PuSH callback to '._ve($this->callback).' for '._ve($this->getTopic()).' trying HTTPS callback: '._ve($httpscallback));
             $response = $request->post($httpscallback, $headers);
             if ($response->isOk()) {
                 $orig = clone($this);
index 9cab847cc29646b3f8a2469d44dd7d17fc01728f..590f2e3b25e99c1304a9093a9c4c8a3729ba71cf 100644 (file)
@@ -44,10 +44,11 @@ class HubOutQueueHandler extends QueueHandler
 
         try {
             $sub->push($atom);
+        } catch (AlreadyFulfilledException $e) {
+            common_log(LOG_INFO, "Failed PuSH to $sub->callback for $sub->topic (".get_class($e)."): " . $e->getMessage());
         } catch (Exception $e) {
             $retries--;
-            $msg = "Failed PuSH to $sub->callback for $sub->topic: " .
-                   $e->getMessage();
+            $msg = "Failed PuSH to $sub->callback for $sub->topic (".get_class($e)."): " . $e->getMessage();
             if ($retries > 0) {
                 common_log(LOG_INFO, "$msg; scheduling for $retries more tries");