Skip to content

Commit

Permalink
refs #8 don't get avatars of private repos
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
Julien Veyssier committed Oct 9, 2020
1 parent ba6dd88 commit 94829fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/Service/GitlabAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private function getMyProjectsInfo(string $url, string $accessToken): array {
$projectsInfo[$pid] = [
'path_with_namespace' => $project['path_with_namespace'],
'avatar_url' => $project['avatar_url'],
'visibility' => $project['visibility'],
];
}
return $projectsInfo;
Expand Down Expand Up @@ -294,16 +295,19 @@ public function getTodos(string $url, string $accessToken, ?string $since = null
$pid = $todo['project']['id'];
if (array_key_exists($pid, $projectsInfo)) {
$result[$k]['project']['avatar_url'] = $projectsInfo[$pid]['avatar_url'];
$result[$k]['project']['visibility'] = $projectsInfo[$pid]['visibility'];
} else {
// get the project avatar
$projectInfo = $this->request($url, $accessToken, 'projects/' . $pid);
if (isset($projectInfo['error'])) {
return $projectInfo;
}
$result[$k]['project']['avatar_url'] = $projectInfo['avatar_url'];
$result[$k]['project']['visibility'] = $projectInfo['visibility'];
// cache result
$projectsInfo[$pid] = [
'avatar_url' => $projectInfo['avatar_url']
'avatar_url' => $projectInfo['avatar_url'],
'visibility' => $projectInfo['visibility'],
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default {
return n.id + ':' + n.updated_at
},
getNotificationImage(n) {
return (n.project && n.project.avatar_url)
return (n.project && n.project.avatar_url && n.project.visibility !== 'private')
? generateUrl('/apps/integration_gitlab/avatar?') + encodeURIComponent('url') + '=' + encodeURIComponent(n.project.avatar_url)
: ''
},
Expand Down

0 comments on commit 94829fc

Please sign in to comment.