From acfa5c236dea8abedb6ab01fb55e7cd35b13e8ca Mon Sep 17 00:00:00 2001 From: eta Date: Fri, 21 Aug 2020 19:40:25 +0100 Subject: [PATCH] Don't send "phone number"-named roster entries in roster exchanges --- db.lisp | 4 ++-- stuff.lisp | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/db.lisp b/db.lisp index b4eb944..d8a9f1f 100644 --- a/db.lisp +++ b/db.lisp @@ -65,14 +65,14 @@ while (sqlite:step-statement get-stmt) append (column-values get-stmt)))) -(defun get-contact-name (uid localpart) +(defun get-contact-name (uid localpart &key no-phone-number) "Get a name for LOCALPART, a possible contact for the user with ID UID." (with-prepared-statements ((get-stmt "SELECT name, notify FROM user_contacts WHERE user_id = ? AND wa_jid = ?")) (bind-parameters get-stmt uid localpart) (when (sqlite:step-statement get-stmt) (with-bound-columns (name notify) get-stmt - (or name notify (substitute #\+ #\u localpart)))))) + (or name notify (unless no-phone-number (substitute #\+ #\u localpart))))))) (defun get-contact-status (uid localpart) "Get the contact status text for LOCALPART, a possible contact for the user with ID UID." diff --git a/stuff.lisp b/stuff.lisp index 08f424d..3d6f89e 100644 --- a/stuff.lisp +++ b/stuff.lisp @@ -908,13 +908,15 @@ Returns three values: avatar data (as two values), and a generalized boolean spe ct-localpart "@" (component-name comp))) - (ct-name (get-contact-name uid ct-localpart))) - (cxml:with-element "item" - (cxml:attribute "action" "add") - (cxml:attribute "jid" ct-jid) - (cxml:attribute "name" ct-name) - (cxml:with-element "group" - (cxml:text "WhatsApp")))))))))) + (ct-name (get-contact-name uid ct-localpart + :no-phone-number t))) + (when ct-name + (cxml:with-element "item" + (cxml:attribute "action" "add") + (cxml:attribute "jid" ct-jid) + (cxml:attribute "name" ct-name) + (cxml:with-element "group" + (cxml:text "WhatsApp"))))))))))) (defun handle-admin-command (comp from body uid) "Handles an admin command sent to COMP."