aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authoralexkursell <alex@awk.run>2020-12-03 06:01:49 -0500
committerGitHub <noreply@github.com>2020-12-03 11:01:49 +0000
commit2b03d24358aeac14ba7c8c63e35012d6e91c1509 (patch)
tree172f618874202f7e05fe2c351d314f5808d3edab /clientapi
parentec7a0e42aea91d881eea8be7ca9fdf2cd69eeaef (diff)
Fix /joined_members API response (#1606)
* Fix /joined_members API response * Fix golint issue
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/memberships.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/clientapi/routing/memberships.go b/clientapi/routing/memberships.go
index 457f81cb..513fcefd 100644
--- a/clientapi/routing/memberships.go
+++ b/clientapi/routing/memberships.go
@@ -44,6 +44,13 @@ type joinedMember struct {
AvatarURL string `json:"avatar_url"`
}
+// The database stores 'displayname' without an underscore.
+// Deserialize into this and then change to the actual API response
+type databaseJoinedMember struct {
+ DisplayName string `json:"displayname"`
+ AvatarURL string `json:"avatar_url"`
+}
+
// GetMemberships implements GET /rooms/{roomId}/members
func GetMemberships(
req *http.Request, device *userapi.Device, roomID string, joinedOnly bool,
@@ -72,12 +79,12 @@ func GetMemberships(
var res getJoinedMembersResponse
res.Joined = make(map[string]joinedMember)
for _, ev := range queryRes.JoinEvents {
- var content joinedMember
+ var content databaseJoinedMember
if err := json.Unmarshal(ev.Content, &content); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("failed to unmarshal event content")
return jsonerror.InternalServerError()
}
- res.Joined[ev.Sender] = content
+ res.Joined[ev.Sender] = joinedMember(content)
}
return util.JSONResponse{
Code: http.StatusOK,