From 98de4e7c05d9cd953cc9402965f25f99d52bd363 Mon Sep 17 00:00:00 2001 From: SUMUKHA-PK Date: Wed, 13 Mar 2019 14:59:38 +0530 Subject: [PATCH] Issue #657 reolved. --- .../dendrite/clientapi/routing/room_tagging.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/room_tagging.go b/src/github.com/matrix-org/dendrite/clientapi/routing/room_tagging.go index 2513077cb..4ceeab078 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/room_tagging.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/room_tagging.go @@ -47,7 +47,11 @@ func GetTag(req *http.Request, userId string, roomId string) util.JSONResponse { req.Context(), localpart, "ROOM_ID", "m.tag", ) - json.Unmarshal([]byte(data), &mtag) + if err != nil { + return httputil.LogThenError(req, err) + } + + err = json.Unmarshal([]byte(data), &mtag) if err != nil { return httputil.LogThenError(req, err) @@ -85,13 +89,17 @@ func PutTag(req *http.Request, userId string, roomId string, tag string) util.JS mtag := NewMTag() + var properties TagProperties + + if reqErr := httputil.UnmarshalJSONRequest(req, &properties); reqErr != nil { + return *reqErr + } + if len(data) > 0 { json.Unmarshal([]byte(data), &mtag) } - mtag.Tags[tag] = TagProperties{ - Order: 0.5, // Change value based on need - } + mtag.Tags[tag] = properties newTagData, _ := json.Marshal(mtag)