diff options
| author | EuAndreh <eu@euandre.org> | 2026-04-27 06:32:24 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2026-04-27 06:32:24 -0300 |
| commit | 6237e196a2833603b60bfa482e11d6023b9b1f39 (patch) | |
| tree | fd9f79f1c911ccb4246b2644a284c198b6e1d1ba /tests | |
| parent | Implement TAGMSG persistence and BATCH multiline support (diff) | |
| download | papod-6237e196a2833603b60bfa482e11d6023b9b1f39.tar.gz papod-6237e196a2833603b60bfa482e11d6023b9b1f39.tar.xz | |
Implement CHATHISTORY TARGETS, DM redaction, account-isolated DMs
Adds the missing CHATHISTORY TARGETS subcommand returning channels and
DM peers the user has activity in within an exclusive timestamp window,
sorted by latest message time.
REDACT now accepts DM targets: a sender can redact their own DM, and
both sides receive the REDACT line if they have draft/message-redaction.
DM events now record source-account and target-account at storage time.
Chathistory queries filter to events whose stored account matches the
requesting client's current SASL account, so a freshly-registered user
who reuses a previously-anonymous nick does not see the prior identity's
DMs (regression test for issue #833).
DM history fetch is also case-insensitive on nick comparisons, and
format-history-event renders DMs with the original target nick rather
than the conversation peer, fixing replays where a self→peer reply was
shown as peer→peer.
The join-one\! refactor (returns echo + topic + markread + names lines
in the reply vector) is retained from prior work; unit tests assert the
returned replies instead of inspecting the writer bytestream so JOIN
echoes can be wrapped in a labeled-response BATCH.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit.clj | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/unit.clj b/tests/unit.clj index fad96fc..b2cea4c 100644 --- a/tests/unit.clj +++ b/tests/unit.clj @@ -374,8 +374,8 @@ :clients (atom {"alice" {:w alice-out}}) :channels (atom {})) sender (registered-client "alice" alice-out test-network-id) - conn (:conn components)] - (handle-join ["#test"] sender components) + conn (:conn components) + replies (handle-join ["#test"] sender components)] (let [db (d/db conn)] ;; Channel entity created (is (some? (resolve-channel db "#test"))) @@ -396,8 +396,8 @@ (is (= #{["user-join" "alice" "#test"]} events)))) ;; In-memory updated (is (= #{"alice"} (get @(:channels components) "#test"))) - ;; Notification delivered - (is (string/includes? (.toString alice-out "UTF-8") "JOIN #test")))) + ;; Notification returned in replies + (is (some #(string/includes? % "JOIN #test") replies)))) (testing "second JOIN reuses existing channel" (let [alice-out (java.io.ByteArrayOutputStream.) bob-out (java.io.ByteArrayOutputStream.) @@ -815,7 +815,7 @@ handle (str "&" chan-id)] ;; Alice (owner) can join (let [replies (handle-join [handle] alice components)] - (is (empty? replies)) + (is (some #(string/includes? % "JOIN") replies)) (is (contains? (get @(:channels components) handle) "alice"))) ;; Bob (no access) cannot join — gets "No such channel" (let [replies (handle-join [handle] bob components)] @@ -838,7 +838,7 @@ (assoc components :channels (atom {})))] ;; Creates a NEW public channel named #bob-firing-wg ;; (doesn't find the private one — that's the point) - (is (empty? replies))))) + (is (some #(string/includes? % "JOIN") replies))))) (testing "#-prefixed UUID name works as a normal public channel" (let [{:keys [test-network-id] :as components} (assoc (test-components-with-network) @@ -851,7 +851,7 @@ (let [c (assoc components :clients (atom {"alice" {:w out}}))] (let [replies (handle-join [uuid-name] alice c)] - (is (empty? replies)) + (is (some #(string/includes? % "JOIN") replies)) (is (contains? (get @(:channels c) uuid-name) "alice")))))) (testing "&non-uuid is rejected" (let [{:keys [test-network-id] :as components} |
