Skip to content

Commit

Permalink
Merge branch 'develop' into feat/single-contact-id
Browse files Browse the repository at this point in the history
  • Loading branch information
tapiarafael authored Oct 17, 2024
2 parents 8ef5eee + f63d8e2 commit 8e83b07
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 24 deletions.
1 change: 1 addition & 0 deletions apps/meteor/app/api/server/helpers/parseJsonQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export async function parseJsonQuery(api: PartialThis): Promise<{
'/api/v1/integrations.list',
'/api/v1/custom-user-status.list',
'/api/v1/custom-sounds.list',
'/api/v1/channels.list',
].includes(route);

const isUnsafeQueryParamsAllowed = process.env.ALLOW_UNSAFE_QUERY_AND_FIELDS_API_PARAMS?.toUpperCase() === 'TRUE';
Expand Down
10 changes: 9 additions & 1 deletion apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
isChannelsConvertToTeamProps,
isChannelsSetReadOnlyProps,
isChannelsDeleteProps,
isChannelsListProps,
isChannelsFilesListProps,
} from '@rocket.chat/rest-typings';
import { Meteor } from 'meteor/meteor';
Expand Down Expand Up @@ -929,14 +930,21 @@ API.v1.addRoute(
permissionsRequired: {
GET: { permissions: ['view-c-room', 'view-joined-room'], operation: 'hasAny' },
},
validateParams: isChannelsListProps,
},
{
async get() {
const { offset, count } = await getPaginationItems(this.queryParams);
const { sort, fields, query } = await this.parseJsonQuery();
const hasPermissionToSeeAllPublicChannels = await hasPermissionAsync(this.userId, 'view-c-room');

const ourQuery: Record<string, any> = { ...query, t: 'c' };
const { _id } = this.queryParams;

const ourQuery = {
...query,
...(_id ? { _id } : {}),
t: 'c',
};

if (!hasPermissionToSeeAllPublicChannels) {
const roomIds = (
Expand Down
13 changes: 7 additions & 6 deletions apps/meteor/client/providers/AppsProvider/AppsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useDebouncedCallback } from '@rocket.chat/fuselage-hooks';
import { usePermission, useStream } from '@rocket.chat/ui-contexts';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import type { ReactNode } from 'react';
import React, { useEffect, useState } from 'react';
import React, { useEffect } from 'react';

import { AppClientOrchestratorInstance } from '../../apps/orchestrator';
import { AppsContext } from '../../contexts/AppsContext';
Expand Down Expand Up @@ -47,8 +47,6 @@ const AppsProvider = ({ children }: AppsProviderProps) => {
const { isLoading: isLicenseInformationLoading, data: { license, limits } = {} } = useLicense({ loadValues: true });
const isEnterprise = isLicenseInformationLoading ? undefined : !!license;

const [marketplaceError, setMarketplaceError] = useState<Error>();

const invalidateAppsCountQuery = useInvalidateAppsCountQueryCallback();
const invalidateLicenseQuery = useInvalidateLicense();

Expand Down Expand Up @@ -80,8 +78,7 @@ const AppsProvider = ({ children }: AppsProviderProps) => {
const result = await AppClientOrchestratorInstance.getAppsFromMarketplace(isAdminUser);
queryClient.invalidateQueries(['marketplace', 'apps-stored']);
if (result.error && typeof result.error === 'string') {
setMarketplaceError(new Error(result.error));
return [];
throw new Error(result.error);
}
return result.apps;
},
Expand Down Expand Up @@ -125,7 +122,11 @@ const AppsProvider = ({ children }: AppsProviderProps) => {
children={children}
value={{
installedApps: getAppState(isMarketplaceDataLoading, installedAppsData),
marketplaceApps: getAppState(isMarketplaceDataLoading, marketplaceAppsData, marketplaceError),
marketplaceApps: getAppState(
isMarketplaceDataLoading,
marketplaceAppsData,
marketplace.error instanceof Error ? marketplace.error : undefined,
),
privateApps: getAppState(isMarketplaceDataLoading, privateAppsData),

reload: async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const MarketplaceHeader = ({ title, unsupportedVersion }: { title: string; unsup
<PageHeader title={title}>
{result.isLoading && <GenericResourceUsageSkeleton mi={16} />}

{result.isSuccess && !result.data.hasUnlimitedApps && (
{!unsupportedVersion && result.isSuccess && !result.data.hasUnlimitedApps && (
<Margins inline={16}>
<EnabledAppsCount
{...result.data}
Expand All @@ -56,10 +56,6 @@ const MarketplaceHeader = ({ title, unsupportedVersion }: { title: string; unsup
)}

<ButtonGroup wrap align='end'>
{!unsupportedVersion && result.isSuccess && !result.data.hasUnlimitedApps && (
<EnabledAppsCount {...result.data} context={context} />
)}

{!unsupportedVersion && isAdmin && result.isSuccess && !result.data.hasUnlimitedApps && context !== 'private' && (
<Button
onClick={() => {
Expand All @@ -71,7 +67,7 @@ const MarketplaceHeader = ({ title, unsupportedVersion }: { title: string; unsup
)}

{isAdmin && context === 'private' && <Button onClick={handleClickPrivate}>{t('Upload_private_app')}</Button>}
{isAdmin && result.isSuccess && !privateAppsEnabled && context === 'private' && <UpdateRocketChatButton />}
{unsupportedVersion && isAdmin && context !== 'private' && <UpdateRocketChatButton />}
</ButtonGroup>
</PageHeader>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/apps/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class AppServerOrchestrator {
continue;
}

await this.getManager().loadOne(app.getID());
await this.getManager().loadOne(app.getID(), true);
}
/* eslint-enable no-await-in-loop */

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/apps/storage/AppRealStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AppRealStorage extends AppMetadataStorage {
}

public async update(item: IAppStorageItem): Promise<IAppStorageItem> {
await this.db.updateOne({ id: item.id }, { $set: item });
await this.db.updateOne({ id: item.id, _id: item._id }, { $set: item });
return this.retrieveOne(item.id);
}

Expand Down
4 changes: 1 addition & 3 deletions apps/meteor/tests/end-to-end/api/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,7 @@ describe('[Channels]', () => {
.get(api('channels.list'))
.set(credentials)
.query({
query: JSON.stringify({
_id: testChannel._id,
}),
_id: testChannel._id,
})
.expect('Content-Type', 'application/json')
.expect(200)
Expand Down
2 changes: 2 additions & 0 deletions ee/packages/license/src/v2/bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const bundles: IBundle = {
'custom-roles',
'accessibility-certification',
'unlimited-presence',
'contact-id-verification',
'teams-voip',
],
pro: [],
};
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/license/src/v2/convertToV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const convertToV3 = (v2: ILicenseV2): ILicenseV3 => {
},
grantedModules: [
...new Set(
['hide-watermark', ...v2.modules]
['teams-voip', 'contact-id-verification', 'hide-watermark', ...v2.modules]
.map((licenseModule) => (isBundle(licenseModule) ? getBundleModules(licenseModule) : [licenseModule]))
.reduce((prev, curr) => [...prev, ...curr], [])
.map((licenseModule) => ({ module: licenseModule as LicenseModule })),
Expand Down
6 changes: 3 additions & 3 deletions packages/apps-engine/src/server/AppManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ export class AppManager {
*
* @param appId the id of the application to load
*/
public async loadOne(appId: string): Promise<ProxiedApp> {
public async loadOne(appId: string, silenceStatus = false): Promise<ProxiedApp> {
const rl = this.apps.get(appId);

if (!rl) {
Expand All @@ -941,14 +941,14 @@ export class AppManager {

const item = rl.getStorageItem();

await this.initializeApp(item, rl, false);
await this.initializeApp(item, rl, false, silenceStatus);

if (!this.areRequiredSettingsSet(item)) {
await rl.setStatus(AppStatus.INVALID_SETTINGS_DISABLED);
}

if (!AppStatusUtils.isDisabled(await rl.getStatus()) && AppStatusUtils.isEnabled(rl.getPreviousStatus())) {
await this.enableApp(item, rl, false, rl.getPreviousStatus() === AppStatus.MANUALLY_ENABLED);
await this.enableApp(item, rl, false, rl.getPreviousStatus() === AppStatus.MANUALLY_ENABLED, silenceStatus);
}

return this.apps.get(item.id);
Expand Down
3 changes: 2 additions & 1 deletion packages/core-typings/src/license/LicenseModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export type LicenseModule =
| 'custom-roles'
| 'accessibility-certification'
| 'unlimited-presence'
| 'contact-id-verification';
| 'contact-id-verification'
| 'teams-voip';
6 changes: 5 additions & 1 deletion packages/rest-typings/src/v1/channels/ChannelsListProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ const ajv = new Ajv({
coerceTypes: true,
});

export type ChannelsListProps = PaginatedRequest<{ query?: string }>;
export type ChannelsListProps = PaginatedRequest<{ _id?: string; query?: string }>;

const channelsListPropsSchema = {
type: 'object',
properties: {
_id: {
type: 'string',
nullable: true,
},
query: {
type: 'string',
nullable: true,
Expand Down
1 change: 1 addition & 0 deletions packages/rest-typings/src/v1/channels/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type { ChannelsSetTypeProps } from './ChannelsSetTypeProps';
import type { ChannelsUnarchiveProps } from './ChannelsUnarchiveProps';

export * from './ChannelsFilesListProps';
export * from './ChannelsListProps';

export type ChannelsEndpoints = {
'/v1/channels.files': {
Expand Down

0 comments on commit 8e83b07

Please sign in to comment.