diff --git a/composer.lock b/composer.lock index 379b97db..b0c6dab8 100644 --- a/composer.lock +++ b/composer.lock @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/daita/my-small-php-tools.git", - "reference": "ba839f3253672defc4bbb181493c78e2c96e272a" + "reference": "12090dc3ae29d2eb49d5274ca3f6ebfb76ce5997" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/ba839f3253672defc4bbb181493c78e2c96e272a", - "reference": "ba839f3253672defc4bbb181493c78e2c96e272a", + "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/12090dc3ae29d2eb49d5274ca3f6ebfb76ce5997", + "reference": "12090dc3ae29d2eb49d5274ca3f6ebfb76ce5997", "shasum": "" }, "require": { @@ -40,7 +40,7 @@ } ], "description": "My small PHP Tools", - "time": "2018-11-27T14:31:43+00:00" + "time": "2018-11-28T10:47:43+00:00" } ], "packages-dev": [], diff --git a/lib/Service/CurlService.php b/lib/Service/CurlService.php index 3a420560..1aa94cc3 100644 --- a/lib/Service/CurlService.php +++ b/lib/Service/CurlService.php @@ -44,6 +44,7 @@ class CurlService { const ASYNC_TOKEN = '/async/token/{token}'; + const USER_AGENT = 'Nextcloud Social'; /** @var ConfigService */ @@ -104,6 +105,13 @@ class CurlService { } + public function assignUserAgent(Request $request) { + $request->setUserAgent( + self::USER_AGENT . ' ' . $this->configService->getAppValue('installed_version') + ); + } + + /** * @param string $token * @@ -139,6 +147,7 @@ class CurlService { $headers[] = 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; + curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent()); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($curl, CURLOPT_TIMEOUT, 20);