• exec/tests/user/can_send_

    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/6067458395924c2d5c9c002f
    Added Files:
    exec/tests/user/can_send_mail/child.inc rules.js skipif
    Modified Files:
    exec/load/userdefs.js src/sbbs3/email.cpp js_user.cpp netmail.cpp sbbsdefs.h userdat.c userdat.h
    Log Message:
    Terminal e-mail and netmail use user_can_send_mail()

    The terminal server applied its "may this user send mail" rules inline
    in email.cpp and netmail.cpp, and user_can_send_mail() (also User.can_send_mail() for scripts, which web mail uses) had drifted from
    them. email(), netmail(), inetmail(), qnetmail() and qwktonetmail() now
    call the function, which gains a flags argument:

    CANSEND_SYSOP treat the sender as a sysop (the terminal passes its
    temporary-sysop state this way)
    CANSEND_NO_LIMIT skip the e-mail-per-day limit
    CANSEND_QWK_HUB a QWK hub's packet: there is no sending user, so
    only the system-wide netmail settings apply

    A network type other than NET_NONE, NET_FIDO or NET_INTERNET (netmail()
    passes NET_UNKNOWN before the address is parsed) checks the sender's
    netmail restriction and the daily limit only.

    Rules that change for users:

    - The E and S restrictions go by the recipient's security level, in the
    function as in the terminal: E stops local e-mail to anyone who is not
    a sysop, S stops e-mail to any sysop. The function used to treat only
    user #1 as "the sysop". Without a recipient (user number 0) neither
    applies, as before.
    - A user with E or S may send a first message (no e-mail or feedback
    sent yet) to the new user validation user. The terminal already
    allowed this; the function now does too.
    - FidoNet netmail with no FidoNet address configured is refused by the
    function for everyone, sysops included, as the terminal did.
    - When a user is both restricted and at the daily limit, the
    restriction is reported. email(), netmail() and qnetmail() reported
    the limit first; inetmail() already reported the restriction.
    - Sysops are exempt from "Internet mail allowed" being off in
    netmail()'s Internet branch and in qwktonetmail(), as they already
    were in inetmail() and for FidoNet.

    - Netmail in a user's REP packet counts toward the e-mail-per-day limit
    and is refused at the limit. It was not counted against the limit
    before. A QWK hub's packet stays exempt.
    - A restricted sender is refused when the recipient's user record
    cannot be read, and a deleted or inactive recipient is never taken
    for a sysop.

    The S restriction's description in sbbsdefs.h and userdefs.js now says
    "a sysop", not "user #1".

    Not changed: netmail_addr_is_supported() still refuses an Internet or
    FidoNet address for everyone when that kind of netmail is off, and
    netmail() calls it before the checks above, so a sysop typing such an
    address at the e-mail prompt still gets "invalid address". Scripts
    reach the same check as system.check_netmail_addr() with no sender, and
    depend on that answer.

    Also not changed: a sysop's own E, S and netmail restrictions apply to
    them; the wording of each refusal on each path.

    exec/tests/user/can_send_mail runs User.can_send_mail() against scratch configurations and a scratch user base, covering the restriction,
    validation, FidoNet-address, netmail-allowed and daily-limit rules. The
    order of refusals, the flags and the terminal call sites cannot be
    reached from a script: those were read and compiled only. Built with
    GCC only.

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