• exec/tests/mailbox/store_

    From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Thu Nov 19 15:05:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/3d25d13289a385d7e81155cb
    Added Files:
    exec/tests/mailbox/store_owner.js store_rows.js store_star.js
    Modified Files:
    exec/load/mailbox.js mailbox_tags.js exec/tests/mailbox/read.js store_read.js store_write.js tags.js
    Log Message:
    Mailbox library: stars as an attribute, cached list rows, 16-bit users

    Three changes to the stock mailbox library (exec/load/mailbox*.js)
    that the web mail client needs. Nothing but that client calls the
    library yet.

    - A starred message has the MSG_VALIDATED attribute, in the mail base
    and in a private mailbox alike, in place of a "$Starred" tag. It is
    the bit the IMAP service shows as \Flagged (#1369 asks for IMAP to
    let a user set it on their own mail). Being an index attribute, a
    star is read on every call without opening a header, and it stays
    with a message moved between the bases, to Trash and back.
    - The list rows of mail in the shared base (sender, subject, dates,
    size) are kept in the per-user cache the library already had, so a
    page of the Inbox and a search read no headers for messages seen
    before. Read, replied, spam and star still come from the index on
    every call. Measured by counting file operations for a 500-message
    Inbox and a 2,000-message private mailbox: a page of the Inbox went
    from 1,335 to about 510, a search from 8,449 to about 390. Rows are
    cached only for records the user owns.
    - A user number above 65535 is refused. The mail index holds user
    numbers in 16 bits and the stock mail code matches on that field, so
    mail cannot work for such a user.

    Also: reading a message can mark it read and return only its list row
    (for a message the caller already holds).

    Tests are in exec/tests/mailbox. Run on Linux only.

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Fri Nov 20 15:25:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/4481a15807362affffd3ac85
    Added Files:
    exec/tests/mailbox/store_refresh.js store_sent.js
    Modified Files:
    exec/load/mailbox.js mailbox_files.js mailbox_tags.js exec/tests/mailbox/files.js read.js store_limits.js store_read.js store_write.js tags.js
    Log Message:
    Mailbox library: Sent copies, safer shown text, fewer file operations

    What a client that sends mail and changes mail needs from the Store:

    - save_sent(header, body_path): a Sent copy saved from a body file
    (never a JavaScript string), tagged $Sent $Unsent, from the user and
    with no to_ext, so it never counts as mail received and cannot be
    moved to the Inbox. Made inside one Summary.modify() after the move
    journal is reconciled, under the quota rule of moves into the private
    base. mark_sent(id) removes $Unsent once the mail was delivered;
    remove_sent(id) removes an unsent copy for real (a delivered copy is
    refused); find_sent(message_id) finds a copy whose number was never
    recorded; set_replied(id) sets the replied attribute. A Sent copy
    whose outcome is not known is tagged $Unknown and listed with
    delivery "unknown". get().headers.bcc is the BCC list a Sent copy
    keeps (for $Sent messages only).
    - A Sent item whose delivery failed carries the id of the failure
    notice (delivery.notice) while that notice is still in the user's
    mail; the newest wins. A Sent page reads no extra header for it.
    - inbox_max_age() is a public method: the days the Inbox keeps mail
    (the mail base's max_age), 0 for no limit.

    Text that is shown to the user:

    - Recipient lists are parsed from the raw header first and each display
    name is decoded afterwards. An encoded word that decodes to
    "Alice <alice@x.example>, Mallory" can no longer add a recipient to a
    reply; before, the whole list was decoded and then parsed. get() adds
    headers.to_list, cc_list and reply_to_list ([{name, addr}]), and to,
    cc and reply_to are written from the same entries.
    - Bidirectional controls (U+061C, U+200E, U+200F, U+202A to U+202E,
    U+2066 to U+2069) are removed from decoded names and from the from,
    to and subject of list items. The sender address is shown without
    control characters and marked from_addr_bad when it held one.
    - Folder names refuse those controls and the C1 control characters,
    with the existing reason "invalid".

    Fewer file operations per call, for a data directory on a network
    mount:

    - mailbox.js loads its tag, summary and MIME libraries, smbdefs.js and
    822header.js on first use; state() needs none of them.
    - refresh() uses the shared base handle that Store.open() made as it
    is, for the first call only. Every later call reopens, because a
    handle opened earlier returns header fields as of its open after
    another handle rewrote them in place (#1356), and a flag change could
    write those old fields back.
    - JsonFiles.locked(name, fn) takes a file's lock without rewriting the
    file; update() is built on it.

    The move journal is not touched.

    Tests in exec/tests/mailbox: store_sent.js and store_refresh.js are
    new; read.js gains crafted To, Cc, Reply-To and From headers; files.js
    covers locked(). Run on Linux only.

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Sat Nov 21 11:03:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/01d02e610d1759274b147ccf
    Added Files:
    exec/tests/mailbox/store_quota.js exec/tests/user/mailbox_full/quota_library.js
    Modified Files:
    exec/load/mailbox.js mailbox_files.js mailbox_summary.js exec/tests/mailbox/store_limits.js store_rows.js store_star.js store_write.js exec/tests/user/mailbox_full/quota_child.inc exec/tests/webmail/api.js webmail/lib/api.js webmail/lib/locale/en_us.ini webmail/root/css/style.css webmail/root/js/folders.js mail.js settings.js
    Log Message:
    WebMail: the mailbox quota covers the Inbox

    The mailbox library (exec/load/mailbox.js) counted only the private base against the mailbox quota, so WebMail's meter left out the Inbox, and the
    quota was applied where it no longer makes sense: a move from the Inbox
    into a folder was refused, or removed the oldest Trash, although the
    message takes the same space in either place.

    The library:
    - usage() returns { bytes, quota, full }: bytes is the private base plus
    the user's mail in the shared base (Inbox and Spam), full is true once
    bytes reaches the quota. overview() returns folders() and usage() from
    one pass over the mail index, for folder.list.
    - No move is refused for the quota and none removes Trash: Inbox to a
    folder or Archive, to Trash, back to the Inbox. The "quota" error no
    longer comes from a move.
    - A Sent copy is the one thing the library still checks, now against all
    of the user's mail: the oldest Trash is removed to make room, and when
    that would not be enough the copy is not kept and nothing is removed
    (WebMail sends anyway and says no copy was kept, as before).
    - An Inbox message's size counts its attached files, as a filed message's
    does, so filing does not move the meter (the facts cache version is
    raised: each user's cache is rebuilt once).
    - The private base's total is written to
    data/user/NNNN/mailbox.usage.ini ("bytes=<n>") for the servers, which
    apply the quota to new mail (user_mailbox_full()). Written under the
    state lock by the same replace-by-rename as the JSON side files, when
    the total changes and when the file is missing; a failed write is
    logged and the servers then count the base's file sizes.

    WebMail:
    - folder.list's usage is that figure, and the meter and the settings page
    show it. At the quota a line under the meter says that new mail is
    being refused and to delete messages and empty Trash. Old Trash is not
    removed automatically for it.
    - A user with the W exemption gets a store without a quota: nothing is
    refused, no Trash is removed for room, and the meter shows the usage
    with no limit and no bar.

    For users: the meter now shows all of their mail, so it jumps for anyone
    with a large Inbox. Deleting moves mail to Trash, which still counts:
    room comes from emptying Trash.

    Measured on a copy of a mail base's index and headers (9,262 records),
    local disk, warm caches, one store per call as the API makes: folders()
    plus usage() before against overview() after took 100 to 102 ms and 102
    to 103 ms for an Inbox of 5,486 messages, 37 to 38 and 38 to 39 ms for
    919, 27 to 28 ms both for 24. A send adds one index pass for the Sent
    copy's check: 26 to 85 ms on the same copy.

    Tested by script: exec/tests/mailbox/store_quota.js (usage with Inbox,
    Spam, another user's mail and an attached file; mailbox.usage.ini after
    a move, a delete, a flag change, a Sent copy, a Trash purge by age and
    emptying Trash, rewritten when missing and left alone for an unchanged
    total; deleting and filing over the quota; a Sent copy refused, kept, and
    kept by removing Trash, against Inbox mail; no quota), the changed quota sections of store_write.js and store_limits.js, exec/tests/webmail/api.js (usage and full through folder.list, the W exemption, one index pass)
    and exec/tests/user/mailbox_full/quota_library.js (User.mailbox_full()
    agrees with the library's total at the quota and one block under it,
    from the file the library wrote). The meter and its warning were not
    seen in a browser.

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>