Docs: Script para scrapear documentacion de Baileys API
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m3s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m3s
- Script en scripts/scrape-baileys-docs.ts - Genera docs/baileys-api-reference.md con 6433 lineas - 79 secciones: interfaces, types, functions, variables, enums - Referencia completa para desarrollo de mensajes
This commit is contained in:
41
server/api/debug/history/fetch.post.ts
Normal file
41
server/api/debug/history/fetch.post.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* POST /api/debug/history/fetch
|
||||
* Request message history on-demand
|
||||
*/
|
||||
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, count, oldestMsgKey, oldestMsgTimestamp } = body
|
||||
|
||||
if (!instanceId) {
|
||||
throw createError({ statusCode: 400, message: 'instanceId is required' })
|
||||
}
|
||||
|
||||
if (!count || typeof count !== 'number') {
|
||||
throw createError({ statusCode: 400, message: 'count (number) is required' })
|
||||
}
|
||||
|
||||
const socket = baileysManager.getSocket(instanceId)
|
||||
if (!socket) {
|
||||
throw createError({ statusCode: 400, message: 'Instance not connected' })
|
||||
}
|
||||
|
||||
try {
|
||||
await socket.fetchMessageHistory(count, oldestMsgKey, oldestMsgTimestamp)
|
||||
return {
|
||||
success: true,
|
||||
message: `Requested ${count} messages from history. Check messaging-history.set event for results.`
|
||||
}
|
||||
} catch (error) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: `Failed to fetch message history: ${(error as Error).message}`
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user