Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(notification): sms subject output #298

Merged
merged 5 commits into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ export const Print = {

return `✖ ${buildProductString(link, store)} :: CAPTCHA`;
},
inStock(link: Link, store: Store, color?: boolean): string {
inStock(link: Link, store: Store, color?: boolean, sms?: boolean): string {
if (color) {
return chalk.bgGreen.white.bold(`🚀🚨 ${buildProductString(link, store, false)} :: IN STOCK 🚨🚀`);
}

return `🚀🚨 ${buildProductString(link, store)} :: IN STOCK 🚨🚀`;
const productString = `${buildProductString(link, store)} :: IN STOCK`;
if (sms) {
return productString;
}

return `🚀🚨 ${productString} 🚨🚀`;
},
inStockWaiting(link: Link, store: Store, color?: boolean): string {
if (color) {
Expand Down
2 changes: 1 addition & 1 deletion src/notification/sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function sendSMS(link: Link, store: Store) {
}
] : undefined,
from: email.username,
subject: Print.inStock(link, store),
subject: Print.inStock(link, store, false, true),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I forgot to do the false here. My bad. I thought I tested that 😢

That being said, do you need to scrape the emojis as well? I don't really care, but does it not send otherwise?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only required change really. Just set this to

Suggested change
subject: Print.inStock(link, store, false, true),
subject: Print.inStock(link, store, false),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jef look at the signature of the inStock print function:

inStock(link: Link, store: Store, color?: boolean, sms?: boolean)

It's always had a 3rd parameter to enable color scheme for console output, which is default to undefined (false) in most places that have nothing to do with console output. It's an optional parameter. I added a 4th optional parameter to control removing the emoji's from non-console output. Only SMS subject line is currently affected by them, everywhere else can take emojis but no color (which is the default of both optional parameters). SMS subject line specifies false for color and true for removing emojis. Everywhere else does not

Copy link
Owner

@jef jef Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SMS subject line specifies false for color and true for removing emojis. Everywhere else does not

Right, I understand the change you're making. But I'm interested if we really need to scrape everything and add another parameter as opposed to updating the call and setting the color param to false.

Copy link
Owner

@jef jef Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously color is going to screw up the SMS. That's why I introduced this logic in the first place, but I had mistakenly forgot to set the color to false for this statement.

That being said, do emojis not work?

Oddly enough, my SMS doesn't work as is, but can definitely see this being a problem.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess not for SMS.

Alright, I'll merge this one in. Thank you for the contribution!

text: link.cartUrl ? link.cartUrl : link.url,
to: generateAddress()
};
Expand Down
2 changes: 1 addition & 1 deletion src/store/model/bestbuy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const BestBuy: Store = {
brand: 'test:brand',
model: 'test:model',
series: 'test:series',
url: 'https://www.bestbuy.com/site/nvidia-geforce-rtx-2060-super-8gb-gddr6-pci-express-graphics-card-black-silver/6361329.p?skuId=6361329&intl=nosplash'
url: 'https://www.bestbuy.com/site/evga-ko-ultra-gaming-nvidia-geforce-rtx-2060-6gb-gddr6-pci-express-3-0-graphics-card-black-gray/6403801.p?skuId=6403801&intl=nosplash'
},
{
brand: 'nvidia',
Expand Down