Merge branch 'main' of github.com:matrix-org/dendrite into s7evink/v0133

This commit is contained in:
Till Faelligen 2023-09-28 07:41:18 +02:00
commit c81465c444
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E
4 changed files with 25 additions and 17 deletions

View file

@ -36,7 +36,7 @@ If you have further questions, please take a look at [our FAQ](docs/FAQ.md) or j
See the [Planning your Installation](https://matrix-org.github.io/dendrite/installation/planning) page for See the [Planning your Installation](https://matrix-org.github.io/dendrite/installation/planning) page for
more information on requirements. more information on requirements.
To build Dendrite, you will need Go 1.18 or later. To build Dendrite, you will need Go 1.20 or later.
For a usable federating Dendrite deployment, you will also need: For a usable federating Dendrite deployment, you will also need:

View file

@ -95,7 +95,7 @@ Consider enabling the DNS cache by modifying the `global` section of your config
## Time synchronisation ## Time synchronisation
Matrix relies heavily on TLS which requires the system time to be correct. If the clock Matrix relies heavily on TLS which requires the system time to be correct. If the clock
drifts then you may find that federation no works reliably (or at all) and clients may drifts then you may find that federation will not work reliably (or at all) and clients may
struggle to connect to your Dendrite server. struggle to connect to your Dendrite server.
Ensure that the time is synchronised on your system by enabling NTP sync. Ensure that the time is synchronised on your system by enabling NTP sync.

View file

@ -368,7 +368,16 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
// in the create event (such as for the room types MSC). // in the create event (such as for the room types MSC).
newCreateContent := map[string]interface{}{} newCreateContent := map[string]interface{}{}
_ = json.Unmarshal(oldCreateEvent.Content(), &newCreateContent) _ = json.Unmarshal(oldCreateEvent.Content(), &newCreateContent)
newCreateContent["creator"] = string(senderID)
switch newVersion {
case gomatrixserverlib.RoomVersionV11:
// RoomVersionV11 removed the creator field from the create content: https://github.com/matrix-org/matrix-spec-proposals/pull/2175
// So if we are upgrading from pre v11, we need to remove the field.
delete(newCreateContent, "creator")
default:
newCreateContent["creator"] = senderID
}
newCreateContent["room_version"] = newVersion newCreateContent["room_version"] = newVersion
newCreateContent["predecessor"] = gomatrixserverlib.PreviousRoom{ newCreateContent["predecessor"] = gomatrixserverlib.PreviousRoom{
EventID: tombstoneEvent.EventID(), EventID: tombstoneEvent.EventID(),

View file

@ -266,8 +266,8 @@ func (s *OutputRoomEventConsumer) updateMDirect(ctx context.Context, oldRoomID,
directChats := gjson.ParseBytes(directChatsRaw) directChats := gjson.ParseBytes(directChatsRaw)
newDirectChats := make(map[string][]string) newDirectChats := make(map[string][]string)
// iterate over all userID -> roomIDs // iterate over all userID -> roomIDs
directChats.ForEach(func(userID, roomIDs gjson.Result) bool {
var found bool var found bool
directChats.ForEach(func(userID, roomIDs gjson.Result) bool {
for _, roomID := range roomIDs.Array() { for _, roomID := range roomIDs.Array() {
newDirectChats[userID.Str] = append(newDirectChats[userID.Str], roomID.Str) newDirectChats[userID.Str] = append(newDirectChats[userID.Str], roomID.Str)
// add the new roomID to m.direct // add the new roomID to m.direct
@ -276,22 +276,21 @@ func (s *OutputRoomEventConsumer) updateMDirect(ctx context.Context, oldRoomID,
newDirectChats[userID.Str] = append(newDirectChats[userID.Str], newRoomID) newDirectChats[userID.Str] = append(newDirectChats[userID.Str], newRoomID)
} }
} }
return true
})
// Only hit the database if we found the old room as a DM for this user // Only hit the database if we found the old room as a DM for this user
if found { if found {
var data []byte var data []byte
data, err = json.Marshal(newDirectChats) data, err = json.Marshal(newDirectChats)
if err != nil { if err != nil {
return true return err
} }
if err = s.db.SaveAccountData(ctx, localpart, serverName, "", "m.direct", data); err != nil { if err = s.db.SaveAccountData(ctx, localpart, serverName, "", "m.direct", data); err != nil {
return true return fmt.Errorf("failed to update m.direct state: %w", err)
} }
} }
return true
})
if err != nil {
return fmt.Errorf("failed to update m.direct state")
}
return nil return nil
} }