Add to Calendar: hand phones the .ics file instead of a Google link
On a phone the Google Calendar app claims calendar.google.com links and opens its own home screen, dropping the event. The pop-up now offers one "Add to Calendar" button that goes to the calendar file on iOS/Android (served inline so the phone hands it to its calendar) and to the Google event editor on desktop, with the other route as the second button either way. The .ics is also folded to RFC 5545 line lengths so Outlook accepts it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -689,8 +689,14 @@ async function handleApi(req,res,pathname){
|
||||
'UID:'+(c.announceId||'event')+'@rmcircle.team','DTSTAMP:'+fmt(Date.now()),'DTSTART:'+fmt(st),'DTEND:'+fmt(st+dur),
|
||||
'SUMMARY:'+esc(title),'DESCRIPTION:'+esc(desc),'LOCATION:'+esc(c.announceMeetUrl||''),
|
||||
...(c.announceMeetUrl?['URL:'+c.announceMeetUrl]:[]),
|
||||
'BEGIN:VALARM','TRIGGER:-PT30M','ACTION:DISPLAY','DESCRIPTION:'+esc(title),'END:VALARM','END:VEVENT','END:VCALENDAR'].join('\r\n')+'\r\n';
|
||||
res.writeHead(200,{'Content-Type':'text/calendar; charset=utf-8','Content-Disposition':'attachment; filename="rm-circle-huddle.ics"','Cache-Control':'no-store'});
|
||||
'BEGIN:VALARM','TRIGGER:-PT30M','ACTION:DISPLAY','DESCRIPTION:'+esc(title),'END:VALARM','END:VEVENT','END:VCALENDAR']
|
||||
.map(l=>{ // RFC 5545 line folding: Outlook rejects content lines past 75 octets
|
||||
if(l.length<=72)return l;let out=l.slice(0,72),rest=l.slice(72);
|
||||
while(rest.length){out+='\r\n '+rest.slice(0,71);rest=rest.slice(71);}return out;
|
||||
}).join('\r\n')+'\r\n';
|
||||
// ?open=1 (phones): served inline so the phone hands it to its calendar instead of filing it away
|
||||
const inline=new URL(req.url,'http://x').searchParams.get('open')==='1';
|
||||
res.writeHead(200,{'Content-Type':'text/calendar; charset=utf-8','Content-Disposition':(inline?'inline':'attachment')+'; filename="rm-circle-huddle.ics"','Cache-Control':'no-store'});
|
||||
return res.end(ics);
|
||||
}
|
||||
if(req.method==='GET'&&pathname==='/api/public/member'){
|
||||
|
||||
Reference in New Issue
Block a user