]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Present http:// alias by default in WebFinger output
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 15 Feb 2015 12:17:04 +0000 (13:17 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 15 Feb 2015 12:17:51 +0000 (13:17 +0100)
because it might help us (and especially StatusNet sites) to recognize
profiles that have migrated from HTTP to HTTPS!

plugins/WebFinger/WebFingerPlugin.php
plugins/WebFinger/lib/webfingerresource.php

index f7e428e54cd8202caa31b131c604a5fc62ae6925..e1e6a1b41c1f075c0a4a8e5ad586804832377bdc 100644 (file)
@@ -31,6 +31,13 @@ if (!defined('GNUSOCIAL')) { exit(1); }
 
 class WebFingerPlugin extends Plugin
 {
+    public $http_alias = true;
+
+    public function initialize()
+    {
+        common_config_set('webfinger', 'http_alias', $this->http_alias);
+    }
+
     public function onRouterInitialized($m)
     {
         $m->connect('.well-known/host-meta', array('action' => 'hostmeta'));
index d473d95628f4a73f3ea28068ba3002fc4108e94c..61b2cc09adbedcd81350ed2d82db256aa59fb151 100644 (file)
@@ -34,7 +34,12 @@ abstract class WebFingerResource
         $aliases = array();
 
         // Add the URI as an identity, this is _not_ necessarily an HTTP url
-        $aliases[] = $this->object->getUri();
+        $uri = $this->object->getUri();
+        $aliases[] = $uri;
+        if (common_config('webfinger', 'http_alias')
+                && strtolower(parse_url($uri, PHP_URL_SCHEME)) === 'https') {
+            $aliases[] = preg_replace('/^https:/', 'http:', $uri, 1);
+        }
 
         try {
             $aliases[] = $this->object->getUrl();