Deletion seems to be complete

This commit is contained in:
SUMUKHA-PK 2019-03-12 21:16:43 +05:30
parent 9f7b1290af
commit 00840e35db

View file

@ -81,13 +81,8 @@ func PutTag(req *http.Request, userId string, roomId string, tag string) util.JS
mtag := NewMTag()
// outInterface := map[string]interface{}{}
if len(data) > 0 {
json.Unmarshal([]byte(data), &mtag)
if outInterface[tag] != nil {
// Error saying this Tag already exists
}
}
mtag.Tags[tag] = TagProperties{
@ -123,6 +118,31 @@ func DeleteTag(req *http.Request, userId string, roomId string, tag string) util
return httputil.LogThenError(req, err)
}
data, err := accountDB.GetAccountDataByType(
req.Context(), localpart, "ROOM_ID", "m.tag",
)
if err != nil {
return httputil.LogThenError(req, err)
}
mtag := NewMTag()
if len(data) > 0 {
json.Unmarshal([]byte(data), &mtag)
} else {
//Error indicating there is no Tag data
return util.JSONResponse{}
}
//Check whether the Tag to be deleted exists
if _, ok := mtag.Tags[tag]; ok {
delete(mtag.Tags, tag) //Deletion completed
} else {
//Error indicating that there is no Tag to delete
return util.JSONResponse{}
}
return util.JSONResponse{
Code: http.StatusOK,
JSON: {},