Files
tower/apps/api/check-groups.ts
T
2026-06-09 02:02:40 +05:30

52 lines
1.4 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const groups = await prisma.group.findMany({
orderBy: { createdAt: 'desc' },
take: 10,
select: {
id: true,
name: true,
platformId: true,
claimStatus: true,
accountId: true,
tenantId: true,
claimExpiresAt: true,
createdAt: true,
},
});
console.log(`Found ${groups.length} groups:`);
for (const g of groups) {
console.log(JSON.stringify(g, null, 2));
}
const accounts = await prisma.account.findMany({
where: { isBot: true },
select: { id: true, jid: true, status: true, displayName: true, createdAt: true },
});
console.log(`\nFound ${accounts.length} bot accounts:`);
for (const a of accounts) {
console.log(JSON.stringify(a, null, 2));
}
const audits = await prisma.auditEvent.findMany({
where: { action: { in: ['GROUP_PENDING_CLAIM', 'BOT_PAIRED', 'BOT_INITIATED'] } },
orderBy: { createdAt: 'desc' },
take: 10,
select: { action: true, resourceId: true, createdAt: true, payload: true, tenantId: true },
});
console.log(`\nFound ${audits.length} relevant audit events:`);
for (const a of audits) {
console.log(JSON.stringify(a, null, 2));
}
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(() => prisma.$disconnect());