mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 05:12:26 +03:00
Add PerformInvite and refactor how errors get handled (#1158)
* Add PerformInvite and refactor how errors get handled - Rename `JoinError` to `PerformError` - Remove `error` from the API function signature entirely. This forces errors to be bundled into `PerformError` which makes it easier for callers to detect and handle errors. On network errors, HTTP clients will make a `PerformError`. * Unbreak everything; thanks Go! * Send back JSONResponse according to the PerformError * Update federation invite code too
This commit is contained in:
parent
ebaaf65c54
commit
002fe05a20
16 changed files with 469 additions and 332 deletions
|
@ -111,16 +111,16 @@ func SendMembership(
|
|||
switch membership {
|
||||
case gomatrixserverlib.Invite:
|
||||
// Invites need to be handled specially
|
||||
err = roomserverAPI.SendInvite(
|
||||
perr := roomserverAPI.SendInvite(
|
||||
req.Context(), rsAPI,
|
||||
event.Headered(verRes.RoomVersion),
|
||||
nil, // ask the roomserver to draw up invite room state for us
|
||||
cfg.Matrix.ServerName,
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("producer.SendInvite failed")
|
||||
return jsonerror.InternalServerError()
|
||||
if perr != nil {
|
||||
util.GetLogger(req.Context()).WithError(perr).Error("producer.SendInvite failed")
|
||||
return perr.JSONResponse()
|
||||
}
|
||||
case gomatrixserverlib.Join:
|
||||
// The join membership requires the room id to be sent in the response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue