Skip to content

Commit 81fa5fa

Browse files
chore: migrate e2e.acceptSuggestedGroupKey endpoint to chained API pattern with AJV validation
1 parent aa37226 commit 81fa5fa

File tree

2 files changed

+26
-20
lines changed
  • apps/meteor/app/api/server/v1
  • packages/rest-typings/src/v1

2 files changed

+26
-20
lines changed

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,30 @@ const e2eEndpoints = API.v1.post(
7575

7676
return API.v1.success();
7777
},
78-
);
78+
)
79+
.post(
80+
'e2e.acceptSuggestedGroupKey',
81+
{
82+
authRequired: true,
83+
body: ise2eGetUsersOfRoomWithoutKeyParamsGET,
84+
response: {
85+
200: ajv.compile<void>({
86+
type: 'object',
87+
properties: {
88+
success: { type: 'boolean', enum: [true] },
89+
},
90+
required: ['success'],
91+
}),
92+
},
93+
},
94+
async function action() {
95+
const { rid } = this.bodyParams;
96+
97+
await handleSuggestedGroupKey('accept', rid, this.userId, 'e2e.acceptSuggestedGroupKey');
98+
99+
return API.v1.success();
100+
},
101+
);
79102

80103
API.v1.addRoute(
81104
'e2e.fetchMyKeys',
@@ -213,22 +236,7 @@ API.v1.addRoute(
213236
},
214237
);
215238

216-
API.v1.addRoute(
217-
'e2e.acceptSuggestedGroupKey',
218-
{
219-
authRequired: true,
220-
validateParams: ise2eGetUsersOfRoomWithoutKeyParamsGET,
221-
},
222-
{
223-
async post() {
224-
const { rid } = this.bodyParams;
225-
226-
await handleSuggestedGroupKey('accept', rid, this.userId, 'e2e.acceptSuggestedGroupKey');
227239

228-
return API.v1.success();
229-
},
230-
},
231-
);
232240

233241
API.v1.addRoute(
234242
'e2e.rejectSuggestedGroupKey',
@@ -327,5 +335,5 @@ export type E2eEndpoints = ExtractRoutesFromAPI<typeof e2eEndpoints>;
327335

328336
declare module '@rocket.chat/rest-typings' {
329337
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
330-
interface Endpoints extends E2eEndpoints {}
338+
interface Endpoints extends E2eEndpoints { }
331339
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ export type E2eEndpoints = {
160160
'/v1/e2e.updateGroupKey': {
161161
POST: (params: E2eUpdateGroupKeyProps) => void;
162162
};
163-
'/v1/e2e.acceptSuggestedGroupKey': {
164-
POST: (params: E2eGetUsersOfRoomWithoutKeyProps) => void;
165-
};
163+
166164
'/v1/e2e.rejectSuggestedGroupKey': {
167165
POST: (params: E2eGetUsersOfRoomWithoutKeyProps) => void;
168166
};

0 commit comments

Comments
 (0)