|
19 | 19 | use OCA\Libresign\Service\Identify\ResultFilter; |
20 | 20 | use OCA\Libresign\Service\Identify\ResultFormatter; |
21 | 21 | use OCA\Libresign\Service\Identify\SearchNormalizer; |
| 22 | +use OCA\Libresign\Service\Identify\ShareTypeResolver; |
22 | 23 | use OCA\Libresign\Service\Identify\SignerSearchContext; |
23 | | -use OCA\Libresign\Service\IdentifyMethod\Account; |
24 | | -use OCA\Libresign\Service\IdentifyMethod\Email; |
25 | 24 | use OCP\AppFramework\Http; |
26 | 25 | use OCP\AppFramework\Http\Attribute\ApiRoute; |
27 | 26 | use OCP\AppFramework\Http\Attribute\NoAdminRequired; |
28 | 27 | use OCP\AppFramework\Http\DataResponse; |
29 | 28 | use OCP\Collaboration\Collaborators\ISearch; |
30 | 29 | use OCP\IRequest; |
31 | | -use OCP\Share\IShare; |
32 | 30 |
|
33 | 31 | /** |
34 | 32 | * @psalm-import-type LibresignIdentifyAccount from ResponseDefinitions |
35 | 33 | */ |
36 | 34 | class IdentifyController extends AEnvironmentAwareController { |
37 | | - private const PHONE_METHODS = ['whatsapp', 'sms', 'telegram', 'signal']; |
38 | | - |
39 | 35 | public function __construct( |
40 | 36 | IRequest $request, |
41 | 37 | private ISearch $collaboratorSearch, |
42 | | - private Email $identifyEmailMethod, |
43 | | - private Account $identifyAccountMethod, |
| 38 | + private ShareTypeResolver $shareTypeResolver, |
44 | 39 | private SearchNormalizer $searchNormalizer, |
45 | 40 | private SignerSearchContext $signerSearchContext, |
46 | 41 | private ResultFilter $resultFilter, |
@@ -76,7 +71,7 @@ public function search(string $search = '', string $method = '', int $page = 1, |
76 | 71 | return new DataResponse([]); |
77 | 72 | } |
78 | 73 |
|
79 | | - $shareTypes = $this->getShareTypes(); |
| 74 | + $shareTypes = $this->shareTypeResolver->resolve($method); |
80 | 75 | $offset = $limit * ($page - 1); |
81 | 76 |
|
82 | 77 | $this->signerSearchContext->set($method, $search, $rawSearch); |
@@ -112,21 +107,4 @@ private function registerPlugin(): void { |
112 | 107 | $refProperty->setValue($this->collaboratorSearch, $plugins); |
113 | 108 | } |
114 | 109 |
|
115 | | - private function getShareTypes(): array { |
116 | | - $shareTypes = []; |
117 | | - $settings = $this->identifyEmailMethod->getSettings(); |
118 | | - if ($settings['enabled']) { |
119 | | - $shareTypes[] = IShare::TYPE_EMAIL; |
120 | | - } |
121 | | - $settings = $this->identifyAccountMethod->getSettings(); |
122 | | - if ($settings['enabled']) { |
123 | | - $shareTypes[] = IShare::TYPE_USER; |
124 | | - } |
125 | | - |
126 | | - $shareTypes[] = SignerPlugin::TYPE_SIGNER; |
127 | | - $shareTypes[] = AccountPhonePlugin::TYPE_SIGNER_ACCOUNT_PHONE; |
128 | | - $shareTypes[] = ContactPhonePlugin::TYPE_SIGNER_CONTACT_PHONE; |
129 | | - $shareTypes[] = ManualPhonePlugin::TYPE_SIGNER_MANUAL_PHONE; |
130 | | - return $shareTypes; |
131 | | - } |
132 | 110 | } |
0 commit comments