|
|
|
@ -76,12 +76,8 @@ const get_place = (event) => { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
place = ''; |
|
|
|
place = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
if (place === '' || place == null) { |
|
|
|
if (place == null) { |
|
|
|
console.log(event); |
|
|
|
place = ''; |
|
|
|
console.log(place); |
|
|
|
|
|
|
|
if (place === undefined) { |
|
|
|
|
|
|
|
process.exit(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return place; |
|
|
|
return place; |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -119,7 +115,6 @@ const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); |
|
|
|
`${hostname}/search/events/?facebook_id=${event.facebook_id}&token=${token}` |
|
|
|
`${hostname}/search/events/?facebook_id=${event.facebook_id}&token=${token}` |
|
|
|
); |
|
|
|
); |
|
|
|
if (!search.ok) { |
|
|
|
if (!search.ok) { |
|
|
|
console.error(117, search.status); |
|
|
|
|
|
|
|
console.error(118, 'search not ok'); |
|
|
|
console.error(118, 'search not ok'); |
|
|
|
console.error(119, await search.text()); |
|
|
|
console.error(119, await search.text()); |
|
|
|
await sleep(1000); |
|
|
|
await sleep(1000); |
|
|
|
@ -134,22 +129,35 @@ const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); |
|
|
|
if (old_event.ticket_url.length > 0 && event.ticket_url.length == 0) { |
|
|
|
if (old_event.ticket_url.length > 0 && event.ticket_url.length == 0) { |
|
|
|
delete event.ticket_url; |
|
|
|
delete event.ticket_url; |
|
|
|
} |
|
|
|
} |
|
|
|
console.error('132', event); |
|
|
|
|
|
|
|
res = await fetch(`${hostname}/events/${event.id}/?token=${token}`, { |
|
|
|
res = await fetch(`${hostname}/events/${event.id}/?token=${token}`, { |
|
|
|
method: 'PATCH', |
|
|
|
method: 'PATCH', |
|
|
|
body: JSON.stringify(event), |
|
|
|
body: JSON.stringify(event), |
|
|
|
headers: { 'Content-Type': 'application/json' } |
|
|
|
headers: { 'Content-Type': 'application/json' } |
|
|
|
}); |
|
|
|
}); |
|
|
|
console.error(138, await res.text()); |
|
|
|
console.error(137, 'Updated'); |
|
|
|
console.error(139, 'update'); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
res = await fetch(`${hostname}/events/?token=${token}`, { |
|
|
|
res = await fetch(`${hostname}/events/?token=${token}`, { |
|
|
|
method: 'POST', |
|
|
|
method: 'POST', |
|
|
|
body: JSON.stringify(event), |
|
|
|
body: JSON.stringify(event), |
|
|
|
headers: { 'Content-Type': 'application/json' } |
|
|
|
headers: { 'Content-Type': 'application/json' } |
|
|
|
}); |
|
|
|
}); |
|
|
|
console.error(146, 'new'); |
|
|
|
let newEvent = await res.text(); |
|
|
|
|
|
|
|
console.error(145, newEvent); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
newEvent = JSON.parse(newEvent); |
|
|
|
|
|
|
|
await fetch(`http://localhost:8080/v2/send`, { |
|
|
|
|
|
|
|
body: JSON.stringify({ |
|
|
|
|
|
|
|
message: `${new Date(newEvent.start * 1000)} ${newEvent.name}`, |
|
|
|
|
|
|
|
number: '+4793478353', |
|
|
|
|
|
|
|
recipients: ['dansbart.dev'] |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
|
|
headers: { 'Content-Type': 'application/json' } |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.error(148, res.status); |
|
|
|
console.error(161, res.status); |
|
|
|
} |
|
|
|
} |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|