diff --git a/dev/Styles/User/MessageView.less b/dev/Styles/User/MessageView.less index a5630fc1c..9ba14a9c3 100644 --- a/dev/Styles/User/MessageView.less +++ b/dev/Styles/User/MessageView.less @@ -318,6 +318,7 @@ html.rl-no-preview-pane { border-bottom: 1px solid var(--border-color, #bbb); } .attachmentsControls > * { + display: inline-block; margin-right: 0.5em; white-space: nowrap; } diff --git a/integrations/nextcloud/snappymail/lib/ContentSecurityPolicy.php b/integrations/nextcloud/snappymail/lib/ContentSecurityPolicy.php index cc2f7f6d9..5a2d9bfba 100644 --- a/integrations/nextcloud/snappymail/lib/ContentSecurityPolicy.php +++ b/integrations/nextcloud/snappymail/lib/ContentSecurityPolicy.php @@ -21,6 +21,8 @@ class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy $CSP->script )); $this->allowedScriptDomains = \array_diff($this->allowedScriptDomains, ["'unsafe-inline'", "'unsafe-eval'"]); + + // Nextcloud only sets 'strict-dynamic' when browserSupportsCspV3() ? \method_exists($this, 'useStrictDynamic') ? $this->useStrictDynamic(true) // NC24+ : $this->addAllowedScriptDomain("'strict-dynamic'"); diff --git a/plugins/nextcloud/js/message.js b/plugins/nextcloud/js/message.js index cbb4a4ed1..37f2956df 100644 --- a/plugins/nextcloud/js/message.js +++ b/plugins/nextcloud/js/message.js @@ -1,8 +1,54 @@ (rl => { // if (rl.settings.get('Nextcloud')) + const templateId = 'MailMessageView'; addEventListener('rl-view-model.create', e => { - if ('MailMessageView' === e.detail.viewModelTemplateID) { + if (templateId === e.detail.viewModelTemplateID) { + + const + template = document.getElementById(templateId), + cfg = rl.settings.get('Nextcloud'), + attachmentsControls = template.content.querySelector('.attachmentsControls'), + msgMenu = template.content.querySelector('#more-view-dropdown-id + menu'); + + if (attachmentsControls) { + attachmentsControls.append(Element.fromHTML(` + + 💾 + + `)); + + // https://github.com/nextcloud/calendar/issues/4684 + if (cfg.CalDAV) { + attachmentsControls.append(Element.fromHTML(` + + `)); + } + } +/* + // https://github.com/the-djmaze/snappymail/issues/592 + if (cfg.CalDAV) { + const attachmentsPlace = template.content.querySelector('.attachmentsPlace'); + attachmentsPlace.after(Element.fromHTML(` + + + + + + + + + +
Summary
Organizer
Start
End
Transparency
`)); + } +*/ + if (msgMenu) { + msgMenu.append(Element.fromHTML(`
  • + +
  • `)); + } + let view = e.detail; view.saveNextcloudError = ko.observable(false).extend({ falseTimeout: 7000 }); view.saveNextcloudLoading = ko.observable(false); @@ -65,7 +111,7 @@ view.nextcloudSaveICS = () => { let VEVENT = view.nextcloudICS(); VEVENT && rl.nextcloud.selectCalendar() - .then(href => href && rl.nextcloud.calendarPut(href, VEVENT.rawText)); + .then(href => href && rl.nextcloud.calendarPut(href, VEVENT)); } /** @@ -73,7 +119,7 @@ */ view.message.subscribe(msg => { view.nextcloudICS(null); - if (msg) { + if (msg && cfg.CalDAV) { let ics = msg.attachments.find(attachment => 'text/calendar' == attachment.mimeType); if (ics && ics.download) { // fetch it and parse the VEVENT @@ -119,7 +165,7 @@ } } // METHOD:REPLY || METHOD:REQUEST - console.dir({VEVENT:VEVENT}); +// console.dir({VEVENT:VEVENT}); if (VEVENT) { VEVENT.rawText = text; VEVENT.isCancelled = () => VEVENT.STATUS?.includes('CANCELLED'); @@ -138,47 +184,4 @@ } }); - let template = document.getElementById('MailMessageView'); - let cfg = rl.settings.get('Nextcloud'); - - const attachmentsControls = template.content.querySelector('.attachmentsControls'); - if (attachmentsControls) { - attachmentsControls.append(Element.fromHTML(` - - 💾 - - `)); - - // https://github.com/nextcloud/calendar/issues/4684 - if (cfg.CalDAV) { - attachmentsControls.append(Element.fromHTML(` - - `)); - } - } -/* - // https://github.com/the-djmaze/snappymail/issues/592 - if (cfg.CalDAV) { - const attachmentsPlace = template.content.querySelector('.attachmentsPlace'); - attachmentsPlace.after(Element.fromHTML(` - - - - - - - - - -
    Summary
    Organizer
    Start
    End
    Transparency
    `)); - } -*/ - const msgMenu = template.content.querySelector('#more-view-dropdown-id + menu'); - if (msgMenu) { - msgMenu.append(Element.fromHTML(`
  • - -
  • `)); - } - })(window.rl); diff --git a/plugins/nextcloud/js/webdav.js b/plugins/nextcloud/js/webdav.js index d45cdef55..07dde6cba 100644 --- a/plugins/nextcloud/js/webdav.js +++ b/plugins/nextcloud/js/webdav.js @@ -242,6 +242,7 @@ class NextcloudFilesPopupView extends rl.pluginPopupView { ) .then(response => (response.status < 400) ? response.json() : Promise.reject(new Error({ response }))) .then(json => { +// PUT /ocs/v2.php/apps/files_sharing/api/v1/shares/2 {"password":"ABC09"} this.select = [{url:json.ocs.data.url}]; this.close(); }); @@ -365,20 +366,29 @@ rl.nextcloud = { }), calendarPut: (path, event) => { - // Validation error in iCalendar: A calendar object on a CalDAV server MUST NOT have a METHOD property. - event = event.replace(/METHOD:.+\r?\n/i, ''); - - let m = event.match(/UID:(.+)/); - davFetch('calendars', path + '/' + m[1] + '.ics', { + davFetch('calendars', path + '/' + event.UID + '.ics', { method: 'PUT', headers: { 'Content-Type': 'text/calendar' }, - body: event + // Validation error in iCalendar: A calendar object on a CalDAV server MUST NOT have a METHOD property. + body: event.rawText + .replace('METHOD:', 'X-METHOD:') + // https://github.com/nextcloud/calendar/issues/4684 + .replace('ATTENDEE:', 'X-ATTENDEE:') + .replace('ORGANIZER:', 'X-ORGANIZER:') + .replace(/RSVP=TRUE/g, 'RSVP=FALSE') + .replace(/\r?\n/g, '\r\n') }) - .then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response }))) - .then(text => { - console.dir({event_response:text}); + .then(response => { + if (201 == response.status) { + // Created + } else if (204 == response.status) { + // Not modified + } else { +// response.text().then(text => console.error({status:response.status, body:text})); + Promise.reject(new Error({ response })); + } }); }, diff --git a/plugins/nextcloud/style.css b/plugins/nextcloud/style.css index aab6db5f7..e99ac0767 100644 --- a/plugins/nextcloud/style.css +++ b/plugins/nextcloud/style.css @@ -3,6 +3,7 @@ } #V-PopupsNextcloudFiles li { clear: right; + line-height: 2.5em; } #V-PopupsNextcloudFiles li button { cursor: pointer;