Skip to content

Commit

Permalink
prevent empty notification
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Feb 2, 2024
1 parent b52ad51 commit 19d85b8
Showing 1 changed file with 34 additions and 16 deletions.
50 changes: 34 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class Parcel extends utils.Adapter {
url: 'https://login.dhl.de/af5f9bb6-27ad-4af4-9445-008e7a5cddb8/login/authorize',
params: {
redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
state: 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
state:
'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
client_id: '83471082-5c13-4fce-8dcb-19d2a3fca413',
response_type: 'code',
scope: 'openid offline_access',
Expand Down Expand Up @@ -303,7 +304,8 @@ class Parcel extends utils.Adapter {
redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
response_type: 'code',
scope: 'openid',
state: 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
state:
'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
ui_locales: 'de-DE",',
},
headers: {
Expand Down Expand Up @@ -351,7 +353,8 @@ class Parcel extends utils.Adapter {
redirect_uri: 'dhllogin://de.deutschepost.dhl/login',
response_type: 'code',
scope: 'openid',
state: 'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
state:
'eyJycyI6dHJ1ZSwicnYiOmZhbHNlLCJmaWQiOiJhcHAtbG9naW4tbWVoci1mb290ZXIiLCJoaWQiOiJhcHAtbG9naW4tbWVoci1oZWFkZXIiLCJycCI6ZmFsc2V9',
ui_locales: 'de-DE',
},
headers: {
Expand Down Expand Up @@ -609,7 +612,8 @@ class Parcel extends utils.Adapter {
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.20 Safari/537.36',
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.20 Safari/537.36',
accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'sec-fetch-site': 'same-site',
Expand Down Expand Up @@ -653,7 +657,8 @@ class Parcel extends utils.Adapter {
accept: 'application/json, text/plain, */*',
'content-type': 'application/x-www-form-urlencoded',
'sec-ch-ua-mobile': '?0',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.20 Safari/537.36',
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.20 Safari/537.36',
'sec-ch-ua-platform': '"macOS"',
origin: 'https://login.aliexpress.com',
'sec-fetch-site': 'same-site',
Expand Down Expand Up @@ -683,7 +688,9 @@ class Parcel extends utils.Adapter {
})
.then(async (res) => {
// this.log.debug(JSON.stringify(res.data));
res.data.indexOf('Session has expired') !== -1 ? this.log.error('Session has expired') : this.log.info('Login to Aliexpress successful');
res.data.indexOf('Session has expired') !== -1
? this.log.error('Session has expired')
: this.log.info('Login to Aliexpress successful');
})
.catch(async (error) => {
error.response && this.log.error(JSON.stringify(error.response.data));
Expand Down Expand Up @@ -777,7 +784,7 @@ class Parcel extends utils.Adapter {
.catch((error) => {
this.log.error('Amazon first login step failed');
this.log.error(
'https://www.amazon.de/ap/signin?_encoding=UTF8&accountStatusPolicy=P1&openid.assoc_handle=deflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.de%2Fgp%2Fcss%2Forder-history%3Fie%3DUTF8%26ref_%3Dnav_orders_first&pageId=webcs-yourorder&showRmrMe=1'
'https://www.amazon.de/ap/signin?_encoding=UTF8&accountStatusPolicy=P1&openid.assoc_handle=deflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.de%2Fgp%2Fcss%2Forder-history%3Fie%3DUTF8%26ref_%3Dnav_orders_first&pageId=webcs-yourorder&showRmrMe=1',
);
this.log.error(error);
if (error.response) {
Expand Down Expand Up @@ -811,7 +818,7 @@ class Parcel extends utils.Adapter {
this.log.error(JSON.stringify(error.response.data));
}
this.log.info(
'Delete amazon cookie please restart the adapter to trigger relogin. If this is not working please manualy delete parcel.0.auth.cookie'
'Delete amazon cookie please restart the adapter to trigger relogin. If this is not working please manualy delete parcel.0.auth.cookie',
);
delete this.cookieJar.store.idx['amazon.de'];
});
Expand Down Expand Up @@ -895,11 +902,11 @@ class Parcel extends utils.Adapter {
this.log.error('Login to Amazon failed, please login to Amazon manually and check the login');
if (res.data.indexOf('captcha-placeholder') !== -1) {
this.log.warn(
'Captcha required. Please login into your account to check the state of the account. If this is not wokring please pause the adapter for 24h.'
'Captcha required. Please login into your account to check the state of the account. If this is not wokring please pause the adapter for 24h.',
);
}
this.log.info(
'Amazon cookie are removed. Please restart the adapter to trigger a relogin. If this is not working please manually delete parcel.0.auth.cookie'
'Amazon cookie are removed. Please restart the adapter to trigger a relogin. If this is not working please manually delete parcel.0.auth.cookie',
);
delete this.cookieJar.store.idx['amazon.de'];
this.log.info('Start relogin');
Expand Down Expand Up @@ -938,7 +945,8 @@ class Parcel extends utils.Adapter {
url: 'https://www.dpd.com/de/de/mydpd-anmelden-und-registrieren/',
headers: {
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.66 Safari/537.36',
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.66 Safari/537.36',
accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'accept-language': 'de,en;q=0.9',
Expand Down Expand Up @@ -1731,6 +1739,7 @@ class Parcel extends utils.Adapter {
}
sendungsObject.direction = sendung.sendungsinfo.sendungsrichtung;
this.mergedJsonObject[sendung.id] = sendungsObject;

return sendungsObject;
});
this.mergedJson = this.mergedJson.concat(sendungsArray);
Expand Down Expand Up @@ -1920,7 +1929,12 @@ class Parcel extends utils.Adapter {
const sendungen = this.mergedJsonObject;
const ids = Object.keys(sendungen);
for (const id of ids) {
if (this.alreadySentMessages[id + sendungen[id].source] === sendungen[id].status) {
if (
this.alreadySentMessages[id + sendungen[id].source] === sendungen[id].status ||
sendungen[id].status === '' ||
sendungen[id].status === 'undefined' ||
sendungen[id].status === 'null'
) {
continue;
}

Expand Down Expand Up @@ -2221,7 +2235,8 @@ class Parcel extends utils.Adapter {
'sec-fetch-site': 'same-origin',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'viewport-width': '1264',
},
})
Expand Down Expand Up @@ -2362,7 +2377,8 @@ class Parcel extends utils.Adapter {
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'device-memory': '8',
downlink: '10',
dpr: '2',
Expand Down Expand Up @@ -2395,10 +2411,12 @@ class Parcel extends utils.Adapter {

for (const order of orders) {
const descHandle = order.querySelector(
'.a-fixed-right-grid-col.a-col-left .a-fixed-left-grid-col.a-col-right div:first-child .a-link-normal'
'.a-fixed-right-grid-col.a-col-left .a-fixed-left-grid-col.a-col-right div:first-child .a-link-normal',
);
const desc = descHandle ? descHandle.textContent.replace(/\n */g, '') : '';
let url = order.querySelector('.track-package-button a') ? order.querySelector('.track-package-button a').getAttribute('href') : '';
let url = order.querySelector('.track-package-button a')
? order.querySelector('.track-package-button a').getAttribute('href')
: '';
if (!url) {
const allLinks = order.querySelectorAll('.a-button-inner a');
for (const link of allLinks) {
Expand Down

0 comments on commit 19d85b8

Please sign in to comment.