Skip to content

Commit 5fa0bee

Browse files
committed
fix CI
1 parent 13bba40 commit 5fa0bee

File tree

8 files changed

+80
-71
lines changed

8 files changed

+80
-71
lines changed

apps/meteor/app/api/server/v1/misc.ts

+18-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
isMethodCallAnonProps,
1515
isMeteorCall,
1616
} from '@rocket.chat/rest-typings';
17+
import { IUser } from '@rocket.chat/core-typings';
1718

1819
import { hasPermission } from '../../../authorization/server';
1920
import { Users } from '../../../models/server';
@@ -166,17 +167,24 @@ API.v1.addRoute(
166167
'me',
167168
{ authRequired: true },
168169
{
169-
get() {
170+
async get() {
170171
const fields = getDefaultUserFields();
171-
const user = Users.findOneById(this.userId, { fields });
172-
173-
// The password hash shouldn't be leaked but the client may need to know if it exists.
174-
if (user?.services?.password?.bcrypt) {
175-
user.services.password.exists = true;
176-
delete user.services.password.bcrypt;
177-
}
178-
179-
return API.v1.success(this.getUserInfo(user));
172+
const { services, ...user } = Users.findOneById(this.userId, { fields }) as IUser;
173+
174+
return API.v1.success(
175+
this.getUserInfo({
176+
...user,
177+
...(services && {
178+
services: {
179+
...services,
180+
password: {
181+
// The password hash shouldn't be leaked but the client may need to know if it exists.
182+
exists: Boolean(services?.password?.bcrypt),
183+
} as any,
184+
},
185+
}),
186+
}),
187+
);
180188
},
181189
},
182190
);

apps/meteor/client/lib/meteorCallWrapper.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ function wrapMeteorDDPCalls(): void {
4949
});
5050
Meteor.connection.onMessage(_message);
5151
};
52+
const method = encodeURIComponent(message.method.replace(/\//g, ':'));
5253

53-
APIClient.post(
54-
`/v1/${endpoint}/${encodeURIComponent(message.method.replace(/\//g, ':'))}` as Parameters<typeof APIClient.post>[0],
55-
restParams as any,
56-
)
54+
APIClient.post(`/v1/${endpoint}/${method}`, restParams)
5755
.then(({ message: _message }) => {
5856
processResult(_message);
5957
if (message.method === 'login') {
60-
const parsedMessage = DDPCommon.parseDDP(_message) as { result?: { token?: string } };
58+
const parsedMessage = DDPCommon.parseDDP(_message as any) as { result?: { token?: string } };
6159
if (parsedMessage.result?.token) {
6260
Meteor.loginWithToken(parsedMessage.result.token);
6361
}

apps/meteor/client/providers/ServerProvider.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ const callEndpoint = <TMethod extends Method, TPath extends PathFor<TMethod>>(
3030
): Promise<Serialized<OperationResult<TMethod, MatchPathPattern<TPath>>>> => {
3131
switch (method) {
3232
case 'GET':
33-
return APIClient.get(path as Parameters<typeof APIClient.get>[0], params) as any;
33+
return APIClient.get(path as Parameters<typeof APIClient.get>[0], params as any | undefined) as any;
3434

3535
case 'POST':
36-
return APIClient.post(path as Parameters<typeof APIClient.post>[0], params) as ReturnType<typeof APIClient.post>;
36+
return APIClient.post(path as Parameters<typeof APIClient.post>[0], params as never) as ReturnType<typeof APIClient.post>;
3737

3838
case 'DELETE':
39-
return APIClient.delete(path as Parameters<typeof APIClient.delete>[0], params) as ReturnType<typeof APIClient.delete>;
39+
return APIClient.delete(path as Parameters<typeof APIClient.delete>[0], params as never) as ReturnType<typeof APIClient.delete>;
4040

4141
default:
4242
throw new Error('Invalid HTTP method');
4343
}
4444
};
4545

46-
const uploadToEndpoint = (endpoint: PathFor<'POST'>, formData: any): Promise<UploadResult> => APIClient.post(endpoint, formData);
46+
const uploadToEndpoint = (endpoint: PathFor<'POST'>, formData: any): Promise<UploadResult> => APIClient.post(endpoint, formData as never);
4747

4848
const getStream = (streamName: string, options: {} = {}): (<T>(eventName: string, callback: (data: T) => void) => () => void) => {
4949
const streamer = Meteor.StreamerCentral.instances[streamName]

apps/meteor/client/views/admin/apps/AppDetailsPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
44
import { useTranslation, useCurrentRoute, useRoute, useRouteParameter } from '@rocket.chat/ui-contexts';
55
import React, { useState, useCallback, useRef, FC } from 'react';
66

7-
import { ISettings, ISettingsPayload } from '../../../../app/apps/client/@types/IOrchestrator';
7+
import { ISettings } from '../../../../app/apps/client/@types/IOrchestrator';
88
import { Apps } from '../../../../app/apps/client/orchestrator';
99
import Page from '../../../components/Page';
1010
import APIsDisplay from './APIsDisplay';
@@ -49,7 +49,7 @@ const AppDetailsPage: FC<{ id: string }> = function AppDetailsPage({ id }) {
4949
(Object.values(settings || {}) as ISetting[]).map((value) => ({
5050
...value,
5151
value: current?.[value.id],
52-
})) as unknown as ISettingsPayload,
52+
})),
5353
);
5454
} catch (e) {
5555
handleAPIError(e);

apps/meteor/client/views/admin/apps/hooks/useCategories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useTranslation } from '@rocket.chat/ui-contexts';
22
import { useCallback, useEffect, useMemo, useState } from 'react';
33

4-
import { ICategory } from '../../../../../app/apps/client/@types/IOrchestrator';
54
import { Apps } from '../../../../../app/apps/client/orchestrator';
65
import { CategoryDropdownItem, CategoryDropDownListProps } from '../definitions/CategoryDropdownDefinitions';
76
import { handleAPIError } from '../helpers';
@@ -21,7 +20,7 @@ export const useCategories = (): [
2120
try {
2221
const fetchedCategories = await Apps.getCategories();
2322

24-
const mappedCategories = fetchedCategories.map((currentCategory: ICategory) => ({
23+
const mappedCategories = fetchedCategories.map((currentCategory) => ({
2524
id: currentCategory.id,
2625
label: currentCategory.title,
2726
checked: false,

packages/core-typings/src/IUser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export interface IUser extends IRocketChatRecord {
116116
status?: UserStatus;
117117
statusConnection?: string;
118118
lastLogin?: Date;
119+
bio?: string;
119120
avatarOrigin?: string;
120121
avatarETag?: string;
121122
utcOffset?: number;

packages/rest-typings/src/v1/me.ts

+42-29
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
1-
import type { IUser, Serialized } from '@rocket.chat/core-typings';
1+
import type { IUser } from '@rocket.chat/core-typings';
22

3-
type RawUserData = Serialized<
4-
Pick<
5-
IUser,
6-
| '_id'
7-
| 'type'
8-
| 'name'
9-
| 'username'
10-
| 'emails'
11-
| 'status'
12-
| 'statusDefault'
13-
| 'statusText'
14-
| 'statusConnection'
15-
| 'avatarOrigin'
16-
| 'utcOffset'
17-
| 'language'
18-
| 'settings'
19-
| 'roles'
20-
| 'active'
21-
| 'defaultRoom'
22-
| 'customFields'
23-
| 'statusLivechat'
24-
| 'oauth'
25-
| 'createdAt'
26-
| '_updatedAt'
27-
| 'avatarETag'
28-
>
29-
>;
3+
type Keys =
4+
| 'name'
5+
| 'username'
6+
| 'nickname'
7+
| 'emails'
8+
| 'status'
9+
| 'statusDefault'
10+
| 'statusText'
11+
| 'statusConnection'
12+
| 'bio'
13+
| 'avatarOrigin'
14+
| 'utcOffset'
15+
| 'language'
16+
| 'settings'
17+
| 'idleTimeLimit'
18+
| 'roles'
19+
| 'active'
20+
| 'defaultRoom'
21+
| 'customFields'
22+
| 'requirePasswordChange'
23+
| 'requirePasswordChangeReason'
24+
| 'services.github'
25+
| 'services.gitlab'
26+
| 'services.tokenpass'
27+
| 'services.password.bcrypt'
28+
| 'services.totp.enabled'
29+
| 'services.email2fa.enabled'
30+
| 'statusLivechat'
31+
| 'banners'
32+
| 'oauth.authorizedClients'
33+
| '_updatedAt'
34+
| 'avatarETag'
35+
| 'extension';
3036

3137
export type MeEndpoints = {
3238
'/v1/me': {
33-
GET: () => RawUserData;
39+
GET: (params: { fields: Record<Keys, 0> | Record<Keys, 1>; user: IUser }) => IUser & {
40+
email?: string;
41+
settings: {
42+
profile: {};
43+
preferences: unknown;
44+
};
45+
avatarUrl: string;
46+
};
3447
};
3548
};

packages/rest-typings/src/v1/misc.ts

+9-19
Original file line numberDiff line numberDiff line change
@@ -180,45 +180,35 @@ export type MiscEndpoints = {
180180
}[];
181181
};
182182
};
183-
'me': {
184-
GET: (params: { fields: { [k: string]: number }; user: IUser }) => IUser & {
185-
email?: string;
186-
settings: {
187-
profile: {};
188-
preferences: unknown;
189-
};
190-
avatarUrl: string;
191-
};
192-
};
193183

194-
'shield.svg': {
184+
'/v1/shield.svg': {
195185
GET: (params: ShieldSvg) => {
196186
svg: string;
197187
};
198188
};
199189

200-
'spotlight': {
190+
'/v1/spotlight': {
201191
GET: (params: Spotlight) => {
202192
users: Pick<IUser, 'username' | 'name' | 'status' | 'statusText' | 'avatarETag'>[];
203193
rooms: IRoom[];
204194
};
205195
};
206196

207-
'directory': {
197+
'/v1/directory': {
208198
GET: (params: Directory) => PaginatedResult<{
209199
result: (IUser | IRoom | ITeam)[];
210200
}>;
211201
};
212202

213-
'method.call': {
214-
POST: (params: MethodCall) => {
215-
result: unknown;
203+
'/v1/method.call/:method': {
204+
POST: (params: { message: string }) => {
205+
message: unknown;
216206
};
217207
};
218208

219-
'method.callAnon': {
220-
POST: (params: MethodCallAnon) => {
221-
result: unknown;
209+
'/v1/method.callAnon/:method': {
210+
POST: (params: { message: string }) => {
211+
message: unknown;
222212
};
223213
};
224214
};

0 commit comments

Comments
 (0)