@@ -4,15 +4,13 @@ import {
44 OrganizationInvitations ,
55 organizationInvitationEntityGuard ,
66} from '@logto/schemas' ;
7- import { isObject } from '@silverhand/essentials' ;
87import { z } from 'zod' ;
98
109import RequestError from '#src/errors/RequestError/index.js' ;
1110import koaGuard from '#src/middleware/koa-guard.js' ;
1211import SchemaRouter from '#src/utils/SchemaRouter.js' ;
1312import assertThat from '#src/utils/assert-that.js' ;
1413
15- import koaEmailI18n from '../../middleware/koa-email-i18n.js' ;
1614import { errorHandler } from '../organization/utils.js' ;
1715import { type ManagementApiRouter , type RouterInitArgs } from '../types.js' ;
1816
@@ -96,22 +94,11 @@ export default function organizationInvitationRoutes<T extends ManagementApiRout
9694 body : sendMessagePayloadGuard ,
9795 status : [ 204 ] ,
9896 } ) ,
99- koaEmailI18n ( queries ) ,
10097 async ( ctx , next ) => {
10198 const {
10299 params : { id } ,
103100 body,
104101 } = ctx . guard ;
105- // The `koaEmailI18n` properties are not available in the `SchemaRouter` context.
106- // So we have to assert its existence here to make TypeScript happy.
107- assertThat (
108- 'emailI18n' in ctx && isObject ( ctx . emailI18n ) ,
109- new RequestError ( {
110- status : 422 ,
111- code : 'request.invalid_input' ,
112- details : 'The email i18n context is missing.' ,
113- } )
114- ) ;
115102 const { invitee, organizationId, inviterId } = await invitations . findById ( id ) ;
116103
117104 const templateContext =
@@ -121,7 +108,6 @@ export default function organizationInvitationRoutes<T extends ManagementApiRout
121108 ) ;
122109
123110 await organizationInvitations . sendEmail ( invitee , {
124- ...ctx . emailI18n ,
125111 ...templateContext ,
126112 ...body ,
127113 } ) ;
0 commit comments