kopia lustrzana https://github.com/nextcloud/social
include nextcloud subject
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/1226/head
rodzic
9773264678
commit
82f0eea430
|
@ -31,20 +31,13 @@ declare(strict_types=1);
|
|||
namespace OCA\Social\AppInfo;
|
||||
|
||||
|
||||
use Closure;
|
||||
use OC\DB\SchemaWrapper;
|
||||
use OCA\Social\Handlers\WebfingerHandler;
|
||||
use OCA\Social\Notification\Notifier;
|
||||
use OCA\Social\Search\UnifiedSearchProvider;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\UpdateService;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\IServerContainer;
|
||||
use Throwable;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
|
@ -56,8 +49,10 @@ require_once __DIR__ . '/../../vendor/autoload.php';
|
|||
class Application extends App implements IBootstrap {
|
||||
|
||||
|
||||
const APP_NAME = 'social';
|
||||
|
||||
const APP_ID = 'social';
|
||||
const APP_NAME = 'Social';
|
||||
const APP_REL = 'https://apps.nextcloud.com/apps/social';
|
||||
const NEXTCLOUD_SUBJECT = 'http://nextcloud.com/';
|
||||
|
||||
/**
|
||||
* Application constructor.
|
||||
|
@ -65,7 +60,7 @@ class Application extends App implements IBootstrap {
|
|||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params = []) {
|
||||
parent::__construct(self::APP_NAME, $params);
|
||||
parent::__construct(self::APP_ID, $params);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ use TNC20Logger;
|
|||
FollowService $followService, StreamService $streamService, ConfigService $configService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->socialPubController = $socialPubController;
|
||||
$this->fediverseService = $fediverseService;
|
||||
|
|
|
@ -125,7 +125,7 @@ class ApiController extends Controller {
|
|||
FollowService $followService, StreamService $streamService, ConfigService $configService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->userSession = $userSession;
|
||||
$this->instanceService = $instanceService;
|
||||
|
|
|
@ -138,7 +138,7 @@ class LocalController extends Controller {
|
|||
BoostService $boostService, LikeService $likeService, DocumentService $documentService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->userId = $userId;
|
||||
$this->cacheActorService = $cacheActorService;
|
||||
|
|
|
@ -115,7 +115,7 @@ class NavigationController extends Controller {
|
|||
AccountService $accountService, DocumentService $documentService,
|
||||
ConfigService $configService, CheckService $checkService, MiscService $miscService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->userId = $userId;
|
||||
$this->l10n = $l10n;
|
||||
|
@ -168,8 +168,8 @@ class NavigationController extends Controller {
|
|||
if ($cloudAddress !== null) {
|
||||
$this->configService->setCloudUrl($cloudAddress);
|
||||
} else {
|
||||
$this->initialStateService->provideInitialState(Application::APP_NAME, 'serverData', $serverData);
|
||||
return new TemplateResponse(Application::APP_NAME, 'main');
|
||||
$this->initialStateService->provideInitialState(Application::APP_ID, 'serverData', $serverData);
|
||||
return new TemplateResponse(Application::APP_ID, 'main');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ class NavigationController extends Controller {
|
|||
// neither.
|
||||
}
|
||||
|
||||
$this->initialStateService->provideInitialState(Application::APP_NAME, 'serverData', $serverData);
|
||||
return new TemplateResponse(Application::APP_NAME, 'main');
|
||||
$this->initialStateService->provideInitialState(Application::APP_ID, 'serverData', $serverData);
|
||||
return new TemplateResponse(Application::APP_ID, 'main');
|
||||
}
|
||||
|
||||
private function setupCloudAddress(): string {
|
||||
|
|
|
@ -102,7 +102,7 @@ class OAuthController extends Controller {
|
|||
CacheActorService $cacheActorService, ClientService $clientService, ConfigService $configService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->userSession = $userSession;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
|
|
|
@ -91,7 +91,7 @@ class OStatusController extends Controller {
|
|||
IRequest $request, IInitialStateService $initialStateService, CacheActorService $cacheActorService, AccountService $accountService,
|
||||
CurlService $curlService, MiscService $miscService, IUserSession $userSession
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->initialStateService = $initialStateService;
|
||||
$this->cacheActorService = $cacheActorService;
|
||||
|
|
|
@ -73,7 +73,7 @@ class QueueController extends Controller {
|
|||
IRequest $request, RequestQueueService $requestQueueService, ActivityService $activityService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->requestQueueService = $requestQueueService;
|
||||
$this->activityService = $activityService;
|
||||
|
|
|
@ -107,7 +107,7 @@ class SocialPubController extends Controller {
|
|||
NavigationController $navigationController, CacheActorService $cacheActorService,
|
||||
AccountService $accountService, StreamService $streamService, ConfigService $configService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
|
||||
$this->userId = $userId;
|
||||
$this->initialStateService = $initialStateService;
|
||||
|
@ -151,7 +151,7 @@ class SocialPubController extends Controller {
|
|||
'public' => true,
|
||||
]
|
||||
);
|
||||
$page = new PublicTemplateResponse(Application::APP_NAME, 'main', $data);
|
||||
$page = new PublicTemplateResponse(Application::APP_ID, 'main', $data);
|
||||
$page->setStatus($status);
|
||||
$page->setHeaderTitle($this->l10n->t('Social'));
|
||||
|
||||
|
@ -241,14 +241,14 @@ class SocialPubController extends Controller {
|
|||
'application' => 'Social'
|
||||
];
|
||||
|
||||
$this->initialStateService->provideInitialState(Application::APP_NAME, 'item', $stream);
|
||||
$this->initialStateService->provideInitialState(Application::APP_ID, 'item', $stream);
|
||||
$this->initialStateService->provideInitialState(
|
||||
Application::APP_NAME, 'serverData', [
|
||||
Application::APP_ID, 'serverData', [
|
||||
'public' => ($this->userId === null),
|
||||
]
|
||||
);
|
||||
|
||||
return new TemplateResponse(Application::APP_NAME, 'main', $data);
|
||||
return new TemplateResponse(Application::APP_ID, 'main', $data);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace OCA\Social\Handlers;
|
|||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Db\CacheActorsRequest;
|
||||
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
|
@ -117,6 +118,12 @@ class WebfingerHandler implements IHandler {
|
|||
$response = new JrdResponse($subject);
|
||||
}
|
||||
|
||||
if ($subject === Application::NEXTCLOUD_SUBJECT) {
|
||||
$this->manageNextcloudSubject($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
if (strpos($subject, 'acct:') === 0) {
|
||||
$subject = substr($subject, 5);
|
||||
}
|
||||
|
@ -149,5 +156,19 @@ class WebfingerHandler implements IHandler {
|
|||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param JrdResponse $response
|
||||
*/
|
||||
private function manageNextcloudSubject(JrdResponse $response) {
|
||||
$info = [
|
||||
'app' => Application::APP_ID,
|
||||
'name' => Application::APP_NAME,
|
||||
'version' => $this->configService->getAppValue('installed_version')
|
||||
];
|
||||
|
||||
$response->addLink(Application::APP_REL, '', '', [], $info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class Notifier implements INotifier {
|
|||
* @since 17.0.0
|
||||
*/
|
||||
public function getID(): string {
|
||||
return Application::APP_NAME;
|
||||
return Application::APP_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,11 +104,11 @@ class Notifier implements INotifier {
|
|||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
if ($notification->getApp() !== Application::APP_NAME) {
|
||||
if ($notification->getApp() !== Application::APP_ID) {
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
|
||||
$l10n = $this->factory->get(Application::APP_NAME, $languageCode);
|
||||
$l10n = $this->factory->get(Application::APP_ID, $languageCode);
|
||||
|
||||
$notification->setIcon(
|
||||
$this->url->getAbsoluteURL($this->url->imagePath('social', 'social_dark.svg'))
|
||||
|
|
|
@ -29,6 +29,7 @@ use daita\MySmallPhpTools\Traits\TStringTools;
|
|||
use Exception;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use OC\User\NoUserException;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Db\CacheActorsRequest;
|
||||
use OCA\Social\Db\FollowsRequest;
|
||||
use OCA\Social\Db\StreamDestRequest;
|
||||
|
@ -315,8 +316,9 @@ class CheckService {
|
|||
* @return bool
|
||||
*/
|
||||
private function requestWellKnown(string $base) {
|
||||
|
||||
try {
|
||||
$url = $base . '/.well-known/webfinger';
|
||||
$url = $base . '/.well-known/webfinger?resource=' . Application::NEXTCLOUD_SUBJECT;
|
||||
$options['nextcloud']['allow_local_address'] = true;
|
||||
$response = $this->clientService->newClient()
|
||||
->get($url, $options);
|
||||
|
|
|
@ -158,7 +158,7 @@ class ConfigService {
|
|||
$defaultValue = $this->defaults[$key];
|
||||
}
|
||||
|
||||
return $this->config->getAppValue(Application::APP_NAME, $key, $defaultValue);
|
||||
return $this->config->getAppValue(Application::APP_ID, $key, $defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,7 +174,7 @@ class ConfigService {
|
|||
$defaultValue = $this->defaults[$key];
|
||||
}
|
||||
|
||||
return (int)$this->config->getAppValue(Application::APP_NAME, $key, $defaultValue);
|
||||
return (int)$this->config->getAppValue(Application::APP_ID, $key, $defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,7 +186,7 @@ class ConfigService {
|
|||
* @return void
|
||||
*/
|
||||
public function setAppValue($key, $value) {
|
||||
$this->config->setAppValue(Application::APP_NAME, $key, $value);
|
||||
$this->config->setAppValue(Application::APP_ID, $key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,7 +197,7 @@ class ConfigService {
|
|||
* @return string
|
||||
*/
|
||||
public function deleteAppValue($key) {
|
||||
return $this->config->deleteAppValue(Application::APP_NAME, $key);
|
||||
return $this->config->deleteAppValue(Application::APP_ID, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,7 +216,7 @@ class ConfigService {
|
|||
|
||||
$defaultValue = '';
|
||||
if ($app === '') {
|
||||
$app = Application::APP_NAME;
|
||||
$app = Application::APP_ID;
|
||||
if (array_key_exists($key, $this->defaults)) {
|
||||
$defaultValue = $this->defaults[$key];
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ class ConfigService {
|
|||
* @throws PreConditionNotMetException
|
||||
*/
|
||||
public function setUserValue($key, $value) {
|
||||
return $this->config->setUserValue($this->userId, Application::APP_NAME, $key, $value);
|
||||
return $this->config->setUserValue($this->userId, Application::APP_ID, $key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,7 +247,7 @@ class ConfigService {
|
|||
* @return string
|
||||
*/
|
||||
public function getValueForUser($userId, $key) {
|
||||
return $this->config->getUserValue($userId, Application::APP_NAME, $key);
|
||||
return $this->config->getUserValue($userId, Application::APP_ID, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +261,7 @@ class ConfigService {
|
|||
* @throws PreConditionNotMetException
|
||||
*/
|
||||
public function setValueForUser($userId, $key, $value) {
|
||||
return $this->config->setUserValue($userId, Application::APP_NAME, $key, $value);
|
||||
return $this->config->setUserValue($userId, Application::APP_ID, $key, $value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -294,7 +294,7 @@ class ConfigService {
|
|||
*
|
||||
*/
|
||||
public function unsetAppConfig() {
|
||||
$this->config->deleteAppValues(Application::APP_NAME);
|
||||
$this->config->deleteAppValues(Application::APP_ID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class MiscService {
|
|||
*/
|
||||
public function log($message, $level = 2) {
|
||||
$data = array(
|
||||
'app' => Application::APP_NAME,
|
||||
'app' => Application::APP_ID,
|
||||
'level' => $level
|
||||
);
|
||||
|
||||
|
|
|
@ -587,7 +587,7 @@ class SignatureService {
|
|||
private static function getContextCacheFolder(): ISimpleFolder {
|
||||
$path = 'context';
|
||||
|
||||
$appData = OC::$server->getAppDataDir(Application::APP_NAME);
|
||||
$appData = OC::$server->getAppDataDir(Application::APP_ID);
|
||||
try {
|
||||
$folder = $appData->getFolder($path);
|
||||
} catch (NotFoundException $e) {
|
||||
|
|
Ładowanie…
Reference in New Issue