diff --git a/public/my.js b/public/my.js index fd9e471..34c91f5 100644 --- a/public/my.js +++ b/public/my.js @@ -307,6 +307,15 @@ try{ const foot=document.createElement('div'); foot.style.cssText='margin-top:12px;padding-top:10px;border-top:1px solid var(--line, #24425d)'; + // Already connected? Say so and stop asking. Offering to connect someone + // who IS connected is how a working link looks broken. + if(data&&data.tgLinked){ + foot.innerHTML='
✈️ Telegram connected. ' + +'Payout pings, team messages and join alerts arrive in your chat with the bot. ' + +'Open the bot and tap ☰ for your dashboard inside Telegram.
'; + el.appendChild(foot); + return; + } foot.innerHTML=''; el.appendChild(foot); const tb=document.getElementById('tgLinkBtn'); diff --git a/server.js b/server.js index 1f7a48f..6f009d4 100644 --- a/server.js +++ b/server.js @@ -1238,7 +1238,12 @@ async function handleApi(req,res,pathname){ if(req.method==='GET'&&pathname==='/api/public/msg-inbox'){ const s=messages.authFromCookie(req); if(!s)return json(res,401,{error:'Not signed in.'}); - return json(res,200,messages.inbox(s)); + // Whether this position already has a Telegram chat attached. Without it + // the panel keeps offering "Connect Telegram" to people who are already + // connected, which reads as the link having silently failed. + let tgLinked=false; + try{ tgLinked=!!tgbot.memberChat(s.id); }catch(err){} + return json(res,200,Object.assign({},messages.inbox(s),{tgLinked:tgLinked})); } if(req.method==='POST'&&pathname.startsWith('/api/tg-hook/')){ if(pathname.slice('/api/tg-hook/'.length)!==tgbot.webhookSecret())return json(res,404,{error:'Not found'});