Create placeholder handler for room directory updates

This commit is contained in:
Brendan Abolivier 2017-08-07 15:10:03 +01:00
parent c35803c9d8
commit 29e5e7942b
No known key found for this signature in database
GPG key ID: 8EF1500759F70623
2 changed files with 62 additions and 0 deletions

View file

@ -133,6 +133,20 @@ func Setup(
}),
).Methods("DELETE")
r0mux.Handle("/directory/list/room/{roomID}",
common.MakeAPI("directory_list", func(req *http.Request) util.JSONResponse {
vars := mux.Vars(req)
return writers.GetVisibility(req, vars["roomID"])
}),
).Methods("GET")
r0mux.Handle("/directory/list/room/{roomID}",
common.MakeAuthAPI("directory_list", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
vars := mux.Vars(req)
return writers.SetVisibility(req, *device, vars["roomID"], cfg)
}),
).Methods("PUT", "OPTIONS")
r0mux.Handle("/logout",
common.MakeAuthAPI("logout", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
return readers.Logout(req, deviceDB, device)

View file

@ -0,0 +1,48 @@
// Copyright 2017 Vector Creations Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package writers
import (
"net/http"
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/common/config"
"github.com/matrix-org/util"
)
type roomDirectoryVisibility struct {
Visibility string `json:"visibility"`
}
// GetVisibility implements GET /directory/list/room/{roomID}
func GetVisibility(
req *http.Request, roomID string,
) util.JSONResponse {
return util.JSONResponse{
Code: 200,
JSON: roomDirectoryVisibility{"public"},
}
}
// SetVisibility implements PUT /directory/list/room/{roomID}
func SetVisibility(
req *http.Request, device authtypes.Device, roomID string,
cfg config.Dendrite,
) util.JSONResponse {
return util.JSONResponse{
Code: 200,
JSON: struct{}{},
}
}