mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 04:52:46 +00:00
Synchronous invites (#1273)
* Refactor invites to be synchronous * Fix synchronous invites * Fix client API return type for send invite error * Linter * Restore PerformError on rsAPI.PerformInvite * Update sytest-whitelist * Don't override PerformError with normal errors * Fix error passing * Un-whitelist a couple of tests * Update sytest-whitelist * Try to handle multiple invite rejections better * nolint * Update gomatrixserverlib * Fix /v1/invite test * Remove replace from go.mod
This commit is contained in:
parent
6820b3e024
commit
6cb1a65809
23 changed files with 334 additions and 443 deletions
|
@ -386,8 +386,12 @@ func createRoom(
|
|||
var strippedState []gomatrixserverlib.InviteV2StrippedState
|
||||
for _, event := range candidates {
|
||||
switch event.Type() {
|
||||
// TODO: case gomatrixserverlib.MRoomEncryption:
|
||||
// fallthrough
|
||||
case gomatrixserverlib.MRoomName:
|
||||
fallthrough
|
||||
case gomatrixserverlib.MRoomCanonicalAlias:
|
||||
fallthrough
|
||||
case "m.room.encryption": // TODO: move this to gmsl
|
||||
fallthrough
|
||||
case gomatrixserverlib.MRoomMember:
|
||||
fallthrough
|
||||
case gomatrixserverlib.MRoomJoinRules:
|
||||
|
@ -398,15 +402,23 @@ func createRoom(
|
|||
}
|
||||
}
|
||||
// Send the invite event to the roomserver.
|
||||
if perr := roomserverAPI.SendInvite(
|
||||
err = roomserverAPI.SendInvite(
|
||||
req.Context(), rsAPI,
|
||||
inviteEvent.Headered(roomVersion),
|
||||
strippedState, // invite room state
|
||||
cfg.Matrix.ServerName, // send as server
|
||||
nil, // transaction ID
|
||||
); perr != nil {
|
||||
util.GetLogger(req.Context()).WithError(perr).Error("SendInvite failed")
|
||||
return perr.JSONResponse()
|
||||
)
|
||||
switch e := err.(type) {
|
||||
case *roomserverAPI.PerformError:
|
||||
return e.JSONResponse()
|
||||
case nil:
|
||||
default:
|
||||
util.GetLogger(req.Context()).WithError(err).Error("roomserverAPI.SendInvite failed")
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.InternalServerError(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ func SendInvite(
|
|||
roomID string, cfg *config.ClientAPI,
|
||||
rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI,
|
||||
) util.JSONResponse {
|
||||
body, evTime, roomVer, reqErr := extractRequestData(req, roomID, rsAPI)
|
||||
body, evTime, _, reqErr := extractRequestData(req, roomID, rsAPI)
|
||||
if reqErr != nil {
|
||||
return *reqErr
|
||||
}
|
||||
|
@ -214,20 +214,27 @@ func SendInvite(
|
|||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
||||
perr := roomserverAPI.SendInvite(
|
||||
err = roomserverAPI.SendInvite(
|
||||
req.Context(), rsAPI,
|
||||
event.Event.Headered(roomVer),
|
||||
*event,
|
||||
nil, // ask the roomserver to draw up invite room state for us
|
||||
cfg.Matrix.ServerName,
|
||||
nil,
|
||||
)
|
||||
if perr != nil {
|
||||
util.GetLogger(req.Context()).WithError(perr).Error("producer.SendInvite failed")
|
||||
return perr.JSONResponse()
|
||||
}
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct{}{},
|
||||
switch e := err.(type) {
|
||||
case *roomserverAPI.PerformError:
|
||||
return e.JSONResponse()
|
||||
case nil:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
default:
|
||||
util.GetLogger(req.Context()).WithError(err).Error("roomserverAPI.SendInvite failed")
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.InternalServerError(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue