mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 04:52:46 +00: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
|
@ -98,15 +98,15 @@ func Invite(
|
|||
)
|
||||
|
||||
// Add the invite event to the roomserver.
|
||||
if err = api.SendInvite(
|
||||
if perr := api.SendInvite(
|
||||
httpReq.Context(), rsAPI,
|
||||
signedEvent.Headered(inviteReq.RoomVersion()),
|
||||
inviteReq.InviteRoomState(),
|
||||
event.Origin(),
|
||||
nil,
|
||||
); err != nil {
|
||||
); perr != nil {
|
||||
util.GetLogger(httpReq.Context()).WithError(err).Error("producer.SendInvite failed")
|
||||
return jsonerror.InternalServerError()
|
||||
return perr.JSONResponse()
|
||||
}
|
||||
|
||||
// Return the signed event to the originating server, it should then tell
|
||||
|
|
|
@ -97,12 +97,18 @@ func (t *testRoomserverAPI) InputRoomEvents(
|
|||
return nil
|
||||
}
|
||||
|
||||
func (t *testRoomserverAPI) PerformInvite(
|
||||
ctx context.Context,
|
||||
req *api.PerformInviteRequest,
|
||||
res *api.PerformInviteResponse,
|
||||
) {
|
||||
}
|
||||
|
||||
func (t *testRoomserverAPI) PerformJoin(
|
||||
ctx context.Context,
|
||||
req *api.PerformJoinRequest,
|
||||
res *api.PerformJoinResponse,
|
||||
) error {
|
||||
return nil
|
||||
) {
|
||||
}
|
||||
|
||||
func (t *testRoomserverAPI) PerformLeave(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue