element-hq / element-hq/synapse

Creating and deleting aliases could be more consistent

Open
#7,320 0 comments 0 reactions 0 assignees View on GitHub
T-Task z-p3
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#7320](https://github.com/matrix-org/synapse/issues/7320).

---

This is the promised follow-up to #7052 about how to creating and deleting aliases could be more consistent. In general these are implemented via the `create_association` and `delete_association` methods of `DirectoryHandler`.

The checks done for each of these (copied from #7052 and clarified a bit) below. They're a bit confusing (and maybe make more sense as the flow-charts I wrote out), but the overall checks aren't too complicated.

### Creation

1. Check if the length is valid.
1. If `require_membership_for_aliases` is true in the config, the creator must be in the room or be a server admin.
2. The spam checker's `user_may_create_room_alias` method is queried.
3. The `alias_creation_rules` are checked from the config.
4. Services are checked to see whether they have an "exclusive lock" on an alias.

### Deletion

1. Ensure that the user is the room creator, if one exists.
2. Ensure that the alias points to a room ID.
3. The user must be one of the following:
1. A server admin.
2. In the room and have sufficient power level to delete an alias (>= moderator).
5. Services are checked to see whether the have an "exclusive lock" on an alias.

## Potential improvements

There aren't too many changes I came up with, but see ideas below:

1. Check `require_room_membership_for_aliases` during alias deletion.
2. Ensure that a user has the proper power level during creation (but that probably only makes sense for the canonical alias, which already happens).

There's a chance that some of the code could be re-used by combining some of the checks, but probably not. Frankly this might just be good enough the way it is.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.