[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [gettor/master] Remove completed gettor requests from database



commit c2930fe339d0be0deceb4120e771bc4f24f28770
Author: Cecylia Bocovich <cohosh@xxxxxxxxxxxxxx>
Date:   Fri Jan 31 17:15:56 2020 -0500

    Remove completed gettor requests from database
    
    This will remove gettor requests from the requests database when they
    are completed (rather than changing the status to 'SENT'). There's no
    need to keep this information around, and we don't want to store
    hashed email addresses as identifiers long term.
---
 gettor/services/email/sendmail.py | 10 ++++------
 gettor/utils/db.py                |  9 ++++-----
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/gettor/services/email/sendmail.py b/gettor/services/email/sendmail.py
index 8d895d7..3f4cfed 100644
--- a/gettor/services/email/sendmail.py
+++ b/gettor/services/email/sendmail.py
@@ -191,9 +191,8 @@ class Sendmail(object):
                         service="email"
                     )
 
-                    yield self.conn.update_request(
-                        id=id, hid=hid.hexdigest(), status="SENT",
-                        service="email", date=date
+                    yield self.conn.remove_request(
+                        id=id, service="email", date=date
                     )
 
             except SMTPError as e:
@@ -245,9 +244,8 @@ class Sendmail(object):
                         service="email"
                     )
 
-                    yield self.conn.update_request(
-                        id=id, hid=hid.hexdigest(), status="SENT",
-                        service="email", date=date
+                    yield self.conn.remove_request(
+                        id=id, service="email", date=date
                     )
 
             except SMTPError as e:
diff --git a/gettor/utils/db.py b/gettor/utils/db.py
index 1ccdf8e..0ca11aa 100644
--- a/gettor/utils/db.py
+++ b/gettor/utils/db.py
@@ -72,15 +72,14 @@ class SQLite3(object):
 			query, (id, service)
 		).addCallback(self.query_callback).addErrback(self.query_errback)
 
-	def update_request(self, id, hid, status, service, date):
+	def remove_request(self, id, service, date):
 		"""
-		Update request record in the database
+		Removes completed request record from the database
 		"""
-		query = "UPDATE requests SET id=?, status=? WHERE id=? AND "\
-		"service=? AND date=?"
+		query = "DELETE FROM requests WHERE id=? AND service=? AND date=?"
 
 		return self.dbpool.runQuery(
-			query, (hid, status, id, service, date)
+			query, (id, service, date)
 		).addCallback(self.query_callback).addErrback(self.query_errback)
 
 	def update_stats(self, command, service, platform=None, language='en'):



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits