Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated m.room.aliases references #2759

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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