All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m2s
35 lines
940 B
TypeScript
35 lines
940 B
TypeScript
/**
|
|
* GET /api/debug/blocklist
|
|
* Fetch the blocklist for an instance
|
|
*/
|
|
import { baileysManager } from '../../../services/baileys/manager'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const username = getHeader(event, 'x-authentik-username')
|
|
if (!username) {
|
|
throw createError({ statusCode: 401, message: 'Unauthorized' })
|
|
}
|
|
|
|
const query = getQuery(event)
|
|
const instanceId = query.instanceId as string
|
|
|
|
if (!instanceId) {
|
|
throw createError({ statusCode: 400, message: 'instanceId is required' })
|
|
}
|
|
|
|
const socket = baileysManager.getSocket(instanceId)
|
|
if (!socket) {
|
|
throw createError({ statusCode: 400, message: 'Instance not connected' })
|
|
}
|
|
|
|
try {
|
|
const result = await socket.fetchBlocklist()
|
|
return { success: true, data: result }
|
|
} catch (error) {
|
|
throw createError({
|
|
statusCode: 500,
|
|
message: `Failed to fetch blocklist: ${(error as Error).message}`
|
|
})
|
|
}
|
|
})
|