Skip to content

Commit

Permalink
Remove deprecated m.room.aliases references (#2759)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Oct 17, 2022
1 parent be11fa6 commit 041f995
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
4 changes: 0 additions & 4 deletions src/@types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/models/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
};

/**
Expand Down
29 changes: 0 additions & 29 deletions src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 041f995

Please sign in to comment.