Skip to content
Open
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
11 changes: 9 additions & 2 deletions calendar/experiments/calendar/parent/ext-calendar-calendars.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ this.calendar_calendars = class extends ExtensionAPI {
return {
calendar: {
calendars: {
async query({ type, url, name, color, readOnly, enabled, visible }) {
async query({ type, url, name, color, readOnly, enabled, visible, username }) {
const calendars = cal.manager.getCalendars();

let pattern = null;
Expand Down Expand Up @@ -69,6 +69,10 @@ this.calendar_calendars = class extends ExtensionAPI {
matches = false;
}

if (username && username != calendar.getProperty("username")) {
matches = false;
}

Comment on lines +72 to +75
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should gate being able to query by username behind some sort of permission. Maybe accountsRead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jobisoft Thoughts on this? Am I being too cautious?

return matches;
})
.map(calendar => convertCalendar(context.extension, calendar));
Expand Down Expand Up @@ -108,6 +112,9 @@ this.calendar_calendars = class extends ExtensionAPI {
if (createProperties.showReminders != null) {
calendar.setProperty("suppressAlarms", !createProperties.showReminders);
}
if (createProperties.username != null) {
calendar.setProperty("username", createProperties.username);
}
if (createProperties.capabilities != null) {
if (!isOwnCalendar(calendar, context.extension)) {
throw new ExtensionError("Cannot set capabilities on foreign calendar types");
Expand Down Expand Up @@ -150,7 +157,7 @@ this.calendar_calendars = class extends ExtensionAPI {
calendar.setProperty("suppressAlarms", !updateProperties.showReminders);
}

for (const prop of ["readOnly", "name", "color"]) {
for (const prop of ["readOnly", "name", "color", "username"]) {
if (updateProperties[prop] != null) {
calendar.setProperty(prop, updateProperties[prop]);
}
Expand Down
13 changes: 9 additions & 4 deletions calendar/experiments/calendar/schema/calendar-calendars.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"visible": { "type": "boolean" },
"showReminders": { "type": "boolean" },
"color": { "type": "string", "optional": true },
"capabilities": { "$ref": "CalendarCapabilities", "optional": true }
"capabilities": { "$ref": "CalendarCapabilities", "optional": true },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the original patch for the username addition, it appears there is also a capability for usernames. Maybe we should add it to CalendarCapabilities and add a check in the provider code while we're at it?

"username": { "type": "string", "optional": true }
}
},
{
Expand All @@ -29,7 +30,8 @@
"enabled": { "type": "boolean" },
"visible": { "type": "boolean" },
"showReminders": { "type": "boolean" },
"color": { "type": "string", "optional": true }
"color": { "type": "string", "optional": true },
"username": { "type": "string", "optional": true }
}
},
{
Expand Down Expand Up @@ -115,7 +117,8 @@
"color": { "type": "string", "optional": true },
"readOnly": { "type": "boolean", "optional": true },
"visible": { "type": "boolean", "optional": true },
"enabled": { "type": "boolean", "optional": true }
"enabled": { "type": "boolean", "optional": true },
"username": { "type": "string", "optional": true }
}
}
]
Expand Down Expand Up @@ -150,7 +153,8 @@
"optional": true,
"additionalProperties": true,
"description": "This is normally CalendarCapabilities, but we don't want to inherit default values here"
}
},
"username": { "type": "string", "optional": true }
}
}
]
Expand All @@ -171,6 +175,7 @@
"enabled": { "type": "boolean", "optional": true },
"color": { "type": "string", "optional": true },
"lastError": { "type": "string", "optional": true },
"username": { "type": "string", "optional": true },
"capabilities": {
"type": "object",
"optional": true,
Expand Down
Loading