Fix bug when rejecting invites (#1907)
* Fix rejecting invites maybe * Remove comment that is no longer correct * Review comment on performFederatedRejectInvite
This commit is contained in:
parent
70e4bbda3b
commit
816e1a402b
@ -64,7 +64,14 @@ func (r *Leaver) performLeaveRoomByID(
|
|||||||
// that.
|
// that.
|
||||||
isInvitePending, senderUser, eventID, err := helpers.IsInvitePending(ctx, r.DB, req.RoomID, req.UserID)
|
isInvitePending, senderUser, eventID, err := helpers.IsInvitePending(ctx, r.DB, req.RoomID, req.UserID)
|
||||||
if err == nil && isInvitePending {
|
if err == nil && isInvitePending {
|
||||||
return r.performRejectInvite(ctx, req, res, senderUser, eventID)
|
var host gomatrixserverlib.ServerName
|
||||||
|
_, host, err = gomatrixserverlib.SplitID('@', senderUser)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Sender %q is invalid", senderUser)
|
||||||
|
}
|
||||||
|
if host != r.Cfg.Matrix.ServerName {
|
||||||
|
return r.performFederatedRejectInvite(ctx, req, res, senderUser, eventID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's no invite pending, so first of all we want to find out
|
// There's no invite pending, so first of all we want to find out
|
||||||
@ -94,9 +101,7 @@ func (r *Leaver) performLeaveRoomByID(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error getting membership: %w", err)
|
return nil, fmt.Errorf("Error getting membership: %w", err)
|
||||||
}
|
}
|
||||||
if membership != gomatrixserverlib.Join {
|
if membership != gomatrixserverlib.Join && membership != gomatrixserverlib.Invite {
|
||||||
// TODO: should be able to handle "invite" in this case too, if
|
|
||||||
// it's a case of kicking or banning or such
|
|
||||||
return nil, fmt.Errorf("User %q is not joined to the room (membership is %q)", req.UserID, membership)
|
return nil, fmt.Errorf("User %q is not joined to the room (membership is %q)", req.UserID, membership)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +152,7 @@ func (r *Leaver) performLeaveRoomByID(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Leaver) performRejectInvite(
|
func (r *Leaver) performFederatedRejectInvite(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *api.PerformLeaveRequest,
|
req *api.PerformLeaveRequest,
|
||||||
res *api.PerformLeaveResponse, // nolint:unparam
|
res *api.PerformLeaveResponse, // nolint:unparam
|
||||||
|
Loading…
Reference in New Issue
Block a user