Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "cancelled" and newsflash to ical feed #799

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/endpoints/ical.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,25 @@ function buildCalEntry(evt, at) {
}
const endAt = evt.addDuration(startAt);
const url = at.getShareable();
let title = evt.title;
// google calendar doesn't indicated canceled events well;
// so force it to.
if (at.isUnscheduled()) {
title = "CANCELLED: " + title;
}
let news = at.getNewsFlash();
if (!news) {
news = ""; // no news is null news; we want an empty string.
} else {
news += "\n";
}
return {
uid: "event-" + at.pkid + "@shift2bikes.org",
url,
summary: escapeBreak("SUMMARY:", evt.title),
summary: escapeBreak("SUMMARY:", title),
contact: escapeBreak("CONTACT:", evt.name),
description: escapeBreak("DESCRIPTION:",
news,
evt.descr, evt.timedetails,
evt.locend? "Ends at "+ evt.locend: null,
url),
Expand Down
6 changes: 5 additions & 1 deletion app/models/calDaily.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ const methods = {
(this.eventstatus == EventStatus.Delisted);
},

getNewsFlash() {
return !this.isDelisted() ? this.newsflash : null
},

// return a summary of this occurrence for the "events" endpoint.
// backcompat: include the endtime if specified.
getJSON(endtime) {
Expand All @@ -106,7 +110,7 @@ const methods = {
// don't send newsflash when delisted:
// it's not scheduled and may be deleted
// either way, its not info we want to show.
newsflash: !this.isDelisted() ? this.newsflash : null,
newsflash: this.getNewsFlash(),
status: this.eventstatus,
};
// see notes in CalEvent.getJSON()
Expand Down
18 changes: 9 additions & 9 deletions app/test/ical_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ String.raw`BEGIN:VEVENT`,
String.raw`UID:[email protected]`,
String.raw`SUMMARY:ride 2 title`,
String.raw`CONTACT:organizer`,
String.raw`DESCRIPTION:Quis ex cupidatat pariatur cillum pariatur esse id magna sit `,
String.raw` ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw`DESCRIPTION:news flash\nQuis ex cupidatat pariatur cillum pariatur esse id`,
String.raw` magna sit ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw` end.\nhttp://localhost:3080/calendar/event-201`,
String.raw`LOCATION:location\, name.\n<address>\nlocation && details`,
String.raw`STATUS:CONFIRMED`,
Expand All @@ -176,8 +176,8 @@ String.raw`BEGIN:VEVENT`,
String.raw`UID:[email protected]`,
String.raw`SUMMARY:ride 2 title`,
String.raw`CONTACT:organizer`,
String.raw`DESCRIPTION:Quis ex cupidatat pariatur cillum pariatur esse id magna sit `,
String.raw` ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw`DESCRIPTION:news flash\nQuis ex cupidatat pariatur cillum pariatur esse id`,
String.raw` magna sit ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw` end.\nhttp://localhost:3080/calendar/event-202`,
String.raw`LOCATION:location\, name.\n<address>\nlocation && details`,
String.raw`STATUS:CONFIRMED`,
Expand Down Expand Up @@ -217,10 +217,10 @@ String.raw`X-WR-CALDESC:Find fun bike events and make new friends!`,
String.raw`X-WR-RELCALID:[email protected]`,
String.raw`BEGIN:VEVENT`,
String.raw`UID:[email protected]`,
String.raw`SUMMARY:ride 2 title`,
String.raw`SUMMARY:CANCELLED: ride 2 title`,
String.raw`CONTACT:organizer`,
String.raw`DESCRIPTION:Quis ex cupidatat pariatur cillum pariatur esse id magna sit `,
String.raw` ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw`DESCRIPTION:news flash\nQuis ex cupidatat pariatur cillum pariatur esse id`,
String.raw` magna sit ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw` end.\nhttp://localhost:3080/calendar/event-201`,
String.raw`LOCATION:location\, name.\n<address>\nlocation && details`,
String.raw`STATUS:CANCELLED`,
Expand All @@ -235,8 +235,8 @@ String.raw`BEGIN:VEVENT`,
String.raw`UID:[email protected]`,
String.raw`SUMMARY:ride 2 title`,
String.raw`CONTACT:organizer`,
String.raw`DESCRIPTION:Quis ex cupidatat pariatur cillum pariatur esse id magna sit `,
String.raw` ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw`DESCRIPTION:news flash\nQuis ex cupidatat pariatur cillum pariatur esse id`,
String.raw` magna sit ipsum duis elit.\ntime details\nEnds at location\; `,
String.raw` end.\nhttp://localhost:3080/calendar/event-202`,
String.raw`LOCATION:location\, name.\n<address>\nlocation && details`,
String.raw`STATUS:CONFIRMED`,
Expand Down