Fix invites maybe

This commit is contained in:
Neil Alexander 2020-12-17 17:40:06 +00:00
parent cf8f637ae0
commit 4222175cb9
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 12 additions and 14 deletions

View file

@ -275,14 +275,14 @@ func (s *OutputRoomEventConsumer) onNewInviteEvent(
}).Panicf("roomserver output log: write invite failure")
return nil
}
s.notifier.OnNewInvite(types.StreamingToken{PDUPosition: pduPos}, *msg.Event.StateKey())
s.notifier.OnNewInvite(types.StreamingToken{InvitePosition: pduPos}, *msg.Event.StateKey())
return nil
}
func (s *OutputRoomEventConsumer) onRetireInviteEvent(
ctx context.Context, msg api.OutputRetireInviteEvent,
) error {
sp, err := s.db.RetireInviteEvent(ctx, msg.EventID)
pduPos, err := s.db.RetireInviteEvent(ctx, msg.EventID)
if err != nil {
// panic rather than continue with an inconsistent database
log.WithFields(log.Fields{
@ -293,7 +293,7 @@ func (s *OutputRoomEventConsumer) onRetireInviteEvent(
}
// Notify any active sync requests that the invite has been retired.
// Invites share the same stream counter as PDUs
s.notifier.OnNewEvent(nil, "", []string{msg.TargetUserID}, types.StreamingToken{PDUPosition: sp})
s.notifier.OnNewInvite(types.StreamingToken{InvitePosition: pduPos}, msg.TargetUserID)
return nil
}

View file

@ -503,7 +503,6 @@ func (d *Database) addPDUDeltaToResponse(
ctx context.Context,
device userapi.Device,
r types.Range,
ir types.Range,
numRecentEventsPerRoom int,
wantFullState bool,
res *types.Response,
@ -545,11 +544,6 @@ func (d *Database) addPDUDeltaToResponse(
}
}
// TODO: This should be done in getStateDeltas
if err = d.addInvitesToResponse(ctx, txn, device.UserID, ir, res); err != nil {
return nil, fmt.Errorf("d.addInvitesToResponse: %w", err)
}
succeeded = true
return joinedRoomIDs, nil
}
@ -704,12 +698,8 @@ func (d *Database) IncrementalSync(
From: fromPos.PDUPosition,
To: toPos.PDUPosition,
}
ir := types.Range{
From: fromPos.InvitePosition,
To: toPos.InvitePosition,
}
joinedRoomIDs, err = d.addPDUDeltaToResponse(
ctx, device, r, ir, numRecentEventsPerRoom, wantFullState, res,
ctx, device, r, numRecentEventsPerRoom, wantFullState, res,
)
if err != nil {
return nil, fmt.Errorf("d.addPDUDeltaToResponse: %w", err)
@ -732,6 +722,14 @@ func (d *Database) IncrementalSync(
return nil, fmt.Errorf("d.addEDUDeltaToResponse: %w", err)
}
ir := types.Range{
From: fromPos.InvitePosition,
To: toPos.InvitePosition,
}
if err = d.addInvitesToResponse(ctx, nil, device.UserID, ir, res); err != nil {
return nil, fmt.Errorf("d.addInvitesToResponse: %w", err)
}
return res, nil
}