diff --git a/api.go b/api.go
index 3229f25..f616037 100644
--- a/api.go
+++ b/api.go
@@ -206,7 +206,7 @@ func availabilityHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Pa
w.WriteHeader(http.StatusBadRequest)
return
}
-
+ t.TypeOfRequest=requestTypeAvailability
if err := validateAndCleanup(&t); err != nil {
if errors.Is(err, websiteNotSupported) {
w.WriteHeader(http.StatusNotAcceptable)
diff --git a/chrome-exten/popup.html b/chrome-exten/popup.html
index 58b89b3..841b5bd 100644
--- a/chrome-exten/popup.html
+++ b/chrome-exten/popup.html
@@ -10,11 +10,11 @@
SELECT AN OPTION
-
+
-
+
diff --git a/chrome-exten/popup.js b/chrome-exten/popup.js
index 206e62a..0ef6147 100644
--- a/chrome-exten/popup.js
+++ b/chrome-exten/popup.js
@@ -1,5 +1,5 @@
-//var apiurl=`https://smuly-test-ground.ue.r.appspot.com`
-var apiurl=`http:localhost:8006`
+var apiurl=`https://smuly-test-ground.ue.r.appspot.com`
+//var apiurl=`http:localhost:8006`
var activeUrl
let emailid
chrome.identity.getAuthToken({ interactive: true, scopes: ['email'] }, function(token) {
diff --git a/email.go b/email.go
index f504ed1..87fa8c3 100644
--- a/email.go
+++ b/email.go
@@ -23,10 +23,11 @@ const (
const notificationEmailBody = `
-
Product is available
+
![Logo](cid:logo.png)
+
Product is available
Product Name
-
HURRAY! The product you are looking for is available at price(₹value)
+
HURRAY! The product you are looking for is PRICE
Place Order
@@ -87,8 +88,7 @@ func sendTrackNotificationEmail(t trackInput, p scrape.Product) error {
func prepareTrackNotificationEmail(t trackInput, p scrape.Product) (*mail.Message, error) {
var emailBody string
- priceString := strconv.FormatFloat(p.Price, 'f', -1, 64)
- log.Println(p.Name)
+ var priceString string
log.Println("creating mail")
m := mail.NewMessage()
m.SetHeader("From", systemEmailID)
@@ -100,11 +100,17 @@ func prepareTrackNotificationEmail(t trackInput, p scrape.Product) (*mail.Messag
} else {
return nil, fmt.Errorf("invalid request type %s", t.TypeOfRequest)
}
+ m.Embed("./chrome-exten/logo.png") //previously i got this error because of wrong path gomail: could not send email 1: open /chrome-exten/logo.png: no such file or directory
emailBody = strings.Replace(notificationEmailBody, "PRODUCT_URL", t.URL, -1)
emailBody = strings.Replace(emailBody, "Product Name", p.Name, -1)
emailBody = strings.Replace(emailBody, "product-image", p.Image, -1)
- emailBody = strings.Replace(emailBody, "value", priceString, -1)
-
+ if p.Price != 0 {
+ priceString = strconv.FormatFloat(p.Price, 'f', -1, 64)
+ emailBody = strings.Replace(emailBody, "PRICE", "available at ₹"+priceString+"", -1)
+ } else {
+ emailBody = strings.Replace(emailBody, "PRICE", "available now", -1)
+ }
+
m.SetBody("text/html", emailBody)
return m, nil
}