Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place

update dns worker to check pending sites

Changed files
+35 -15
src
+35 -15
src/lib/dns-verification-worker.ts
··· 71 71 }; 72 72 73 73 try { 74 - // Get all verified custom domains 75 - const domains = await db` 76 - SELECT id, domain, did FROM custom_domains WHERE verified = true 74 + // Get all custom domains (both verified and pending) 75 + const domains = await db<Array<{ 76 + id: string; 77 + domain: string; 78 + did: string; 79 + verified: boolean; 80 + }>>` 81 + SELECT id, domain, did, verified FROM custom_domains 77 82 `; 78 83 79 84 if (!domains || domains.length === 0) { 80 - this.log('No verified custom domains to check'); 85 + this.log('No custom domains to check'); 81 86 this.lastRunTime = Date.now(); 82 87 return; 83 88 } 84 89 85 - this.log(`Checking ${domains.length} verified custom domains`); 90 + const verifiedCount = domains.filter(d => d.verified).length; 91 + const pendingCount = domains.filter(d => !d.verified).length; 92 + this.log(`Checking ${domains.length} custom domains (${verifiedCount} verified, ${pendingCount} pending)`); 86 93 87 94 // Verify each domain 88 95 for (const row of domains) { 89 96 runStats.totalChecked++; 90 - const { id, domain, did } = row; 97 + const { id, domain, did, verified: wasVerified } = row; 91 98 92 99 try { 93 100 // Extract hash from id (SHA256 of did:domain) ··· 97 104 const result = await verifyCustomDomain(domain, did, expectedHash); 98 105 99 106 if (result.verified) { 100 - // Update last_verified_at timestamp 107 + // Update verified status and last_verified_at timestamp 101 108 await db` 102 109 UPDATE custom_domains 103 - SET last_verified_at = EXTRACT(EPOCH FROM NOW()) 110 + SET verified = true, 111 + last_verified_at = EXTRACT(EPOCH FROM NOW()) 104 112 WHERE id = ${id} 105 113 `; 106 114 runStats.verified++; 107 - this.log(`Domain verified: ${domain}`, { did }); 115 + if (!wasVerified) { 116 + this.log(`Domain newly verified: ${domain}`, { did }); 117 + } else { 118 + this.log(`Domain re-verified: ${domain}`, { did }); 119 + } 108 120 } else { 109 - // Mark domain as unverified 121 + // Mark domain as unverified or keep it pending 110 122 await db` 111 123 UPDATE custom_domains 112 124 SET verified = false, ··· 114 126 WHERE id = ${id} 115 127 `; 116 128 runStats.failed++; 117 - this.log(`Domain verification failed: ${domain}`, { 118 - did, 119 - error: result.error, 120 - found: result.found, 121 - }); 129 + if (wasVerified) { 130 + this.log(`Domain verification failed (was verified): ${domain}`, { 131 + did, 132 + error: result.error, 133 + found: result.found, 134 + }); 135 + } else { 136 + this.log(`Domain still pending: ${domain}`, { 137 + did, 138 + error: result.error, 139 + found: result.found, 140 + }); 141 + } 122 142 } 123 143 } catch (error) { 124 144 runStats.errors++;