mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-28 01:00:52 -07:00
Tether query rolls to channel membership in ERC
* lisp/erc/erc-backend.el (erc-server-JOIN): Update query membership via `erc--ensure-query-member' when someone else joins a channel. (erc-server-NICK): Update query membership via `erc--ensure-query-member' after someone else changes their nick. (erc-server-PRIVMSG): After printing a query message from some other person, remove their nick's data from the query buffer's user table if they're "untracked," i.e., not a member of a channel. (erc-server-263, erc-server-263-functions): New function and variable, a default response handler and hook for "RPL_TRYAGAIN", which servers send for things like rejecting "WHO" and "WHOX" responses due to rate limiting. (erc-server-311): Fix call to `erc-update-user-nick' so the userhost login component is no longer supplied as the `info' parameter but rather, correctly, as the `login'. (erc--extract-352-full-name): Factor out trailing hop-count and GECOS parsing for use by overriding handlers or those for adjacent numerics. (erc-server-352): Refactor to handle asterisk as `channel' parameter, which indicates a nick rather than a channel target. (erc-server-366): Update membership in all query buffers via `erc--ensure-query-members' after all names have been received. (erc-server-401): Forget a known user completely when the server reports them as nonexistent. * lisp/erc/erc-common.el (erc--get-server-user): New function, a thin wrapper around `erc-get-server-user' for cases were inlining would require declaring symbols not defined in erc-common. * lisp/erc/erc.el (erc-channel-members): Mention that instances are used for query-participant tables as well. (erc--decouple-query-and-channel-membership-p): New variable, a compatibility flag to access pre-5.6 query bookkeeping behavior. (erc--ensure-query-member, erc--ensure-query-members): New functions. (erc-cmd-QUERY): Ensure parties are present in the query buffer's membership table if they're known to be on the server by simple virtue of being present in some joined channel. (erc-message-english-s352-you): New variable. * test/lisp/erc/erc-scenarios-base-query-participants.el (erc-scenarios-base-query-participants) (erc-scenarios-base-query-participants/legacy): Rename former to latter. Enable compat flag to activate legacy query behavior in which channel membership does not impact query membership. (erc-scenarios-base-query-participants/coupled): New test asserting new behavior in which channel membership dictates query membership. (Bug#70928)
This commit is contained in:
parent
75aefe6514
commit
04477cf97b
4 changed files with 183 additions and 26 deletions
|
|
@ -24,7 +24,7 @@
|
|||
(let ((load-path (cons (ert-resource-directory) load-path)))
|
||||
(require 'erc-scenarios-common)))
|
||||
|
||||
(ert-deftest erc-scenarios-base-query-participants ()
|
||||
(ert-deftest erc-scenarios-base-query-participants/legacy ()
|
||||
:tags '(:expensive-test)
|
||||
|
||||
(erc-scenarios-common-with-cleanup
|
||||
|
|
@ -32,6 +32,7 @@
|
|||
(erc-server-flood-penalty 0.1)
|
||||
(dumb-server (erc-d-run "localhost" t 'legacy))
|
||||
(expect (erc-d-t-make-expecter))
|
||||
(erc--decouple-query-and-channel-membership-p t)
|
||||
(port (process-contact dumb-server :service)))
|
||||
|
||||
(ert-info ("Connect to foonet")
|
||||
|
|
@ -113,5 +114,95 @@
|
|||
(should-not (erc-get-server-user "bob")) ; missing from query
|
||||
(should (erc-get-server-user "dummy"))))))
|
||||
|
||||
(ert-deftest erc-scenarios-base-query-participants/coupled ()
|
||||
:tags '(:expensive-test)
|
||||
|
||||
(erc-scenarios-common-with-cleanup
|
||||
((erc-scenarios-common-dialog "base/query-participants")
|
||||
(erc-server-flood-penalty 0.1)
|
||||
(dumb-server (erc-d-run "localhost" t 'legacy))
|
||||
(expect (erc-d-t-make-expecter))
|
||||
(port (process-contact dumb-server :service)))
|
||||
|
||||
(ert-info ("Connect to foonet")
|
||||
(with-current-buffer (erc :server "127.0.0.1"
|
||||
:port port
|
||||
:nick "tester"
|
||||
:user "tester"
|
||||
:full-name "tester")
|
||||
(funcall expect 10 "This server is in debug mode")
|
||||
(erc-scenarios-common-say "/query bob")))
|
||||
|
||||
(ert-info ("Opening query on untracked user bob doesn't create entry.")
|
||||
(with-current-buffer "bob"
|
||||
(should-not (erc-get-channel-member "bob"))))
|
||||
|
||||
(ert-info ("DM from untracked user also doesn't create a query entry.")
|
||||
(with-current-buffer (erc-d-t-wait-for 10 (get-buffer "dummy"))
|
||||
(funcall expect 10 "<dummy> hi")
|
||||
(should-not (erc-get-channel-member "dummy"))
|
||||
(should-not (erc-get-server-user "dummy"))))
|
||||
|
||||
(with-current-buffer "foonet"
|
||||
(erc-scenarios-common-say "/join #chan"))
|
||||
|
||||
(ert-info ("Members in new chan added to existing query buffers")
|
||||
(with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
|
||||
(funcall expect 10 "bob ")) ; bob is present in #chan (353)
|
||||
(with-current-buffer "bob"
|
||||
(should (erc-get-server-user "bob"))
|
||||
;; Can't assert immediately: must wait until 366 arrives.
|
||||
(erc-d-t-wait-for 10 (erc-get-channel-member "bob"))))
|
||||
|
||||
(ert-info ("Opening query on tracked user creates entry")
|
||||
(with-current-buffer "#chan"
|
||||
(funcall expect 10 " alice") ;; alice is present
|
||||
(erc-scenarios-common-say "hi channel") ; gate
|
||||
(funcall expect 10 "<tester> hi channel")
|
||||
(erc-scenarios-common-say "/query alice"))
|
||||
(with-current-buffer "alice"
|
||||
(should (erc-get-channel-member "alice"))))
|
||||
|
||||
;; Bob says something.
|
||||
(with-current-buffer "bob"
|
||||
(funcall expect 10 "<bob> hi")
|
||||
(should (erc-get-channel-member "bob")))
|
||||
|
||||
(ert-info ("Query pal parting channel removes them from query")
|
||||
;; Identical result if they're kicked: they're removed from the
|
||||
;; server AND their target buffers
|
||||
(with-current-buffer "#chan"
|
||||
(funcall expect 10 "has left")
|
||||
(should-not (erc-get-channel-member "dummy"))
|
||||
(should-not (erc-get-server-user "dummy")))
|
||||
(with-current-buffer "dummy"
|
||||
(should-not (erc-get-channel-member "dummy"))))
|
||||
|
||||
;; This is unchanged from legacy behavior.
|
||||
(ert-info ("Query pal quitting channel removes them everywhere")
|
||||
(with-current-buffer "#chan"
|
||||
(funcall expect 10 "has quit")
|
||||
(should-not (erc-get-channel-member "bob"))
|
||||
(should-not (erc-get-server-user "bob")))
|
||||
(with-current-buffer "bob"
|
||||
(should-not (erc-get-channel-member "bob"))))
|
||||
|
||||
(ert-info ("Query pal re-joining repopulates query")
|
||||
(with-current-buffer "#chan"
|
||||
(erc-scenarios-common-say "bob gone")
|
||||
(funcall expect 10 "<alice> bob, welcome back!")
|
||||
(should (erc-get-server-user "bob")))
|
||||
(with-current-buffer "bob"
|
||||
(should (erc-get-channel-member "bob"))))
|
||||
|
||||
(ert-info ("Parting removes chan members from server and queries")
|
||||
(with-current-buffer "#chan"
|
||||
(erc-scenarios-common-say "/part")
|
||||
(funcall expect 10 "you have left")
|
||||
(should-not (erc-get-server-user "fsbot"))
|
||||
(should-not (erc-get-server-user "alice")) ; she never said anything
|
||||
(should-not (erc-get-server-user "bob")) ; missing from query
|
||||
(should-not (erc-get-server-user "dummy"))))))
|
||||
|
||||
|
||||
;;; erc-scenarios-base-query-participants.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue