aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing/membership.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-08-17 11:40:49 +0100
committerGitHub <noreply@github.com>2020-08-17 11:40:49 +0100
commit6cb1a65809ccfbeaede6ff164c281ba0ddf90ab7 (patch)
tree56406ef5a5d4335d03e7805c19fa35aad805871e /clientapi/routing/membership.go
parent6820b3e024474e2c44f7a0632261d2dc86257d77 (diff)
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
Diffstat (limited to 'clientapi/routing/membership.go')
-rw-r--r--clientapi/routing/membership.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go
index 8303a68e..37fafa5a 100644
--- a/clientapi/routing/membership.go
+++ b/clientapi/routing/membership.go
@@ -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(),
+ }
}
}