Work out what synapse is doing

This commit is contained in:
Kegan Dougal 2017-03-07 16:07:09 +00:00
parent 20dde888d1
commit c28f9a7458

View file

@ -2,6 +2,7 @@ package writers
import ( import (
"encoding/json" "encoding/json"
"fmt"
"net/http" "net/http"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
@ -22,6 +23,12 @@ type createRoomRequest struct {
RoomAliasName string `json:"room_alias_name"` 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 // CreateRoom implements /createRoom
func CreateRoom(req *http.Request) util.JSONResponse { func CreateRoom(req *http.Request) util.JSONResponse {
logger := util.GetLogger(req.Context()) logger := util.GetLogger(req.Context())
@ -35,8 +42,44 @@ func CreateRoom(req *http.Request) util.JSONResponse {
return *resErr 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{ logger.WithFields(log.Fields{
"userID": userID, "userID": userID,
"roomID": roomID,
}).Info("Creating room") }).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") return util.MessageResponse(404, "Not implemented yet")
} }