diff --git a/users-refresher-lambda/src/google/isDefinitelyDifferentAvatar.ts b/users-refresher-lambda/src/google/isDefinitelyDifferentAvatar.ts deleted file mode 100644 index ac83bb2a..00000000 --- a/users-refresher-lambda/src/google/isDefinitelyDifferentAvatar.ts +++ /dev/null @@ -1,31 +0,0 @@ -import fetch from "node-fetch"; - -/* - * The Google People API returns an unstable avatar URL (i.e. different every time) - * for a handful of users (long-serving staff members we think - i.e. old avatars). - * So this function downloads the avatars to compare the file content, so we can - * only update the DB when the avatar image has truly changed. - * */ -export const isDefinitelyDifferentAvatar = async ( - userEmail: string, - databaseAvatarUrl: string | null | undefined, - apiAvatarUrl: string | null -): Promise => { - if (databaseAvatarUrl === apiAvatarUrl) { - return false; - } - if (!databaseAvatarUrl || !apiAvatarUrl) { - return true; - } - const [databaseAvatar, apiAvatar] = await Promise.all( - [databaseAvatarUrl, apiAvatarUrl].map((url) => - fetch(url).then((res) => res.text()) - ) - ); - if (databaseAvatar === apiAvatar) { - console.warn( - `Avatar for ${userEmail} has the same content, but the URLs are different - thanks Google!` - ); - } - return databaseAvatar !== apiAvatar; -}; diff --git a/users-refresher-lambda/src/index.ts b/users-refresher-lambda/src/index.ts index 64e01555..fb816b45 100644 --- a/users-refresher-lambda/src/index.ts +++ b/users-refresher-lambda/src/index.ts @@ -19,7 +19,6 @@ import { import { buildUserLookupFromDatabase } from "./google/buildUserLookupFromDatabase"; import { getGroupMembersFromGoogle } from "./google/getGroupMembersFromGoogle"; import { getGroupDetailFromGoogle } from "./google/getGroupDetailFromGoogle"; -import { isDefinitelyDifferentAvatar } from "./google/isDefinitelyDifferentAvatar"; const s3 = new S3(standardAwsConfig); @@ -146,11 +145,7 @@ export const handler = async ({ maybeUserFromDatabase.firstName !== maybeUserFromGoogle.firstName || maybeUserFromDatabase.lastName !== maybeUserFromGoogle.lastName || maybeUserFromDatabase.googleID !== maybeUserFromGoogle.googleID || - (await isDefinitelyDifferentAvatar( - email, - maybeUserFromDatabase.avatarUrl, - maybeAvatarUrl - )) + maybeUserFromDatabase.avatarUrl !== maybeAvatarUrl // annoyingly these URLs often differ despite the image not changing - thanks Google!! ) { console.log(`Updating details for user ${email}`); await sql`