Don't send "phone number"-named roster entries in roster exchanges

This commit is contained in:
eta 2020-08-21 19:40:25 +01:00
parent 807acd42b3
commit acfa5c236d
2 changed files with 11 additions and 9 deletions

View File

@ -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."

View File

@ -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."