Tweaks to alias

This commit is contained in:
Neil Alexander 2021-07-21 10:45:14 +01:00
parent 23e392adc5
commit e0e3628717
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -270,6 +270,7 @@ func createRoom(
var nameEvent *fledglingEvent
var topicEvent *fledglingEvent
var guestAccessEvent *fledglingEvent
var aliasEvent *fledglingEvent
if r.Name != "" {
nameEvent = &fledglingEvent{
@ -316,6 +317,13 @@ func createRoom(
if aliasResp.RoomID != "" {
return util.MessageResponse(400, "Alias already exists")
}
aliasEvent = &fledglingEvent{
Type: gomatrixserverlib.MRoomCanonicalAlias,
Content: eventutil.CanonicalAlias{
Alias: roomAlias,
},
}
}
var initialStateEvents []fledglingEvent
@ -377,11 +385,11 @@ func createRoom(
if topicEvent != nil {
eventsToMake = append(eventsToMake, *topicEvent)
}
if roomAlias != "" {
if aliasEvent != nil {
// TODO: bit of a chicken and egg problem here as the alias doesn't exist and cannot until we have made the room.
// This means we might fail creating the alias but say the canonical alias is something that doesn't exist.
// m.room.aliases is handled when we call roomserver.SetRoomAlias
eventsToMake = append(eventsToMake, fledglingEvent{gomatrixserverlib.MRoomCanonicalAlias, "", eventutil.CanonicalAlias{Alias: roomAlias}})
eventsToMake = append(eventsToMake, *aliasEvent)
}
eventsToMake = append(eventsToMake, initialStateEvents...)