fix: reject unconfirmed Telegram tests and invalid update responses
This commit is contained in:
+4
-2
@@ -911,8 +911,10 @@ const server = http.createServer(async (req, res) => {
|
||||
const body = await readBody(req);
|
||||
if (body.islem === 'test') {
|
||||
if (!tg?.chatId) return json(res, 400, { success: false, error: 'Telegram bağlı değil' });
|
||||
await sendTelegram(tg.chatId, '✅ İhaleist bağlantı testi — bildirimler bu sohbete gelecek.');
|
||||
return json(res, 200, { success: true });
|
||||
if(!telegramConfigured())return json(res,503,{success:false,error:'Telegram hizmeti etkin değil.'});
|
||||
const receipt=await sendTelegram(tg.chatId,'✅ İhaleist bağlantı testi.',{parseMode:null,returnReceipt:true});
|
||||
if(!receipt?.id)throw new Error('Telegram gönderim kabulü doğrulanamadı.');
|
||||
return json(res,200,{success:true,id:receipt.id});
|
||||
}
|
||||
const linker=createTelegramLinker(store);
|
||||
if(body.islem==='kod'){
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ export async function kodIleBagla(kod, {issuedAt,expiresAt,now=Date.now()} = {})
|
||||
if(!/^[a-f0-9]{48}$/.test(String(kod))||!Number.isFinite(issuedAt)||!Number.isFinite(expiresAt)||now>=expiresAt)return null;
|
||||
const r = await fetch(`${API()}/getUpdates?limit=100`, { signal: AbortSignal.timeout(15000) });
|
||||
const d = await r.json().catch(() => ({}));
|
||||
if (!d.ok) throw new Error(d.description || 'getUpdates başarısız');
|
||||
if (!r.ok || d.ok!==true || !Array.isArray(d.result)) throw new Error(d.description || 'Telegram güncelleme yanıtı doğrulanamadı. Yeniden deneyin.');
|
||||
const aranan = String(kod);
|
||||
for (const u of [...(d.result || [])].reverse()) {
|
||||
const m = u.message;
|
||||
|
||||
Reference in New Issue
Block a user