Remove deprecated m.room.aliases references (#2759)
This commit is contained in:
committed by
GitHub
parent
be11fa6b5a
commit
041f9951c5
@@ -33,10 +33,6 @@ export enum EventType {
|
||||
RoomGuestAccess = "m.room.guest_access",
|
||||
RoomServerAcl = "m.room.server_acl",
|
||||
RoomTombstone = "m.room.tombstone",
|
||||
/**
|
||||
* @deprecated Should not be used.
|
||||
*/
|
||||
RoomAliases = "m.room.aliases", // deprecated https://matrix.org/docs/spec/client_server/r0.6.1#historical-events
|
||||
|
||||
SpaceChild = "m.space.child",
|
||||
SpaceParent = "m.space.parent",
|
||||
|
||||
@@ -1585,7 +1585,6 @@ const REDACT_KEEP_CONTENT_MAP = {
|
||||
'kick': 1, 'redact': 1, 'state_default': 1,
|
||||
'users': 1, 'users_default': 1,
|
||||
},
|
||||
[EventType.RoomAliases]: { 'aliases': 1 },
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1369,35 +1369,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
||||
return this.currentState.getStateEvents(EventType.RoomAvatar, "")?.getContent()?.url || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aliases this room has according to the room's state
|
||||
* The aliases returned by this function may not necessarily
|
||||
* still point to this room.
|
||||
* @return {array} The room's alias as an array of strings
|
||||
* @deprecated this uses m.room.aliases events, replaced by Room::getAltAliases()
|
||||
*/
|
||||
public getAliases(): string[] {
|
||||
const aliasStrings: string[] = [];
|
||||
|
||||
const aliasEvents = this.currentState.getStateEvents(EventType.RoomAliases);
|
||||
if (aliasEvents) {
|
||||
for (const aliasEvent of aliasEvents) {
|
||||
if (Array.isArray(aliasEvent.getContent().aliases)) {
|
||||
const filteredAliases = aliasEvent.getContent<{ aliases: string[] }>().aliases.filter(a => {
|
||||
if (typeof(a) !== "string") return false;
|
||||
if (a[0] !== '#') return false;
|
||||
if (!a.endsWith(`:${aliasEvent.getStateKey()}`)) return false;
|
||||
|
||||
// It's probably valid by here.
|
||||
return true;
|
||||
});
|
||||
aliasStrings.push(...filteredAliases);
|
||||
}
|
||||
}
|
||||
}
|
||||
return aliasStrings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this room's canonical alias
|
||||
* The alias returned by this function may not necessarily
|
||||
|
||||
Reference in New Issue
Block a user