Build errors resolved

This commit is contained in:
SUMUKHA-PK 2019-03-16 18:14:00 +05:30
parent 03e2de54cc
commit 3f88b84798

View file

@ -76,7 +76,11 @@ func PutTag(
roomID string, roomID string,
tag string, tag string,
) util.JSONResponse { ) util.JSONResponse {
localpart, data := obtainSavedTags(req, userID, roomID, accountDB) localpart, data, err := obtainSavedTags(req, userID, roomID, accountDB)
if err != nil {
return httputil.LogThenError(req, err)
}
mtag := newMTag() mtag := newMTag()
var properties common.TagProperties var properties common.TagProperties
@ -107,7 +111,11 @@ func DeleteTag(
roomID string, roomID string,
tag string, tag string,
) util.JSONResponse { ) util.JSONResponse {
localpart, data := obtainSavedTags(req, userID, roomID, accountDB) localpart, data, err := obtainSavedTags(req, userID, roomID, accountDB)
if err != nil {
return httputil.LogThenError(req, err)
}
mtag := newMTag() mtag := newMTag()
if len(data) > 0 { if len(data) > 0 {
@ -141,20 +149,20 @@ func DeleteTag(
} }
// obtainSavedTags is a utility function to get all the tags saved in the DB // obtainSavedTags is a utility function to get all the tags saved in the DB
func obtainSavedTags(req *http.Request, userID string, roomID string, accountDB *accounts.Database) (string, []gomatrixserverlib.ClientEvent) { func obtainSavedTags(req *http.Request, userID string, roomID string, accountDB *accounts.Database) (string, []gomatrixserverlib.ClientEvent, error) {
localpart, _, err := gomatrixserverlib.SplitID('@', userID) localpart, _, err := gomatrixserverlib.SplitID('@', userID)
if err != nil { if err != nil {
raiseError(req, err) return "", []gomatrixserverlib.ClientEvent{}, err
} }
data, err := accountDB.GetAccountDataByType( data, err := accountDB.GetAccountDataByType(
req.Context(), localpart, roomID, "m.tag", req.Context(), localpart, roomID, "m.tag",
) )
if err != nil { if err != nil {
raiseError(req, err) return "", []gomatrixserverlib.ClientEvent{}, err
} }
return localpart, data
return localpart, data, nil
} }
// addDataToDB is a utility function to save the tag data into the DB // addDataToDB is a utility function to save the tag data into the DB
@ -168,7 +176,7 @@ func addDataToDB(req *http.Request, localpart string, roomID string, accountDB *
} }
} }
// raiseError helps in returning a error via a JSONResponse // // raiseError helps in returning a error via a JSONResponse
func raiseError(req *http.Request, err error) util.JSONResponse { // func raiseError(req *http.Request, err error) util.JSONResponse {
return httputil.LogThenError(req, err) // return httputil.LogThenError(req, err)
} // }