diff --git a/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go b/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go index 58b07be26..b68e53bc0 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go +++ b/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go @@ -2,6 +2,7 @@ package writers import ( "encoding/json" + "fmt" "net/http" log "github.com/Sirupsen/logrus" @@ -22,6 +23,12 @@ type createRoomRequest struct { RoomAliasName string `json:"room_alias_name"` } +// http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom +type createRoomResponse struct { + RoomID string `json:"room_id"` + RoomAlias string `json:"room_alias,omitempty"` // in synapse not spec +} + // CreateRoom implements /createRoom func CreateRoom(req *http.Request) util.JSONResponse { logger := util.GetLogger(req.Context()) @@ -35,8 +42,44 @@ func CreateRoom(req *http.Request) util.JSONResponse { return *resErr } + // TODO: apply rate-limit + // TODO: parse room_alias_name + // TODO: parse invite list (all valid user ids) + // TODO: invite 3pid list (all valid 3pids) + // TODO: visibility + + hostname := "localhost" + roomID := fmt.Sprintf("!%s:%s", util.RandomString(16), hostname) + logger.WithFields(log.Fields{ "userID": userID, + "roomID": roomID, }).Info("Creating room") + + // TODO: Check room ID doesn't clash with an existing one + // TODO: Create room alias association + + // TODO: handle preset + // TODO: handle raw initial state + // TODO: handle creation content + + // send events into the room in order of: + // 1- m.room.create + // 2- room creator join member + // 3- m.room.power_levels + // 4- m.room.canonical_alias (opt) TODO + // 5- m.room.join_rules + // 6- m.room.history_visibility + // 7- m.room.guest_access (opt) TODO + // 8- other initial state items TODO + // 9- m.room.name (opt) + // 10- m.room.topic (opt) + // 11- invite events (opt) - with is_direct flag if applicable TODO + // 12- 3pid invite events (opt) TODO + // 13- m.room.aliases event for HS (if alias specified) TODO + // This differs from Synapse slightly. Synapse would vary the ordering of 3-7 + // depending on if those events were in "initial_state" or not. This made it + // harder to reason about, hence sticking to a strict static ordering. + return util.MessageResponse(404, "Not implemented yet") }