12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- declare(strict_types=1);
- namespace OC\Core\Controller;
- use OC\Contacts\ContactsMenu\Manager;
- use OC\Core\ResponseDefinitions;
- use OCP\AppFramework\Http;
- use OCP\AppFramework\Http\Attribute\ApiRoute;
- use OCP\AppFramework\Http\Attribute\NoAdminRequired;
- use OCP\AppFramework\Http\DataResponse;
- use OCP\IRequest;
- use OCP\IUserSession;
- use OCP\Share\IShare;
- class HoverCardController extends \OCP\AppFramework\OCSController {
- public function __construct(
- IRequest $request,
- private IUserSession $userSession,
- private Manager $manager,
- ) {
- parent::__construct('core', $request);
- }
-
-
-
- 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 = $contact->jsonSerialize();
- $actions = $data['actions'];
- if ($data['topAction']) {
- array_unshift($actions, $data['topAction']);
- }
-
- return new DataResponse([
- 'userId' => $userId,
- 'displayName' => $contact->getFullName(),
- 'actions' => $actions,
- ]);
- }
- }
|