Some progress in building roomtags

This commit is contained in:
SUMUKHA-PK 2019-03-11 10:26:12 +05:30
parent 7832e77f4f
commit 795bb5b6f8
2 changed files with 35 additions and 22 deletions

View file

@ -14,31 +14,19 @@
package routing
const pathPrefixR0 = "/_matrix/client/r0"
import "net/http"
func TagRoom(
req *http.Request
) util.JSONResponse {
// GetTag implements GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags
func GetTag(req *http.Request, userId string, roomId string) {
r0mux := apiMux.PathPrefix(pathPrefixR0).Subrouter()
}
// PutTag implements GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
func PutTag(req *http.Request, userId string, roomId string, tag string) {
r0mux.Handle("/user/{userId}/rooms/{roomId}/tags",
common.MakeAuthAPI("account_3pid", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
return GetTag()
}),
).Methods(http.MethodGet, http.MethodOptions)
}
r0mux.Handle("/user/{userId}/rooms/{roomId}/tags/{tag}",
common.MakeAuthAPI("account_3pid", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
return PutTag()
}),
).Methods(http.MethodPut, http.MethodOptions)
// DeleteTag implements DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
func DeleteTag(req *http.Request, userId string, roomId string, tag string) {
r0mux.Handle("/user/{userId}/rooms/{roomId}/tags/{tag}",
common.MakeAuthAPI("account_3pid", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
return DeleteTag()
}),
).Methods(http.MethodDelete, http.MethodOptions)
}
}

View file

@ -406,4 +406,29 @@ func Setup(
}}
}),
).Methods(http.MethodGet, http.MethodOptions)
r0mux.Handle("/user/{userId}/rooms/{roomId}/tags",
common.MakeAuthAPI("account_3pid", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
// When a GET tag request is done, obtain all data of user from here and provide a JSON response.
// MakeAuthAPI will convert it to a HTTP response and reflect it on the browser.
vars := mux.Vars(req)
return GetTag(req, vars["userId"], vars["roomId"])
}),
).Methods(http.MethodGet, http.MethodOptions)
r0mux.Handle("/user/{userId}/rooms/{roomId}/tags/{tag}",
common.MakeAuthAPI("account_3pid", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
// When a PUT tag request is done, obtain all data of user from here and provide a JSON response.
// MakeAuthAPI will convert it to a HTTP response and reflect it on the browser.
return PutTag(req, vars["userId"], vars["roomId"], vars["tag"])
}),
).Methods(http.MethodPut, http.MethodOptions)
r0mux.Handle("/user/{userId}/rooms/{roomId}/tags/{tag}",
common.MakeAuthAPI("account_3pid", authData, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
// When a DELETE tag request is done, obtain all data of user from here and provide a JSON response.
// MakeAuthAPI will convert it to a HTTP response and reflect it on the browser.
return DeleteTagreq, (vars["userId"], vars["roomId"], vars["tag"])
}),
).Methods(http.MethodDelete, http.MethodOptions)
}