Skip to content
Open
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
3 changes: 1 addition & 2 deletions apps/meteor/app/apps/server/bridges/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ export class AppCommandsBridge extends CommandBridge {
providesPreview: command.providesPreview,
previewer: command.providesPreview ? this._appCommandPreviewer.bind(this) : undefined,
previewCallback: (command.providesPreview ? this._appCommandPreviewExecutor.bind(this) : undefined) as
| (typeof slashCommands.commands)[string]['previewCallback']
| undefined,
(typeof slashCommands.commands)[string]['previewCallback'] | undefined,
} as SlashCommand;

slashCommands.commands[command.command.toLowerCase()] = item;
Expand Down
7 changes: 1 addition & 6 deletions apps/meteor/app/apps/server/bridges/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,7 @@ type HandleFileUploadEvent = {
};

export type HandleEvent =
| HandleMessageEvent
| HandleRoomEvent
| HandleLivechatEvent
| HandleUserEvent
| HandleFileUploadEvent
| HandleDefaultEvent;
HandleMessageEvent | HandleRoomEvent | HandleLivechatEvent | HandleUserEvent | HandleFileUploadEvent | HandleDefaultEvent;

export class AppListenerBridge {
constructor(private readonly orch: IAppServerOrchestrator) {}
Expand Down
12 changes: 5 additions & 7 deletions apps/meteor/client/apps/RealAppsEngineUIHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ export class RealAppsEngineUIHost extends AppsEngineUIHost {
try {
const { members } = await sdk.rest.get('/v1/groups.members', { roomId: id });

cachedMembers = members.map(
({ _id, username }): IExternalComponentUserInfo => ({
id: _id,
username: username!,
avatarUrl: this.getUserAvatarUrl(username!),
}),
);
cachedMembers = members.map(({ _id, username }): IExternalComponentUserInfo => ({
id: _id,
username: username!,
avatarUrl: this.getUserAvatarUrl(username!),
}));
} catch (error) {
console.warn(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export type AttachmentsProps = {

const Attachments = ({ attachments, id, source }: AttachmentsProps) => {
return (
<>{attachments?.map((attachment, index) => <AttachmentsItem key={index} id={id} attachment={{ ...attachment }} source={source} />)}</>
<>
{attachments?.map((attachment, index) => (
<AttachmentsItem key={index} id={id} attachment={{ ...attachment }} source={source} />
))}
</>
);
};

Expand Down
12 changes: 5 additions & 7 deletions apps/meteor/client/hooks/useRoomRolesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ export const useRoomRolesQuery = <TData = RoomRoles[]>(rid: IRoom['_id'], option
rid,
});

return roles.map(
(record): RoomRoles => ({
rid: record.rid,
u: record.u,
roles: record.roles ?? [],
}),
);
return roles.map((record): RoomRoles => ({
rid: record.rid,
u: record.u,
roles: record.roles ?? [],
}));
},
staleTime: Infinity,
...options,
Expand Down
10 changes: 4 additions & 6 deletions apps/meteor/client/hooks/useUserRolesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ export const useUserRolesQuery = <TData = UserRoles[]>(options?: UseUserRolesQue
queryFn: async () => {
const { users } = await getUserRoles();

return users.map(
(record): UserRoles => ({
uid: record._id,
roles: record.roles,
}),
);
return users.map((record): UserRoles => ({
uid: record._id,
roles: record.roles,
}));
},
staleTime: Infinity,
...options,
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/client/lib/2fa/process2faReturn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ function assertModalProps(props: {
method: TwoFactorMethod;
emailOrUsername?: string;
}): asserts props is
| { method: 'totp' | 'password'; invalidAttempt?: boolean }
| { method: 'email'; emailOrUsername: string; invalidAttempt?: boolean } {
{ method: 'totp' | 'password'; invalidAttempt?: boolean } | { method: 'email'; emailOrUsername: string; invalidAttempt?: boolean } {
if (props.method === 'email' && typeof props.emailOrUsername !== 'string') {
throw new Error('Invalid Two Factor method');
}
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/client/lib/createRouteGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ type GroupPrefix<TGroupName extends GroupName> = IRouterPaths[`${TGroupName}-ind

type RouteNamesOf<TGroupName extends GroupName> = (
| keyof {
[TRouteName in RouteName as IRouterPaths[TRouteName]['pattern'] extends `${GroupPrefix<TGroupName>}/${string}`
? TRouteName
: never]: never;
[
TRouteName in RouteName as IRouterPaths[TRouteName]['pattern'] extends `${GroupPrefix<TGroupName>}/${string}` ? TRouteName : never
]: never;
}
| `${GroupName}-index`
) &
Expand Down
9 changes: 1 addition & 8 deletions apps/meteor/client/lib/e2ee/E2ERoomState.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
export type E2ERoomState =
| 'NOT_STARTED'
| 'DISABLED'
| 'ESTABLISHING'
| 'CREATING_KEYS'
| 'WAITING_KEYS'
| 'KEYS_RECEIVED'
| 'READY'
| 'ERROR';
'NOT_STARTED' | 'DISABLED' | 'ESTABLISHING' | 'CREATING_KEYS' | 'WAITING_KEYS' | 'KEYS_RECEIVED' | 'READY' | 'ERROR';
6 changes: 3 additions & 3 deletions apps/meteor/client/lib/e2ee/crypto/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export const encryptBuffer = <TKey extends IKey, TParams extends ParamsOf<TKey>>
key: HasUsage<TKey, 'encrypt'>,
params: TParams,
data: BufferSource,
): Promise<ArrayBuffer> => subtle.encrypt(params, key, data) as Promise<ArrayBuffer>;
): Promise<ArrayBuffer> => subtle.encrypt(params, key, data);
export const decryptBuffer = <TKey extends IKey>(
key: HasUsage<TKey, 'decrypt'>,
params: ParamsOf<TKey>,
data: BufferSource,
): Promise<ArrayBuffer> => subtle.decrypt(params, key, data) as Promise<ArrayBuffer>;
): Promise<ArrayBuffer> => subtle.decrypt(params, key, data);
export const deriveBits = (...args: Parameters<typeof subtle.deriveBits>) => subtle.deriveBits(...args);

type AesParams = {
Expand Down Expand Up @@ -163,7 +163,7 @@ type KtyParams = {

export async function importJwk<
const TKeyData extends JsonWebKey,
const TAlgorithm extends TKeyData extends { kty: infer Kty extends keyof KtyParams } ? KtyParams[Kty] : KeyAlgorithm,
const TAlgorithm extends (TKeyData extends { kty: infer Kty extends keyof KtyParams } ? KtyParams[Kty] : KeyAlgorithm),
const TExtractable extends boolean = boolean,
const TUsages extends KeyUsage[] = KeyUsage[],
const TKeyType extends KeyType = TKeyData extends { kty: 'oct' }
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/lib/errors/NotSubscribedToRoomError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { RocketChatError } from './RocketChatError';
type NotSubscribedToRoomErrorDetails = { rid: IRoom['_id'] };

export class NotSubscribedToRoomError extends RocketChatError<'not-subscribed-room', NotSubscribedToRoomErrorDetails> {
public declare readonly reason: string;
declare public readonly reason: string;

public declare readonly details: NotSubscribedToRoomErrorDetails;
declare public readonly details: NotSubscribedToRoomErrorDetails;

constructor(message = 'Not subscribed to this room', details: NotSubscribedToRoomErrorDetails) {
super('not-subscribed-room', message, details);
Expand Down
9 changes: 3 additions & 6 deletions apps/meteor/client/meteor/minimongo/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@ interface BaseQuery<T extends { _id: string }, TOptions extends Options<T> = Opt
}

export interface UnorderedQuery<T extends { _id: string }, TOptions extends Options<T> = Options<T>>
extends BaseQuery<T, TOptions>,
UnorderedObserver<T> {
extends BaseQuery<T, TOptions>, UnorderedObserver<T> {
readonly ordered: false;
readonly comparator: null;
results: IdMap<T['_id'], T>;
resultsSnapshot: IdMap<T['_id'], T> | null;
}

export interface OrderedQuery<T extends { _id: string }, TOptions extends Options<T> = Options<T>>
extends BaseQuery<T, TOptions>,
OrderedObserver<T> {
extends BaseQuery<T, TOptions>, OrderedObserver<T> {
readonly ordered: true;
readonly comparator: ((a: T, b: T) => number) | null;
results: T[];
resultsSnapshot: T[] | null;
}

export type Query<T extends { _id: string }, TOptions extends Options<T> = Options<T>> =
| UnorderedQuery<T, TOptions>
| OrderedQuery<T, TOptions>;
UnorderedQuery<T, TOptions> | OrderedQuery<T, TOptions>;
Original file line number Diff line number Diff line change
Expand Up @@ -134,29 +134,25 @@ export const useStatusItems = (user?: IUser): GenericMenuItemProps[] => {
!user?.statusText && !customStatusExpiration && user?.status === statusType;
const presetItems = (statuses ?? [])
.filter((s) => userStatuses.isValidType(s.id))
.map(
(status): GenericMenuItemProps => ({
id: status.id,
status: <UserStatus status={status.statusType} />,
content: <MarkdownText content={status.localizeName ? t(status.name) : status.name} parseEmoji variant='inline' />,
addon: <RadioButton checked={isPresetSelected(status.statusType)} readOnly />,
onClick: () => setStatusMutation.mutate(status),
}),
);
.map((status): GenericMenuItemProps => ({
id: status.id,
status: <UserStatus status={status.statusType} />,
content: <MarkdownText content={status.localizeName ? t(status.name) : status.name} parseEmoji variant='inline' />,
addon: <RadioButton checked={isPresetSelected(status.statusType)} readOnly />,
onClick: () => setStatusMutation.mutate(status),
}));

// Admin-defined custom statuses
const customItems = allowUserStatusMessageChange
? (statuses ?? [])
.filter((s) => !userStatuses.isValidType(s.id))
.map(
(status): GenericMenuItemProps => ({
id: status.id,
status: <UserStatus status={status.statusType} />,
content: <MarkdownText content={status.localizeName ? t(status.name) : status.name} parseEmoji variant='inline' />,
addon: <RadioButton checked={user?.statusText === status.name} readOnly />,
onClick: () => setStatusMutation.mutate(status),
}),
)
.map((status): GenericMenuItemProps => ({
id: status.id,
status: <UserStatus status={status.statusType} />,
content: <MarkdownText content={status.localizeName ? t(status.name) : status.name} parseEmoji variant='inline' />,
addon: <RadioButton checked={user?.statusText === status.name} readOnly />,
onClick: () => setStatusMutation.mutate(status),
}))
: [];

return [...items, ...presetItems, ...customItems];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ const AuthenticationProvider = ({ children }: AuthenticationProviderProps) => {
loginWithCustomOauth: (service: string, options: { redirectUrl: string }, callback) => {
const methodName = `loginWith${capitalizeService(service, true)}`;
const method = (Meteor as any)[methodName] as
| ((options: { redirectUrl: string }, cb?: (response: unknown) => void) => void)
| undefined;
((options: { redirectUrl: string }, cb?: (response: unknown) => void) => void) | undefined;
if (!method) {
return;
}
Expand Down
32 changes: 17 additions & 15 deletions apps/meteor/client/stories/contexts/ServerContextMock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,24 @@ const getStream = (
};

type Operations = {
[TOperation in Method extends infer TMethod
? TMethod extends Method
? PathPattern extends infer TPathPattern
? TPathPattern extends PathPattern
? {
id: `${TMethod} ${TPathPattern extends `/${string}` ? TPathPattern : `/v1/${TPathPattern}`}`;
fn: (
params: void extends OperationParams<TMethod, TPathPattern> ? void : OperationParams<TMethod, TPathPattern>,
) => Promise<void extends OperationResult<TMethod, TPathPattern> ? Serialized<OperationResult<TMethod, TPathPattern>> : void>;
}
[
TOperation in Method extends infer TMethod
? TMethod extends Method
? PathPattern extends infer TPathPattern
? TPathPattern extends PathPattern
? {
id: `${TMethod} ${TPathPattern extends `/${string}` ? TPathPattern : `/v1/${TPathPattern}`}`;
fn: (
params: void extends OperationParams<TMethod, TPathPattern> ? void : OperationParams<TMethod, TPathPattern>,
) => Promise<
void extends OperationResult<TMethod, TPathPattern> ? Serialized<OperationResult<TMethod, TPathPattern>> : void
>;
}
: never
: never
: never
: never
: never as TOperation['id']]: TOperation['fn'];
: never as TOperation['id']
]: TOperation['fn'];
};

export type ServerContextMockProps = Omit<Partial<ContextType<typeof ServerContext>>, 'callEndpoint' | 'callMethod'> & {
Expand All @@ -60,9 +64,7 @@ export type ServerContextMockProps = Omit<Partial<ContextType<typeof ServerConte
};
callMethod?: {
[TMethodName in ServerMethodName]?:
| ((...args: ServerMethodParameters<TMethodName>) => Promise<ServerMethodReturn<TMethodName>>)
| 'infinite'
| 'errored';
((...args: ServerMethodParameters<TMethodName>) => Promise<ServerMethodReturn<TMethodName>>) | 'infinite' | 'errored';
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ const CustomUserStatus = ({ reload, onClick }: CustomUserStatusProps) => {
</GenericTableHeader>
<GenericTableBody>
{isLoading && <GenericTableLoadingTable headerCells={2} />}
{data?.map((status) => <CustomUserStatusRow key={status._id} status={status} onClick={onClick} />)}
{data?.map((status) => (
<CustomUserStatusRow key={status._id} status={status} onClick={onClick} />
))}
</GenericTableBody>
</GenericTable>
{isFetched && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ function ImportHistoryPage() {
{latestOperations.data
.filter(({ _id }) => !currentOperation.data.valid || currentOperation.data._id !== _id)
// Forcing valid=false as the current API only accept preparation/progress over currentOperation
?.map((operation) => <ImportOperationSummary key={operation._id} {...operation} valid={false} small={small} />)}
?.map((operation) => (
<ImportOperationSummary key={operation._id} {...operation} valid={false} small={small} />
))}
</>
)}
</TableBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ const PermissionsTable = ({ roleList, permissions, setFilter, total, paginationD
<GenericTable className={[tableCustomStyle]} fixed={false}>
<GenericTableHeader>
<GenericTableHeaderCell width='x120'>{t('Name')}</GenericTableHeaderCell>
{roleList?.map(({ _id, name, description }) => <RoleHeader key={_id} _id={_id} name={name} description={description} />)}
{roleList?.map(({ _id, name, description }) => (
<RoleHeader key={_id} _id={_id} name={name} description={description} />
))}
</GenericTableHeader>
<GenericTableBody>
{permissions.map((permission) => (
Expand Down
13 changes: 6 additions & 7 deletions apps/meteor/client/views/admin/rooms/RoomsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ const RoomsTable = ({ reload }: { reload: MutableRefObject<() => void> }) => {
count: itemsPerPage,
offset: searchText === prevRoomFilterText.current ? current : 0,
types: (roomFilters.types.length ? [...roomFilters.types.map((roomType) => roomType.id)] : DEFAULT_TYPES) as unknown as (
| 'c'
| 'd'
| 'p'
| 'l'
| 'discussions'
| 'teams'
'c' | 'd' | 'p' | 'l' | 'discussions' | 'teams'
)[],
};
}, [searchText, sortBy, sortDirection, itemsPerPage, current, roomFilters.types, setCurrent]),
Expand Down Expand Up @@ -151,7 +146,11 @@ const RoomsTable = ({ reload }: { reload: MutableRefObject<() => void> }) => {
<>
<GenericTable>
<GenericTableHeader>{headers}</GenericTableHeader>
<GenericTableBody>{data.rooms?.map((room) => <RoomRow key={room._id} room={room} />)}</GenericTableBody>
<GenericTableBody>
{data.rooms?.map((room) => (
<RoomRow key={room._id} room={room} />
))}
</GenericTableBody>
</GenericTable>
<Pagination
divider
Expand Down
Loading
Loading