From e133516feddeb88316d206dccc1cffbe4c612ed9 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Fri, 20 May 2022 17:33:33 -0600 Subject: [PATCH] provisioning/contacts: send avatar URL --- provisioning.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/provisioning.go b/provisioning.go index 5733bf4..e532079 100644 --- a/provisioning.go +++ b/provisioning.go @@ -290,7 +290,22 @@ func (prov *ProvisioningAPI) ListContacts(w http.ResponseWriter, r *http.Request ErrCode: "failed to get contacts", }) } else { - jsonResponse(w, http.StatusOK, contacts) + augmentedContacts := map[types.JID]interface{}{} + for jid, contact := range contacts { + var avatarUrl id.ContentURI + if puppet := prov.bridge.DB.Puppet.Get(jid); puppet != nil { + avatarUrl = puppet.AvatarURL + } + augmentedContacts[jid] = map[string]interface{}{ + "Found": contact.Found, + "FirstName": contact.FirstName, + "FullName": contact.FullName, + "PushName": contact.PushName, + "BusinessName": contact.BusinessName, + "AvatarURL": avatarUrl, + } + } + jsonResponse(w, http.StatusOK, augmentedContacts) } }