Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

bugfix: retire invites even when we cannot talk to the remote server to make/send_leave #1918

Merged
merged 3 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion roomserver/internal/perform/perform_leave.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/matrix-org/dendrite/roomserver/storage"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
)

type Leaver struct {
Expand Down Expand Up @@ -171,7 +172,9 @@ func (r *Leaver) performFederatedRejectInvite(
}
leaveRes := fsAPI.PerformLeaveResponse{}
if err := r.FSAPI.PerformLeave(ctx, &leaveReq, &leaveRes); err != nil {
return nil, err
// failures in PerformLeave should NEVER stop us from telling other components like the
// sync API that the invite was withdrawn. Otherwise we can end up with stuck invites.
util.GetLogger(ctx).WithError(err).Errorf("failed to PerformLeave, still retiring invite event")
}

// Withdraw the invite, so that the sync API etc are
Expand Down
13 changes: 13 additions & 0 deletions syncapi/streams/stream_invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package streams

import (
"context"
"strconv"
"time"

"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/gomatrixserverlib"
)

type InviteStreamProvider struct {
Expand Down Expand Up @@ -56,6 +59,16 @@ func (p *InviteStreamProvider) IncrementalSync(
for roomID := range retiredInvites {
if _, ok := req.Response.Rooms.Join[roomID]; !ok {
lr := types.NewLeaveResponse()
lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{
// fake event ID which muxes in the to position
EventID: "$stub-retired-invite-" + roomID + "-" + strconv.FormatInt(int64(to), 10),
kegsay marked this conversation as resolved.
Show resolved Hide resolved
OriginServerTS: gomatrixserverlib.AsTimestamp(time.Now()),
RoomID: roomID,
Sender: req.Device.UserID,
StateKey: &req.Device.UserID,
Type: "m.room.member",
Content: gomatrixserverlib.RawJSON(`{"membership":"leave"}`),
})
req.Response.Rooms.Leave[roomID] = *lr
}
}
Expand Down
3 changes: 3 additions & 0 deletions sytest-whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,6 @@ POST /_synapse/admin/v1/register with shared secret disallows symbols
Membership event with an invalid displayname in the send_join response should not cause room join to fail
Inbound federation rejects incorrectly-signed invite rejections
Inbound federation can receive invite rejections
Inbound federation can receive invite and reject when remote replies with a 403
Inbound federation can receive invite and reject when remote replies with a 500
Inbound federation can receive invite and reject when remote is unreachable