Fix to the JSONMarshal issue

This commit is contained in:
SUMUKHA-PK 2019-05-02 09:54:27 +05:30
parent 9a97a68ff3
commit ac81cefbf1

View file

@ -163,20 +163,20 @@ func obtainSavedTags(
userID string,
roomID string,
accountDB *accounts.Database,
) (string, gomatrixserverlib.RawJSON, error) {
) (string, []gomatrixserverlib.RawJSON, error) {
localpart, _, err := gomatrixserverlib.SplitID('@', userID)
if err != nil {
return "",gomatrixserverlib.RawJSON{}, err
return "", []gomatrixserverlib.RawJSON{}, err
}
data, err := accountDB.GetAccountDataByType(
req.Context(), localpart, roomID, "tag",
)
if err != nil {
return "", gomatrixserverlib.RawJSON{}, err
return "", []gomatrixserverlib.RawJSON{}, err
}
return localpart, data.Content, nil
return localpart, getContentFromData(data), nil
}
// addDataToDB is a utility function to save the tag data into the DB
@ -197,3 +197,11 @@ func addDataToDB(
httputil.LogThenError(req, err)
}
}
func getContentFromData(data []gomatrixserverlib.ClientEvent) []gomatrixserverlib.RawJSON {
var contentData []gomatrixserverlib.RawJSON
for i:=0 ; i< len(data); i++{
contentData = append(contentData,data[i].Content)
}
return contentData
}