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

fix: async operations #31412

Merged
merged 3 commits into from
Jan 10, 2024
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: 1 addition & 3 deletions apps/meteor/app/statistics/server/lib/getAppsStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export async function getAppsStatistics() {
totalActive: Apps.isInitialized() && (await Apps.getManager().get({ enabled: true })).length,
totalFailed:
Apps.isInitialized() &&
Apps.getManager()
.get({ disabled: true })
.filter(({ app: { status } }) => status !== AppStatus.MANUALLY_DISABLED).length,
(await Apps.getManager().get({ disabled: true })).filter(({ app: { status } }) => status !== AppStatus.MANUALLY_DISABLED).length,
};
}
4 changes: 2 additions & 2 deletions apps/meteor/ee/lib/misc/formatAppInstanceForRest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ interface IAppInfoRest extends IAppInfo {
migrated: boolean;
}

export function formatAppInstanceForRest(app: ProxiedApp): IAppInfoRest {
export async function formatAppInstanceForRest(app: ProxiedApp): Promise<IAppInfoRest> {
const appRest: IAppInfoRest = {
...app.getInfo(),
status: app.getStatus(),
status: await app.getStatus(),
languages: app.getStorageItem().languageContent,
private: getInstallationSourceFromAppStorageItem(app.getStorageItem()) === 'private',
migrated: !!app.getStorageItem().migrated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export const appsCountHandler = (apiManager: AppsRestApi) =>
authRequired: false,
},
{
get(): SuccessResult<AppsCountResult> {
async get(): Promise<SuccessResult<AppsCountResult>> {
const manager = apiManager._manager as AppManager;

const apps = manager.get({ enabled: true });
const apps = await manager.get({ enabled: true });
const { maxMarketplaceApps, maxPrivateApps } = License.getAppsConfig();

return API.v1.success({
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/ee/server/apps/communication/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class AppsRestApi {
{ authRequired: true },
{
async get() {
const apps = manager.get().map(formatAppInstanceForRest);
const apps = (await manager.get()).map(formatAppInstanceForRest);
return API.v1.success({ apps });
},
},
Expand Down Expand Up @@ -302,7 +302,7 @@ export class AppsRestApi {
}
apiDeprecationLogger.endpoint(this.request.route, '7.0.0', this.response, 'Use /apps/installed to get the installed apps list.');

const apps = manager.get().map(formatAppInstanceForRest);
const apps = (await manager.get()).map(formatAppInstanceForRest);

return API.v1.success({ apps });
},
Expand Down Expand Up @@ -506,8 +506,8 @@ export class AppsRestApi {
'languages',
{ authRequired: false },
{
get() {
const apps = manager.get().map((prl) => ({
async get() {
const apps = (await manager.get()).map((prl) => ({
id: prl.getID(),
languages: prl.getStorageItem().languageContent,
}));
Expand Down Expand Up @@ -788,7 +788,7 @@ export class AppsRestApi {
await manager.remove(prl.getID(), { user });

const info: IAppInfo & { status?: AppStatus } = prl.getInfo();
info.status = prl.getStatus();
info.status = await prl.getStatus();

void notifyAppInstall(orchestrator.getMarketplaceUrl() as string, 'uninstall', info);

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/apps/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const notifyAdminsAboutRenewedApps = async function _notifyAdminsAboutRenewedApp
}

const renewedApps = apps.filter(
(app) => app.getStatus() === AppStatus.DISABLED && app.getPreviousStatus() === AppStatus.INVALID_LICENSE_DISABLED,
async (app) => (await app.getStatus()) === AppStatus.DISABLED && app.getPreviousStatus() === AppStatus.INVALID_LICENSE_DISABLED,
);

if (renewedApps.length === 0) {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/ee/server/apps/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ export class AppServerOrchestrator {
await this.getManager().load();

// Before enabling each app we verify if there is still room for it
await this.getManager()
.get()
(await this.getManager().get())
// We reduce everything to a promise chain so it runs sequentially
.reduce(
(control, app) =>
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"@rocket.chat/account-utils": "workspace:^",
"@rocket.chat/agenda": "workspace:^",
"@rocket.chat/api-client": "workspace:^",
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "deno",
"@rocket.chat/base64": "workspace:^",
"@rocket.chat/cas-validate": "workspace:^",
"@rocket.chat/core-services": "workspace:^",
Expand Down
4 changes: 1 addition & 3 deletions apps/meteor/server/services/apps-engine/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ export class AppsEngineService extends ServiceClassInternal implements IAppsEngi
}

async getApps(query: IGetAppsFilter): Promise<IAppInfo[] | undefined> {
return Apps.getManager()
?.get(query)
.map((app) => app.getApp().getInfo());
return (await Apps.getManager()?.get(query))?.map((app) => app.getInfo());
}

async getAppStorageItemById(appId: string): Promise<IAppStorageItem | undefined> {
Expand Down
52 changes: 51 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8680,6 +8680,26 @@ __metadata:
languageName: node
linkType: hard

"@rocket.chat/apps-engine@npm:deno":
version: 1.42.0-deno.485
resolution: "@rocket.chat/apps-engine@npm:1.42.0-deno.485"
dependencies:
adm-zip: ^0.5.9
cryptiles: ^4.1.3
deno-bin: 1.37.1
jose: ^4.11.1
jsonrpc-lite: ^2.2.0
lodash.clonedeep: ^4.5.0
semver: ^5.7.1
stack-trace: 0.0.10
uuid: ~8.3.2
vm2: ^3.9.19
peerDependencies:
"@rocket.chat/ui-kit": "*"
checksum: 90cdc4cd45ef0a56c12987f49df0379c79d453de3bd67f6788860bcaa24fb7e714ce95ed098a45fdf6ede6d96b05bda275cb79357f0350d9142030c2ed835d80
languageName: node
linkType: hard

"@rocket.chat/authorization-service@workspace:ee/apps/authorization-service":
version: 0.0.0-use.local
resolution: "@rocket.chat/authorization-service@workspace:ee/apps/authorization-service"
Expand Down Expand Up @@ -9450,7 +9470,7 @@ __metadata:
"@rocket.chat/account-utils": "workspace:^"
"@rocket.chat/agenda": "workspace:^"
"@rocket.chat/api-client": "workspace:^"
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": deno
"@rocket.chat/base64": "workspace:^"
"@rocket.chat/cas-validate": "workspace:^"
"@rocket.chat/core-services": "workspace:^"
Expand Down Expand Up @@ -20322,6 +20342,19 @@ __metadata:
languageName: node
linkType: hard

"deno-bin@npm:1.37.1":
version: 1.37.1
resolution: "deno-bin@npm:1.37.1"
dependencies:
adm-zip: ^0.5.4
follow-redirects: ^1.10.0
bin:
deno: bin/deno.js
deno-bin: bin/deno.js
checksum: 1c985611aa67b4b72f68b5608644af73dbff75619ac4fba67fecf036763acf76c66a9bb537cf09865c855313ceec6af1190474fa0163a616620b8af705c82736
languageName: node
linkType: hard

"depd@npm:2.0.0, depd@npm:~2.0.0":
version: 2.0.0
resolution: "depd@npm:2.0.0"
Expand Down Expand Up @@ -23103,6 +23136,16 @@ __metadata:
languageName: node
linkType: hard

"follow-redirects@npm:^1.10.0":
version: 1.15.4
resolution: "follow-redirects@npm:1.15.4"
peerDependenciesMeta:
debug:
optional: true
checksum: e178d1deff8b23d5d24ec3f7a94cde6e47d74d0dc649c35fc9857041267c12ec5d44650a0c5597ef83056ada9ea6ca0c30e7c4f97dbf07d035086be9e6a5b7b6
languageName: node
linkType: hard

"fontkit@npm:^2.0.2":
version: 2.0.2
resolution: "fontkit@npm:2.0.2"
Expand Down Expand Up @@ -27913,6 +27956,13 @@ __metadata:
languageName: node
linkType: hard

"jsonrpc-lite@npm:^2.2.0":
version: 2.2.0
resolution: "jsonrpc-lite@npm:2.2.0"
checksum: 3062101d3c93401d176c1c24b90e0feebdd063546f8ed89c299531dd792c4d37c6766666d160efb83b94f17f7e2deed4346cdd9124b99581ed4620779e8733bb
languageName: node
linkType: hard

"jsonwebtoken@npm:^8.1.0, jsonwebtoken@npm:^8.5.1":
version: 8.5.1
resolution: "jsonwebtoken@npm:8.5.1"
Expand Down
Loading