|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
|
|
|
|
import { getSettings } from 'soapbox/actions/settings';
|
|
|
|
import { getSettings } from 'soapbox/actions/settings';
|
|
|
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
|
|
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
|
|
|
import { normalizeAd, normalizeCard } from 'soapbox/normalizers';
|
|
|
|
import { normalizeAd, normalizeCard } from 'soapbox/normalizers';
|
|
|
@ -28,14 +30,13 @@ const RumbleAdProvider: AdProvider = {
|
|
|
|
const endpoint = soapboxConfig.extensions.getIn(['ads', 'endpoint']) as string | undefined;
|
|
|
|
const endpoint = soapboxConfig.extensions.getIn(['ads', 'endpoint']) as string | undefined;
|
|
|
|
|
|
|
|
|
|
|
|
if (endpoint) {
|
|
|
|
if (endpoint) {
|
|
|
|
const response = await fetch(endpoint, {
|
|
|
|
try {
|
|
|
|
|
|
|
|
const { data } = await axios.get<RumbleApiResponse>(endpoint, {
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
|
'Accept-Language': settings.get('locale', '*') as string,
|
|
|
|
'Accept-Language': settings.get('locale', '*') as string,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
|
|
|
const data = await response.json() as RumbleApiResponse;
|
|
|
|
|
|
|
|
return data.ads.map(item => normalizeAd({
|
|
|
|
return data.ads.map(item => normalizeAd({
|
|
|
|
impression: item.impression,
|
|
|
|
impression: item.impression,
|
|
|
|
card: normalizeCard({
|
|
|
|
card: normalizeCard({
|
|
|
@ -45,6 +46,8 @@ const RumbleAdProvider: AdProvider = {
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
expires_at: new Date(item.expires * 1000),
|
|
|
|
expires_at: new Date(item.expires * 1000),
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|