From bc83eb5c4e7baadadfd19df62418848a6918cfc5 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 Jan 2020 05:57:05 +0000 Subject: [PATCH] Improved server platform detection --- src/Model/GServer.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Model/GServer.php b/src/Model/GServer.php index a85ab2408d..eca4c5a7e2 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -931,6 +931,11 @@ class GServer $serverdata['site_name'] = $data['title']; } + if (!empty($data['title']) && empty($serverdata['platform']) && empty($serverdata['network'])) { + $serverdata['platform'] = 'mastodon'; + $serverdata['network'] = Protocol::ACTIVITYPUB; + } + if (!empty($data['description'])) { $serverdata['info'] = trim($data['description']); } @@ -944,9 +949,14 @@ class GServer $serverdata['version'] = $matches[2]; } - if (!empty($serverdata['version']) && strstr($serverdata['version'], 'Pleroma')) { + if (!empty($serverdata['version']) && strstr(strtolower($serverdata['version']), 'pleroma')) { + $serverdata['platform'] = 'pleroma'; + $serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version'])); + } + + if (!empty($serverdata['platform']) && strstr($serverdata['platform'], 'pleroma')) { + $serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform'])); $serverdata['platform'] = 'pleroma'; - $serverdata['version'] = trim(str_replace('Pleroma', '', $serverdata['version'])); } return $serverdata; @@ -1203,10 +1213,8 @@ class GServer $serverdata['network'] = Protocol::ACTIVITYPUB; } } - - if ($attr['name'] == 'generator') { + if (($attr['name'] == 'generator') && (empty($serverdata['platform']) || (substr(strtolower($attr['content']), 0, 9) == 'wordpress'))) { $serverdata['platform'] = strtolower($attr['content']); - $version_part = explode(' ', $attr['content']); if (count($version_part) == 2) { -- 2.39.5