Skip to content

Commit e93c8e3

Browse files
committed
Remove expired DMs during cleanup
1 parent 37856cf commit e93c8e3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sogs/cleanup.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ def cleanup():
1515
app.logger.debug("Pruning expired items")
1616
files = prune_files()
1717
msg_hist = prune_message_history()
18+
dms = prune_expired_dms()
1819
room_act = prune_room_activity()
1920
perm_upd = apply_permission_updates()
2021
exp_nonces = expire_nonce_history()
2122
app.logger.debug(
2223
f"Pruned {files} files, {msg_hist} msg hist, {room_act} room activity, "
23-
f"{exp_nonces} nonces; applied {perm_upd} perm updates."
24+
f"{exp_nonces} nonces, {dms} inbox msgs; applied {perm_upd} perm updates."
2425
)
2526
return (files, msg_hist, room_act, perm_upd, exp_nonces)
2627
except Exception as e:
@@ -76,6 +77,14 @@ def prune_message_history():
7677
return count
7778

7879

80+
def prune_expired_dms():
81+
count = query("DELETE FROM inbox WHERE expiry < :now", now=time.time()).rowcount
82+
83+
if count > 0:
84+
app.logger.info(f"Removed {count} expired inbox/message requests")
85+
return count
86+
87+
7988
def prune_room_activity():
8089
count = query(
8190
"DELETE FROM room_users WHERE last_active < :t",

0 commit comments

Comments
 (0)