From db62866d820cf524b67cebe34033d3928804cf3c Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 28 Mar 2021 11:05:21 -0400 Subject: feat(web/panettone): Noping issue authors' usernames When sending irc notifications, insert a zero-width space after the first character of the username of the author of issues, to prevent that user from receiving a ping. Fixes: b/95 Change-Id: Ibcacb45129b2cb99b587744eb61f4f1dbc0060d6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2693 Tested-by: BuildkiteCI Reviewed-by: tazjin --- web/panettone/src/irc.lisp | 6 ++++++ web/panettone/src/packages.lisp | 3 ++- web/panettone/src/panettone.lisp | 9 +++++++-- web/panettone/test/irc_test.lisp | 5 +++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 web/panettone/test/irc_test.lisp diff --git a/web/panettone/src/irc.lisp b/web/panettone/src/irc.lisp index f116e2a70631..2ab72a2e391e 100644 --- a/web/panettone/src/irc.lisp +++ b/web/panettone/src/irc.lisp @@ -2,6 +2,12 @@ (in-package :panettone.irc) +(defun noping (s) + (format nil "~A~A~A" + (char s 0) + #\ZERO_WIDTH_SPACE + (subseq s 1))) + (defun get-irccat-config () "Reads the IRCCATHOST and IRCCATPORT environment variables, and returns them as two values" diff --git a/web/panettone/src/packages.lisp b/web/panettone/src/packages.lisp index c5fe79b7bc81..3b6edcdd14e3 100644 --- a/web/panettone/src/packages.lisp +++ b/web/panettone/src/packages.lisp @@ -13,8 +13,9 @@ (:export :render-inline-markdown)) (defpackage panettone.irc + (:nicknames :irc) (:use :cl :usocket) - (:export :send-irc-notification)) + (:export :noping :send-irc-notification)) (defpackage :panettone.authentication (:nicknames :authn) diff --git a/web/panettone/src/panettone.lisp b/web/panettone/src/panettone.lisp index 6e43312327ea..c97a988404fa 100644 --- a/web/panettone/src/panettone.lisp +++ b/web/panettone/src/panettone.lisp @@ -460,7 +460,9 @@ (send-irc-notification (format nil "b/~A: \"~A\" opened by ~A - https://b.tvl.fyi/issues/~A" - (id issue) subject (cn *user*) + (id issue) + subject + (irc:noping (cn *user*)) (id issue)) :channel (or (uiop:getenvp "ISSUECHANNEL") "##tvl-dev")) @@ -524,7 +526,10 @@ (send-irc-notification (format nil "b/~A: \"~A\" closed by ~A - https://b.tvl.fyi/issues/~A" - id (subject issue) (cn *user*) id) + id + (subject issue) + (irc:noping (cn *user*)) + id) :channel (or (uiop:getenvp "ISSUECHANNEL") "##tvl-dev"))) (hunchentoot:redirect (format nil "/issues/~A" id))) diff --git a/web/panettone/test/irc_test.lisp b/web/panettone/test/irc_test.lisp new file mode 100644 index 000000000000..0224836cbc32 --- /dev/null +++ b/web/panettone/test/irc_test.lisp @@ -0,0 +1,5 @@ +(in-package :panettone.tests) +(declaim (optimize (safety 3))) + +(test noping-test + (is (not (equal "grfn" (panettone.irc:noping "grfn"))))) -- cgit 1.4.1