hash the event ID

This commit is contained in:
Kegan Dougal 2021-07-13 16:59:08 +01:00
parent aa06e37cad
commit 5fa9a4f270

View file

@ -2,6 +2,8 @@ package streams
import ( import (
"context" "context"
"crypto/sha256"
"encoding/hex"
"strconv" "strconv"
"time" "time"
@ -59,9 +61,10 @@ func (p *InviteStreamProvider) IncrementalSync(
for roomID := range retiredInvites { for roomID := range retiredInvites {
if _, ok := req.Response.Rooms.Join[roomID]; !ok { if _, ok := req.Response.Rooms.Join[roomID]; !ok {
lr := types.NewLeaveResponse() lr := types.NewLeaveResponse()
h := sha256.Sum256(append([]byte(roomID), []byte(strconv.FormatInt(int64(to), 10))...))
lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{ lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{
// fake event ID which muxes in the to position // fake event ID which muxes in the to position
EventID: "$stub-retired-invite-" + roomID + "-" + strconv.FormatInt(int64(to), 10), EventID: "$" + hex.EncodeToString(h[:]),
OriginServerTS: gomatrixserverlib.AsTimestamp(time.Now()), OriginServerTS: gomatrixserverlib.AsTimestamp(time.Now()),
RoomID: roomID, RoomID: roomID,
Sender: req.Device.UserID, Sender: req.Device.UserID,