summaryrefslogtreecommitdiff
path: root/emailcanary/canarydb.py
diff options
context:
space:
mode:
Diffstat (limited to 'emailcanary/canarydb.py')
-rw-r--r--emailcanary/canarydb.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/emailcanary/canarydb.py b/emailcanary/canarydb.py
index 8bf944f..400fc6d 100644
--- a/emailcanary/canarydb.py
+++ b/emailcanary/canarydb.py
@@ -8,14 +8,14 @@ class CanaryDB:
# Create Tables if necessary
cursor = self.conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS pings (listAddress, address, uuid, timesent timestamp, timereceived timestamp)")
- cursor.execute("CREATE TABLE IF NOT EXISTS accounts (list, address, imapserver, password)")
+ cursor.execute("CREATE TABLE IF NOT EXISTS accounts (list, address, imapserver, password, mute)")
def close(self):
self.conn.close()
def add_account(self, listAddress, address, imapserver, password):
cursor = self.conn.cursor()
- cursor.execute("INSERT INTO accounts (list, address, imapserver, password) VALUES (?, ?, ?, ?)", \
+ cursor.execute("INSERT INTO accounts (list, address, imapserver, password, mute) VALUES (?, ?, ?, ?, 0)", \
(listAddress, address, imapserver, password))
self.conn.commit()
@@ -24,19 +24,25 @@ class CanaryDB:
cursor.execute("DELETE FROM accounts WHERE list=? AND address=?", (listAddress, address))
self.conn.commit()
+ def mute_account(self, listAddress, address, until):
+ cursor = self.conn.cursor()
+ cursor.execute("UPDATE accounts SET mute=? WHERE list=? AND address=?", (until, listAddress, address))
+ self.conn.commit()
+
def get_accounts(self, listAddress = None):
cursor = self.conn.cursor()
if listAddress:
- cursor.execute("SELECT list, address, imapserver, password FROM accounts WHERE list=?", (listAddress,));
+ cursor.execute("SELECT list, address, imapserver, password, mute FROM accounts WHERE list=?", (listAddress,));
else:
- cursor.execute("SELECT list, address, imapserver, password FROM accounts");
+ cursor.execute("SELECT list, address, imapserver, password, mute FROM accounts");
results = list()
for row in cursor:
listAddress = row[0]
address = row[1]
imapserver = row[2]
password = row[3]
- results.append((listAddress, address, imapserver, password))
+ mute = row[4]
+ results.append((listAddress, address, imapserver, password, mute))
return results
def get_recipients_for_list(self, listAddress):
@@ -59,11 +65,13 @@ class CanaryDB:
(time, address, uuid))
self.conn.commit()
- def get_missing_pongs(self, listAddress = None):
+ def get_missing_pongs(self, listAddress = None, address = None):
'''Return a list of tupls of missing pongs.
Each tupl contains (listAddress, uuid, address, time since send)'''
cursor = self.conn.cursor()
- if listAddress:
+ if listAddress and address:
+ cursor.execute("SELECT listAddress, uuid, address, timesent FROM pings WHERE timereceived IS NULL AND listAddress = ? AND address = ?", (listAddress, address,));
+ elif listAddress:
cursor.execute("SELECT listAddress, uuid, address, timesent FROM pings WHERE timereceived IS NULL AND listAddress = ?", (listAddress,));
else:
cursor.execute("SELECT listAddress, uuid, address, timesent FROM pings WHERE timereceived IS NULL");