From d8d8be34013d961f6120006f0a993b455c6c420f Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Wed, 14 Dec 2022 20:32:30 -0300 Subject: [PATCH 01/19] 1.37.0-alpha.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b9e702ca4..03dcb2c41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.36.0", + "version": "1.37.0-alpha.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 083866593..ad3e56ef7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.36.0", + "version": "1.37.0-alpha.0", "description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.", "main": "index", "typings": "index", From bea2daa8f8cb822717759187eb4645d37713f703 Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Wed, 14 Dec 2022 20:59:26 -0300 Subject: [PATCH 02/19] Bump version to 1.37.0-alpha --- package-lock.json | 2 +- package.json | 2 +- src/definition/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03dcb2c41..acfcb9727 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.37.0-alpha.0", + "version": "1.37.0-alpha", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ad3e56ef7..9cf78b629 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.37.0-alpha.0", + "version": "1.37.0-alpha", "description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.", "main": "index", "typings": "index", diff --git a/src/definition/package.json b/src/definition/package.json index 2e60f3760..7ce80c383 100644 --- a/src/definition/package.json +++ b/src/definition/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-ts-definition", - "version": "1.35.0-alpha", + "version": "1.37.0-alpha", "description": "Contains the TypeScript definitions for the Rocket.Chat Applications.", "main": "index.js", "typings": "index", From bedfc95765a25fde4204a243831ac9972d4c1246 Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Thu, 22 Dec 2022 11:40:50 -0300 Subject: [PATCH 03/19] 2.0.0-alpha --- package-lock.json | 2 +- package.json | 2 +- src/definition/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index acfcb9727..3b692390d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.37.0-alpha", + "version": "2.0.0-alpha", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9cf78b629..da4ab8e17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "1.37.0-alpha", + "version": "2.0.0-alpha", "description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.", "main": "index", "typings": "index", diff --git a/src/definition/package.json b/src/definition/package.json index 7ce80c383..ea512e23d 100644 --- a/src/definition/package.json +++ b/src/definition/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-ts-definition", - "version": "1.37.0-alpha", + "version": "2.0.0-alpha", "description": "Contains the TypeScript definitions for the Rocket.Chat Applications.", "main": "index.js", "typings": "index", From af162f89ea43be28d6896dbff4478f69128e1367 Mon Sep 17 00:00:00 2001 From: Thassio Victor Date: Wed, 18 Jan 2023 18:24:42 -0300 Subject: [PATCH 04/19] Chore: Adjustments for using raw models at rocket chat (#543) --- src/definition/persistence/IPersistenceItem.ts | 7 +++++++ src/definition/persistence/index.ts | 1 + src/server/logging/ILoggerStorageEntry.ts | 1 + src/server/storage/AppMetadataStorage.ts | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/definition/persistence/IPersistenceItem.ts create mode 100644 src/definition/persistence/index.ts diff --git a/src/definition/persistence/IPersistenceItem.ts b/src/definition/persistence/IPersistenceItem.ts new file mode 100644 index 000000000..e4fbd9a9d --- /dev/null +++ b/src/definition/persistence/IPersistenceItem.ts @@ -0,0 +1,7 @@ +import { RocketChatAssociationRecord } from '../../definition/metadata'; + +export interface IPersistenceItem { + appId: string; + data: Record; + associations?: Array; +} diff --git a/src/definition/persistence/index.ts b/src/definition/persistence/index.ts new file mode 100644 index 000000000..22abe9e93 --- /dev/null +++ b/src/definition/persistence/index.ts @@ -0,0 +1 @@ +export * from './IPersistenceItem'; diff --git a/src/server/logging/ILoggerStorageEntry.ts b/src/server/logging/ILoggerStorageEntry.ts index 88f238356..5f0823a85 100644 --- a/src/server/logging/ILoggerStorageEntry.ts +++ b/src/server/logging/ILoggerStorageEntry.ts @@ -8,6 +8,7 @@ export interface ILoggerStorageEntry { startTime: Date; endTime: Date; totalTime: number; + instanceId?: string; // Internal value to be used for sorting _createdAt: Date; } diff --git a/src/server/storage/AppMetadataStorage.ts b/src/server/storage/AppMetadataStorage.ts index 3ee87598d..e7fe7bafe 100644 --- a/src/server/storage/AppMetadataStorage.ts +++ b/src/server/storage/AppMetadataStorage.ts @@ -8,7 +8,7 @@ export abstract class AppMetadataStorage { } public abstract create(item: IAppStorageItem): Promise; - public abstract retrieveOne(id: string): Promise; + public abstract retrieveOne(id: string): Promise; public abstract retrieveAll(): Promise>; public abstract update(item: IAppStorageItem): Promise; public abstract remove(id: string): Promise<{ success: boolean }>; From d017731aff04890c40750edeb5ad007b25457619 Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Wed, 18 Jan 2023 18:25:33 -0300 Subject: [PATCH 05/19] Revert "2.0.0-alpha" This reverts commit bedfc95765a25fde4204a243831ac9972d4c1246. --- package-lock.json | 2 +- package.json | 2 +- src/definition/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3b692390d..acfcb9727 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "2.0.0-alpha", + "version": "1.37.0-alpha", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index da4ab8e17..9cf78b629 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-engine", - "version": "2.0.0-alpha", + "version": "1.37.0-alpha", "description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.", "main": "index", "typings": "index", diff --git a/src/definition/package.json b/src/definition/package.json index ea512e23d..7ce80c383 100644 --- a/src/definition/package.json +++ b/src/definition/package.json @@ -1,6 +1,6 @@ { "name": "@rocket.chat/apps-ts-definition", - "version": "2.0.0-alpha", + "version": "1.37.0-alpha", "description": "Contains the TypeScript definitions for the Rocket.Chat Applications.", "main": "index.js", "typings": "index", From 0e55a6e332e34fc7365b2cf265ebc945ef16e6bd Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Mon, 6 Feb 2023 17:53:09 -0300 Subject: [PATCH 06/19] [IMPROVE] Adapt startup flow (#581) --- src/server/AppManager.ts | 32 ++++++++++++++++----------- src/server/storage/IAppStorageItem.ts | 7 ++++++ src/server/storage/index.ts | 2 +- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/server/AppManager.ts b/src/server/AppManager.ts index 7dac3a270..1335f3c87 100644 --- a/src/server/AppManager.ts +++ b/src/server/AppManager.ts @@ -28,6 +28,7 @@ import { ProxiedApp } from './ProxiedApp'; import { AppsEngineEmptyRuntime } from './runtime/AppsEngineEmptyRuntime'; import { AppLogStorage, AppMetadataStorage, IAppStorageItem } from './storage'; import { AppSourceStorage } from './storage/AppSourceStorage'; +import { AppInstallationSource } from './storage/IAppStorageItem'; export interface IAppInstallParameters { enable: boolean; @@ -209,22 +210,18 @@ export class AppManager { * Expect this to take some time, as it goes through a very * long process of loading all the Apps up. */ - public async load(): Promise> { + public async load(): Promise { // You can not load the AppManager system again // if it has already been loaded. if (this.isLoaded) { - return; + return true; } const items: Map = await this.appMetadataStorage.retrieveAll(); - const affs: Array = new Array(); for (const item of items.values()) { - const aff = new AppFabricationFulfillment(); try { - aff.setAppInfo(item.info); - aff.setImplementedInterfaces(item.implemented); const appPackage = await this.appSourceStorage.fetch(item); const unpackageResult = await this.getParser().unpackageApp(appPackage); @@ -232,7 +229,6 @@ export class AppManager { const app = this.getCompiler().toSandBox(this, item, unpackageResult); this.apps.set(item.id, app); - aff.setApp(app); } catch (e) { console.warn(`Error while compiling the App "${ item.info.name } (${ item.id })":`); console.error(e); @@ -243,14 +239,24 @@ export class AppManager { const prl = new ProxiedApp(this, item, app, new AppsEngineEmptyRuntime(app)); this.apps.set(item.id, prl); - aff.setApp(prl); } - - affs.push(aff); } + return this.isLoaded = true; + } + + public async enableAll(): Promise> { + const affs: Array = new Array(); + // Let's initialize them for (const rl of this.apps.values()) { + const aff = new AppFabricationFulfillment(); + + aff.setAppInfo(rl.getInfo()); + aff.setImplementedInterfaces(rl.getImplementationList()); + aff.setApp(rl); + affs.push(aff); + if (AppStatusUtils.isDisabled(rl.getStatus())) { // Usually if an App is disabled before it's initialized, // then something (such as an error) occured while @@ -261,7 +267,7 @@ export class AppManager { continue; } - await this.initializeApp(items.get(rl.getID()), rl, false, true).catch(console.error); + await this.initializeApp(rl.getStorageItem(), rl, false, true).catch(console.error); } // Let's ensure the required settings are all set @@ -279,14 +285,13 @@ export class AppManager { // but are not currently disabled. for (const app of this.apps.values()) { if (!AppStatusUtils.isDisabled(app.getStatus()) && AppStatusUtils.isEnabled(app.getPreviousStatus())) { - await this.enableApp(items.get(app.getID()), app, true, app.getPreviousStatus() === AppStatus.MANUALLY_ENABLED).catch(console.error); + await this.enableApp(app.getStorageItem(), app, true, app.getPreviousStatus() === AppStatus.MANUALLY_ENABLED).catch(console.error); } else if (!AppStatusUtils.isError(app.getStatus())) { this.listenerManager.lockEssentialEvents(app); this.uiActionButtonManager.clearAppActionButtons(app.getID()); } } - this.isLoaded = true; return affs; } @@ -456,6 +461,7 @@ export class AppManager { status: AppStatus.UNKNOWN, settings: {}, implemented: result.implemented.getValues(), + installationSource: !!marketplaceInfo ? AppInstallationSource.MARKETPLACE : AppInstallationSource.PRIVATE, marketplaceInfo, permissionsGranted, languageContent: result.languageContent, diff --git a/src/server/storage/IAppStorageItem.ts b/src/server/storage/IAppStorageItem.ts index 55eeb2cc9..d3af8340f 100644 --- a/src/server/storage/IAppStorageItem.ts +++ b/src/server/storage/IAppStorageItem.ts @@ -11,6 +11,7 @@ export interface IAppStorageItem { updatedAt?: Date; status: AppStatus; info: IAppInfo; + installationSource: AppInstallationSource; /** * The path that represents where the source of the app storaged. */ @@ -20,4 +21,10 @@ export interface IAppStorageItem { implemented: { [int: string]: boolean }; marketplaceInfo?: IMarketplaceInfo; permissionsGranted?: Array; + migrated?: boolean; +} + +export enum AppInstallationSource { + MARKETPLACE = 'marketplace', + PRIVATE = 'private', } diff --git a/src/server/storage/index.ts b/src/server/storage/index.ts index ee90a4977..5f0993129 100644 --- a/src/server/storage/index.ts +++ b/src/server/storage/index.ts @@ -1,4 +1,4 @@ export { AppLogStorage, IAppLogStorageFindOptions } from './AppLogStorage'; export { AppMetadataStorage } from './AppMetadataStorage'; -export { IAppStorageItem } from './IAppStorageItem'; +export { IAppStorageItem, AppInstallationSource } from './IAppStorageItem'; export { AppSourceStorage } from './AppSourceStorage'; From 4f0a81363805a6afdf3360a9c2e7cb9d428738dc Mon Sep 17 00:00:00 2001 From: Yuqing Bian Date: Wed, 8 Feb 2023 12:20:11 -0500 Subject: [PATCH 07/19] [NEW] Update IModifyCreator to expose IUserBuilder to enable user creation (#536) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fábio Albuquerque <6733883+albuquerquefabio@users.noreply.github.com> Co-authored-by: albuquerquefabio Co-authored-by: Allan Ribeiro Co-authored-by: Allan RIbeiro <35040806+AllanPazRibeiro@users.noreply.github.com> --- src/definition/accessors/IModifyCreator.ts | 13 +++++- src/definition/accessors/IModifyDeleter.ts | 4 ++ src/definition/users/IBotUser.ts | 6 +++ src/server/accessors/ModifyCreator.ts | 47 ++++++++++++++++++---- src/server/accessors/ModifyDeleter.ts | 7 +++- src/server/bridges/UserBridge.ts | 36 ++++++++++++----- tests/test-data/bridges/userBridge.ts | 6 ++- 7 files changed, 99 insertions(+), 20 deletions(-) create mode 100644 src/definition/users/IBotUser.ts diff --git a/src/definition/accessors/IModifyCreator.ts b/src/definition/accessors/IModifyCreator.ts index 0282981bb..c53c45765 100644 --- a/src/definition/accessors/IModifyCreator.ts +++ b/src/definition/accessors/IModifyCreator.ts @@ -3,12 +3,14 @@ import { IMessage } from '../messages'; import { IRoom } from '../rooms'; import { BlockBuilder } from '../uikit'; import { AppVideoConference } from '../videoConferences'; +import { IBotUser } from './../users/IBotUser'; import { IDiscussionBuilder } from './IDiscussionBuilder'; import { ILivechatCreator } from './ILivechatCreator'; import { ILivechatMessageBuilder } from './ILivechatMessageBuilder'; import { IMessageBuilder } from './IMessageBuilder'; import { IRoomBuilder } from './IRoomBuilder'; import { IUploadCreator } from './IUploadCreator'; +import { IUserBuilder } from './IUserBuilder'; import { IVideoConferenceBuilder } from './IVideoConferenceBuilder'; export interface IModifyCreator { @@ -71,11 +73,20 @@ export interface IModifyCreator { */ startVideoConference(data?: Partial): IVideoConferenceBuilder; + /** + * Starts the process for building a new bot user. + * + * @param data (optional) the initial data to pass into the builder, + * the `id` property will be ignored + * @return an IUserBuilder instance + */ + startBotUser(data?: Partial): IUserBuilder; + /** * Finishes the creating process, saving the object to the database. * * @param builder the builder instance * @return the resulting `id` of the resulting object */ - finish(builder: IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IDiscussionBuilder | IVideoConferenceBuilder): Promise; + finish(builder: IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IDiscussionBuilder | IVideoConferenceBuilder | IUserBuilder): Promise; } diff --git a/src/definition/accessors/IModifyDeleter.ts b/src/definition/accessors/IModifyDeleter.ts index 58485732a..b8ff82326 100644 --- a/src/definition/accessors/IModifyDeleter.ts +++ b/src/definition/accessors/IModifyDeleter.ts @@ -1,3 +1,7 @@ +import type { IUser } from '../users'; + export interface IModifyDeleter { deleteRoom(roomId: string): Promise; + + deleteBotUsers(appId: Exclude): Promise; } diff --git a/src/definition/users/IBotUser.ts b/src/definition/users/IBotUser.ts new file mode 100644 index 000000000..397e31a0d --- /dev/null +++ b/src/definition/users/IBotUser.ts @@ -0,0 +1,6 @@ +import { IUser } from './IUser'; +import { UserType } from './UserType'; + +export interface IBotUser extends Omit { + type: UserType.BOT; +} diff --git a/src/server/accessors/ModifyCreator.ts b/src/server/accessors/ModifyCreator.ts index b25d399a7..44e561837 100644 --- a/src/server/accessors/ModifyCreator.ts +++ b/src/server/accessors/ModifyCreator.ts @@ -6,6 +6,7 @@ import { IModifyCreator, IRoomBuilder, IUploadCreator, + IUserBuilder, IVideoConferenceBuilder, } from '../../definition/accessors'; import { ILivechatMessage } from '../../definition/livechat/ILivechatMessage'; @@ -15,12 +16,15 @@ import { IRoom, RoomType } from '../../definition/rooms'; import { BlockBuilder } from '../../definition/uikit'; import { AppVideoConference } from '../../definition/videoConferences'; import { AppBridges } from '../bridges'; +import { IBotUser } from './../../definition/users/IBotUser'; +import { UserType } from './../../definition/users/UserType'; import { DiscussionBuilder } from './DiscussionBuilder'; import { LivechatCreator } from './LivechatCreator'; import { LivechatMessageBuilder } from './LivechatMessageBuilder'; import { MessageBuilder } from './MessageBuilder'; import { RoomBuilder } from './RoomBuilder'; import { UploadCreator } from './UploadCreator'; +import { UserBuilder } from './UserBuilder'; import { VideoConferenceBuilder } from './VideoConferenceBuilder'; export class ModifyCreator implements IModifyCreator { @@ -80,7 +84,30 @@ export class ModifyCreator implements IModifyCreator { return new VideoConferenceBuilder(data); } - public finish(builder: IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IDiscussionBuilder | IVideoConferenceBuilder): Promise { + public startBotUser(data?: Partial): IUserBuilder { + if (data) { + delete data.id; + + if (data.roles && data.roles.length) { + const roles = data.roles; + const hasRole = roles.map((role) => role.toLocaleLowerCase()).some((role) => role === 'admin' || role === 'owner' || role === 'moderator'); + + if (hasRole) { + throw new Error('Invalid role assigned to the user. Should not be admin, owner or moderator.'); + } + } + + if (!data.type) { + data.type = UserType.BOT; + } + } + + return new UserBuilder(data); + } + + public finish( + builder: IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IDiscussionBuilder | IVideoConferenceBuilder | IUserBuilder, + ): Promise { switch (builder.kind) { case RocketChatAssociationModel.MESSAGE: return this._finishMessage(builder); @@ -92,6 +119,8 @@ export class ModifyCreator implements IModifyCreator { return this._finishDiscussion(builder as IDiscussionBuilder); case RocketChatAssociationModel.VIDEO_CONFERENCE: return this._finishVideoConference(builder); + case RocketChatAssociationModel.USER: + return this._finishUser(builder); default: throw new Error('Invalid builder passed to the ModifyCreator.finish function.'); } @@ -180,13 +209,9 @@ export class ModifyCreator implements IModifyCreator { throw new Error('Invalid parentRoom assigned to the discussion.'); } - return this.bridges.getRoomBridge().doCreateDiscussion( - room, - builder.getParentMessage(), - builder.getReply(), - builder.getMembersToBeAddedUsernames(), - this.appId, - ); + return this.bridges + .getRoomBridge() + .doCreateDiscussion(room, builder.getParentMessage(), builder.getReply(), builder.getMembersToBeAddedUsernames(), this.appId); } private _finishVideoConference(builder: IVideoConferenceBuilder): Promise { @@ -206,4 +231,10 @@ export class ModifyCreator implements IModifyCreator { return this.bridges.getVideoConferenceBridge().doCreate(videoConference, this.appId); } + + private _finishUser(builder: IUserBuilder): Promise { + const user = builder.getUser(); + + return this.bridges.getUserBridge().doCreate(user, this.appId); + } } diff --git a/src/server/accessors/ModifyDeleter.ts b/src/server/accessors/ModifyDeleter.ts index f78adb8d7..498bd49b8 100644 --- a/src/server/accessors/ModifyDeleter.ts +++ b/src/server/accessors/ModifyDeleter.ts @@ -1,10 +1,15 @@ import { IModifyDeleter } from '../../definition/accessors'; import { AppBridges } from '../bridges'; +import { IUser, UserType } from './../../definition/users'; export class ModifyDeleter implements IModifyDeleter { - constructor(private readonly bridges: AppBridges, private readonly appId: string) { } + constructor(private readonly bridges: AppBridges, private readonly appId: string) {} public async deleteRoom(roomId: string): Promise { return this.bridges.getRoomBridge().doDelete(roomId, this.appId); } + + public async deleteBotUsers(appId: Exclude): Promise { + return this.bridges.getUserBridge().doDeleteUsersCreatedByApp(appId, UserType.BOT); + } } diff --git a/src/server/bridges/UserBridge.ts b/src/server/bridges/UserBridge.ts index 633df3d5d..58709dd98 100644 --- a/src/server/bridges/UserBridge.ts +++ b/src/server/bridges/UserBridge.ts @@ -1,4 +1,4 @@ -import { IUser, IUserCreationOptions } from '../../definition/users'; +import type { IUser, IUserCreationOptions, UserType } from '../../definition/users'; import { PermissionDeniedError } from '../errors/PermissionDeniedError'; import { AppPermissionManager } from '../managers/AppPermissionManager'; import { AppPermissions } from '../permissions/AppPermissions'; @@ -45,6 +45,12 @@ export abstract class UserBridge extends BaseBridge { } } + public async doDeleteUsersCreatedByApp(appId: string, type: UserType.BOT): Promise { + if (this.hasWritePermission(appId)) { + return this.deleteUsersCreatedByApp(appId, type); + } + } + protected abstract getById(id: string, appId: string): Promise; protected abstract getByUsername(username: string, appId: string): Promise; protected abstract getAppUser(appId?: string): Promise; @@ -79,15 +85,25 @@ export abstract class UserBridge extends BaseBridge { */ protected abstract update(user: IUser, updates: Partial, appId: string): Promise; + /** + * Deletes all bot or app users created by the App. + * @param appId the App's ID. + * @param type the type of the user to be deleted. + * @returns true if any user was deleted, false otherwise. + */ + protected abstract deleteUsersCreatedByApp(appId: string, type: UserType.APP | UserType.BOT): Promise; + private hasReadPermission(appId: string): boolean { if (AppPermissionManager.hasPermission(appId, AppPermissions.user.read)) { return true; } - AppPermissionManager.notifyAboutError(new PermissionDeniedError({ - appId, - missingPermissions: [AppPermissions.user.read], - })); + AppPermissionManager.notifyAboutError( + new PermissionDeniedError({ + appId, + missingPermissions: [AppPermissions.user.read], + }), + ); return false; } @@ -97,10 +113,12 @@ export abstract class UserBridge extends BaseBridge { return true; } - AppPermissionManager.notifyAboutError(new PermissionDeniedError({ - appId, - missingPermissions: [AppPermissions.user.write], - })); + AppPermissionManager.notifyAboutError( + new PermissionDeniedError({ + appId, + missingPermissions: [AppPermissions.user.write], + }), + ); return false; } diff --git a/tests/test-data/bridges/userBridge.ts b/tests/test-data/bridges/userBridge.ts index 18993c1ca..0f86f0e5e 100644 --- a/tests/test-data/bridges/userBridge.ts +++ b/tests/test-data/bridges/userBridge.ts @@ -1,4 +1,4 @@ -import { IUser } from '../../../src/definition/users'; +import type { IUser, UserType } from '../../../src/definition/users'; import { UserBridge } from '../../../src/server/bridges'; @@ -31,6 +31,10 @@ export class TestsUserBridge extends UserBridge { throw new Error('Method not implemented'); } + public async deleteUsersCreatedByApp(appId: string, type: UserType.BOT): Promise { + throw new Error('Method not implemented'); + } + protected getUserUnreadMessageCount(uid: string): Promise { throw new Error('Method not implemented.'); } From aea1df8ea4c05d1c7f395438dbf92faa83124ea5 Mon Sep 17 00:00:00 2001 From: Pierre Lehnen <55164754+pierre-lehnen-rc@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:14:47 -0300 Subject: [PATCH 08/19] [NEW] Add "password" setting type (#577) --- docs/enums/settings_settingtype.settingtype.html | 14 ++++++++++++++ src/definition/settings/SettingType.ts | 3 +++ 2 files changed, 17 insertions(+) diff --git a/docs/enums/settings_settingtype.settingtype.html b/docs/enums/settings_settingtype.settingtype.html index a06261339..389e9fed3 100644 --- a/docs/enums/settings_settingtype.settingtype.html +++ b/docs/enums/settings_settingtype.settingtype.html @@ -83,6 +83,7 @@

Enumeration members

  • NUMBER
  • SELECT
  • STRING
  • +
  • PASSWORD
  • @@ -170,6 +171,16 @@

    STRING

    +
    + +

    PASSWORD

    +
    PASSWORD: = "password"
    + +