mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 14:12:47 +00:00
Add canonical alias support (#2236)
* Add canonical support * Add test * Check that the send event is actually an m.room.canonical_alias Check that we got an event from the database * Update to get correct required events * Add flakey test to blacklist
This commit is contained in:
parent
86d4eef9f1
commit
9fbaa1194b
7 changed files with 190 additions and 6 deletions
|
@ -14,6 +14,8 @@
|
|||
|
||||
package api
|
||||
|
||||
import "regexp"
|
||||
|
||||
// SetRoomAliasRequest is a request to SetRoomAlias
|
||||
type SetRoomAliasRequest struct {
|
||||
// ID of the user setting the alias
|
||||
|
@ -84,3 +86,20 @@ type RemoveRoomAliasResponse struct {
|
|||
// Did we remove it?
|
||||
Removed bool `json:"removed"`
|
||||
}
|
||||
|
||||
type AliasEvent struct {
|
||||
Alias string `json:"alias"`
|
||||
AltAliases []string `json:"alt_aliases"`
|
||||
}
|
||||
|
||||
var validateAliasRegex = regexp.MustCompile("^#.*:.+$")
|
||||
|
||||
func (a AliasEvent) Valid() bool {
|
||||
for _, alias := range a.AltAliases {
|
||||
if !validateAliasRegex.MatchString(alias) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return a.Alias == "" || validateAliasRegex.MatchString(a.Alias)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue