mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 09:23:09 -06:00
Document
This commit is contained in:
parent
16dae95478
commit
5057d62787
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MakeJoin implements the /make_join API
|
||||||
func MakeJoin(
|
func MakeJoin(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
httpReq *http.Request,
|
httpReq *http.Request,
|
||||||
|
|
@ -54,6 +55,7 @@ func MakeJoin(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try building an event for the server
|
||||||
builder := gomatrixserverlib.EventBuilder{
|
builder := gomatrixserverlib.EventBuilder{
|
||||||
Sender: userID,
|
Sender: userID,
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
|
|
@ -76,7 +78,7 @@ func MakeJoin(
|
||||||
return httputil.LogThenError(httpReq, err)
|
return httputil.LogThenError(httpReq, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check to see if this user can perform this operation
|
// Check that the join is allowed or not
|
||||||
stateEvents := make([]*gomatrixserverlib.Event, len(queryRes.StateEvents))
|
stateEvents := make([]*gomatrixserverlib.Event, len(queryRes.StateEvents))
|
||||||
for i := range queryRes.StateEvents {
|
for i := range queryRes.StateEvents {
|
||||||
stateEvents[i] = &queryRes.StateEvents[i]
|
stateEvents[i] = &queryRes.StateEvents[i]
|
||||||
|
|
@ -85,7 +87,7 @@ func MakeJoin(
|
||||||
if err = gomatrixserverlib.Allowed(*event, &provider); err != nil {
|
if err = gomatrixserverlib.Allowed(*event, &provider); err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: 403,
|
Code: 403,
|
||||||
JSON: jsonerror.Forbidden(err.Error()), // TODO: Is this error string comprehensible to the client?
|
JSON: jsonerror.Forbidden(err.Error()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,6 +97,7 @@ func MakeJoin(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendJoin implements the /send_join API
|
||||||
func SendJoin(
|
func SendJoin(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
httpReq *http.Request,
|
httpReq *http.Request,
|
||||||
|
|
@ -155,6 +158,8 @@ 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 stateAndAuthChainRepsonse api.QueryStateAndAuthChainResponse
|
||||||
err = query.QueryStateAndAuthChain(ctx, &api.QueryStateAndAuthChainRequest{
|
err = query.QueryStateAndAuthChain(ctx, &api.QueryStateAndAuthChainRequest{
|
||||||
PrevEventIDs: event.PrevEventIDs(),
|
PrevEventIDs: event.PrevEventIDs(),
|
||||||
|
|
@ -164,8 +169,9 @@ func SendJoin(
|
||||||
return httputil.LogThenError(httpReq, err)
|
return httputil.LogThenError(httpReq, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the events to the room server.
|
||||||
// We are responsible for notifying other servers that the user has joined
|
// We are responsible for notifying other servers that the user has joined
|
||||||
// the room
|
// the room, so set SendAsServer to cfg.Matrix.ServerName
|
||||||
err = producer.SendEvents(ctx, []gomatrixserverlib.Event{event}, cfg.Matrix.ServerName)
|
err = producer.SendEvents(ctx, []gomatrixserverlib.Event{event}, cfg.Matrix.ServerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(httpReq, err)
|
return httputil.LogThenError(httpReq, err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue