LOC-11 Add a field to record the last activity in a room
LOC-11 Add a field to record the last activity in a room

Currently unused by anything, but will be used for the automatic room closure.

Only gets updated when a message is sent by a user. May want to think about whether or not we want to also update when system messages are sent - it probably makes sense to, as it'd be irritating if you joined seconds before the closure threshold and hadn't sent a message yet.

--- a/server/LocalChat.py
+++ b/server/LocalChat.py
@@ -76,7 +76,8 @@
         sql = """ CREATE TABLE rooms (
             id INTEGER PRIMARY KEY,
             name TEXT NOT NULL UNIQUE,
-            owner TEXT NOT NULL
+            owner TEXT NOT NULL,
+            lastactivity INTEGER DEFAULT 0
         );
         
         
@@ -502,6 +503,12 @@
             last = 0
         else:
             last = r[0]
+        
+        
+        # Update the last activity field in the DB
+        # See LOC-11
+        self.cursor.execute("UPDATE rooms set lastactivity=? where id=?",(time.time(),room))
+        self.conn.commit()
         
         return {
                 "status" : "ok",