mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-22 13:33:09 -06:00
fix stream_invite regression (#50)
This commit is contained in:
parent
ed8b5d09eb
commit
bcf4ac9c9d
|
|
@ -7,10 +7,9 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
||||
"github.com/matrix-org/dendrite/syncapi/storage"
|
||||
"github.com/matrix-org/dendrite/syncapi/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
type InviteStreamProvider struct {
|
||||
|
|
@ -74,12 +73,19 @@ func (p *InviteStreamProvider) IncrementalSync(
|
|||
return to
|
||||
}
|
||||
for roomID := range retiredInvites {
|
||||
if _, ok := req.Response.Rooms.Invite[roomID]; ok {
|
||||
if req.Response.Rooms.Invite[roomID] != nil {
|
||||
continue
|
||||
}
|
||||
if _, ok := req.Response.Rooms.Join[roomID]; ok {
|
||||
if req.Response.Rooms.Join[roomID] != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
joinedUsers, err := snapshot.AllJoinedUsersInRoom(ctx, []string{roomID})
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if !contains(joinedUsers[roomID], req.Device.UserID) {
|
||||
lr := types.NewLeaveResponse()
|
||||
h := sha256.Sum256(append([]byte(roomID), []byte(strconv.FormatInt(int64(to), 10))...))
|
||||
lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{
|
||||
|
|
@ -93,8 +99,17 @@ func (p *InviteStreamProvider) IncrementalSync(
|
|||
Content: gomatrixserverlib.RawJSON(`{"membership":"leave"}`),
|
||||
})
|
||||
req.Response.Rooms.Leave[roomID] = lr
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return maxID
|
||||
}
|
||||
|
||||
func contains(values []string, findVal string) bool {
|
||||
for _, v := range values {
|
||||
if v == findVal {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue