From e32b8a75ee024fe33622c7010ca17a414abbe0ee Mon Sep 17 00:00:00 2001 From: Germain Date: Tue, 22 Mar 2022 21:34:20 +0000 Subject: [PATCH 1/3] Lazy load thread list timeline set (#2254) --- src/models/room.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/models/room.ts b/src/models/room.ts index 5d7cba5d68e..3da055e6ec6 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -346,15 +346,6 @@ export class Room extends TypedEventEmitter RoomEvent.TimelineReset, ]); - if (this.client?.supportsExperimentalThreads) { - Promise.all([ - this.createThreadTimelineSet(), - this.createThreadTimelineSet(ThreadFilterType.My), - ]).then((timelineSets) => { - this.threadsTimelineSets.push(...timelineSets); - }); - } - this.fixUpLegacyTimelineFields(); if (this.opts.pendingEventOrdering === PendingEventOrdering.Detached) { @@ -381,6 +372,26 @@ export class Room extends TypedEventEmitter } } + private threadTimelineSetsPromise: Promise<[EventTimelineSet, EventTimelineSet]> | null = null; + public async createThreadsTimelineSets(): Promise<[EventTimelineSet, EventTimelineSet]> { + if (this.threadTimelineSetsPromise) { + return this.threadTimelineSetsPromise; + } + + if (this.client?.supportsExperimentalThreads) { + try { + this.threadTimelineSetsPromise = Promise.all([ + this.createThreadTimelineSet(), + this.createThreadTimelineSet(ThreadFilterType.My), + ]); + const timelineSets = await this.threadTimelineSetsPromise; + this.threadsTimelineSets.push(...timelineSets); + } catch (e) { + this.threadTimelineSetsPromise = null; + } + } + } + /** * Bulk decrypt critical events in a room * From 65316ffb5c630a6fd98e1c3e266c1f32896e8977 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 22 Mar 2022 18:14:23 -0400 Subject: [PATCH 2/3] Voice rooms prototype (#2249) * Support call room type from MSC3417 Signed-off-by: Robin Townsend * Make it more clear that call room type is unstable Signed-off-by: Robin Townsend --- src/@types/event.ts | 1 + src/models/room.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/@types/event.ts b/src/@types/event.ts index 98c7de32f88..05f85cc4742 100644 --- a/src/@types/event.ts +++ b/src/@types/event.ts @@ -119,6 +119,7 @@ export const RoomCreateTypeField = "type"; export enum RoomType { Space = "m.space", + UnstableCall = "org.matrix.msc3417.call", } /** diff --git a/src/models/room.ts b/src/models/room.ts index 3da055e6ec6..283cf55bce9 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -2425,7 +2425,7 @@ export class Room extends TypedEventEmitter /** * Returns the type of the room from the `m.room.create` event content or undefined if none is set - * @returns {?string} the type of the room. Currently only RoomType.Space is known. + * @returns {?string} the type of the room. */ public getType(): RoomType | string | undefined { const createEvent = this.currentState.getStateEvents(EventType.RoomCreate, ""); @@ -2447,6 +2447,14 @@ export class Room extends TypedEventEmitter return this.getType() === RoomType.Space; } + /** + * Returns whether the room is a call-room as defined by MSC3417. + * @returns {boolean} true if the room's type is RoomType.UnstableCall + */ + public isCallRoom(): boolean { + return this.getType() === RoomType.UnstableCall; + } + /** * This is an internal method. Calculates the name of the room from the current * room state. From d0b964837f2820940bd93e718a2450b5f528bffc Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 22 Mar 2022 16:20:32 -0600 Subject: [PATCH 3/3] Remove groups (#2234) This API is due for removal in Synapse and has been deprecated for a very long time. People should move away from it soon, but just in case we'll declare this as a breaking change. There is no impact on sync storage here: we happen to store the data in a way that is backwards-compatible for group-supporting clients, and the code guards against missing data from the stores. So, if someone were to revert, they'd be "safe" (probably lose all their group info, but the app wouldn't crash). --- src/client.ts | 406 +-------------------------- src/matrix.ts | 1 - src/models/group.js | 100 ------- src/store/index.ts | 26 +- src/store/indexeddb-local-backend.ts | 6 +- src/store/memory.ts | 30 -- src/store/stub.ts | 27 -- src/sync-accumulator.ts | 50 ---- src/sync.ts | 76 +---- 9 files changed, 4 insertions(+), 718 deletions(-) delete mode 100644 src/models/group.js diff --git a/src/client.ts b/src/client.ts index 57c45778aec..640fb724dac 100644 --- a/src/client.ts +++ b/src/client.ts @@ -37,7 +37,6 @@ import { Filter, IFilterDefinition } from "./filter"; import { CallEventHandlerEvent, CallEventHandler, CallEventHandlerEventHandlerMap } from './webrtc/callEventHandler'; import * as utils from './utils'; import { sleep } from './utils'; -import { Group } from "./models/group"; import { Direction, EventTimeline } from "./models/event-timeline"; import { IActionsObject, PushProcessor } from "./pushprocessor"; import { AutoDiscovery, AutoDiscoveryAction } from "./autodiscovery"; @@ -783,11 +782,6 @@ export enum ClientEvent { DeleteRoom = "deleteRoom", SyncUnexpectedError = "sync.unexpectedError", ClientWellKnown = "WellKnown.client", - /* @deprecated */ - Group = "Group", - // The following enum members are both deprecated and in the wrong place, Groups haven't been TSified - GroupProfile = "Group.profile", - GroupMyMembership = "Group.myMembership", } type RoomEvents = RoomEvent.Name @@ -856,9 +850,6 @@ export type ClientEventHandlerMap = { [ClientEvent.DeleteRoom]: (roomId: string) => void; [ClientEvent.SyncUnexpectedError]: (error: Error) => void; [ClientEvent.ClientWellKnown]: (data: IClientWellKnown) => void; - [ClientEvent.Group]: (group: Group) => void; - [ClientEvent.GroupProfile]: (group: Group) => void; - [ClientEvent.GroupMyMembership]: (group: Group) => void; } & RoomEventHandlerMap & RoomStateEventHandlerMap & CryptoEventHandlerMap @@ -3241,27 +3232,6 @@ export class MatrixClient extends TypedEventEmitter { - // TODO: support groups + // TODO: support search groups const body = { search_categories: { @@ -8838,368 +8808,6 @@ export class MatrixClient extends TypedEventEmitter { - const path = utils.encodeUri("/groups/$groupId/summary", { $groupId: groupId }); - return this.http.authedRequest(undefined, Method.Get, path); - } - - /** - * @param {string} groupId - * @return {Promise} Resolves: Group profile object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroupProfile(groupId: string): Promise { - const path = utils.encodeUri("/groups/$groupId/profile", { $groupId: groupId }); - return this.http.authedRequest(undefined, Method.Get, path); - } - - /** - * @param {string} groupId - * @param {Object} profile The group profile object - * @param {string=} profile.name Name of the group - * @param {string=} profile.avatar_url MXC avatar URL - * @param {string=} profile.short_description A short description of the room - * @param {string=} profile.long_description A longer HTML description of the room - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public setGroupProfile(groupId: string, profile: any): Promise { - const path = utils.encodeUri("/groups/$groupId/profile", { $groupId: groupId }); - return this.http.authedRequest( - undefined, Method.Post, path, undefined, profile, - ); - } - - /** - * @param {string} groupId - * @param {object} policy The join policy for the group. Must include at - * least a 'type' field which is 'open' if anyone can join the group - * the group without prior approval, or 'invite' if an invite is - * required to join. - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public setGroupJoinPolicy(groupId: string, policy: any): Promise { - const path = utils.encodeUri( - "/groups/$groupId/settings/m.join_policy", - { $groupId: groupId }, - ); - return this.http.authedRequest( - undefined, Method.Put, path, undefined, { - 'm.join_policy': policy, - }, - ); - } - - /** - * @param {string} groupId - * @return {Promise} Resolves: Group users list object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroupUsers(groupId: string): Promise { - const path = utils.encodeUri("/groups/$groupId/users", { $groupId: groupId }); - return this.http.authedRequest(undefined, Method.Get, path); - } - - /** - * @param {string} groupId - * @return {Promise} Resolves: Group users list object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroupInvitedUsers(groupId: string): Promise { - const path = utils.encodeUri("/groups/$groupId/invited_users", { $groupId: groupId }); - return this.http.authedRequest(undefined, Method.Get, path); - } - - /** - * @param {string} groupId - * @return {Promise} Resolves: Group rooms list object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroupRooms(groupId: string): Promise { - const path = utils.encodeUri("/groups/$groupId/rooms", { $groupId: groupId }); - return this.http.authedRequest(undefined, Method.Get, path); - } - - /** - * @param {string} groupId - * @param {string} userId - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public inviteUserToGroup(groupId: string, userId: string): Promise { - const path = utils.encodeUri( - "/groups/$groupId/admin/users/invite/$userId", - { $groupId: groupId, $userId: userId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, {}); - } - - /** - * @param {string} groupId - * @param {string} userId - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public removeUserFromGroup(groupId: string, userId: string): Promise { - const path = utils.encodeUri( - "/groups/$groupId/admin/users/remove/$userId", - { $groupId: groupId, $userId: userId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, {}); - } - - /** - * @param {string} groupId - * @param {string} userId - * @param {string} roleId Optional. - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public addUserToGroupSummary(groupId: string, userId: string, roleId: string): Promise { - const path = utils.encodeUri( - roleId ? - "/groups/$groupId/summary/$roleId/users/$userId" : - "/groups/$groupId/summary/users/$userId", - { $groupId: groupId, $roleId: roleId, $userId: userId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, {}); - } - - /** - * @param {string} groupId - * @param {string} userId - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public removeUserFromGroupSummary(groupId: string, userId: string): Promise { - const path = utils.encodeUri( - "/groups/$groupId/summary/users/$userId", - { $groupId: groupId, $userId: userId }, - ); - return this.http.authedRequest(undefined, Method.Delete, path, undefined, {}); - } - - /** - * @param {string} groupId - * @param {string} roomId - * @param {string} categoryId Optional. - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public addRoomToGroupSummary(groupId: string, roomId: string, categoryId: string): Promise { - const path = utils.encodeUri( - categoryId ? - "/groups/$groupId/summary/$categoryId/rooms/$roomId" : - "/groups/$groupId/summary/rooms/$roomId", - { $groupId: groupId, $categoryId: categoryId, $roomId: roomId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, {}); - } - - /** - * @param {string} groupId - * @param {string} roomId - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public removeRoomFromGroupSummary(groupId: string, roomId: string): Promise { - const path = utils.encodeUri( - "/groups/$groupId/summary/rooms/$roomId", - { $groupId: groupId, $roomId: roomId }, - ); - return this.http.authedRequest(undefined, Method.Delete, path, undefined, {}); - } - - /** - * @param {string} groupId - * @param {string} roomId - * @param {boolean} isPublic Whether the room-group association is visible to non-members - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public addRoomToGroup(groupId: string, roomId: string, isPublic: boolean): Promise { - if (isPublic === undefined) { - isPublic = true; - } - const path = utils.encodeUri( - "/groups/$groupId/admin/rooms/$roomId", - { $groupId: groupId, $roomId: roomId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, - { "m.visibility": { type: isPublic ? "public" : "private" } }, - ); - } - - /** - * Configure the visibility of a room-group association. - * @param {string} groupId - * @param {string} roomId - * @param {boolean} isPublic Whether the room-group association is visible to non-members - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public updateGroupRoomVisibility(groupId: string, roomId: string, isPublic: boolean): Promise { - // NB: The /config API is generic but there's not much point in exposing this yet as synapse - // is the only server to implement this. In future we should consider an API that allows - // arbitrary configuration, i.e. "config/$configKey". - - const path = utils.encodeUri( - "/groups/$groupId/admin/rooms/$roomId/config/m.visibility", - { $groupId: groupId, $roomId: roomId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, - { type: isPublic ? "public" : "private" }, - ); - } - - /** - * @param {string} groupId - * @param {string} roomId - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public removeRoomFromGroup(groupId: string, roomId: string): Promise { - const path = utils.encodeUri( - "/groups/$groupId/admin/rooms/$roomId", - { $groupId: groupId, $roomId: roomId }, - ); - return this.http.authedRequest(undefined, Method.Delete, path, undefined, {}); - } - - /** - * @param {string} groupId - * @param {Object} opts Additional options to send alongside the acceptance. - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public acceptGroupInvite(groupId: string, opts = null): Promise { - const path = utils.encodeUri( - "/groups/$groupId/self/accept_invite", - { $groupId: groupId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, opts || {}); - } - - /** - * @param {string} groupId - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public joinGroup(groupId: string): Promise { - const path = utils.encodeUri( - "/groups/$groupId/self/join", - { $groupId: groupId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, {}); - } - - /** - * @param {string} groupId - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public leaveGroup(groupId: string): Promise { - const path = utils.encodeUri( - "/groups/$groupId/self/leave", - { $groupId: groupId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, {}); - } - - /** - * @return {Promise} Resolves: The groups to which the user is joined - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getJoinedGroups(): Promise { - const path = utils.encodeUri("/joined_groups", {}); - return this.http.authedRequest(undefined, Method.Get, path); - } - - /** - * @param {Object} content Request content - * @param {string} content.localpart The local part of the desired group ID - * @param {Object} content.profile Group profile object - * @return {Promise} Resolves: Object with key group_id: id of the created group - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public createGroup(content: any): Promise { - const path = utils.encodeUri("/create_group", {}); - return this.http.authedRequest( - undefined, Method.Post, path, undefined, content, - ); - } - - /** - * @param {string[]} userIds List of user IDs - * @return {Promise} Resolves: Object as exmaple below - * - * { - * "users": { - * "@bob:example.com": { - * "+example:example.com" - * } - * } - * } - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getPublicisedGroups(userIds: string[]): Promise { - const path = utils.encodeUri("/publicised_groups", {}); - return this.http.authedRequest( - undefined, Method.Post, path, undefined, { user_ids: userIds }, - ); - } - - /** - * @param {string} groupId - * @param {boolean} isPublic Whether the user's membership of this group is made public - * @return {Promise} Resolves: Empty object - * @return {module:http-api.MatrixError} Rejects: with an error response. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public setGroupPublicity(groupId: string, isPublic: boolean): Promise { - const path = utils.encodeUri( - "/groups/$groupId/self/update_publicity", - { $groupId: groupId }, - ); - return this.http.authedRequest(undefined, Method.Put, path, undefined, { - publicise: isPublic, - }); - } - /** * @experimental */ @@ -9523,18 +9131,6 @@ export class MatrixClient extends TypedEventEmitterThis event - * is experimental and may change. - * @event module:client~MatrixClient#"Group" - * @param {Group} group The newly created, fully populated group. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - * @example - * matrixClient.on("Group", function(group){ - * var groupId = group.groupId; - * }); - */ - /** * Fires whenever a new Room is added. This will fire when you are invited to a * room, as well as when you join a room. This event is experimental and diff --git a/src/matrix.ts b/src/matrix.ts index e687926f67f..5379b461acf 100644 --- a/src/matrix.ts +++ b/src/matrix.ts @@ -30,7 +30,6 @@ export * from "./errors"; export * from "./models/beacon"; export * from "./models/event"; export * from "./models/room"; -export * from "./models/group"; export * from "./models/event-timeline"; export * from "./models/event-timeline-set"; export * from "./models/room-member"; diff --git a/src/models/group.js b/src/models/group.js deleted file mode 100644 index 29f0fb3846c..00000000000 --- a/src/models/group.js +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright 2017 New Vector Ltd -Copyright 2019 The Matrix.org Foundation C.I.C. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - * @module models/group - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - -// eslint-disable-next-line no-restricted-imports -import { EventEmitter } from "events"; - -import * as utils from "../utils"; - -/** - * Construct a new Group. - * - * @param {string} groupId The ID of this group. - * - * @prop {string} groupId The ID of this group. - * @prop {string} name The human-readable display name for this group. - * @prop {string} avatarUrl The mxc URL for this group's avatar. - * @prop {string} myMembership The logged in user's membership of this group - * @prop {Object} inviter Infomation about the user who invited the logged in user - * to the group, if myMembership is 'invite'. - * @prop {string} inviter.userId The user ID of the inviter - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ -export function Group(groupId) { - this.groupId = groupId; - this.name = null; - this.avatarUrl = null; - this.myMembership = null; - this.inviter = null; -} -utils.inherits(Group, EventEmitter); - -Group.prototype.setProfile = function(name, avatarUrl) { - if (this.name === name && this.avatarUrl === avatarUrl) return; - - this.name = name || this.groupId; - this.avatarUrl = avatarUrl; - - this.emit("Group.profile", this); -}; - -Group.prototype.setMyMembership = function(membership) { - if (this.myMembership === membership) return; - - this.myMembership = membership; - - this.emit("Group.myMembership", this); -}; - -/** - * Sets the 'inviter' property. This does not emit an event (the inviter - * will only change when the user is revited / reinvited to a room), - * so set this before setting myMembership. - * @param {Object} inviter Infomation about who invited us to the room - */ -Group.prototype.setInviter = function(inviter) { - this.inviter = inviter; -}; - -/** - * Fires whenever a group's profile information is updated. - * This means the 'name' and 'avatarUrl' properties. - * @event module:client~MatrixClient#"Group.profile" - * @param {Group} group The group whose profile was updated. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - * @example - * matrixClient.on("Group.profile", function(group){ - * var name = group.name; - * }); - */ - -/** - * Fires whenever the logged in user's membership status of - * the group is updated. - * @event module:client~MatrixClient#"Group.myMembership" - * @param {Group} group The group in which the user's membership changed - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - * @example - * matrixClient.on("Group.myMembership", function(group){ - * var myMembership = group.myMembership; - * }); - */ diff --git a/src/store/index.ts b/src/store/index.ts index f4bf214a7eb..a9966b4282d 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -15,19 +15,17 @@ limitations under the License. */ import { EventType } from "../@types/event"; -import { Group } from "../models/group"; import { Room } from "../models/room"; import { User } from "../models/user"; import { IEvent, MatrixEvent } from "../models/event"; import { Filter } from "../filter"; import { RoomSummary } from "../models/room-summary"; -import { IMinimalEvent, IGroups, IRooms, ISyncResponse } from "../sync-accumulator"; +import { IMinimalEvent, IRooms, ISyncResponse } from "../sync-accumulator"; import { IStartClientOpts } from "../client"; export interface ISavedSync { nextBatch: string; roomsData: IRooms; - groupsData: IGroups; accountData: IMinimalEvent[]; } @@ -53,28 +51,6 @@ export interface IStore { */ setSyncToken(token: string): void; - /** - * No-op. - * @param {Group} group - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - storeGroup(group: Group): void; - - /** - * No-op. - * @param {string} groupId - * @return {null} - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - getGroup(groupId: string): Group | null; - - /** - * No-op. - * @return {Array} An empty array. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - getGroups(): Group[]; - /** * No-op. * @param {Room} room diff --git a/src/store/indexeddb-local-backend.ts b/src/store/indexeddb-local-backend.ts index 1dd1a125bf9..72a287522fd 100644 --- a/src/store/indexeddb-local-backend.ts +++ b/src/store/indexeddb-local-backend.ts @@ -215,7 +215,6 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend { this.syncAccumulator.accumulate({ next_batch: syncData.nextBatch, rooms: syncData.roomsData, - groups: syncData.groupsData, account_data: { events: accountData, }, @@ -405,7 +404,7 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend { await Promise.all([ this.persistUserPresenceEvents(userTuples), this.persistAccountData(syncData.accountData), - this.persistSyncData(syncData.nextBatch, syncData.roomsData, syncData.groupsData), + this.persistSyncData(syncData.nextBatch, syncData.roomsData), ]); } @@ -413,13 +412,11 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend { * Persist rooms /sync data along with the next batch token. * @param {string} nextBatch The next_batch /sync value. * @param {Object} roomsData The 'rooms' /sync data from a SyncAccumulator - * @param {Object} groupsData The 'groups' /sync data from a SyncAccumulator * @return {Promise} Resolves if the data was persisted. */ private persistSyncData( nextBatch: string, roomsData: ISyncResponse["rooms"], - groupsData: ISyncResponse["groups"], ): Promise { logger.log("Persisting sync data up to", nextBatch); return utils.promiseTry(() => { @@ -429,7 +426,6 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend { clobber: "-", // constant key so will always clobber nextBatch, roomsData, - groupsData, }); // put == UPSERT return txnAsPromise(txn).then(); }); diff --git a/src/store/memory.ts b/src/store/memory.ts index b29d3d3647a..8fbbeec0b7a 100644 --- a/src/store/memory.ts +++ b/src/store/memory.ts @@ -20,7 +20,6 @@ limitations under the License. */ import { EventType } from "../@types/event"; -import { Group } from "../models/group"; import { Room } from "../models/room"; import { User } from "../models/user"; import { IEvent, MatrixEvent } from "../models/event"; @@ -53,7 +52,6 @@ export interface IOpts { */ export class MemoryStore implements IStore { private rooms: Record = {}; // roomId: Room - private groups: Record = {}; // groupId: Group private users: Record = {}; // userId: User private syncToken: string = null; // userId: { @@ -90,34 +88,6 @@ export class MemoryStore implements IStore { this.syncToken = token; } - /** - * Store the given room. - * @param {Group} group The group to be stored - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public storeGroup(group: Group) { - this.groups[group.groupId] = group; - } - - /** - * Retrieve a group by its group ID. - * @param {string} groupId The group ID. - * @return {Group} The group or null. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroup(groupId: string): Group | null { - return this.groups[groupId] || null; - } - - /** - * Retrieve all known groups. - * @return {Group[]} A list of groups, which may be empty. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroups(): Group[] { - return Object.values(this.groups); - } - /** * Store the given room. * @param {Room} room The room to be stored. All properties must be stored. diff --git a/src/store/stub.ts b/src/store/stub.ts index 95b231db142..c3a5b6347de 100644 --- a/src/store/stub.ts +++ b/src/store/stub.ts @@ -20,7 +20,6 @@ limitations under the License. */ import { EventType } from "../@types/event"; -import { Group } from "../models/group"; import { Room } from "../models/room"; import { User } from "../models/user"; import { IEvent, MatrixEvent } from "../models/event"; @@ -58,32 +57,6 @@ export class StubStore implements IStore { this.fromToken = token; } - /** - * No-op. - * @param {Group} group - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public storeGroup(group: Group) {} - - /** - * No-op. - * @param {string} groupId - * @return {null} - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroup(groupId: string): Group | null { - return null; - } - - /** - * No-op. - * @return {Array} An empty array. - * @deprecated groups/communities never made it to the spec and support for them is being discontinued. - */ - public getGroups(): Group[] { - return []; - } - /** * No-op. * @param {Room} room diff --git a/src/sync-accumulator.ts b/src/sync-accumulator.ts index 65b5cf00ad5..f50f80b566a 100644 --- a/src/sync-accumulator.ts +++ b/src/sync-accumulator.ts @@ -128,12 +128,6 @@ interface IDeviceLists { left: string[]; } -export interface IGroups { - [Category.Join]: object; - [Category.Invite]: object; - [Category.Leave]: object; -} - export interface ISyncResponse { next_batch: string; rooms: IRooms; @@ -142,8 +136,6 @@ export interface ISyncResponse { to_device?: IToDevice; device_lists?: IDeviceLists; device_one_time_keys_count?: Record; - - groups: IGroups; // unspecced } /* eslint-enable camelcase */ @@ -174,7 +166,6 @@ export interface ISyncData { nextBatch: string; accountData: IMinimalEvent[]; roomsData: IRooms; - groupsData: IGroups; } /** @@ -197,13 +188,6 @@ export class SyncAccumulator { // streaming from without losing events. private nextBatch: string = null; - // { ('invite'|'join'|'leave'): $groupId: { ... sync 'group' data } } - private groups: Record = { - invite: {}, - join: {}, - leave: {}, - }; - /** * @param {Object} opts * @param {Number=} opts.maxTimelineEntries The ideal maximum number of @@ -219,7 +203,6 @@ export class SyncAccumulator { public accumulate(syncResponse: ISyncResponse, fromDatabase = false): void { this.accumulateRooms(syncResponse, fromDatabase); - this.accumulateGroups(syncResponse); this.accumulateAccountData(syncResponse); this.nextBatch = syncResponse.next_batch; } @@ -505,38 +488,6 @@ export class SyncAccumulator { } } - /** - * Accumulate incremental /sync group data. - * @param {Object} syncResponse the complete /sync JSON - */ - private accumulateGroups(syncResponse: ISyncResponse): void { - if (!syncResponse.groups) { - return; - } - if (syncResponse.groups.invite) { - Object.keys(syncResponse.groups.invite).forEach((groupId) => { - this.accumulateGroup(groupId, Category.Invite, syncResponse.groups.invite[groupId]); - }); - } - if (syncResponse.groups.join) { - Object.keys(syncResponse.groups.join).forEach((groupId) => { - this.accumulateGroup(groupId, Category.Join, syncResponse.groups.join[groupId]); - }); - } - if (syncResponse.groups.leave) { - Object.keys(syncResponse.groups.leave).forEach((groupId) => { - this.accumulateGroup(groupId, Category.Leave, syncResponse.groups.leave[groupId]); - }); - } - } - - private accumulateGroup(groupId: string, category: Category, data: object): void { - for (const cat of [Category.Invite, Category.Leave, Category.Join]) { - delete this.groups[cat][groupId]; - } - this.groups[category][groupId] = data; - } - /** * Return everything under the 'rooms' key from a /sync response which * represents all room data that should be stored. This should be paired @@ -694,7 +645,6 @@ export class SyncAccumulator { return { nextBatch: this.nextBatch, roomsData: data, - groupsData: this.groups, accountData: accData, }; } diff --git a/src/sync.ts b/src/sync.ts index 5d629b0172d..6299977397d 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -25,7 +25,6 @@ limitations under the License. import { User, UserEvent } from "./models/user"; import { NotificationCountType, Room, RoomEvent } from "./models/room"; -import { Group } from "./models/group"; import * as utils from "./utils"; import { IDeferred } from "./utils"; import { Filter } from "./filter"; @@ -35,7 +34,6 @@ import { logger } from './logger'; import { InvalidStoreError } from './errors'; import { ClientEvent, IStoredClientOpts, MatrixClient, PendingEventOrdering } from "./client"; import { - Category, IEphemeral, IInvitedRoom, IInviteState, @@ -213,21 +211,6 @@ export class SyncApi { return room; } - /** - * @param {string} groupId - * @return {Group} - */ - public createGroup(groupId: string): Group { - const client = this.client; - const group = new Group(groupId); - client.reEmitter.reEmit(group, [ - ClientEvent.GroupProfile, - ClientEvent.GroupMyMembership, - ]); - client.store.storeGroup(group); - return group; - } - /** * @param {Room} room * @private @@ -768,7 +751,6 @@ export class SyncApi { const data: ISyncResponse = { next_batch: nextSyncToken, rooms: savedSync.roomsData, - groups: savedSync.groupsData, account_data: { events: savedSync.accountData, }, @@ -1055,20 +1037,7 @@ export class SyncApi { // timeline: { events: [], prev_batch: $token } // } // } - // }, - // groups: { - // invite: { - // $groupId: { - // inviter: $inviter, - // profile: { - // avatar_url: $avatarUrl, - // name: $groupName, - // }, - // }, - // }, - // join: {}, - // leave: {}, - // }, + // } // } // TODO-arch: @@ -1172,20 +1141,6 @@ export class SyncApi { this.catchingUp = false; } - if (data.groups) { - if (data.groups.invite) { - this.processGroupSyncEntry(data.groups.invite, Category.Invite); - } - - if (data.groups.join) { - this.processGroupSyncEntry(data.groups.join, Category.Join); - } - - if (data.groups.leave) { - this.processGroupSyncEntry(data.groups.leave, Category.Leave); - } - } - // the returned json structure is a bit crap, so make it into a // nicer form (array) after applying sanity to make sure we don't fail // on missing keys (on the off chance) @@ -1542,35 +1497,6 @@ export class SyncApi { }); } - /** - * @param {Object} groupsSection Groups section object, eg. response.groups.invite - * @param {string} sectionName Which section this is ('invite', 'join' or 'leave') - */ - private processGroupSyncEntry(groupsSection: object, sectionName: Category) { - // Processes entries from 'groups' section of the sync stream - for (const groupId of Object.keys(groupsSection)) { - const groupInfo = groupsSection[groupId]; - let group = this.client.store.getGroup(groupId); - const isBrandNew = group === null; - if (group === null) { - group = this.createGroup(groupId); - } - if (groupInfo.profile) { - group.setProfile( - groupInfo.profile.name, groupInfo.profile.avatar_url, - ); - } - if (groupInfo.inviter) { - group.setInviter({ userId: groupInfo.inviter }); - } - group.setMyMembership(sectionName); - if (isBrandNew) { - // Now we've filled in all the fields, emit the Group event - this.client.emit(ClientEvent.Group, group); - } - } - } - /** * @param {Object} obj * @return {Object[]}