Skip to content

Commit

Permalink
Save multiple .EML to Nextcloud Files storage
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Oct 24, 2022
1 parent b1bcbc1 commit aeabb16
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/nextcloud/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public function Init() : void
$this->addJs('js/message.js');
$this->addHook('json.attachments', 'DoAttachmentsActions');
$this->addJsonHook('NextcloudSaveMsg', 'NextcloudSaveMsg');
$this->addJsonHook('NextcloudAttachFile', 'NextcloudAttachFile');

$this->addJs('js/composer.js');
$this->addJsonHook('NextcloudAttachFile', 'NextcloudAttachFile');

$this->addJs('js/messagelist.js');

$this->addTemplate('templates/PopupsNextcloudFiles.html');
}
Expand Down
40 changes: 40 additions & 0 deletions plugins/nextcloud/js/messagelist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(rl => {
// if (rl.settings.get('Nextcloud'))

addEventListener('rl-view-model.create', e => {
if ('MailMessageList' === e.detail.viewModelTemplateID) {
let view = e.detail;
view.nextcloudSaveMsgs = () => {
view.messageList.hasChecked()
&& rl.ncFiles.selectFolder().then(folder => {
folder && view.messageList.forEach(msg => {
msg.checked() && rl.pluginRemoteRequest(
(iError, data) => {
console.dir({
iError:iError,
data:data
});
},
'NextcloudSaveMsg',
{
'msgHash': msg.requestHash,
'folder': folder,
'filename': msg.subject()
}
);
});
});
};
}
});

let template = document.getElementById('MailMessageList');

const msgMenu = template.content.querySelector('#more-list-dropdown-id + menu [data-bind*="forwardCommand"]');
if (msgMenu) {
msgMenu.after(Element.fromHTML('<li role="presentation" data-bind="css:{disabled:!messageList.hasChecked()}">'
+ '<a href="#" tabindex="-1" data-icon="📥" data-bind="click: nextcloudSaveMsgs" data-i18n="NEXTCLOUD/SAVE_EML"></a>'
+ '</li>'));
}

})(window.rl);

0 comments on commit aeabb16

Please sign in to comment.