Skip to content

Commit 5b40fe6

Browse files
chore: migrate e2e.acceptSuggestedGroupKey endpoint to chained API pattern with AJV validation
1 parent 3c30636 commit 5b40fe6

File tree

2 files changed

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

2 files changed

+24
-19
lines changed

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

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,29 @@ const e2eEndpoints = API.v1
212212

213213
await updateGroupKey(rid, uid, key, this.userId);
214214

215+
return API.v1.success();
216+
},
217+
)
218+
.post(
219+
'e2e.acceptSuggestedGroupKey',
220+
{
221+
authRequired: true,
222+
body: ise2eGetUsersOfRoomWithoutKeyParamsGET,
223+
response: {
224+
200: ajv.compile<void>({
225+
type: 'object',
226+
properties: {
227+
success: { type: 'boolean', enum: [true] },
228+
},
229+
required: ['success'],
230+
}),
231+
},
232+
},
233+
async function action() {
234+
const { rid } = this.bodyParams;
235+
236+
await handleSuggestedGroupKey('accept', rid, this.userId, 'e2e.acceptSuggestedGroupKey');
237+
215238
return API.v1.success();
216239
},
217240
);
@@ -271,22 +294,7 @@ API.v1.addRoute(
271294
},
272295
);
273296

274-
API.v1.addRoute(
275-
'e2e.acceptSuggestedGroupKey',
276-
{
277-
authRequired: true,
278-
validateParams: ise2eGetUsersOfRoomWithoutKeyParamsGET,
279-
},
280-
{
281-
async post() {
282-
const { rid } = this.bodyParams;
283-
284-
await handleSuggestedGroupKey('accept', rid, this.userId, 'e2e.acceptSuggestedGroupKey');
285297

286-
return API.v1.success();
287-
},
288-
},
289-
);
290298

291299
API.v1.addRoute(
292300
'e2e.rejectSuggestedGroupKey',
@@ -385,5 +393,5 @@ export type E2eEndpoints = ExtractRoutesFromAPI<typeof e2eEndpoints>;
385393

386394
declare module '@rocket.chat/rest-typings' {
387395
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
388-
interface Endpoints extends E2eEndpoints {}
396+
interface Endpoints extends E2eEndpoints { }
389397
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ export type E2eEndpoints = {
124124
'/v1/e2e.setUserPublicAndPrivateKeys': {
125125
POST: (params: E2eSetUserPublicAndPrivateKeysProps) => void;
126126
};
127-
'/v1/e2e.acceptSuggestedGroupKey': {
128-
POST: (params: E2eGetUsersOfRoomWithoutKeyProps) => void;
129-
};
130127
'/v1/e2e.rejectSuggestedGroupKey': {
131128
POST: (params: E2eGetUsersOfRoomWithoutKeyProps) => void;
132129
};

0 commit comments

Comments
 (0)