From 9d6e759b111c530cfde642a4d1e62565814c7ad8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 04:43:06 +0000 Subject: [PATCH 1/9] Update dependency @cloudflare/workers-types to ^4.20231016.0 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ae70e6..667e5bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "toucan-js": "^3.3.0" }, "devDependencies": { - "@cloudflare/workers-types": "^4.20231010.0", + "@cloudflare/workers-types": "^4.20231016.0", "@microsoft/eslint-formatter-sarif": "^3.0.0", "@sentry/esbuild-plugin": "^2.8.0", "@sentry/integrations": "^7.74.0", @@ -796,9 +796,9 @@ } }, "node_modules/@cloudflare/workers-types": { - "version": "4.20231010.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20231010.0.tgz", - "integrity": "sha512-Jscqg52ScJMTMRHHVeoUvXYYiXPT4V59NKaClQVju9B6oPAzuePFYHwi5PLQ5Yr+xEbJ6+bHuq1aYV/69z6L0w==", + "version": "4.20231016.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20231016.0.tgz", + "integrity": "sha512-eGB0cRVyoJpeyGJx2re5sbd9R316a61sY73xwnqm4cwGpb+OxCK2gc651RxGiN7H4w6LY1RpysUgeGLmj5B3+g==", "dev": true }, "node_modules/@esbuild-plugins/node-globals-polyfill": { diff --git a/package.json b/package.json index 6eb00b3..a2dae83 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "author": "dangered wolf", "license": "MIT", "devDependencies": { - "@cloudflare/workers-types": "^4.20231010.0", + "@cloudflare/workers-types": "^4.20231016.0", "@microsoft/eslint-formatter-sarif": "^3.0.0", "@sentry/esbuild-plugin": "^2.8.0", "@sentry/integrations": "^7.74.0", From 6a2edd834f3ca8f5922c7acffff80fb53d51b58d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:40:03 +0000 Subject: [PATCH 2/9] Update dependency wrangler to ^3.13.2 --- package-lock.json | 64 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index 667e5bc..44e4322 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "ts-jest": "^29.1.1", "ts-loader": "^9.5.0", "typescript": "^5.2.2", - "wrangler": "^3.13.1" + "wrangler": "^3.13.2" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -716,9 +716,9 @@ } }, "node_modules/@cloudflare/workerd-darwin-64": { - "version": "1.20231010.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20231010.0.tgz", - "integrity": "sha512-LM9ePAh88EGoQkYisAfdLMEDzcaMinRer0mY11GOiN4A9ZU+6APRVvhh5JBRzI0F6Dkb8nHtrzhisioWCRaY1w==", + "version": "1.20231016.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20231016.0.tgz", + "integrity": "sha512-rPAnF8Q25+eHEsAopihWeftPW/P0QapY9d7qaUmtOXztWdd6YPQ7JuiWVj4Nvjphge1BleehxAbo4I3Z4L2H1g==", "cpu": [ "x64" ], @@ -732,9 +732,9 @@ } }, "node_modules/@cloudflare/workerd-darwin-arm64": { - "version": "1.20231010.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20231010.0.tgz", - "integrity": "sha512-Vr7Z1O+vJRCnVeWaF0YSv0EMHiMRY7yYCxr7O509FzvJAXsZuXZ7DYC5TAD7a8HSeeqsxFTAbF9jg0y9A2wKVw==", + "version": "1.20231016.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20231016.0.tgz", + "integrity": "sha512-MvydDdiLXt+jy57vrVZ2lU6EQwCdpieyZoN8uBXSWzfG3zR/6dxU1+okvPQPlHN0jtlufqPeHrpJyAqqgLHUKA==", "cpu": [ "arm64" ], @@ -748,9 +748,9 @@ } }, "node_modules/@cloudflare/workerd-linux-64": { - "version": "1.20231010.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20231010.0.tgz", - "integrity": "sha512-l9oDVPVhPEOHr1JpcGnLSsIf1h8sZnvcIC2Tl1zt+3p/KGFyGqGyAZJMLUoMJ54Q07oRE1x3KAu+JcWWEvdxpg==", + "version": "1.20231016.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20231016.0.tgz", + "integrity": "sha512-y6Sj37yTzM8QbAghG9LRqoSBrsREnQz8NkcmpjSxeK6KMc2g0L5A/OemCdugNlIiv+zRv9BYX1aosaoxY5JbeQ==", "cpu": [ "x64" ], @@ -764,9 +764,9 @@ } }, "node_modules/@cloudflare/workerd-linux-arm64": { - "version": "1.20231010.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20231010.0.tgz", - "integrity": "sha512-NBmYsJu+ns2W8WHcDnglfqLV5O3FP7lXpoTSTvpM64mhexmemdMlOJX5gpRuarTula3fA+GzEehinUojwM9/1g==", + "version": "1.20231016.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20231016.0.tgz", + "integrity": "sha512-LqMIRUHD1YeRg2TPIfIQEhapSKMFSq561RypvJoXZvTwSbaROxGdW6Ku+PvButqTkEvuAtfzN/kGje7fvfQMHg==", "cpu": [ "arm64" ], @@ -780,9 +780,9 @@ } }, "node_modules/@cloudflare/workerd-windows-64": { - "version": "1.20231010.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20231010.0.tgz", - "integrity": "sha512-jWiG71Rvuh4FYdEpOP1+BAygdguTlMYYy+v5d4ZOjxDkl+V8aR86EEtDQrv/QLUJFbpcoEX25SxXnN5UMKtjhQ==", + "version": "1.20231016.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20231016.0.tgz", + "integrity": "sha512-96ojBwIHyiUAbsWlzBqo9P/cvH8xUh8SuBboFXtwAeXcJ6/urwKN2AqPa/QzOGUTCdsurWYiieARHT5WWWPhKw==", "cpu": [ "x64" ], @@ -5418,9 +5418,9 @@ } }, "node_modules/miniflare": { - "version": "3.20231010.0", - "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20231010.0.tgz", - "integrity": "sha512-VETY+/OhJ1RN+yrFpPUqBZysb2R8wXvyx3vzaRZS2qO1aGNKeGASa/vxCvNcBF+gt8UdbWMOalSXX8zY0IgWZA==", + "version": "3.20231016.0", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20231016.0.tgz", + "integrity": "sha512-AmlqI89zsnBJfC+nKKZdCB/fuu0q/br24Kqt9NZwcT6yJEpO5NytNKfjl6nJROHROwuJSRQR1T3yopCtG1/0DA==", "dev": true, "dependencies": { "acorn": "^8.8.0", @@ -5431,7 +5431,7 @@ "source-map-support": "0.5.21", "stoppable": "^1.1.0", "undici": "^5.22.1", - "workerd": "1.20231010.0", + "workerd": "1.20231016.0", "ws": "^8.11.0", "youch": "^3.2.2", "zod": "^3.20.6" @@ -7300,9 +7300,9 @@ } }, "node_modules/workerd": { - "version": "1.20231010.0", - "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20231010.0.tgz", - "integrity": "sha512-ghxfBU8fBSBDa8fCBPfzWivYsWpewYftgy70N308C+acQ5AaKNM1QTdkQNm9YWeC5Jpl1YvBX04ojt7lCc3juw==", + "version": "1.20231016.0", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20231016.0.tgz", + "integrity": "sha512-v2GDb5XitSqgub/xm7EWHVAlAK4snxQu3itdMQxXstGtUG9hl79fQbXS/8fNFbmms2R2bAxUwSv47q8k5T5Erw==", "dev": true, "hasInstallScript": true, "bin": { @@ -7312,17 +7312,17 @@ "node": ">=16" }, "optionalDependencies": { - "@cloudflare/workerd-darwin-64": "1.20231010.0", - "@cloudflare/workerd-darwin-arm64": "1.20231010.0", - "@cloudflare/workerd-linux-64": "1.20231010.0", - "@cloudflare/workerd-linux-arm64": "1.20231010.0", - "@cloudflare/workerd-windows-64": "1.20231010.0" + "@cloudflare/workerd-darwin-64": "1.20231016.0", + "@cloudflare/workerd-darwin-arm64": "1.20231016.0", + "@cloudflare/workerd-linux-64": "1.20231016.0", + "@cloudflare/workerd-linux-arm64": "1.20231016.0", + "@cloudflare/workerd-windows-64": "1.20231016.0" } }, "node_modules/wrangler": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.13.1.tgz", - "integrity": "sha512-CY73h4lfPx/3CmkC/tPj66DRRZ9Y42sMcHys6B6tjCILUo950IeOvnsj759el3/ewFLY4kG4jCrrrikan6TE+Q==", + "version": "3.13.2", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.13.2.tgz", + "integrity": "sha512-Z/ZrAL2mJc7E4ialOV9c3wGry0qagp9DfPl5XVd67vtlFPeTSR+1pemtZ5+qI2BXi59kP3OGHBKrrIyG0d9csg==", "dev": true, "dependencies": { "@cloudflare/kv-asset-handler": "^0.2.0", @@ -7331,7 +7331,7 @@ "blake3-wasm": "^2.1.5", "chokidar": "^3.5.3", "esbuild": "0.17.19", - "miniflare": "3.20231010.0", + "miniflare": "3.20231016.0", "nanoid": "^3.3.3", "path-to-regexp": "^6.2.0", "selfsigned": "^2.0.1", diff --git a/package.json b/package.json index a2dae83..ffbbba1 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ts-jest": "^29.1.1", "ts-loader": "^9.5.0", "typescript": "^5.2.2", - "wrangler": "^3.13.1" + "wrangler": "^3.13.2" }, "dependencies": { "itty-router": "^4.0.23", From 98d3e54ff08083633aba6c4320dec4ea824e6d8f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 02:05:18 +0000 Subject: [PATCH 3/9] Update dependency @sentry/integrations to ^7.74.1 --- package-lock.json | 50 ++++++++++++++++++++++++++++++++++++++++------- package.json | 2 +- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 44e4322..3c665c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@cloudflare/workers-types": "^4.20231016.0", "@microsoft/eslint-formatter-sarif": "^3.0.0", "@sentry/esbuild-plugin": "^2.8.0", - "@sentry/integrations": "^7.74.0", + "@sentry/integrations": "^7.74.1", "@types/jest": "^29.5.5", "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", @@ -2120,14 +2120,14 @@ } }, "node_modules/@sentry/integrations": { - "version": "7.74.0", - "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-7.74.0.tgz", - "integrity": "sha512-O4UyxiV5wzXSDnEd9Z/SIt/5M12URWNtIJPPJjowlllzw8X9e3zBcnXmjMOLZ+mZWjQmRDjOoz3lPPQ17f7fvw==", + "version": "7.74.1", + "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-7.74.1.tgz", + "integrity": "sha512-Q7chPehHpHB4WOQ1J/X6NiN2ptiqJMmxtL+6wHumzIAyrjup3c9XekR83qEs8zpqYJAlb/4MUlwd9fPbkhGXnQ==", "dev": true, "dependencies": { - "@sentry/core": "7.74.0", - "@sentry/types": "7.74.0", - "@sentry/utils": "7.74.0", + "@sentry/core": "7.74.1", + "@sentry/types": "7.74.1", + "@sentry/utils": "7.74.1", "localforage": "^1.8.1", "tslib": "^2.4.1 || ^1.9.3" }, @@ -2135,6 +2135,42 @@ "node": ">=8" } }, + "node_modules/@sentry/integrations/node_modules/@sentry/core": { + "version": "7.74.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.74.1.tgz", + "integrity": "sha512-LvEhOSfdIvwkr+PdlrT/aA/iOLhkXrSkvjqAQyogE4ddCWeYfS0NoirxNt1EaxMBAWKhYZRqzkA7WA4LDLbzlA==", + "dev": true, + "dependencies": { + "@sentry/types": "7.74.1", + "@sentry/utils": "7.74.1", + "tslib": "^2.4.1 || ^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/integrations/node_modules/@sentry/types": { + "version": "7.74.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.74.1.tgz", + "integrity": "sha512-2jIuPc+YKvXqZETwr2E8VYnsH1zsSUR/wkIvg1uTVeVNyoowJv+YsOtCdeGyL2AwiotUBSPKu7O1Lz0kq5rMOQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/integrations/node_modules/@sentry/utils": { + "version": "7.74.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.74.1.tgz", + "integrity": "sha512-qUsqufuHYcy5gFhLZslLxA5kcEOkkODITXW3c7D+x+8iP/AJqa8v8CeUCVNS7RetHCuIeWAbbTClC4c411EwQg==", + "dev": true, + "dependencies": { + "@sentry/types": "7.74.1", + "tslib": "^2.4.1 || ^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sentry/node": { "version": "7.74.0", "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.74.0.tgz", diff --git a/package.json b/package.json index ffbbba1..77d1a59 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@cloudflare/workers-types": "^4.20231016.0", "@microsoft/eslint-formatter-sarif": "^3.0.0", "@sentry/esbuild-plugin": "^2.8.0", - "@sentry/integrations": "^7.74.0", + "@sentry/integrations": "^7.74.1", "@types/jest": "^29.5.5", "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", From 56b26d212173d4176d8c286d24f29b4e1692f0e7 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Tue, 17 Oct 2023 23:44:49 -0400 Subject: [PATCH 4/9] Fix #425 and #426 :D --- src/api/status.ts | 9 +++++++-- src/embed/status.ts | 20 ++++++++++---------- src/worker.ts | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/api/status.ts b/src/api/status.ts index 76a6e8c..569b8c1 100644 --- a/src/api/status.ts +++ b/src/api/status.ts @@ -16,7 +16,7 @@ const populateTweetProperties = async ( conversation: TweetResultsByRestIdResult, // TimelineBlobPartial, language: string | undefined // eslint-disable-next-line sonarjs/cognitive-complexity -): Promise => { +): Promise => { const apiTweet = {} as APITweet; /* Sometimes, Twitter returns a different kind of Tweet type called 'TweetWithVisibilityResults'. @@ -38,6 +38,11 @@ const populateTweetProperties = async ( tweet.views = tweet?.tweet?.views; } + if (typeof tweet.core === 'undefined') { + console.log('Tweet still not valid', tweet); + return null; + } + /* With v2 conversation API we re-add the user object ot the tweet because Twitter stores it separately in the conversation API. This is to consolidate it in case a user appears multiple times in a thread. */ @@ -292,7 +297,7 @@ export const statusAPI = async ( if (quoteTweet) { apiTweet.quote = (await populateTweetProperties(quoteTweet, res, language)) as APITweet; /* Only override the twitter_card if it's a basic tweet, since media always takes precedence */ - if (apiTweet.twitter_card === 'tweet') { + if (apiTweet.twitter_card === 'tweet' && apiTweet.quote !== null) { apiTweet.twitter_card = apiTweet.quote.twitter_card; } } diff --git a/src/embed/status.ts b/src/embed/status.ts index 1bab6d8..8c4f413 100644 --- a/src/embed/status.ts +++ b/src/embed/status.ts @@ -36,6 +36,16 @@ export const handleStatus = async ( const api = await statusAPI(status, language, event as FetchEvent, flags); const tweet = api?.tweet as APITweet; + /* Catch this request if it's an API response */ + if (flags?.api) { + return { + response: new Response(JSON.stringify(api), { + headers: { ...Constants.RESPONSE_HEADERS, ...Constants.API_RESPONSE_HEADERS }, + status: api.code + }) + }; + } + /* If there was any errors fetching the Tweet, we'll return it */ switch (api.code) { case 401: @@ -66,16 +76,6 @@ export const handleStatus = async ( let ivbody = ''; - /* Catch this request if it's an API response */ - if (flags?.api) { - return { - response: new Response(JSON.stringify(api), { - headers: { ...Constants.RESPONSE_HEADERS, ...Constants.API_RESPONSE_HEADERS }, - status: api.code - }) - }; - } - let overrideMedia: APIMedia | undefined; // Check if mediaNumber exists, and if that media exists in tweet.media.all. If it does, we'll store overrideMedia variable diff --git a/src/worker.ts b/src/worker.ts index f3435f9..0629235 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -152,7 +152,7 @@ const statusRequest = async (request: IRequest, event: FetchEvent, flags: InputF Since we obviously have no media to give the user, we'll just redirect to the Tweet. Embeds will return as usual to bots as if direct media was never specified. */ - if (!isBotUA) { + if (!isBotUA && !flags.api) { const baseUrl = getBaseRedirectUrl(request); /* Do not cache if using a custom redirect */ const cacheControl = baseUrl !== Constants.TWITTER_ROOT ? 'max-age=0' : undefined; From 5c3728d199677f0f357bce236b50d42e97cc8a67 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Wed, 18 Oct 2023 04:05:01 -0400 Subject: [PATCH 5/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 434a9c0..89a9f0e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ### Change `x.com` to `fixupx.com` in your link -### For Twitter links on Discord, send a Twitter link and type `s/e/p` to make `twittpr.com`. +### For `twitter.com` links on Discord, send a link and type `s/e/p` to make `twittpr.com`. ### ℹ️ Note: Some extra features described may currently broken due to recent Twitter/X API changes. [Tracking thread for the API changes](https://github.com/FixTweet/FixTweet/issues/333) From fa3a541f95c0fcc0f37e048639cd74a1d87aa2c4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 08:27:13 +0000 Subject: [PATCH 6/9] Update dependency @types/jest to ^29.5.6 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c665c4..b4e27fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@microsoft/eslint-formatter-sarif": "^3.0.0", "@sentry/esbuild-plugin": "^2.8.0", "@sentry/integrations": "^7.74.1", - "@types/jest": "^29.5.5", + "@types/jest": "^29.5.6", "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", "dotenv": "^16.3.1", @@ -2349,9 +2349,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.5", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.5.tgz", - "integrity": "sha512-ebylz2hnsWR9mYvmBFbXJXr+33UPc4+ZdxyDXh5w0FlPBTfCVN3wPL+kuOiQt3xvrK419v7XWeAs+AeOksafXg==", + "version": "29.5.6", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.6.tgz", + "integrity": "sha512-/t9NnzkOpXb4Nfvg17ieHE6EeSjDS2SGSpNYfoLbUAeL/EOueU/RSdOWFpfQTXBEM7BguYW1XQ0EbM+6RlIh6w==", "dev": true, "dependencies": { "expect": "^29.0.0", diff --git a/package.json b/package.json index 77d1a59..5ffdd67 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@microsoft/eslint-formatter-sarif": "^3.0.0", "@sentry/esbuild-plugin": "^2.8.0", "@sentry/integrations": "^7.74.1", - "@types/jest": "^29.5.5", + "@types/jest": "^29.5.6", "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", "dotenv": "^16.3.1", From fda3ccc6198bf1ecb48e1b095ab1c82f40f714f1 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Thu, 19 Oct 2023 01:40:59 -0400 Subject: [PATCH 7/9] Assign mosaic load balancing based on id --- src/helpers/mosaic.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/helpers/mosaic.ts b/src/helpers/mosaic.ts index 44e5c60..e686269 100644 --- a/src/helpers/mosaic.ts +++ b/src/helpers/mosaic.ts @@ -1,16 +1,26 @@ import { Constants } from '../constants'; +const getDomain = (twitterId: string): string | null => { + const mosaicDomains = Constants.MOSAIC_DOMAIN_LIST; + + if (mosaicDomains.length === 0) { + return null; + } + + let hash = 0; + for (let i = 0; i < twitterId.length; i++) { + const char = twitterId.charCodeAt(i); + hash = (hash << 5) - hash + char; + } + return mosaicDomains[Math.abs(hash) % mosaicDomains.length]; +} + /* Handler for mosaic (multi-image combiner) */ export const handleMosaic = async ( mediaList: APIPhoto[], id: string ): Promise => { - const mosaicDomains = Constants.MOSAIC_DOMAIN_LIST; - let selectedDomain: string | null = null; - while (selectedDomain === null && mosaicDomains.length > 0) { - const domain = mosaicDomains[Math.floor(Math.random() * mosaicDomains.length)]; - selectedDomain = domain; - } + const selectedDomain: string | null = getDomain(id); /* Fallback if there are no Mosaic servers */ if (selectedDomain === null) { From ee10bdb51dc4994b7f2816bac19375c13f8f6d2f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 21:48:09 +0000 Subject: [PATCH 8/9] Update dependency wrangler to ^3.14.0 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4e27fb..7aa8a5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "ts-jest": "^29.1.1", "ts-loader": "^9.5.0", "typescript": "^5.2.2", - "wrangler": "^3.13.2" + "wrangler": "^3.14.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -7356,9 +7356,9 @@ } }, "node_modules/wrangler": { - "version": "3.13.2", - "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.13.2.tgz", - "integrity": "sha512-Z/ZrAL2mJc7E4ialOV9c3wGry0qagp9DfPl5XVd67vtlFPeTSR+1pemtZ5+qI2BXi59kP3OGHBKrrIyG0d9csg==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.14.0.tgz", + "integrity": "sha512-4vzw11yG1/KXpYKbumvRJ61Iyhm/yKXb/ayOw/2xiIRdKdpsfN9/796d2l525+CDaGwZWswpLENe6ZMS0p/Ghg==", "dev": true, "dependencies": { "@cloudflare/kv-asset-handler": "^0.2.0", diff --git a/package.json b/package.json index 5ffdd67..9cfcb6c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ts-jest": "^29.1.1", "ts-loader": "^9.5.0", "typescript": "^5.2.2", - "wrangler": "^3.13.2" + "wrangler": "^3.14.0" }, "dependencies": { "itty-router": "^4.0.23", From f26b9d90a08320f7cfe0412cb4d8fc54b73c28b7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 23:24:15 +0000 Subject: [PATCH 9/9] Update dependency eslint to ^8.52.0 --- package-lock.json | 39 +++++++++++++++++++++++---------------- package.json | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7aa8a5b..7849511 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", "dotenv": "^16.3.1", - "eslint": "^8.51.0", + "eslint": "^8.52.0", "eslint-config-prettier": "^9.0.0", "eslint-config-typescript": "^3.0.0", "eslint-plugin-optimize-regex": "^1.2.1", @@ -1223,9 +1223,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.51.0.tgz", - "integrity": "sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", + "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1241,12 +1241,12 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.11", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz", - "integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==", + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", + "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", + "@humanwhocodes/object-schema": "^2.0.1", "debug": "^4.1.1", "minimatch": "^3.0.5" }, @@ -1268,9 +1268,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", + "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "dev": true }, "node_modules/@iarna/toml": { @@ -2589,6 +2589,12 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", @@ -3641,18 +3647,19 @@ } }, "node_modules/eslint": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", - "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", + "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.51.0", - "@humanwhocodes/config-array": "^0.11.11", + "@eslint/js": "8.52.0", + "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", diff --git a/package.json b/package.json index 9cfcb6c..959b400 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", "dotenv": "^16.3.1", - "eslint": "^8.51.0", + "eslint": "^8.52.0", "eslint-config-prettier": "^9.0.0", "eslint-config-typescript": "^3.0.0", "eslint-plugin-optimize-regex": "^1.2.1",