askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
dbbasic-package.json · 4.9 KB · 88 lines
| 1 | { |
| 2 | "id": "app-mail-sync", |
| 3 | "name": "Mail Sync", |
| 4 | "version": "0.1.0", |
| 5 | "description": "Copies new mail from a person's own IMAP mailboxes into their app-messaging inbox, and nothing else: it never sends, never deletes, never marks anything read on the server, and never opens a link it finds in a message. Off unless the operator sets DBBASIC_ENABLE_MAIL_SYNC=true; a feature_flags row mail_sync_enabled=off stops it without a redeploy. A person adds an account at /mail/accounts (server, port, ssl or starttls, user name) and stores its password there too -- the password goes into their own write-only identity vault as imap-<account id>, never into a record, and the page only ever shows whether it is set. system_mail_sync runs every two minutes. It opens folders read-only (EXAMINE) and fetches with BODY.PEEK, so is_read on each copied message is the server's own \\Seen flag and the person's mail program sees no difference; messages are picked by UID, not by UNSEEN, so mail already read elsewhere is still copied. The first sync of a folder takes the newest 200 messages of the last 30 days, not the whole history; after that each pass copies at most 50 messages and 25 MB per account, messages over 10 MB arrive as headers with a sentence saying so, and every connection has a 30 second timeout, because the pass runs inside the daemon's loop. Every row id is derived from the owner, the account and the message (its Message-ID, or a hash when it has none), so a pass that dies half way and repeats writes nothing twice, the same message in two people's mailboxes is two rows, and a reply only ever joins a thread belonging to the same person, found by In-Reply-To and References, never by subject. Transport facts app-messaging does not carry (folder, UID, References, List-Unsubscribe, List-Id, Precedence) live in mail_synced_messages; the cursor per folder lives in mail_sync_state and moves only after the rows are written. Failures are written on the account (sync_attempts, sync_error), the account waits longer between tries so a wrong password is not retried until the provider locks it, and after three failures in a row it is counted on the home page. How the inbox grows: one messages row (plus its recipients and one mail_synced_messages row) per message that arrives, no more, because nothing is copied twice; nothing is trimmed, so the inbox is as big as the mail that arrived after the first window, and the change log for those collections grows with it unless the operator sets DBBASIC_CHANGE_LOG_RETENTION_DAYS. Not here, on purpose: sending mail, AI triage or classification, acting on unsubscribe links, attachments (named at the end of the body, not copied), and following flag changes made after a message was copied.", |
| 6 | "compatibility": { |
| 7 | "dbbasic_object_server": ">=0.1.0" |
| 8 | }, |
| 9 | "dependencies": ["app-messaging"], |
| 10 | "objects": [ |
| 11 | { |
| 12 | "id": "system_mail_sync", |
| 13 | "path": "objects/system/mail_sync.py" |
| 14 | }, |
| 15 | { |
| 16 | "id": "system_mail_sync_attention", |
| 17 | "path": "objects/system/mail_sync_attention.py" |
| 18 | }, |
| 19 | { |
| 20 | "id": "site_mail_accounts", |
| 21 | "path": "objects/site/mail_accounts.py" |
| 22 | } |
| 23 | ], |
| 24 | "schemas": [ |
| 25 | { |
| 26 | "collection": "mail_accounts", |
| 27 | "path": "schemas/mail_accounts.json" |
| 28 | }, |
| 29 | { |
| 30 | "collection": "mail_sync_state", |
| 31 | "path": "schemas/mail_sync_state.json" |
| 32 | }, |
| 33 | { |
| 34 | "collection": "mail_synced_messages", |
| 35 | "path": "schemas/mail_synced_messages.json" |
| 36 | } |
| 37 | ], |
| 38 | "permissions": [ |
| 39 | { |
| 40 | "path": "permissions/rules.json" |
| 41 | } |
| 42 | ], |
| 43 | "seed": [ |
| 44 | { |
| 45 | "collection": "mail_accounts", |
| 46 | "path": "seed/mail_accounts.tsv" |
| 47 | }, |
| 48 | { |
| 49 | "collection": "mail_sync_state", |
| 50 | "path": "seed/mail_sync_state.tsv" |
| 51 | }, |
| 52 | { |
| 53 | "collection": "mail_synced_messages", |
| 54 | "path": "seed/mail_synced_messages.tsv" |
| 55 | } |
| 56 | ], |
| 57 | "migrations": [], |
| 58 | "schedules": [ |
| 59 | { |
| 60 | "id": "mail_sync_every_two_minutes", |
| 61 | "object_id": "system_mail_sync", |
| 62 | "schedule": "*/2 * * * *", |
| 63 | "description": "Copy new mail from every enabled account into its owner's inbox. Every two minutes rather than every minute: new mail two minutes late is still new, and the pass shares the daemon's loop with the minutely template runner, so halving its frequency halves what it can delay. An account with nothing new costs one read-only IMAP check and writes nothing; with the feature off the pass returns at once and says which variable to set." |
| 64 | } |
| 65 | ], |
| 66 | "nav": [ |
| 67 | { |
| 68 | "id": "mail_accounts", |
| 69 | "label": "Mail Accounts", |
| 70 | "path": "/mail/accounts", |
| 71 | "blurb": "The mailboxes whose new mail is copied into your inbox", |
| 72 | "surface": "member", |
| 73 | "group": "Work", |
| 74 | "order": 115 |
| 75 | } |
| 76 | ], |
| 77 | "attention": [ |
| 78 | { |
| 79 | "id": "mail_accounts_failing", |
| 80 | "object_id": "system_mail_sync_attention", |
| 81 | "label": "Mail accounts not syncing", |
| 82 | "path": "/mail/accounts", |
| 83 | "nav_id": "mail_accounts", |
| 84 | "group": "Work", |
| 85 | "severity": "warning" |
| 86 | } |
| 87 | ] |
| 88 | } |