diff --git a/app/soapbox/features/ads/providers/rumble.ts b/app/soapbox/features/ads/providers/rumble.ts index b39ee4cc9..249fc8547 100644 --- a/app/soapbox/features/ads/providers/rumble.ts +++ b/app/soapbox/features/ads/providers/rumble.ts @@ -1,3 +1,4 @@ +import { getSettings } from 'soapbox/actions/settings'; import { getSoapboxConfig } from 'soapbox/actions/soapbox'; import { normalizeCard } from 'soapbox/normalizers'; @@ -22,23 +23,31 @@ interface RumbleApiResponse { const RumbleAdProvider: AdProvider = { getAds: async(getState) => { const state = getState(); + const settings = getSettings(state); const soapboxConfig = getSoapboxConfig(state); const endpoint = soapboxConfig.extensions.getIn(['ads', 'endpoint']) as string | undefined; if (endpoint) { - const response = await fetch(endpoint); - const data = await response.json() as RumbleApiResponse; - return data.ads.map(item => ({ - impression: item.impression, - card: normalizeCard({ - type: item.type === 1 ? 'link' : 'rich', - image: item.asset, - url: item.click, - }), - })); - } else { - return []; + const response = await fetch(endpoint, { + headers: { + 'Accept-Language': settings.get('locale', '*') as string, + }, + }); + + if (response.ok) { + const data = await response.json() as RumbleApiResponse; + return data.ads.map(item => ({ + impression: item.impression, + card: normalizeCard({ + type: item.type === 1 ? 'link' : 'rich', + image: item.asset, + url: item.click, + }), + })); + } } + + return []; }, };