From d28f245a32b2bbe4d7a4bd849b5db26fcf24aa99 Mon Sep 17 00:00:00 2001 From: SUMUKHA-PK Date: Thu, 1 Aug 2019 11:34:31 +0530 Subject: [PATCH] Some changes --- clientapi/routing/room_tagging.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/clientapi/routing/room_tagging.go b/clientapi/routing/room_tagging.go index badfcf58e..6bd9a1b86 100644 --- a/clientapi/routing/room_tagging.go +++ b/clientapi/routing/room_tagging.go @@ -183,7 +183,6 @@ func DeleteTag( if err != nil { return httputil.LogThenError(req, err) } - tagContent := newTag() // If there are no tags in the database, exit. if len(data) == 0 { @@ -194,13 +193,14 @@ func DeleteTag( } } - byteData, err := json.Marshal(data) + dataByte, err := json.Marshal(data) if err != nil { return httputil.LogThenError(req, err) } - if err = json.Unmarshal(byteData, &tagContent); err != nil { - return httputil.LogThenError(req, err) - } + + var tagData []gomatrix.TagData + tagContent := newTag() + err = json.Unmarshal(dataByte, &tagData) // Check whether the Tag to be deleted exists if _, ok := tagContent.Tags[tag]; ok { @@ -275,3 +275,17 @@ func extractEventContents(data []gomatrixserverlib.ClientEvent) []gomatrixserver } return contentData } + +func deleteTagData(req *http.Request, + localpart string, + roomID string, + accountDB *accounts.Database, + Tag gomatrix.TagContent, +) error { + newTagData, err := json.Marshal(Tag) + if err != nil { + return err + } + + return accountDB.SaveAccountData(req.Context(), localpart, roomID, "m.tag", string(newTagData)) +}