Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Controller/HoverCardController.php84
-rw-r--r--core/routes.php2
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
4 files changed, 88 insertions, 0 deletions
diff --git a/core/Controller/HoverCardController.php b/core/Controller/HoverCardController.php
new file mode 100644
index 00000000000..cb85da112a4
--- /dev/null
+++ b/core/Controller/HoverCardController.php
@@ -0,0 +1,84 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright 2021 Joas Schilling <coding@schilljs.com>
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @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 <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC\Core\Controller;
+
+use OC\Contacts\ContactsMenu\Manager;
+use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\Contacts\ContactsMenu\IEntry;
+use OCP\IRequest;
+use OCP\IUserSession;
+use OCP\Share\IShare;
+
+class HoverCardController extends \OCP\AppFramework\OCSController {
+
+ /** @var Manager */
+ private $manager;
+
+ /** @var IUserSession */
+ private $userSession;
+
+ /**
+ * @param IRequest $request
+ * @param IUserSession $userSession
+ * @param Manager $manager
+ */
+ public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) {
+ parent::__construct('core', $request);
+ $this->userSession = $userSession;
+ $this->manager = $manager;
+ }
+
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $userId
+ * @return DataResponse
+ */
+ public function getUser(string $userId): DataResponse {
+ $contact = $this->manager->findOne($this->userSession->getUser(), IShare::TYPE_USER, $userId);
+
+ if (!$contact) {
+ return new DataResponse([], Http::STATUS_NOT_FOUND);
+ }
+
+ $data = $this->entryToArray($contact);
+
+ $actions = $data['actions'];
+ if ($data['topAction']) {
+ array_unshift($actions, $data['topAction']);
+ }
+
+ return new DataResponse([
+ 'userId' => $userId,
+ 'displayName' => $contact->getFullName(),
+ 'actions' => $actions,
+ ]);
+ }
+
+ protected function entryToArray(IEntry $entry): array {
+ return json_decode(json_encode($entry), true);
+ }
+}
diff --git a/core/routes.php b/core/routes.php
index 59988404cd4..5750dac2ad1 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -110,6 +110,8 @@ $application->registerRoutes($this, [
['root' => '/core', 'name' => 'AppPassword#rotateAppPassword', 'url' => '/apppassword/rotate', 'verb' => 'POST'],
['root' => '/core', 'name' => 'AppPassword#deleteAppPassword', 'url' => '/apppassword', 'verb' => 'DELETE'],
+ ['root' => '/hovercard', 'name' => 'HoverCard#getUser', 'url' => '/v1/{userId}', 'verb' => 'GET'],
+
['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'],
['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'],
['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'],
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 53f75ebf27b..72e3ff8a8e4 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -920,6 +920,7 @@ return array(
'OC\\Core\\Controller\\ContactsMenuController' => $baseDir . '/core/Controller/ContactsMenuController.php',
'OC\\Core\\Controller\\CssController' => $baseDir . '/core/Controller/CssController.php',
'OC\\Core\\Controller\\GuestAvatarController' => $baseDir . '/core/Controller/GuestAvatarController.php',
+ 'OC\\Core\\Controller\\HoverCardController' => $baseDir . '/core/Controller/HoverCardController.php',
'OC\\Core\\Controller\\JsController' => $baseDir . '/core/Controller/JsController.php',
'OC\\Core\\Controller\\LoginController' => $baseDir . '/core/Controller/LoginController.php',
'OC\\Core\\Controller\\LostController' => $baseDir . '/core/Controller/LostController.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 3388cc945af..c689a1c011e 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -949,6 +949,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Core\\Controller\\ContactsMenuController' => __DIR__ . '/../../..' . '/core/Controller/ContactsMenuController.php',
'OC\\Core\\Controller\\CssController' => __DIR__ . '/../../..' . '/core/Controller/CssController.php',
'OC\\Core\\Controller\\GuestAvatarController' => __DIR__ . '/../../..' . '/core/Controller/GuestAvatarController.php',
+ 'OC\\Core\\Controller\\HoverCardController' => __DIR__ . '/../../..' . '/core/Controller/HoverCardController.php',
'OC\\Core\\Controller\\JsController' => __DIR__ . '/../../..' . '/core/Controller/JsController.php',
'OC\\Core\\Controller\\LoginController' => __DIR__ . '/../../..' . '/core/Controller/LoginController.php',
'OC\\Core\\Controller\\LostController' => __DIR__ . '/../../..' . '/core/Controller/LostController.php',