diff --git a/plugins/slack-catalog-backend/src/SlackUserProcessor.test.ts b/plugins/slack-catalog-backend/src/SlackUserProcessor.test.ts index dc6041d..98055c0 100644 --- a/plugins/slack-catalog-backend/src/SlackUserProcessor.test.ts +++ b/plugins/slack-catalog-backend/src/SlackUserProcessor.test.ts @@ -59,7 +59,13 @@ describe('SlackUserProcessor', () => { jest.clearAllMocks(); }); - test('should add slack info', async () => { + test.each([ + { beforePicture: '', expectedPicture: 'rufus-192.png' }, + { + beforePicture: 'https://example.com/me.jpg', + expectedPicture: 'https://example.com/me.jpg', + }, + ])('should add slack info', async ({ beforePicture, expectedPicture }) => { const before: UserEntity = { apiVersion: 'backstage.io/v1alpha1', kind: 'User', @@ -67,9 +73,7 @@ describe('SlackUserProcessor', () => { name: 'rufus', }, spec: { - profile: { - email: 'rufus@seatgeek.com', - }, + profile: { email: 'rufus@seatgeek.com', picture: beforePicture }, }, }; const result = await processor.postProcessEntity( @@ -89,7 +93,7 @@ describe('SlackUserProcessor', () => { }, spec: { profile: { - picture: 'rufus-192.png', + picture: expectedPicture, email: 'rufus@seatgeek.com', }, }, diff --git a/plugins/slack-catalog-backend/src/SlackUserProcessor.ts b/plugins/slack-catalog-backend/src/SlackUserProcessor.ts index 6965d10..826258d 100644 --- a/plugins/slack-catalog-backend/src/SlackUserProcessor.ts +++ b/plugins/slack-catalog-backend/src/SlackUserProcessor.ts @@ -138,7 +138,8 @@ export class SlackUserProcessor implements CatalogProcessor { if (slackUser.id) { entity.metadata.annotations['slack.com/user_id'] = slackUser.id; } - if (slackUser.profile?.image_192) { + // if the user entity doesn't already have a profile picture set, *and* there's a slack avatar for the user, add that. + if (!entity.spec.profile.picture && slackUser.profile?.image_192) { entity.spec.profile.picture = slackUser.profile.image_192; }