Skip to content

Commit

Permalink
fixup! feat: Support multiple accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin committed Aug 19, 2024
1 parent 1baa627 commit 60577c0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Search/GitlabSearchReposProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace OCA\Gitlab\Search;

use OCA\Gitlab\AppInfo\Application;
use OCA\Gitlab\Db\GitlabAccount;
use OCA\Gitlab\Db\GitlabAccountMapper;
use OCA\Gitlab\Service\ConfigService;
use OCA\Gitlab\Service\GitlabAPIService;
Expand Down Expand Up @@ -111,8 +112,8 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
continue;
}

$formattedResults[] = array_map(function (array $entry): SearchResultEntry {
$finalThumbnailUrl = $this->getThumbnailUrl($entry);
$formattedResults[] = array_map(function (array $entry) use ($account): SearchResultEntry {
$finalThumbnailUrl = $this->getThumbnailUrl($account, $entry);
return new SearchResultEntry(
$finalThumbnailUrl,
$this->getMainText($entry),
Expand Down Expand Up @@ -159,11 +160,11 @@ protected function getLinkToGitlab(array $entry): string {
* @param array $entry
* @return string
*/
protected function getThumbnailUrl(array $entry): string {
protected function getThumbnailUrl(GitlabAccount $account, array $entry): string {
$projectId = $entry['id'] ?? '';
$avatarUrl = $entry['avatar_url'] ?? '';
return $avatarUrl
? $this->urlGenerator->linkToRoute('integration_gitlab.gitlabAPI.getProjectAvatar', []) . '?projectId=' . urlencode(strval($projectId))
? $this->urlGenerator->linkToRoute('integration_gitlab.gitlabAPI.getProjectAvatar', ['accountId' => $account->getId(), 'projectId' => (string)$projectId])
: '';
}
}

0 comments on commit 60577c0

Please sign in to comment.