diff --git a/src/send_daily_email/app.py b/src/send_daily_email/app.py index 2edde7a..60081fe 100644 --- a/src/send_daily_email/app.py +++ b/src/send_daily_email/app.py @@ -1,6 +1,7 @@ import os import json import boto3 +import urllib.parse from random import randint from datetime import datetime from boto3.dynamodb.conditions import Key @@ -135,9 +136,8 @@ def assemble_html_content(user, todays_words, todays_announcement): with open(os.path.join(abs_dir, 'email_template.html')) as fh: email_template = fh.read() - # Hard coding HSK level before list database refactor # Get first list user is subscribed to and use in unsub link - email_contents = email_template.replace("{unsubscribe_link}", "https://haohaotiantian.com/unsub?list=" + user.subscriptions[0].list_id + "&char=" + user.subscriptions[0].character_set + "&email=" + user.email_address) + email_contents = email_template.replace("{unsubscribe_link}", "https://haohaotiantian.com/unsub?list=" + user.subscriptions[0].list_id + "&char=" + user.subscriptions[0].character_set + "&email=" + urllib.parse.quote_plus(user.email_address)) email_contents = email_contents.replace("{word_contents}", word_content) @@ -181,9 +181,9 @@ def assemble_word_html_content(user_email, subscription, todays_words): word_contents = word_contents.replace("{definition}", word["Definition"]) word_contents = word_contents.replace("{link}", example_link) word_contents = word_contents.replace("{list}", subscription.list_name) - word_contents = word_contents.replace("{quiz_link}", "https://haohaotiantian.com/quiz?list=HSKLevel" + hsk_level + "&days=14&ques=10&char=" + subscription.character_set) - word_contents = word_contents.replace("{signin_link}", "https://haohaotiantian.com/quiz?email=" + user_email) - word_contents = word_contents.replace("{review_link}", "https://haohaotiantian.com/review?list_id=" + subscription.list_id + "&dates=30&char=" + subscription.character_set) + word_contents = word_contents.replace("{quiz_link}", "https://haohaotiantian.com/quiz?list_id=" + subscription.list_id + "&date_range=30&ques=10&char=" + subscription.character_set) + word_contents = word_contents.replace("{signin_link}", "https://haohaotiantian.com/signin?email=" + urllib.parse.quote_plus(user_email)) + word_contents = word_contents.replace("{review_link}", "https://haohaotiantian.com/review?list_id=" + subscription.list_id + "&date_range=30&char=" + subscription.character_set) return word_contents