diff --git a/lib/constants.d.ts b/lib/constants.d.ts index cfcff77b..e25c8d84 100644 --- a/lib/constants.d.ts +++ b/lib/constants.d.ts @@ -67,7 +67,7 @@ export interface Sponsor { name: string | null; login: string; url: string; - avatarUrl: string; + avatarUrl?: string; websiteUrl: string | null; }; createdAt: string; diff --git a/lib/template.js b/lib/template.js index f96a857f..d7496921 100644 --- a/lib/template.js +++ b/lib/template.js @@ -41,14 +41,12 @@ function getSponsors(action) { login url websiteUrl - avatarUrl } ... on User { name login url websiteUrl - avatarUrl } } createdAt @@ -144,7 +142,13 @@ function generateTemplate(response, action) { websiteUrl: (0, util_1.sanitizeAndClean)(sponsorEntity.websiteUrl || sponsorEntity.url), name: (0, util_1.sanitizeAndClean)(sponsorEntity.name || ''), login: (0, util_1.sanitizeAndClean)(sponsorEntity.login), + /** + * The avatar URL provided by the GitHub API includes an expiration token so we circumvent this for now + * by using a path that is always available. + */ avatarUrl: sponsorEntity.avatarUrl + ? sponsorEntity.avatarUrl + : `https://github.com/${(0, util_1.sanitizeAndClean)(sponsorEntity.login)}.png` }; /** * Ensure that the template is safe to render by preventing the usage of triple brackets.