(record)
| 198 | } |
| 199 | |
| 200 | export async function insertVerificationAudit(record) { |
| 201 | try { |
| 202 | if (!db.initialized) { |
| 203 | await db.initialize(); |
| 204 | } |
| 205 | |
| 206 | if (db.isAvailable() && typeof pgDb.insertVerificationAudit === 'function') { |
| 207 | return await pgDb.insertVerificationAudit(record); |
| 208 | } |
| 209 | |
| 210 | const key = `verification:audit:${record.guildId}`; |
| 211 | const existing = await getFromDb(key, []); |
| 212 | const auditEntries = Array.isArray(existing) ? existing : []; |
| 213 | const maxInMemoryAuditEntries = BotConfig?.verification?.maxInMemoryAuditEntries ?? 1000; |
| 214 | |
| 215 | auditEntries.push({ |
| 216 | ...record, |
| 217 | createdAt: record.createdAt || new Date().toISOString() |
| 218 | }); |
| 219 | |
| 220 | if (auditEntries.length > maxInMemoryAuditEntries) { |
| 221 | auditEntries.splice(0, auditEntries.length - maxInMemoryAuditEntries); |
| 222 | } |
| 223 | |
| 224 | await setInDb(key, auditEntries); |
| 225 | return true; |
| 226 | } catch (error) { |
| 227 | logger.error('Error storing verification audit:', error); |
| 228 | return false; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | export function unwrapReplitData(data) { |
| 233 | if ( |
no test coverage detected