aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Kumar <31231064+abhishekkumar2718@users.noreply.github.com>2019-12-20 20:12:57 +0530
committerNeil Alexander <neilalexander@users.noreply.github.com>2019-12-20 14:42:57 +0000
commite2d73855ebdb236aaa4388685872792ba3907925 (patch)
tree0a42278493cb142349433595c1f32a2690aecd0e
parentaf9568ba4468eb106ec305df496fbe1319fd74eb (diff)
Refuse /send_join without m.room.create (#824)
Signed-off-by: Abhishek Kumar <abhishekkumar2718@gmail.com>
-rw-r--r--federationapi/routing/join.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go
index 6f6574dd..e2885dd9 100644
--- a/federationapi/routing/join.go
+++ b/federationapi/routing/join.go
@@ -154,16 +154,23 @@ func SendJoin(
// Fetch the state and auth chain. We do this before we send the events
// on, in case this fails.
- var stateAndAuthChainRepsonse api.QueryStateAndAuthChainResponse
+ var stateAndAuthChainResponse api.QueryStateAndAuthChainResponse
err = query.QueryStateAndAuthChain(httpReq.Context(), &api.QueryStateAndAuthChainRequest{
PrevEventIDs: event.PrevEventIDs(),
AuthEventIDs: event.AuthEventIDs(),
RoomID: roomID,
- }, &stateAndAuthChainRepsonse)
+ }, &stateAndAuthChainResponse)
if err != nil {
return httputil.LogThenError(httpReq, err)
}
+ if !stateAndAuthChainResponse.RoomExists {
+ return util.JSONResponse{
+ Code: http.StatusNotFound,
+ JSON: jsonerror.NotFound("Room does not exist"),
+ }
+ }
+
// Send the events to the room server.
// We are responsible for notifying other servers that the user has joined
// the room, so set SendAsServer to cfg.Matrix.ServerName
@@ -177,8 +184,8 @@ func SendJoin(
return util.JSONResponse{
Code: http.StatusOK,
JSON: map[string]interface{}{
- "state": stateAndAuthChainRepsonse.StateEvents,
- "auth_chain": stateAndAuthChainRepsonse.AuthChainEvents,
+ "state": stateAndAuthChainResponse.StateEvents,
+ "auth_chain": stateAndAuthChainResponse.AuthChainEvents,
},
}
}