Skip to content

Commit

Permalink
Revert change
Browse files Browse the repository at this point in the history
  • Loading branch information
sdepold committed Oct 15, 2023
1 parent a68c269 commit ce55233
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 56 deletions.
77 changes: 22 additions & 55 deletions api/src/models/ethical-ads-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ const fetch = require('node-fetch');

const AD_URL = 'https://server.ethicalads.io/api/v1/decision/';

async function getRawEthicalAd() {
const adId = `ad_${+new Date()}`;

const result = await fetch(
`https://server.ethicalads.io/api/v1/decision/?publisher=feedrappinfo&ad_types=image-v1&div_ids=${adId}&keywords=&campaign_types=paid&format=json&client_version=1.9.0&placement_index=0&url=https%3A%2F%2Ffeedrapp.info%2F`,
{
headers: {
accept: '*/*',
'accept-language': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7',
'cache-control': 'no-cache',
pragma: 'no-cache',
'sec-ch-ua':
'"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'script',
'sec-fetch-mode': 'no-cors',
'sec-fetch-site': 'cross-site',
Referer: 'https://feedrapp.info/',
'Referrer-Policy': 'strict-origin-when-cross-origin'
}
}
);
async function getRawEthicalAd(payload = {}) {
const result = await fetch(AD_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: 'Token 0240ea84e680a7d8eab2236e4a82432655d79607'
},
body: JSON.stringify({
...payload,
publisher: 'feedrappinfo',
campaign_types: ['paid'],
url: 'https://feedrapp.info',
placements: [
{
div_id: `ad_${+new Date()}`,
ad_type: 'image-v1',
priority: 10
}
]
})
});

if (!result.ok) {
throw new Error(
Expand All @@ -35,38 +34,6 @@ async function getRawEthicalAd() {
return result.json();
}

// async function getRawEthicalAd(payload = {}) {
// const result = await fetch(AD_URL, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// Accept: 'application/json',
// Authorization: 'Token 0240ea84e680a7d8eab2236e4a82432655d79607'
// },
// body: JSON.stringify({
// ...payload,
// publisher: 'feedrappinfo',
// campaign_types: ['paid'],
// url: 'https://feedrapp.info',
// placements: [
// {
// div_id: `ad_${+new Date()}`,
// ad_type: 'image-v1',
// priority: 10
// }
// ]
// })
// });

// if (!result.ok) {
// throw new Error(
// `Failed to fetch ad: ${result.status} ${result.statusText}`
// );
// }

// return result.json();
// }

function trackEthicalAd(req, clientIp, viewUrl) {
console.log('Tracking Ethical Ad', viewUrl);

Expand Down
2 changes: 1 addition & 1 deletion api/src/models/ethical-ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function formatEthicalAd(ad) {
publishedDate: new Date().toISOString(),
categories: [{ name: 'ads' }],
author: 'Ethical Ads',
thumbnail: ad.view_url || ad.image
thumbnail: ad.image
};
}

Expand Down

0 comments on commit ce55233

Please sign in to comment.