Fix: Checkboxes de eventos en formulario de webhook
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m2s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m2s
This commit is contained in:
34
server/api/debug/blocklist/index.get.ts
Normal file
34
server/api/debug/blocklist/index.get.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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}`
|
||||
})
|
||||
}
|
||||
})
|
||||
42
server/api/debug/blocklist/update.post.ts
Normal file
42
server/api/debug/blocklist/update.post.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* POST /api/debug/blocklist/update
|
||||
* Block or unblock a JID
|
||||
*/
|
||||
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 body = await readBody(event)
|
||||
const { instanceId, jid, action } = body
|
||||
|
||||
if (!instanceId) {
|
||||
throw createError({ statusCode: 400, message: 'instanceId is required' })
|
||||
}
|
||||
|
||||
if (!jid) {
|
||||
throw createError({ statusCode: 400, message: 'jid is required' })
|
||||
}
|
||||
|
||||
if (!action || !['block', 'unblock'].includes(action)) {
|
||||
throw createError({ statusCode: 400, message: 'action must be "block" or "unblock"' })
|
||||
}
|
||||
|
||||
const socket = baileysManager.getSocket(instanceId)
|
||||
if (!socket) {
|
||||
throw createError({ statusCode: 400, message: 'Instance not connected' })
|
||||
}
|
||||
|
||||
try {
|
||||
await socket.updateBlockStatus(jid, action)
|
||||
return { success: true, message: `User ${action}ed successfully` }
|
||||
} catch (error) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: `Failed to ${action} user: ${(error as Error).message}`
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user