-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-recent-messages.html
More file actions
71 lines (67 loc) · 2.95 KB
/
debug-recent-messages.html
File metadata and controls
71 lines (67 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<title>Debug Recent Messages</title>
</head>
<body>
<h1>Debug Recent Messages</h1>
<button onclick="checkRecentMessages()">Check Recent Messages</button>
<div id="result"></div>
<script>
async function checkRecentMessages() {
const result = document.getElementById('result');
result.innerHTML = 'Checking recent messages...';
try {
const response = await fetch('https://wertssqowjrkykmeovsg.hasura.ap-south-1.nhost.run/v1/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-hasura-admin-secret': 'Hq=1ILX8*V%Df8PlCyljd*BVys-::p,A'
},
body: JSON.stringify({
query: `
query GetRecentMessages {
messages(
order_by: { created_at: desc }
limit: 10
) {
id
content
is_bot
created_at
chat_id
user_id
}
}
`
})
});
const data = await response.json();
console.log('Recent messages:', data);
if (data.data && data.data.messages) {
result.innerHTML = `
<h3>Recent Messages (last 10):</h3>
${data.data.messages.map(msg => `
<div style="border: 1px solid #ccc; margin: 10px; padding: 10px; background: ${msg.is_bot ? '#e3f2fd' : '#f3e5f5'}">
<strong>ID:</strong> ${msg.id}<br>
<strong>Content:</strong> ${msg.content}<br>
<strong>Is Bot:</strong> ${msg.is_bot}<br>
<strong>Chat ID:</strong> ${msg.chat_id}<br>
<strong>User ID:</strong> ${msg.user_id || 'null'}<br>
<strong>Created:</strong> ${new Date(msg.created_at).toLocaleString()}<br>
</div>
`).join('')}
`;
} else if (data.errors) {
result.innerHTML = `<div style="color: red;">Error: ${JSON.stringify(data.errors)}</div>`;
} else {
result.innerHTML = `<div style="color: orange;">No messages found</div>`;
}
} catch (error) {
result.innerHTML = `<div style="color: red;">Error: ${error.message}</div>`;
console.error('Error:', error);
}
}
</script>
</body>
</html>