mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Some changes
This commit is contained in:
parent
6ace5d0737
commit
d28f245a32
|
|
@ -183,7 +183,6 @@ func DeleteTag(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
}
|
}
|
||||||
tagContent := newTag()
|
|
||||||
|
|
||||||
// If there are no tags in the database, exit.
|
// If there are no tags in the database, exit.
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
|
|
@ -194,13 +193,14 @@ func DeleteTag(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byteData, err := json.Marshal(data)
|
dataByte, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
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
|
// Check whether the Tag to be deleted exists
|
||||||
if _, ok := tagContent.Tags[tag]; ok {
|
if _, ok := tagContent.Tags[tag]; ok {
|
||||||
|
|
@ -275,3 +275,17 @@ func extractEventContents(data []gomatrixserverlib.ClientEvent) []gomatrixserver
|
||||||
}
|
}
|
||||||
return contentData
|
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))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue