Skip to content

Commit

Permalink
url encoding for emails
Browse files Browse the repository at this point in the history
  • Loading branch information
em-shea committed Mar 5, 2022
1 parent e249d10 commit dc119e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/send_daily_email/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit dc119e7

Please sign in to comment.