pg: add status to db for external games: claimed, claimed and redeemed, failed
This commit is contained in:
parent
862fd20d5b
commit
0d2ff0c8a9
1 changed files with 6 additions and 1 deletions
|
|
@ -134,10 +134,12 @@ try {
|
||||||
console.log(' External store:', store);
|
console.log(' External store:', store);
|
||||||
const url = page.url().split('?')[0];
|
const url = page.url().split('?')[0];
|
||||||
db.data[user][title] ||= { title, time: datetime(), url, store };
|
db.data[user][title] ||= { title, time: datetime(), url, store };
|
||||||
const notify_game = { title, url, status: `failed - link ${store}` };
|
const notify_game = { title, url };
|
||||||
notify_games.push(notify_game); // status is updated below
|
notify_games.push(notify_game); // status is updated below
|
||||||
if (await page.locator('div:has-text("Link game account")').count()) {
|
if (await page.locator('div:has-text("Link game account")').count()) {
|
||||||
console.error(' Account linking is required to claim this offer!');
|
console.error(' Account linking is required to claim this offer!');
|
||||||
|
notify_game.status = `failed: need account linking for ${store}`;
|
||||||
|
db.data[user][title].status = 'failed: need account linking';
|
||||||
} else {
|
} else {
|
||||||
// print code if there is one
|
// print code if there is one
|
||||||
const redeem = {
|
const redeem = {
|
||||||
|
|
@ -183,6 +185,7 @@ try {
|
||||||
} else { // TODO not logged in? need valid unused code to test.
|
} else { // TODO not logged in? need valid unused code to test.
|
||||||
redeem_action = 'redeemed?';
|
redeem_action = 'redeemed?';
|
||||||
console.log(' Redeemed successfully? Please report your Response from above (if it is new) in https://github.com/vogler/free-games-claimer/issues/5');
|
console.log(' Redeemed successfully? Please report your Response from above (if it is new) in https://github.com/vogler/free-games-claimer/issues/5');
|
||||||
|
// db.data[user][title].status = 'claimed and redeemed';
|
||||||
}
|
}
|
||||||
} else if (store == 'microsoft games') {
|
} else if (store == 'microsoft games') {
|
||||||
console.error(` Redeem on ${store} not yet implemented!`);
|
console.error(` Redeem on ${store} not yet implemented!`);
|
||||||
|
|
@ -204,6 +207,7 @@ try {
|
||||||
await page2.click('#nextButton');
|
await page2.click('#nextButton');
|
||||||
redeem_action = 'redeemed?';
|
redeem_action = 'redeemed?';
|
||||||
console.log(' Redeemed successfully? Please report your Response from above (if it is new) in https://github.com/vogler/free-games-claimer/issues/5');
|
console.log(' Redeemed successfully? Please report your Response from above (if it is new) in https://github.com/vogler/free-games-claimer/issues/5');
|
||||||
|
// db.data[user][title].status = 'claimed and redeemed';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (store == 'legacy games') {
|
} else if (store == 'legacy games') {
|
||||||
|
|
@ -215,6 +219,7 @@ try {
|
||||||
notify_game.status = `<a href="${redeem[store]}">${redeem_action}</a> ${code} on ${store}`;
|
notify_game.status = `<a href="${redeem[store]}">${redeem_action}</a> ${code} on ${store}`;
|
||||||
} else {
|
} else {
|
||||||
notify_game.status = `claimed on ${store}`;
|
notify_game.status = `claimed on ${store}`;
|
||||||
|
db.data[user][title].status = 'claimed';
|
||||||
}
|
}
|
||||||
// save screenshot of potential code just in case
|
// save screenshot of potential code just in case
|
||||||
const p = path.resolve(cfg.dir.screenshots, 'prime-gaming', 'external', `${filenamify(title)}.png`);
|
const p = path.resolve(cfg.dir.screenshots, 'prime-gaming', 'external', `${filenamify(title)}.png`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue