Skip to content

Commit 2e92b16

Browse files
committed
[server] For GitLab projects without an owner avatar, fall back to the namespace avatar
1 parent fc68e47 commit 2e92b16

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

components/server/ee/src/gitlab/gitlab-app-support.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class GitLabAppSupport {
4343
const fullPath = anyProject.path_with_namespace as string;
4444
const cloneUrl = anyProject.http_url_to_repo as string;
4545
const updatedAt = anyProject.last_activity_at as string;
46-
const accountAvatarUrl = anyProject.owner?.avatar_url as string;
46+
const accountAvatarUrl = await this.getAccountAvatarUrl(anyProject, params.provider.host);
4747
const account = fullPath.split("/")[0];
4848

4949
(account === usersGitLabAccount ? ownersRepos : result).push({
@@ -61,4 +61,18 @@ export class GitLabAppSupport {
6161
result.unshift(...ownersRepos);
6262
return result;
6363
}
64+
65+
protected async getAccountAvatarUrl(anyProject: any, providerHost: string): Promise<string> {
66+
if (anyProject.owner?.avatar_url) {
67+
return anyProject.owner.avatar_url;
68+
}
69+
if (anyProject.namespace?.avatar_url) {
70+
let url = anyProject.namespace.avatar_url;
71+
if (url[0] === "/") {
72+
url = `https://${providerHost}${url}`;
73+
}
74+
return url;
75+
}
76+
return "";
77+
}
6478
}

0 commit comments

Comments
 (0)