//! The numbers a chat cannot exceed. One place, because two of these have //! already disagreed across the codebase. //! //! The port of `packages/core/src/messages/limits.ts`. //! //! The body ceiling was 8 000 on the server and 4 000 in the app — so a 6 000 //! character message typed on the web side was accepted, folded, and then sat in //! a file the phone's composer could never have produced. Spec §5.11 picks //! 4 000 and this module is where it lives; the app and the server both import //! it. /// The most characters a message body may carry. /// /// COUNTED IN UTF-16 CODE UNITS, because `String.prototype.length` is what the /// TypeScript compares against — a body of 3 000 emoji is 6 000 by this measure /// on both sides, and a Rust port counting `chars()` would accept a message the /// composer refuses. /// /// Not a CHECK in the file: the op log is append-only, so an oversized row is /// permanent, and a constraint at the server plus a `maxLength` on the composer /// is what actually keeps one out. A CHECK would only turn it into a rejected op /// after the fact. pub const MESSAGE_BODY_MAX: usize = 4000; /// The most characters a thread's denormalised preview line carries. Also UTF-16 /// code units — see [`crate::messages::slice_utf16`]. pub use cotton_rules::messages::preview::MESSAGE_PREVIEW_MAX; /// The most members a Cotton group may hold (spec §5.11). /// /// A CHECK is impossible — membership lives in N files at once — so the service /// refuses the 257th add and the relay refuses to mirror into a thread past the /// cap. Two walls, because either alone can be walked around. /// /// The TypeScript declares this number TWICE, under two names: /// `GROUP_MEMBER_MAX` here and `GROUP_MEMBER_CAP` in `packages/core/src/constants.ts` /// (ported as [`crate::constants::GROUP_MEMBER_CAP`]), read by the relay's /// applier and the peer producer. Both are ported rather than aliased, because /// aliasing would hide the day one of them moves; `the_two_group_caps_agree` /// fails the build if they ever disagree, which is the whole reason to keep both /// names visible. pub const GROUP_MEMBER_MAX: usize = 256; /// The most messages one forward may carry, per target thread. pub const MESSAGE_FORWARD_MAX: usize = 30; #[cfg(test)] #[path = "limits_tests.rs"] mod tests;