@@ -6,7 +6,7 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\LookupServerConnector\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
10 | - 'OCA\\LookupServerConnector\\BackgroundJobs\\RetryJob' => $baseDir . '/../lib/BackgroundJobs/RetryJob.php', |
|
11 | - 'OCA\\LookupServerConnector\\UpdateLookupServer' => $baseDir . '/../lib/UpdateLookupServer.php', |
|
9 | + 'OCA\\LookupServerConnector\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
10 | + 'OCA\\LookupServerConnector\\BackgroundJobs\\RetryJob' => $baseDir.'/../lib/BackgroundJobs/RetryJob.php', |
|
11 | + 'OCA\\LookupServerConnector\\UpdateLookupServer' => $baseDir.'/../lib/UpdateLookupServer.php', |
|
12 | 12 | ); |
@@ -6,29 +6,29 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitLookupServerConnector |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\LookupServerConnector\\' => 26, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\LookupServerConnector\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'OCA\\LookupServerConnector\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
25 | - 'OCA\\LookupServerConnector\\BackgroundJobs\\RetryJob' => __DIR__ . '/..' . '/../lib/BackgroundJobs/RetryJob.php', |
|
26 | - 'OCA\\LookupServerConnector\\UpdateLookupServer' => __DIR__ . '/..' . '/../lib/UpdateLookupServer.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'OCA\\LookupServerConnector\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
25 | + 'OCA\\LookupServerConnector\\BackgroundJobs\\RetryJob' => __DIR__.'/..'.'/../lib/BackgroundJobs/RetryJob.php', |
|
26 | + 'OCA\\LookupServerConnector\\UpdateLookupServer' => __DIR__.'/..'.'/../lib/UpdateLookupServer.php', |
|
27 | 27 | ); |
28 | 28 | |
29 | 29 | public static function getInitializer(ClassLoader $loader) |
30 | 30 | { |
31 | - return \Closure::bind(function () use ($loader) { |
|
31 | + return \Closure::bind(function() use ($loader) { |
|
32 | 32 | $loader->prefixLengthsPsr4 = ComposerStaticInitLookupServerConnector::$prefixLengthsPsr4; |
33 | 33 | $loader->prefixDirsPsr4 = ComposerStaticInitLookupServerConnector::$prefixDirsPsr4; |
34 | 34 | $loader->classMap = ComposerStaticInitLookupServerConnector::$classMap; |
@@ -34,51 +34,51 @@ |
||
34 | 34 | * @package OCA\LookupServerConnector |
35 | 35 | */ |
36 | 36 | class UpdateLookupServer { |
37 | - /** @var IConfig */ |
|
38 | - private $config; |
|
39 | - /** @var IJobList */ |
|
40 | - private $jobList; |
|
37 | + /** @var IConfig */ |
|
38 | + private $config; |
|
39 | + /** @var IJobList */ |
|
40 | + private $jobList; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IJobList $jobList |
|
44 | - * @param IConfig $config |
|
45 | - */ |
|
46 | - public function __construct(IJobList $jobList, |
|
47 | - IConfig $config) { |
|
48 | - $this->config = $config; |
|
49 | - $this->jobList = $jobList; |
|
50 | - } |
|
42 | + /** |
|
43 | + * @param IJobList $jobList |
|
44 | + * @param IConfig $config |
|
45 | + */ |
|
46 | + public function __construct(IJobList $jobList, |
|
47 | + IConfig $config) { |
|
48 | + $this->config = $config; |
|
49 | + $this->jobList = $jobList; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param IUser $user |
|
54 | - */ |
|
55 | - public function userUpdated(IUser $user): void { |
|
56 | - if (!$this->shouldUpdateLookupServer()) { |
|
57 | - return; |
|
58 | - } |
|
52 | + /** |
|
53 | + * @param IUser $user |
|
54 | + */ |
|
55 | + public function userUpdated(IUser $user): void { |
|
56 | + if (!$this->shouldUpdateLookupServer()) { |
|
57 | + return; |
|
58 | + } |
|
59 | 59 | |
60 | - // Reset retry counter |
|
61 | - $this->config->deleteUserValue( |
|
62 | - $user->getUID(), |
|
63 | - 'lookup_server_connector', |
|
64 | - 'update_retries' |
|
65 | - ); |
|
66 | - $this->jobList->add(RetryJob::class, ['userId' => $user->getUID()]); |
|
67 | - } |
|
60 | + // Reset retry counter |
|
61 | + $this->config->deleteUserValue( |
|
62 | + $user->getUID(), |
|
63 | + 'lookup_server_connector', |
|
64 | + 'update_retries' |
|
65 | + ); |
|
66 | + $this->jobList->add(RetryJob::class, ['userId' => $user->getUID()]); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * check if we should update the lookup server, we only do it if |
|
71 | - * |
|
72 | - * + we have an internet connection |
|
73 | - * + the lookup server update was not disabled by the admin |
|
74 | - * + we have a valid lookup server URL |
|
75 | - * |
|
76 | - * @return bool |
|
77 | - */ |
|
78 | - private function shouldUpdateLookupServer(): bool { |
|
79 | - return $this->config->getSystemValueBool('has_internet_connection', true) === true && |
|
80 | - $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') === 'yes' && |
|
81 | - $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') !== ''; |
|
82 | - } |
|
69 | + /** |
|
70 | + * check if we should update the lookup server, we only do it if |
|
71 | + * |
|
72 | + * + we have an internet connection |
|
73 | + * + the lookup server update was not disabled by the admin |
|
74 | + * + we have a valid lookup server URL |
|
75 | + * |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | + private function shouldUpdateLookupServer(): bool { |
|
79 | + return $this->config->getSystemValueBool('has_internet_connection', true) === true && |
|
80 | + $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') === 'yes' && |
|
81 | + $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') !== ''; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
@@ -27,30 +27,30 @@ |
||
27 | 27 | use Symfony\Component\EventDispatcher\GenericEvent; |
28 | 28 | |
29 | 29 | class Application extends App { |
30 | - public function __construct () { |
|
31 | - parent::__construct('lookup_server_connector'); |
|
32 | - } |
|
30 | + public function __construct () { |
|
31 | + parent::__construct('lookup_server_connector'); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Register the different app parts |
|
36 | - */ |
|
37 | - public function register(): void { |
|
38 | - $this->registerHooksAndEvents(); |
|
39 | - } |
|
34 | + /** |
|
35 | + * Register the different app parts |
|
36 | + */ |
|
37 | + public function register(): void { |
|
38 | + $this->registerHooksAndEvents(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Register the hooks and events |
|
43 | - */ |
|
44 | - public function registerHooksAndEvents(): void { |
|
45 | - $dispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
46 | - $dispatcher->addListener('OC\AccountManager::userUpdated', static function(GenericEvent $event) { |
|
47 | - /** @var IUser $user */ |
|
48 | - $user = $event->getSubject(); |
|
41 | + /** |
|
42 | + * Register the hooks and events |
|
43 | + */ |
|
44 | + public function registerHooksAndEvents(): void { |
|
45 | + $dispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
46 | + $dispatcher->addListener('OC\AccountManager::userUpdated', static function(GenericEvent $event) { |
|
47 | + /** @var IUser $user */ |
|
48 | + $user = $event->getSubject(); |
|
49 | 49 | |
50 | - /** @var UpdateLookupServer $updateLookupServer */ |
|
51 | - $updateLookupServer = \OC::$server->query(UpdateLookupServer::class); |
|
52 | - $updateLookupServer->userUpdated($user); |
|
53 | - }); |
|
50 | + /** @var UpdateLookupServer $updateLookupServer */ |
|
51 | + $updateLookupServer = \OC::$server->query(UpdateLookupServer::class); |
|
52 | + $updateLookupServer->userUpdated($user); |
|
53 | + }); |
|
54 | 54 | |
55 | - } |
|
55 | + } |
|
56 | 56 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | use Symfony\Component\EventDispatcher\GenericEvent; |
28 | 28 | |
29 | 29 | class Application extends App { |
30 | - public function __construct () { |
|
30 | + public function __construct() { |
|
31 | 31 | parent::__construct('lookup_server_connector'); |
32 | 32 | } |
33 | 33 |
@@ -36,177 +36,177 @@ |
||
36 | 36 | use OCP\IUserManager; |
37 | 37 | |
38 | 38 | class RetryJob extends Job { |
39 | - /** @var IClientService */ |
|
40 | - private $clientService; |
|
41 | - /** @var string */ |
|
42 | - private $lookupServer; |
|
43 | - /** @var IConfig */ |
|
44 | - private $config; |
|
45 | - /** @var IUserManager */ |
|
46 | - private $userManager; |
|
47 | - /** @var IAccountManager */ |
|
48 | - private $accountManager; |
|
49 | - /** @var Signer */ |
|
50 | - private $signer; |
|
51 | - /** @var int */ |
|
52 | - protected $retries = 0; |
|
53 | - /** @var bool */ |
|
54 | - protected $retainJob = false; |
|
55 | - |
|
56 | - /** |
|
57 | - * @param ITimeFactory $time |
|
58 | - * @param IClientService $clientService |
|
59 | - * @param IConfig $config |
|
60 | - * @param IUserManager $userManager |
|
61 | - * @param IAccountManager $accountManager |
|
62 | - * @param Signer $signer |
|
63 | - */ |
|
64 | - public function __construct(ITimeFactory $time, |
|
65 | - IClientService $clientService, |
|
66 | - IConfig $config, |
|
67 | - IUserManager $userManager, |
|
68 | - IAccountManager $accountManager, |
|
69 | - Signer $signer) { |
|
70 | - parent::__construct($time); |
|
71 | - $this->clientService = $clientService; |
|
72 | - $this->config = $config; |
|
73 | - $this->userManager = $userManager; |
|
74 | - $this->accountManager = $accountManager; |
|
75 | - $this->signer = $signer; |
|
76 | - |
|
77 | - $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); |
|
78 | - if (!empty($this->lookupServer)) { |
|
79 | - $this->lookupServer = rtrim($this->lookupServer, '/'); |
|
80 | - $this->lookupServer .= '/users'; |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * run the job, then remove it from the jobList |
|
86 | - * |
|
87 | - * @param IJobList $jobList |
|
88 | - * @param ILogger|null $logger |
|
89 | - */ |
|
90 | - public function execute($jobList, ILogger $logger = null): void { |
|
91 | - if (!isset($this->argument['userId'])) { |
|
92 | - // Old background job without user id, just drop it. |
|
93 | - $jobList->remove($this, $this->argument); |
|
94 | - return; |
|
95 | - } |
|
96 | - |
|
97 | - $this->retries = (int) $this->config->getUserValue($this->argument['userId'], 'lookup_server_connector', 'update_retries', 0); |
|
98 | - |
|
99 | - if ($this->shouldRemoveBackgroundJob()) { |
|
100 | - $jobList->remove($this, $this->argument); |
|
101 | - return; |
|
102 | - } |
|
103 | - |
|
104 | - if ($this->shouldRun()) { |
|
105 | - parent::execute($jobList, $logger); |
|
106 | - if (!$this->retainJob) { |
|
107 | - $jobList->remove($this, $this->argument); |
|
108 | - } |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Check if we should kill the background job: |
|
114 | - * |
|
115 | - * - internet connection is disabled |
|
116 | - * - no valid lookup server URL given |
|
117 | - * - lookup server was disabled by the admin |
|
118 | - * - max retries are reached (set to 5) |
|
119 | - * |
|
120 | - * @return bool |
|
121 | - */ |
|
122 | - protected function shouldRemoveBackgroundJob(): bool { |
|
123 | - return $this->config->getSystemValueBool('has_internet_connection', true) === false || |
|
124 | - $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') === '' || |
|
125 | - $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') !== 'yes' || |
|
126 | - $this->retries >= 5; |
|
127 | - } |
|
128 | - |
|
129 | - protected function shouldRun(): bool { |
|
130 | - $delay = 100 * 6 ** $this->retries; |
|
131 | - return ($this->time->getTime() - $this->lastRun) > $delay; |
|
132 | - } |
|
133 | - |
|
134 | - protected function run($argument): void { |
|
135 | - $user = $this->userManager->get($this->argument['userId']); |
|
136 | - if (!$user instanceof IUser) { |
|
137 | - // User does not exist anymore |
|
138 | - return; |
|
139 | - } |
|
140 | - |
|
141 | - $data = $this->getUserAccountData($user); |
|
142 | - $signedData = $this->signer->sign('lookupserver', $data, $user); |
|
143 | - $client = $this->clientService->newClient(); |
|
144 | - |
|
145 | - try { |
|
146 | - if (count($data) === 1) { |
|
147 | - // No public data, just the federation Id |
|
148 | - $client->delete($this->lookupServer, |
|
149 | - [ |
|
150 | - 'body' => json_encode($signedData), |
|
151 | - 'timeout' => 10, |
|
152 | - 'connect_timeout' => 3, |
|
153 | - ] |
|
154 | - ); |
|
155 | - } else { |
|
156 | - $client->post($this->lookupServer, |
|
157 | - [ |
|
158 | - 'body' => json_encode($signedData), |
|
159 | - 'timeout' => 10, |
|
160 | - 'connect_timeout' => 3, |
|
161 | - ] |
|
162 | - ); |
|
163 | - } |
|
164 | - |
|
165 | - // Reset retry counter |
|
166 | - $this->config->deleteUserValue( |
|
167 | - $user->getUID(), |
|
168 | - 'lookup_server_connector', |
|
169 | - 'update_retries' |
|
170 | - ); |
|
171 | - |
|
172 | - } catch (\Exception $e) { |
|
173 | - // An error occurred, retry later |
|
174 | - $this->retainJob = true; |
|
175 | - $this->config->setUserValue( |
|
176 | - $user->getUID(), |
|
177 | - 'lookup_server_connector', |
|
178 | - 'update_retries', |
|
179 | - $this->retries + 1 |
|
180 | - ); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - protected function getUserAccountData(IUser $user): array { |
|
185 | - $account = $this->accountManager->getAccount($user); |
|
186 | - |
|
187 | - $publicData = []; |
|
188 | - foreach ($account->getProperties() as $property) { |
|
189 | - if ($property->getScope() === IAccountManager::VISIBILITY_PUBLIC) { |
|
190 | - $publicData[$property->getName()] = $property->getValue(); |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - $data = ['federationId' => $user->getCloudId()]; |
|
195 | - if (!empty($publicData)) { |
|
196 | - $data['name'] = $publicData[IAccountManager::PROPERTY_DISPLAYNAME]['value'] ?? ''; |
|
197 | - $data['email'] = $publicData[IAccountManager::PROPERTY_EMAIL]['value'] ?? ''; |
|
198 | - $data['address'] = $publicData[IAccountManager::PROPERTY_ADDRESS]['value'] ?? ''; |
|
199 | - $data['website'] = $publicData[IAccountManager::PROPERTY_WEBSITE]['value'] ?? ''; |
|
200 | - $data['twitter'] = $publicData[IAccountManager::PROPERTY_TWITTER]['value'] ?? ''; |
|
201 | - $data['phone'] = $publicData[IAccountManager::PROPERTY_PHONE]['value'] ?? ''; |
|
202 | - $data['twitter_signature'] = $publicData[IAccountManager::PROPERTY_TWITTER]['signature'] ?? ''; |
|
203 | - $data['website_signature'] = $publicData[IAccountManager::PROPERTY_WEBSITE]['signature'] ?? ''; |
|
204 | - $data['verificationStatus'] = [ |
|
205 | - IAccountManager::PROPERTY_WEBSITE => $publicData[IAccountManager::PROPERTY_WEBSITE]['verified'] ?? '', |
|
206 | - IAccountManager::PROPERTY_TWITTER => $publicData[IAccountManager::PROPERTY_TWITTER]['verified'] ?? '', |
|
207 | - ]; |
|
208 | - } |
|
209 | - |
|
210 | - return $data; |
|
211 | - } |
|
39 | + /** @var IClientService */ |
|
40 | + private $clientService; |
|
41 | + /** @var string */ |
|
42 | + private $lookupServer; |
|
43 | + /** @var IConfig */ |
|
44 | + private $config; |
|
45 | + /** @var IUserManager */ |
|
46 | + private $userManager; |
|
47 | + /** @var IAccountManager */ |
|
48 | + private $accountManager; |
|
49 | + /** @var Signer */ |
|
50 | + private $signer; |
|
51 | + /** @var int */ |
|
52 | + protected $retries = 0; |
|
53 | + /** @var bool */ |
|
54 | + protected $retainJob = false; |
|
55 | + |
|
56 | + /** |
|
57 | + * @param ITimeFactory $time |
|
58 | + * @param IClientService $clientService |
|
59 | + * @param IConfig $config |
|
60 | + * @param IUserManager $userManager |
|
61 | + * @param IAccountManager $accountManager |
|
62 | + * @param Signer $signer |
|
63 | + */ |
|
64 | + public function __construct(ITimeFactory $time, |
|
65 | + IClientService $clientService, |
|
66 | + IConfig $config, |
|
67 | + IUserManager $userManager, |
|
68 | + IAccountManager $accountManager, |
|
69 | + Signer $signer) { |
|
70 | + parent::__construct($time); |
|
71 | + $this->clientService = $clientService; |
|
72 | + $this->config = $config; |
|
73 | + $this->userManager = $userManager; |
|
74 | + $this->accountManager = $accountManager; |
|
75 | + $this->signer = $signer; |
|
76 | + |
|
77 | + $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); |
|
78 | + if (!empty($this->lookupServer)) { |
|
79 | + $this->lookupServer = rtrim($this->lookupServer, '/'); |
|
80 | + $this->lookupServer .= '/users'; |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * run the job, then remove it from the jobList |
|
86 | + * |
|
87 | + * @param IJobList $jobList |
|
88 | + * @param ILogger|null $logger |
|
89 | + */ |
|
90 | + public function execute($jobList, ILogger $logger = null): void { |
|
91 | + if (!isset($this->argument['userId'])) { |
|
92 | + // Old background job without user id, just drop it. |
|
93 | + $jobList->remove($this, $this->argument); |
|
94 | + return; |
|
95 | + } |
|
96 | + |
|
97 | + $this->retries = (int) $this->config->getUserValue($this->argument['userId'], 'lookup_server_connector', 'update_retries', 0); |
|
98 | + |
|
99 | + if ($this->shouldRemoveBackgroundJob()) { |
|
100 | + $jobList->remove($this, $this->argument); |
|
101 | + return; |
|
102 | + } |
|
103 | + |
|
104 | + if ($this->shouldRun()) { |
|
105 | + parent::execute($jobList, $logger); |
|
106 | + if (!$this->retainJob) { |
|
107 | + $jobList->remove($this, $this->argument); |
|
108 | + } |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Check if we should kill the background job: |
|
114 | + * |
|
115 | + * - internet connection is disabled |
|
116 | + * - no valid lookup server URL given |
|
117 | + * - lookup server was disabled by the admin |
|
118 | + * - max retries are reached (set to 5) |
|
119 | + * |
|
120 | + * @return bool |
|
121 | + */ |
|
122 | + protected function shouldRemoveBackgroundJob(): bool { |
|
123 | + return $this->config->getSystemValueBool('has_internet_connection', true) === false || |
|
124 | + $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') === '' || |
|
125 | + $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') !== 'yes' || |
|
126 | + $this->retries >= 5; |
|
127 | + } |
|
128 | + |
|
129 | + protected function shouldRun(): bool { |
|
130 | + $delay = 100 * 6 ** $this->retries; |
|
131 | + return ($this->time->getTime() - $this->lastRun) > $delay; |
|
132 | + } |
|
133 | + |
|
134 | + protected function run($argument): void { |
|
135 | + $user = $this->userManager->get($this->argument['userId']); |
|
136 | + if (!$user instanceof IUser) { |
|
137 | + // User does not exist anymore |
|
138 | + return; |
|
139 | + } |
|
140 | + |
|
141 | + $data = $this->getUserAccountData($user); |
|
142 | + $signedData = $this->signer->sign('lookupserver', $data, $user); |
|
143 | + $client = $this->clientService->newClient(); |
|
144 | + |
|
145 | + try { |
|
146 | + if (count($data) === 1) { |
|
147 | + // No public data, just the federation Id |
|
148 | + $client->delete($this->lookupServer, |
|
149 | + [ |
|
150 | + 'body' => json_encode($signedData), |
|
151 | + 'timeout' => 10, |
|
152 | + 'connect_timeout' => 3, |
|
153 | + ] |
|
154 | + ); |
|
155 | + } else { |
|
156 | + $client->post($this->lookupServer, |
|
157 | + [ |
|
158 | + 'body' => json_encode($signedData), |
|
159 | + 'timeout' => 10, |
|
160 | + 'connect_timeout' => 3, |
|
161 | + ] |
|
162 | + ); |
|
163 | + } |
|
164 | + |
|
165 | + // Reset retry counter |
|
166 | + $this->config->deleteUserValue( |
|
167 | + $user->getUID(), |
|
168 | + 'lookup_server_connector', |
|
169 | + 'update_retries' |
|
170 | + ); |
|
171 | + |
|
172 | + } catch (\Exception $e) { |
|
173 | + // An error occurred, retry later |
|
174 | + $this->retainJob = true; |
|
175 | + $this->config->setUserValue( |
|
176 | + $user->getUID(), |
|
177 | + 'lookup_server_connector', |
|
178 | + 'update_retries', |
|
179 | + $this->retries + 1 |
|
180 | + ); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + protected function getUserAccountData(IUser $user): array { |
|
185 | + $account = $this->accountManager->getAccount($user); |
|
186 | + |
|
187 | + $publicData = []; |
|
188 | + foreach ($account->getProperties() as $property) { |
|
189 | + if ($property->getScope() === IAccountManager::VISIBILITY_PUBLIC) { |
|
190 | + $publicData[$property->getName()] = $property->getValue(); |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + $data = ['federationId' => $user->getCloudId()]; |
|
195 | + if (!empty($publicData)) { |
|
196 | + $data['name'] = $publicData[IAccountManager::PROPERTY_DISPLAYNAME]['value'] ?? ''; |
|
197 | + $data['email'] = $publicData[IAccountManager::PROPERTY_EMAIL]['value'] ?? ''; |
|
198 | + $data['address'] = $publicData[IAccountManager::PROPERTY_ADDRESS]['value'] ?? ''; |
|
199 | + $data['website'] = $publicData[IAccountManager::PROPERTY_WEBSITE]['value'] ?? ''; |
|
200 | + $data['twitter'] = $publicData[IAccountManager::PROPERTY_TWITTER]['value'] ?? ''; |
|
201 | + $data['phone'] = $publicData[IAccountManager::PROPERTY_PHONE]['value'] ?? ''; |
|
202 | + $data['twitter_signature'] = $publicData[IAccountManager::PROPERTY_TWITTER]['signature'] ?? ''; |
|
203 | + $data['website_signature'] = $publicData[IAccountManager::PROPERTY_WEBSITE]['signature'] ?? ''; |
|
204 | + $data['verificationStatus'] = [ |
|
205 | + IAccountManager::PROPERTY_WEBSITE => $publicData[IAccountManager::PROPERTY_WEBSITE]['verified'] ?? '', |
|
206 | + IAccountManager::PROPERTY_TWITTER => $publicData[IAccountManager::PROPERTY_TWITTER]['verified'] ?? '', |
|
207 | + ]; |
|
208 | + } |
|
209 | + |
|
210 | + return $data; |
|
211 | + } |
|
212 | 212 | } |