Skip to content

Commit bb7cf7d

Browse files
committed
refactor uikit endpoint
1 parent cf1e3d8 commit bb7cf7d

File tree

1 file changed

+7
-9
lines changed
  • apps/meteor/ee/server/apps/communication

1 file changed

+7
-9
lines changed

apps/meteor/ee/server/apps/communication/uikit.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,20 @@ export class AppUIKitInteractionApi {
203203
constructor(orch: IAppServerOrchestrator) {
204204
this.orch = orch;
205205

206-
router.post('/:id', this.routeHandler);
206+
router.post('/:id', this.routeHandler.bind(this));
207207
}
208208

209-
private routeHandler = async (
209+
private async routeHandler(
210210
req: UiKitUserInteractionRequest,
211211
res: Response<OperationResult<'POST', '/apps/ui.interaction/:id'> | { error: unknown }>,
212-
): Promise<void> => {
212+
): Promise<void> {
213213
const { orch } = this;
214214
const { id: appId } = req.params;
215215

216216
switch (req.body.type) {
217217
case 'blockAction': {
218-
const { type, actionId, triggerId, payload, container } = req.body;
218+
const { type, actionId, triggerId, payload, container, rid } = req.body;
219219
const mid = 'mid' in req.body ? req.body.mid : undefined;
220-
const rid = 'rid' in req.body ? req.body.rid : undefined;
221220

222221
const { visitor } = req.body;
223222
const user = orch.getConverters()?.get('users').convertToApp(req.user);
@@ -253,9 +252,9 @@ export class AppUIKitInteractionApi {
253252
case 'viewClosed': {
254253
const {
255254
type,
255+
rid,
256256
payload: { view, isCleared },
257257
} = req.body;
258-
const rid = 'rid' in req.body ? req.body.rid : undefined;
259258

260259
const user = orch.getConverters()?.get('users').convertToApp(req.user);
261260
const room = rid ? await orch.getConverters()?.get('rooms').convertById(rid) : undefined;
@@ -283,8 +282,7 @@ export class AppUIKitInteractionApi {
283282
}
284283

285284
case 'viewSubmit': {
286-
const { type, actionId, triggerId, payload } = req.body;
287-
const rid = 'rid' in req.body ? req.body.rid : undefined;
285+
const { type, actionId, triggerId, payload, rid } = req.body;
288286

289287
const user = orch.getConverters()?.get('users').convertToApp(req.user);
290288
const room = rid ? await orch.getConverters()?.get('rooms').convertById(rid) : undefined;
@@ -357,5 +355,5 @@ export class AppUIKitInteractionApi {
357355
}
358356

359357
// TODO: validate payloads per type
360-
};
358+
}
361359
}

0 commit comments

Comments
 (0)