All necessary tests pass

This commit is contained in:
SUMUKHA-PK 2019-08-01 15:10:59 +05:30
parent 425215ade9
commit 8a46edbddf
2 changed files with 10 additions and 13 deletions

View file

@ -42,6 +42,7 @@ func GetTags(
device *authtypes.Device,
userID string,
roomID string,
syncProducer *producers.SyncAPIProducer,
) util.JSONResponse {
if device.UserID != userID {
@ -71,6 +72,11 @@ func GetTags(
return httputil.LogThenError(req, err)
}
// send data to syncapi
if err := syncProducer.SendData(userID, roomID, "m.tag"); err != nil {
return httputil.LogThenError(req, err)
}
return util.JSONResponse{
Code: http.StatusOK,
JSON: tagContent,
@ -103,9 +109,9 @@ func PutTag(
var properties gomatrix.TagProperties
// if reqErr := httputil.UnmarshalJSONRequest(req, &properties); reqErr != nil {
// return *reqErr
// }
if reqErr := httputil.UnmarshalJSONRequest(req, &properties); reqErr != nil {
return *reqErr
}
tagContent := newTag()
var dataByte []byte
@ -242,12 +248,3 @@ func saveTagData(
return accountDB.SaveAccountData(req.Context(), localpart, roomID, "m.tag", string(newTagData))
}
// extractEventContents is an utility function to obtain "content" from the ClientEvent
func extractEventContents(data []gomatrixserverlib.ClientEvent) []gomatrixserverlib.RawJSON {
contentData := make([]gomatrixserverlib.RawJSON, 0, len(data))
for i := 0; i < len(data); i++ {
contentData = append(contentData, data[i].Content)
}
return contentData
}

View file

@ -490,7 +490,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
return GetTags(req, accountDB, device, vars["userId"], vars["roomId"])
return GetTags(req, accountDB, device, vars["userId"], vars["roomId"],syncProducer)
}),
).Methods(http.MethodGet, http.MethodOptions)