mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
bugfix: retire invites even when we cannot talk to the remote server to make/send_leave (#1918)
* bugfix: retire invites even when we cannot talk to the remote server to make/send_leave Also modify the leave response in /sync to include a fake event as this is ultimately what clients (and sytest) will use to determine leave-ness. * hash the event ID * Base64 not hex
This commit is contained in:
parent
7df3e691f2
commit
e80098e186
3 changed files with 23 additions and 1 deletions
|
@ -2,8 +2,13 @@ package streams
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/syncapi/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
type InviteStreamProvider struct {
|
||||
|
@ -56,6 +61,17 @@ func (p *InviteStreamProvider) IncrementalSync(
|
|||
for roomID := range retiredInvites {
|
||||
if _, ok := req.Response.Rooms.Join[roomID]; !ok {
|
||||
lr := types.NewLeaveResponse()
|
||||
h := sha256.Sum256(append([]byte(roomID), []byte(strconv.FormatInt(int64(to), 10))...))
|
||||
lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{
|
||||
// fake event ID which muxes in the to position
|
||||
EventID: "$" + base64.RawURLEncoding.EncodeToString(h[:]),
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue