Merge pull request #500 from mautrix/add-avatar-to-contacts

provisioning/contacts: send avatar URL
This commit is contained in:
Sumner Evans 2022-05-21 09:24:57 -06:00 committed by GitHub
commit f1a4cfe7d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
}
}