- Ensure leading slash is present at every place the configuration value is used
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Contact;
+
+use Friendica\Core\Config\Capability\IManageConfigValues;
+
+class Header
+{
+ /** @var IManageConfigValues */
+ private $config;
+
+ public function __construct(IManageConfigValues $config)
+ {
+ $this->config = $config;
+ }
+
+ /**
+ * Returns the Mastodon banner path relative to the Friendica folder.
+ *
+ * Ensures the existence of a leading slash.
+ *
+ * @return string
+ */
+ public function getMastodonBannerPath(): string
+ {
+ return '/' . ltrim($this->config->get('api', 'mastodon_banner'), '/');
+ }
+}
namespace Friendica\Model;
use Friendica\Contact\Avatar;
+use Friendica\Contact\Header;
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
use Friendica\Content\Conversation as ConversationContent;
switch ($platform) {
case 'friendica':
case 'friendika':
- $header = DI::baseUrl() . '/images/friendica-banner.jpg';
+ $header = DI::baseUrl() . (new Header(DI::config()))->getMastodonBannerPath();
break;
case 'diaspora':
/**
use Exception;
use Friendica\App;
+use Friendica\Contact\Header;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\System;
/** @var IManageConfigValues */
private $config;
+ /** @var Header */
+ private $contactHeader;
+
public function __construct(
App $app,
L10n $l10n,
) {
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- $this->database = $database;
- $this->config = $config;
+ $this->database = $database;
+ $this->config = $config;
+ $this->contactHeader = new Header($config);
}
/**
$version = '2.8.0 (compatible; Friendica ' . App::VERSION . ')';
$description = $this->config->get('config', 'info');
$usage = $this->buildUsageInfo();
- $thumbnail = new InstanceEntity\Thumbnail($this->baseUrl->withPath('images/friendica-banner.jpg'));
+ $thumbnail = new InstanceEntity\Thumbnail($this->baseUrl . $this->contactHeader->getMastodonBannerPath());
$languages = [$this->config->get('system', 'language')];
$configuration = $this->buildConfigurationInfo();
$registration = $this->buildRegistrationsInfo();
namespace Friendica\Module;
use Friendica\BaseModule;
+use Friendica\Contact\Header;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
if (!empty($photo)) {
return $photo;
}
- return MPhoto::createPhotoForImageData(file_get_contents(DI::basePath() . '/images/friendica-banner.jpg'));
+ return MPhoto::createPhotoForImageData(file_get_contents(DI::basePath() . (new Header(DI::config()))->getMastodonBannerPath()));
}
}
use Friendica\App;
use Friendica\App\BaseURL;
use Friendica\BaseDataTransferObject;
+use Friendica\Contact\Header;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Database\Database;
use Friendica\DI;
$this->version = '2.8.0 (compatible; Friendica ' . App::VERSION . ')';
$this->urls = ['streaming_api' => '']; // Not supported
$this->stats = new Stats($config, $database);
- $this->thumbnail = $baseUrl . $config->get('api', 'mastodon_banner');
+ $this->thumbnail = $baseUrl . (new Header($config))->getMastodonBannerPath();
$this->languages = [$config->get('system', 'language')];
$this->max_toot_chars = (int)$config->get('config', 'api_import_size', $config->get('config', 'max_import_size'));
$this->registrations = ($register_policy != Register::CLOSED);