Skip to content

Commit 553a610

Browse files
authored
fix: add admin post for disableEvents/imageTransformation (#972)
1 parent cd8ad47 commit 553a610

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/http/routes/admin/tenants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ export default async function routes(fastify: FastifyInstance) {
308308
databasePoolUrl,
309309
maxConnections,
310310
tracingMode,
311+
disableEvents,
311312
} = request.body
312313

313314
await multitenantKnex.transaction(async (trx) => {
@@ -332,9 +333,14 @@ export default async function routes(fastify: FastifyInstance) {
332333
feature_vector_buckets: features?.vectorBuckets?.enabled ?? false,
333334
feature_vector_buckets_max_buckets: features?.vectorBuckets?.maxBuckets,
334335
feature_vector_buckets_max_indexes: features?.vectorBuckets?.maxIndexes,
336+
image_transformation_max_resolution:
337+
features?.imageTransformation?.maxResolution === null
338+
? null
339+
: features?.imageTransformation?.maxResolution,
335340
migrations_version: null,
336341
migrations_status: null,
337342
tracing_mode: tracingMode,
343+
disable_events: disableEvents,
338344
})
339345
await jwksManager.generateUrlSigningJwk(tenantId, trx)
340346
})

src/test/tenant.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,40 @@ describe('Tenant configs', () => {
220220
await expect(getFeatures('abc')).resolves.toEqual(payload.features)
221221
})
222222

223+
test('Create tenant config preserves disableEvents and image transformation maxResolution', async () => {
224+
const createPayload = {
225+
...payload,
226+
disableEvents: ['ObjectCreated:*', 'ObjectRemoved:*'],
227+
features: {
228+
...payload.features,
229+
imageTransformation: {
230+
...payload.features.imageTransformation,
231+
maxResolution: 1024,
232+
},
233+
},
234+
}
235+
236+
const createResponse = await adminApp.inject({
237+
method: 'POST',
238+
url: `/tenants/abc`,
239+
payload: createPayload,
240+
headers: {
241+
apikey: process.env.ADMIN_API_KEYS,
242+
},
243+
})
244+
expect(createResponse.statusCode).toBe(201)
245+
246+
const getResponse = await adminApp.inject({
247+
method: 'GET',
248+
url: `/tenants/abc`,
249+
headers: {
250+
apikey: process.env.ADMIN_API_KEYS,
251+
},
252+
})
253+
expect(getResponse.statusCode).toBe(200)
254+
expect(JSON.parse(getResponse.body)).toEqual(createPayload)
255+
})
256+
223257
test('Insert tenant config without required properties', async () => {
224258
const response = await adminApp.inject({
225259
method: 'POST',

0 commit comments

Comments
 (0)