Skip to content

Commit

Permalink
PATCH: Add SpeakEasy HTTP header when loading Link Preview from SAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagedman committed Jun 3, 2024
1 parent 1ea6c2b commit 50b0933
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/meteor/app/oembed/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ const getUrlContent = async (urlObj: URL, redirectCount = 5): Promise<OEmbedUrlC
const sizeLimit = 250000;

log.debug(`Fetching ${url} following redirects ${redirectCount} times`);

const hittingSAPI = urlObj.hostname === "seekingalpha.com" || urlObj.hostname.endsWith(".seekingalpha.com");

Check failure on line 103 in apps/meteor/app/oembed/server/server.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Replace `"seekingalpha.com"·||·urlObj.hostname.endsWith(".seekingalpha.com"` with `'seekingalpha.com'·||·urlObj.hostname.endsWith('.seekingalpha.com'`

const response = await fetch(
url,
{
compress: true,
follow: redirectCount,
headers: {
headers: Object.assign({

Check failure on line 110 in apps/meteor/app/oembed/server/server.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Insert `⏎↹↹↹↹`
'User-Agent': `${settings.get('API_Embed_UserAgent')} Rocket.Chat/${Info.version}`,

Check failure on line 111 in apps/meteor/app/oembed/server/server.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Insert `↹`
'Accept-Language': settings.get('Language') || 'en',

Check failure on line 112 in apps/meteor/app/oembed/server/server.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Insert `↹`
},
}, hittingSAPI ? {[settings.get("API_Embed_SAPI_Key")]: settings.get("API_Embed_SAPI_Value")} : {}),

Check failure on line 113 in apps/meteor/app/oembed/server/server.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Replace `},·hittingSAPI·?·{[settings.get("API_Embed_SAPI_Key")]:·settings.get("API_Embed_SAPI_Value")}·:·{}` with `↹},⏎↹↹↹↹hittingSAPI·?·{·[settings.get('API_Embed_SAPI_Key')]:·settings.get('API_Embed_SAPI_Value')·}·:·{},⏎↹↹↹`
size: sizeLimit, // max size of the response body, this was not working as expected so I'm also manually verifying that on the iterator
},
settings.get('Allow_Invalid_SelfSigned_Certs'),
Expand Down

0 comments on commit 50b0933

Please sign in to comment.