Fix some bugs

This commit is contained in:
Neil Alexander 2021-07-21 15:56:39 +01:00
parent 9925285a87
commit 3de41c60a3
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
5 changed files with 6 additions and 9 deletions

View file

@ -383,7 +383,6 @@ func createRoom(
// 10- m.room.topic (opt) // 10- m.room.topic (opt)
// 11- invite events (opt) - with is_direct flag if applicable TODO // 11- invite events (opt) - with is_direct flag if applicable TODO
// 12- 3pid invite events (opt) TODO // 12- 3pid invite events (opt) TODO
// 13- m.room.aliases event for HS (if alias specified) TODO
// This differs from Synapse slightly. Synapse would vary the ordering of 3-7 // This differs from Synapse slightly. Synapse would vary the ordering of 3-7
// depending on if those events were in "initial_state" or not. This made it // depending on if those events were in "initial_state" or not. This made it
// harder to reason about, hence sticking to a strict static ordering. // harder to reason about, hence sticking to a strict static ordering.
@ -404,7 +403,6 @@ func createRoom(
if aliasEvent != nil { 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. // 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. // 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, *aliasEvent) eventsToMake = append(eventsToMake, *aliasEvent)
} }

View file

@ -293,9 +293,9 @@ func SetVisibility(
return jsonerror.InternalServerError() return jsonerror.InternalServerError()
} }
// NOTSPEC: Check if the user's power is greater than power required to change m.room.aliases event // NOTSPEC: Check if the user's power is greater than power required to change m.room.canonical_alias event
power, _ := gomatrixserverlib.NewPowerLevelContentFromEvent(queryEventsRes.StateEvents[0].Event) power, _ := gomatrixserverlib.NewPowerLevelContentFromEvent(queryEventsRes.StateEvents[0].Event)
if power.UserLevel(dev.UserID) < power.EventLevel(gomatrixserverlib.MRoomAliases, true) { if power.UserLevel(dev.UserID) < power.EventLevel(gomatrixserverlib.MRoomCanonicalAlias, true) {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusForbidden, Code: http.StatusForbidden,
JSON: jsonerror.Forbidden("userID doesn't have power level to change visibility"), JSON: jsonerror.Forbidden("userID doesn't have power level to change visibility"),

View file

@ -53,7 +53,6 @@ func InitialPowerLevelsContent(roomCreator string) (c gomatrixserverlib.PowerLev
"m.room.history_visibility": 100, "m.room.history_visibility": 100,
"m.room.canonical_alias": 50, "m.room.canonical_alias": 50,
"m.room.avatar": 50, "m.room.avatar": 50,
"m.room.aliases": 0, // anyone can publish aliases by default. Has to be 0 else state_default is used.
} }
c.Users = map[string]int64{roomCreator: 100} c.Users = map[string]int64{roomCreator: 100}
return c return c

View file

@ -150,7 +150,7 @@ func (r *RoomserverInternalAPI) RemoveRoomAlias(
request *api.RemoveRoomAliasRequest, request *api.RemoveRoomAliasRequest,
response *api.RemoveRoomAliasResponse, response *api.RemoveRoomAliasResponse,
) error { ) error {
creatorID, err := r.DB.GetCreatorIDForAlias(ctx, request.UserID) creatorID, err := r.DB.GetCreatorIDForAlias(ctx, request.Alias)
if err != nil { if err != nil {
return err return err
} }
@ -159,7 +159,7 @@ func (r *RoomserverInternalAPI) RemoveRoomAlias(
return fmt.Errorf("not allowed to delete this alias") return fmt.Errorf("not allowed to delete this alias")
} }
// Remove the dalias from the database // Remove the alias from the database
if err := r.DB.RemoveRoomAlias(ctx, request.Alias); err != nil { if err := r.DB.RemoveRoomAlias(ctx, request.Alias); err != nil {
return err return err
} }

View file

@ -223,8 +223,8 @@ func buildInviteStrippedState(
// https://matrix.org/docs/spec/client_server/r0.6.0#m-room-member // https://matrix.org/docs/spec/client_server/r0.6.0#m-room-member
for _, t := range []string{ for _, t := range []string{
gomatrixserverlib.MRoomName, gomatrixserverlib.MRoomCanonicalAlias, gomatrixserverlib.MRoomName, gomatrixserverlib.MRoomCanonicalAlias,
gomatrixserverlib.MRoomAliases, gomatrixserverlib.MRoomJoinRules, gomatrixserverlib.MRoomJoinRules, gomatrixserverlib.MRoomAvatar,
"m.room.avatar", "m.room.encryption", gomatrixserverlib.MRoomCreate, gomatrixserverlib.MRoomEncryption, gomatrixserverlib.MRoomCreate,
} { } {
stateWanted = append(stateWanted, gomatrixserverlib.StateKeyTuple{ stateWanted = append(stateWanted, gomatrixserverlib.StateKeyTuple{
EventType: t, EventType: t,