im
Clone
https://git.tahinli.com/Tahinli/im.git
0 watching0 forksRustAGPL-3.0542.8 KiBb9f0726Tahinli27 days ago34 commits
| 1 | //! The sweeper (architecture section 8): once at boot and then hourly, it removes what has expired. |
| 2 | //! |
| 3 | //! - browser sessions past their expiry, with their back-channel logout jobs queued first; |
| 4 | //! - authorization codes that expired more than a day ago (a day is kept so that a reused code is still |
| 5 | //! recognised as reuse, which revokes the tokens it issued); |
| 6 | //! - refresh tokens past their expiry; |
| 7 | //! - revoked access tokens past their expiry (the revocation has done its work by then); |
| 8 | //! - directory change rows older than 30 days (a cursor older than the oldest row gets `resync`); |
| 9 | //! - account links and invitations past their expiry; |
| 10 | //! - sent mail older than 30 days (its body was blanked when it was sent); |
| 11 | //! - failed and abandoned mail older than 30 days; |
| 12 | //! - back-channel deliveries delivered or given up more than 7 days ago; |
| 13 | //! - audit entries older than a year (`AUDIT_KEEP`). |
| 14 | //! |
| 15 | //! Each step runs on its own: one failing step is logged and does not stop the others. |
| 16 | |
| 17 | use Duration; |
| 18 | |
| 19 | use Store; |
| 20 | use ; |
| 21 | use watch; |
| 22 | |
| 23 | /// The time between two sweeps. |
| 24 | const EVERY: Duration = from_secs; |
| 25 | |
| 26 | /// How long a directory change row is kept (contracts 3.2 and architecture section 3). |
| 27 | const DIRECTORY_KEEP: Duration = from_secs; |
| 28 | |
| 29 | /// How long an expired authorization code is kept, so a reuse is still seen as reuse. |
| 30 | const CODE_KEEP: Duration = from_secs; |
| 31 | |
| 32 | /// How long a sent mail is kept in the outbox before it is deleted (architecture section 8). Failed and |
| 33 | /// abandoned mail are kept as long. |
| 34 | const MAIL_KEEP: Duration = from_secs; |
| 35 | |
| 36 | /// How long a finished back-channel delivery (sent or given up) is kept. A week is long enough to inspect |
| 37 | /// a failure on the admin pages. |
| 38 | const OUTBOX_KEEP: Duration = from_secs; |
| 39 | |
| 40 | /// How long an audit entry is kept. A fixed year, not a setting: `docs/architecture.md` section 3 lists it with |
| 41 | /// the other retention rules. Entries older than this are removed. |
| 42 | const AUDIT_KEEP: Duration = from_secs; |
| 43 | |
| 44 | /// Starts the sweeper. It runs until `stop` is set. |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | /// One pass over every table. Failures are logged per step. |
| 58 | pub async |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 |