浏览代码

provisioning/contacts: send avatar URL

Sumner Evans 3 年之前
父节点
当前提交
e133516fed
共有 1 个文件被更改,包括 16 次插入1 次删除
  1. 16 1
      provisioning.go

+ 16 - 1
provisioning.go

@@ -290,7 +290,22 @@ func (prov *ProvisioningAPI) ListContacts(w http.ResponseWriter, r *http.Request
 			ErrCode: "failed to get contacts",
 			ErrCode: "failed to get contacts",
 		})
 		})
 	} else {
 	} 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)
 	}
 	}
 }
 }