Skip to content

Commit 9ca86c0

Browse files
committed
fixup! feat: add delegation backend
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
1 parent 82cec44 commit 9ca86c0

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

lib/Controller/PageController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public function index(): TemplateResponse {
158158
$accountsJson = [];
159159
foreach ($mailAccounts as $mailAccount) {
160160
$json = $mailAccount->jsonSerialize();
161+
$json['isDelegated'] = false;
161162
$json['aliases'] = $this->aliasesService->findAll($mailAccount->getId(),
162163
$this->currentUserId);
163164
try {
@@ -172,6 +173,26 @@ public function index(): TemplateResponse {
172173
}
173174
$accountsJson[] = $json;
174175
}
176+
177+
$delegatedAccounts = $this->accountService->findDelegatedAccounts($this->currentUserId);
178+
foreach ($delegatedAccounts as $delegatedAccount) {
179+
$json = $delegatedAccount->jsonSerialize();
180+
$json['isDelegated'] = true;
181+
$json['aliases'] = $this->aliasesService->findAll($delegatedAccount->getId(),
182+
$delegatedAccount->getUserId());
183+
try {
184+
$mailboxes = $this->mailManager->getMailboxes($delegatedAccount);
185+
$json['mailboxes'] = $mailboxes;
186+
} catch (Throwable $ex) {
187+
$this->logger->critical('Could not load delegated account mailboxes: ' . $ex->getMessage(), [
188+
'exception' => $ex,
189+
]);
190+
$json['mailboxes'] = [];
191+
$json['error'] = true;
192+
}
193+
$accountsJson[] = $json;
194+
}
195+
175196
$this->initialStateService->provideInitialState(
176197
'accounts',
177198
$accountsJson

0 commit comments

Comments
 (0)