-
Notifications
You must be signed in to change notification settings - Fork 0
/
publichandler.py
27 lines (25 loc) · 1.12 KB
/
publichandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# coding=utf-8
import webapp2
from google.appengine.ext.db import GqlQuery
from google.appengine.api import mail
from igaelib import logging
from traceback import format_exc
class BatchSendMail(webapp2.RequestHandler):
def post(self):
try:
kind = self.request.get("kind")
logging.debug(kind)
if kind == "zhihuribao":
insdate = self.request.get("insdate")
result = GqlQuery("select * from zhihuribao where insdate = '%s'" % (insdate,))
ribao = u"\n\n".join([u"%s\n%s" % (r.title, r.href) for r in result])
subscribeusrs = GqlQuery("select * from subscription where rssid = 'zhihuribao'")
for user in subscribeusrs:
if user.email != "":
logging.debug(user.email)
mail.send_mail(sender='asdseal@gmail.com', to=user.email, subject='知乎日报-%s' % insdate, body=ribao)
else:
logging.debug("something wrong")
self.response.out.write("Ok")
except:
logging.error(format_exc())