[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r21972: {weather} Send unsubscribe info mail after successfull subscription (T (in weather/trunk: . lib/weather)
Author: kaner
Date: 2010-03-15 21:18:49 +0000 (Mon, 15 Mar 2010)
New Revision: 21972
Modified:
weather/trunk/Weather.py
weather/trunk/lib/weather/constants.py
weather/trunk/lib/weather/queries.py
Log:
Send unsubscribe info mail after successfull subscription (Thanks, Sebastian)
Modified: weather/trunk/Weather.py
===================================================================
--- weather/trunk/Weather.py 2010-03-15 19:32:28 UTC (rev 21971)
+++ weather/trunk/Weather.py 2010-03-15 21:18:49 UTC (rev 21972)
@@ -15,7 +15,7 @@
from twisted.internet.task import LoopingCall
from weather.torping import TorPing
-from weather.constants import PAGE_TEMPLATE, PAGE_SIGNUP, CONFIRMATION_MAIL, THANKS_OUT, PAGE_SUB_FIN
+from weather.constants import PAGE_TEMPLATE, PAGE_SIGNUP, CONFIRMATION_MAIL, THANKS_OUT, PAGE_SUB_FIN, SUBS_MAIL
from weather.queries import CHECK_SUBS_Q, INSERT_SUBS_Q, CHECK_SUBS_AUTH_Q, ACK_SUB_Q, UNSUBSCRIBE_Q
from weather.poller import WeatherPoller
from weather.config import pollPeriod, URLbase, mailFrom, databaseName
@@ -128,6 +128,8 @@
request.finish()
else:
self.unsubs_auth = str(result[0][0])
+ self.node = str(result[0][1])
+ self.email = str(result[0][2])
return self._ackSubscription(request)
def _ackSubscription(self, request):
@@ -140,6 +142,12 @@
url = URLbase + "/unsubscribe?auth=" + self.unsubs_auth
link = "<a href=\"" + url + "\">" + url + "</a>"
pageout = PAGE_SUB_FIN % link
+ try:
+ mailText = SUBS_MAIL % (self.node, url)
+ utils.sendMail(mailFrom, self.email, mailText)
+ except Exception, e:
+ pageout += "\n\nUnknown error while sending confirmation mail."
+ print e
request.write(utils.pageOut(pageout))
request.finish()
Modified: weather/trunk/lib/weather/constants.py
===================================================================
--- weather/trunk/lib/weather/constants.py 2010-03-15 19:32:28 UTC (rev 21971)
+++ weather/trunk/lib/weather/constants.py 2010-03-15 21:18:49 UTC (rev 21972)
@@ -36,6 +36,19 @@
anything.
"""
+SUBS_MAIL = """
+ Dear human, this is the Tor Weather Report system.
+
+ You successfully subscribed for weather reports about a tor node.
+
+ (node id: %s)
+
+ (You can unsubscribe from these reports at any time by visiting the
+ following url:
+
+ %s )
+"""
+
PAGE_TEMPLATE = """
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
Modified: weather/trunk/lib/weather/queries.py
===================================================================
--- weather/trunk/lib/weather/queries.py 2010-03-15 19:32:28 UTC (rev 21971)
+++ weather/trunk/lib/weather/queries.py 2010-03-15 21:18:49 UTC (rev 21972)
@@ -5,7 +5,7 @@
INSERT_SUBS_Q = """
INSERT INTO subscriptions (email, node, subs_auth, unsubs_auth, subscribed, downtime_grace, seen_down, noticed) VALUES ('%s', '%s', '%s', '%s', 0, '%s', 0, 0)
"""
-CHECK_SUBS_AUTH_Q = "SELECT unsubs_auth FROM subscriptions WHERE subs_auth='%s'"
+CHECK_SUBS_AUTH_Q = "SELECT unsubs_auth, node, email FROM subscriptions WHERE subs_auth='%s'"
ACK_SUB_Q = "UPDATE subscriptions SET subscribed=1 WHERE subs_auth='%s'"
UNSUBSCRIBE_Q = "DELETE from subscriptions where unsubs_auth='%s'"
GETALL_SUBS_Q = "SELECT * from subscriptions WHERE subscribed=1"