Skip to content

Commit

Permalink
Merge pull request #131 from bpannier:master
Browse files Browse the repository at this point in the history
Adding additional event fields from vcal to enable additional use cases.
  • Loading branch information
muness authored Nov 29, 2024
2 parents 55269b7 + 855f71e commit 96c2f4e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ If you want to support my work, you can [buy me a coffee](https://www.buymeacoff
- [Allow plugin to run on mobile](https://github.com/muness/obsidian-ics/pull/46) @TopherMan
- [Implement customizable output format for events](https://github.com/muness/obsidian-ics/pull/55) @GoBeromsu
- [Documenting Dataview usage](https://github.com/muness/obsidian-ics/issues/56#issuecomment-1746417368) @afonsoguerra
- [Vdir enhancements](https://github.com/cloud-atlas-ai/obsidian-ics/pull/131) @bpannier

## Manual Installation

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-ics",
"version": "1.6.6.1",
"version": "1.6.7",
"description": "Adds events from calendar ics published on the web to daily note on demand. Daily Note or Periodic Notes plugins: specifically it gets the date to search for events during from the currently open daily note.",
"main": "dist/main.js",
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions src/IEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ export interface IEvent {
utime: string; // Unix timestamp representing the event start time
time: string; // Human-readable representation of the event start time
endTime: string; // Human-readable representation of the event end time
created: string; // Unix timestamp representation of the creation timestamp of the event
sequence: number; // The revision sequence number of the calendar component within a sequence of revisions.
lastModified: string; // Unix timestamp representation of when the event was last revised
recurrent: boolean; // Is true if this is a recurrent event
icsName: string; // Name of the calendar the event is associated with
summary: string; // Summary or title of the event
description: string; // Detailed description of the event
format: Calendar["format"]; // Format preference for the event
location: string; // Physical location where the event takes place, if applicable
callUrl: string; // URL for joining online meetings/calls associated with the event
callType: string; // Type of online meeting (e.g., Zoom, Skype, etc.)
organizer: IOrganizer; // Email of the organizer of the event
attendees: IAttendee[]; // Array of attendees
}

Expand All @@ -19,4 +24,10 @@ export interface IAttendee {
name: string;
role: string;
status: string; // Participation status (accepted, declined, etc.)
type: string; // Participant type (individual, group, resource, room, etc.)
}

export interface IOrganizer {
email: string;
name: string;
}
4 changes: 4 additions & 0 deletions src/icalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function filterMatchingEvents(icsArray: any[], dayToMatch: string, showOn

return icsArray.reduce((matchingEvents, event) => {
var hasRecurrenceOverride = false

if (event.recurrences !== undefined) {
for (let date in event.recurrences) {
if (moment(date).isSame(dayToMatch, "day")) {
Expand Down Expand Up @@ -86,6 +87,9 @@ export function filterMatchingEvents(icsArray: any[], dayToMatch: string, showOn
// Remove rrule property from clonedEvent
delete clonedEvent.rrule;

// pass through a flag to understand this event is a recurrent event
clonedEvent.recurrent = true;

// Check if the event is really during 'today' in the local timezone
const eventStartLocal = moment(clonedEvent.start);
if (eventStartLocal.isSame(dayToMatch, 'day')) {
Expand Down
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,24 @@ export default class ICSPlugin extends Plugin {
utime: moment(e.start).format('X'),
time: moment(e.start).format(this.data.format.timeFormat),
endTime: moment(e.end).format(this.data.format.timeFormat),
created: moment(e.created).format('X'),
sequence: e.sequence || 0,
recurrent: e.recurrent ? true : false,
lastModified: e.lastmodified ? moment(e.lastmodified).format('X') : moment(e.created).format('X'),
icsName: calendarSetting.icsName,
summary: e.summary,
description: e.description,
format: calendarSetting.format,
location: e.location ? e.location : null,
callUrl: callUrl,
callType: callType,
organizer: { email: e.organizer?.val.substring(7) || null, name: e.organizer?.params?.CN || null },
attendees: e.attendee ? (Array.isArray(e.attendee) ? e.attendee : [e.attendee]).map(attendee => ({
name: attendee.params.CN,
email: attendee.val.substring(7),
status: attendee.params.PARTSTAT,
role: attendee.params.ROLE
role: attendee.params.ROLE,
type: attendee.params.CUTYPE || "INDIVIDUAL"
})) : []
};
events.push(event);
Expand Down Expand Up @@ -180,5 +186,3 @@ export default class ICSPlugin extends Plugin {
await this.loadSettings(); // Reload settings to ensure the plugin state is updated
}
}


0 comments on commit 96c2f4e

Please sign in to comment.