Add MailRepository and enhance calendar functionalities
- Introduced MailRepository for mailbox ID retrieval. - Updated CalendarObjectCreatedListener to handle cookies. - Modified VCalendarHelpers to include MIME type extraction. - Enhanced TalkService with room token retrieval logic. - Updated ProviderController to integrate external API for sharing. - Refactored EmailBoxController to utilize MailRepository for mailbox ID.
This commit is contained in:
parent
124a5ac324
commit
e6a18fd529
@ -7663,11 +7663,13 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var vue_material_design_icons_Plus_vue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! vue-material-design-icons/Plus.vue */ "./node_modules/vue-material-design-icons/Plus.vue");
|
||||
/* harmony import */ var vue_material_design_icons_Email_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! vue-material-design-icons/Email.vue */ "./node_modules/vue-material-design-icons/Email.vue");
|
||||
/* harmony import */ var vue_material_design_icons_ArrowLeft_vue__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! vue-material-design-icons/ArrowLeft.vue */ "./node_modules/vue-material-design-icons/ArrowLeft.vue");
|
||||
/* harmony import */ var _nextcloud_router__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @nextcloud/router */ "./node_modules/@nextcloud/router/dist/index.mjs");
|
||||
/* harmony import */ var _nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.mjs");
|
||||
/* harmony import */ var _utils_logger_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../utils/logger.js */ "./src/utils/logger.js");
|
||||
/* harmony import */ var _services_attachmentService_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../services/attachmentService.js */ "./src/services/attachmentService.js");
|
||||
/* harmony import */ var webdav__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! webdav */ "./node_modules/webdav/dist/web/index.js");
|
||||
/* harmony import */ var vue_material_design_icons_Reload_vue__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! vue-material-design-icons/Reload.vue */ "./node_modules/vue-material-design-icons/Reload.vue");
|
||||
/* harmony import */ var _nextcloud_router__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @nextcloud/router */ "./node_modules/@nextcloud/router/dist/index.mjs");
|
||||
/* harmony import */ var _nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.mjs");
|
||||
/* harmony import */ var _utils_logger_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../utils/logger.js */ "./src/utils/logger.js");
|
||||
/* harmony import */ var _services_attachmentService_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../services/attachmentService.js */ "./src/services/attachmentService.js");
|
||||
/* harmony import */ var webdav__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! webdav */ "./node_modules/webdav/dist/web/index.js");
|
||||
|
||||
|
||||
|
||||
|
||||
@ -7698,7 +7700,9 @@ __webpack_require__.r(__webpack_exports__);
|
||||
NcButton: _nextcloud_vue__WEBPACK_IMPORTED_MODULE_0__.NcButton,
|
||||
Email: vue_material_design_icons_Email_vue__WEBPACK_IMPORTED_MODULE_7__["default"],
|
||||
ArrowLeft: vue_material_design_icons_ArrowLeft_vue__WEBPACK_IMPORTED_MODULE_8__["default"],
|
||||
NcAvatar: _nextcloud_vue__WEBPACK_IMPORTED_MODULE_0__.NcAvatar
|
||||
Reload: vue_material_design_icons_Reload_vue__WEBPACK_IMPORTED_MODULE_9__["default"],
|
||||
NcAvatar: _nextcloud_vue__WEBPACK_IMPORTED_MODULE_0__.NcAvatar,
|
||||
NcLoadingIcon: _nextcloud_vue__WEBPACK_IMPORTED_MODULE_0__.NcLoadingIcon
|
||||
},
|
||||
props: {
|
||||
calendarObjectInstance: {
|
||||
@ -7746,10 +7750,10 @@ __webpack_require__.r(__webpack_exports__);
|
||||
});
|
||||
},
|
||||
async openFilesModal() {
|
||||
const picker = (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_10__.getFilePickerBuilder)(t('calendar', 'Choose a file to add as attachment')).setMultiSelect(false).allowDirectories(true).addButton({
|
||||
const picker = (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_11__.getFilePickerBuilder)(t('calendar', 'Choose a file to add as attachment')).setMultiSelect(false).allowDirectories(true).addButton({
|
||||
label: t('calendar', 'Pick'),
|
||||
type: 'primary',
|
||||
callback: nodes => _utils_logger_js__WEBPACK_IMPORTED_MODULE_11__["default"].debug('Picked attachment', {
|
||||
callback: nodes => _utils_logger_js__WEBPACK_IMPORTED_MODULE_12__["default"].debug('Picked attachment', {
|
||||
nodes
|
||||
})
|
||||
}).build();
|
||||
@ -7758,11 +7762,11 @@ __webpack_require__.r(__webpack_exports__);
|
||||
if (!this.isDuplicateAttachment(filename)) {
|
||||
var _davRes$multistatus;
|
||||
// TODO do not share Move this to PHP
|
||||
const data = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_12__.getFileInfo)(filename, this.currentUser.dav.userId);
|
||||
const davRes = await (0,webdav__WEBPACK_IMPORTED_MODULE_13__.parseXML)(data);
|
||||
const data = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_13__.getFileInfo)(filename, this.currentUser.dav.userId);
|
||||
const davRes = await (0,webdav__WEBPACK_IMPORTED_MODULE_14__.parseXML)(data);
|
||||
const davRespObj = davRes === null || davRes === void 0 || (_davRes$multistatus = davRes.multistatus) === null || _davRes$multistatus === void 0 || (_davRes$multistatus = _davRes$multistatus.response[0]) === null || _davRes$multistatus === void 0 || (_davRes$multistatus = _davRes$multistatus.propstat) === null || _davRes$multistatus === void 0 ? void 0 : _davRes$multistatus.prop;
|
||||
davRespObj.fileName = filename;
|
||||
davRespObj.url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.generateUrl)("/f/".concat(davRespObj.fileid));
|
||||
davRespObj.url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.generateUrl)("/f/".concat(davRespObj.fileid));
|
||||
davRespObj.value = davRespObj.url;
|
||||
this.addAttachmentWithProperty(this.calendarObjectInstance, davRespObj);
|
||||
}
|
||||
@ -7771,7 +7775,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
isDuplicateAttachment(path) {
|
||||
return this.attachments.find(attachment => {
|
||||
if (attachment.fileName === path) {
|
||||
(0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_10__.showError)(t('calendar', 'Attachment {name} already exist!', {
|
||||
(0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_11__.showError)(t('calendar', 'Attachment {name} already exist!', {
|
||||
name: this.getBaseName(path)
|
||||
}));
|
||||
return true;
|
||||
@ -7785,24 +7789,24 @@ __webpack_require__.r(__webpack_exports__);
|
||||
async onLocalAttachmentSelected(e) {
|
||||
try {
|
||||
const attachmentsFolder = await this.$store.dispatch('createAttachmentsFolder');
|
||||
const attachments = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_12__.uploadLocalAttachment)(attachmentsFolder, Array.from(e.target.files), this.currentUser.dav);
|
||||
const attachments = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_13__.uploadLocalAttachment)(attachmentsFolder, Array.from(e.target.files), this.currentUser.dav);
|
||||
// TODO do not share file, move to PHP
|
||||
attachments.map(async attachment => {
|
||||
var _davRes$multistatus2;
|
||||
const data = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_12__.getFileInfo)("".concat(attachmentsFolder, "/").concat(attachment.path), this.currentUser.dav.userId);
|
||||
const davRes = await (0,webdav__WEBPACK_IMPORTED_MODULE_13__.parseXML)(data);
|
||||
const data = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_13__.getFileInfo)("".concat(attachmentsFolder, "/").concat(attachment.path), this.currentUser.dav.userId);
|
||||
const davRes = await (0,webdav__WEBPACK_IMPORTED_MODULE_14__.parseXML)(data);
|
||||
const davRespObj = davRes === null || davRes === void 0 || (_davRes$multistatus2 = davRes.multistatus) === null || _davRes$multistatus2 === void 0 || (_davRes$multistatus2 = _davRes$multistatus2.response[0]) === null || _davRes$multistatus2 === void 0 || (_davRes$multistatus2 = _davRes$multistatus2.propstat) === null || _davRes$multistatus2 === void 0 ? void 0 : _davRes$multistatus2.prop;
|
||||
davRespObj.fileName = attachment.path;
|
||||
davRespObj.url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.generateUrl)("/f/".concat(davRespObj.fileid));
|
||||
davRespObj.url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.generateUrl)("/f/".concat(davRespObj.fileid));
|
||||
davRespObj.value = davRespObj.url;
|
||||
this.addAttachmentWithProperty(this.calendarObjectInstance, davRespObj);
|
||||
});
|
||||
e.target.value = '';
|
||||
} catch (error) {
|
||||
_utils_logger_js__WEBPACK_IMPORTED_MODULE_11__["default"].error('Could not upload attachment(s)', {
|
||||
_utils_logger_js__WEBPACK_IMPORTED_MODULE_12__["default"].error('Could not upload attachment(s)', {
|
||||
error
|
||||
});
|
||||
(0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_10__.showError)(t('calendar', 'Could not upload attachment(s)'));
|
||||
(0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_11__.showError)(t('calendar', 'Could not upload attachment(s)'));
|
||||
}
|
||||
},
|
||||
getIcon(mime) {
|
||||
@ -7810,7 +7814,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
},
|
||||
getPreview(attachment) {
|
||||
if (attachment.xNcHasPreview) {
|
||||
return (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.generateUrl)("/core/preview?fileId=".concat(attachment.xNcFileId, "&x=100&y=100&a=0"));
|
||||
return (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.generateUrl)("/core/preview?fileId=".concat(attachment.xNcFileId, "&x=100&y=100&a=0"));
|
||||
}
|
||||
return attachment.formatType ? OC.MimeType.getIconUrl(attachment.formatType) : OC.MimeType.getIconUrl('folder');
|
||||
},
|
||||
@ -7820,14 +7824,14 @@ __webpack_require__.r(__webpack_exports__);
|
||||
openFile(rawUrl) {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(rawUrl, (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.getBaseUrl)());
|
||||
url = new URL(rawUrl, (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.getBaseUrl)());
|
||||
} catch (error) {
|
||||
_utils_logger_js__WEBPACK_IMPORTED_MODULE_11__["default"].error("Refusing to open invalid URL: ".concat(rawUrl), {
|
||||
_utils_logger_js__WEBPACK_IMPORTED_MODULE_12__["default"].error("Refusing to open invalid URL: ".concat(rawUrl), {
|
||||
error
|
||||
});
|
||||
return;
|
||||
}
|
||||
const baseUrl = new URL((0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.getBaseUrl)());
|
||||
const baseUrl = new URL((0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.getBaseUrl)());
|
||||
if (url.href.startsWith(baseUrl.href)) {
|
||||
// URL belongs to this instance and is safe
|
||||
window.open(url.href, '_blank', 'noopener noreferrer');
|
||||
@ -7853,6 +7857,13 @@ __webpack_require__.r(__webpack_exports__);
|
||||
}];
|
||||
this.showOpenConfirmation = true;
|
||||
},
|
||||
async syncEmailBox() {
|
||||
this.loadingText = 'Synchronisation encours ...';
|
||||
this.loadingDataEmailBox = true;
|
||||
this.mailBoxData = [];
|
||||
await this.loadEmailsBox(true);
|
||||
this.loadingDataEmailBox = false;
|
||||
},
|
||||
async openEmailBoxModal() {
|
||||
this.loadingText = 'Chargement des emails ...';
|
||||
this.showModal = true;
|
||||
@ -7861,7 +7872,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
this.loadingDataEmailBox = false;
|
||||
},
|
||||
async getAttachments(mail) {
|
||||
this.loadingText = 'Chargement des attachements ...';
|
||||
this.loadingText = 'Récupération des piecs jointes ...';
|
||||
this.loadingDataEmailBox = true;
|
||||
this.showAttachmentsSection = true;
|
||||
this.mailAttachments = [];
|
||||
@ -7895,25 +7906,32 @@ __webpack_require__.r(__webpack_exports__);
|
||||
},
|
||||
async loadEmailsBox() {
|
||||
let withSync = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
||||
const ajaxUrl = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.generateUrl)('/apps/calendar/load-email-box');
|
||||
const ajaxUrl = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.generateUrl)('/apps/calendar/load-email-box');
|
||||
await _nextcloud_axios__WEBPACK_IMPORTED_MODULE_1__["default"].get(ajaxUrl, {
|
||||
params: {
|
||||
withSync
|
||||
}
|
||||
}).then(response => {
|
||||
console.log(response.data.success);
|
||||
if (!response.data.success && response.data.message == "MAILBOX_NOT_FOUND") {
|
||||
this.closeMailBoxModal();
|
||||
(0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_11__.showError)(t('calendar', 'Veuillez configurer le compte apps email pour pouvoir utiliser cette fonctionnalité.', {
|
||||
timeout: 7000
|
||||
}));
|
||||
return;
|
||||
}
|
||||
this.mailBoxData = response.data;
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
async loadAttachments(mail) {
|
||||
//TODO
|
||||
// if (!this.hasAttachements(mail)) {
|
||||
// this.mailAttachments = [] ;
|
||||
// this.loadingDataEmailBox = false
|
||||
// return;
|
||||
// }
|
||||
const ajaxUrl = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.generateUrl)('/apps/calendar/load-email-attachement/' + mail.databaseId);
|
||||
if (!this.hasAttachements(mail)) {
|
||||
this.mailAttachments = [];
|
||||
this.loadingDataEmailBox = false;
|
||||
return;
|
||||
}
|
||||
const ajaxUrl = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.generateUrl)('/apps/calendar/load-email-attachement/' + mail.databaseId);
|
||||
await _nextcloud_axios__WEBPACK_IMPORTED_MODULE_1__["default"].get(ajaxUrl).then(response => {
|
||||
console.log(response.data);
|
||||
this.mailAttachments = response.data.attachments;
|
||||
@ -7924,13 +7942,13 @@ __webpack_require__.r(__webpack_exports__);
|
||||
async pickEmailAttachementTodavFile(attachement) {
|
||||
var _davRes$multistatus3;
|
||||
const attachmentsFolder = await this.$store.dispatch('createAttachmentsFolder');
|
||||
const attachment = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_12__.uploadRemoteFile)(attachmentsFolder, attachement.downloadUrl, attachement.fileName, this.currentUser.dav);
|
||||
const attachment = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_13__.uploadRemoteFile)(attachmentsFolder, attachement.downloadUrl, attachement.fileName, this.currentUser.dav);
|
||||
// TODO do not share file, move to PHP
|
||||
const data = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_12__.getFileInfo)("".concat(attachmentsFolder, "/").concat(attachment.path), this.currentUser.dav.userId);
|
||||
const davRes = await (0,webdav__WEBPACK_IMPORTED_MODULE_13__.parseXML)(data);
|
||||
const data = await (0,_services_attachmentService_js__WEBPACK_IMPORTED_MODULE_13__.getFileInfo)("".concat(attachmentsFolder, "/").concat(attachment.path), this.currentUser.dav.userId);
|
||||
const davRes = await (0,webdav__WEBPACK_IMPORTED_MODULE_14__.parseXML)(data);
|
||||
const davRespObj = davRes === null || davRes === void 0 || (_davRes$multistatus3 = davRes.multistatus) === null || _davRes$multistatus3 === void 0 || (_davRes$multistatus3 = _davRes$multistatus3.response[0]) === null || _davRes$multistatus3 === void 0 || (_davRes$multistatus3 = _davRes$multistatus3.propstat) === null || _davRes$multistatus3 === void 0 ? void 0 : _davRes$multistatus3.prop;
|
||||
davRespObj.fileName = attachment.path;
|
||||
davRespObj.url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_9__.generateUrl)("/f/".concat(davRespObj.fileid));
|
||||
davRespObj.url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_10__.generateUrl)("/f/".concat(davRespObj.fileid));
|
||||
davRespObj.value = davRespObj.url;
|
||||
this.addAttachmentWithProperty(this.calendarObjectInstance, davRespObj);
|
||||
},
|
||||
@ -18430,8 +18448,28 @@ var render = function render() {
|
||||
}
|
||||
}, [!_vm.showAttachmentsSection && !_vm.showAttachmentsSection ? _c("div", {
|
||||
staticClass: "modal__content"
|
||||
}, [_c("ul", [_vm._l(_vm.mailBoxData, function (mail) {
|
||||
return _vm.mailBoxData.length > 0 ? [_c("NcListItem", {
|
||||
}, [!_vm.loadingDataEmailBox ? _c("NcButton", {
|
||||
staticStyle: {
|
||||
"text-align": "center"
|
||||
},
|
||||
on: {
|
||||
click: function ($event) {
|
||||
return _vm.syncEmailBox();
|
||||
}
|
||||
},
|
||||
scopedSlots: _vm._u([{
|
||||
key: "icon",
|
||||
fn: function () {
|
||||
return [_c("Reload", {
|
||||
attrs: {
|
||||
size: 20
|
||||
}
|
||||
})];
|
||||
},
|
||||
proxy: true
|
||||
}], null, false, 163584889)
|
||||
}, [_vm._v("\n\t\t\t\tActualiser \n\t\t\t")]) : _vm._e(), _vm._v(" "), _vm._l(_vm.mailBoxData, function (mail) {
|
||||
return _vm.mailBoxData.length > 0 ? [_c("ul", [_c("NcListItem", {
|
||||
attrs: {
|
||||
name: _vm.getLabelEmailBox(mail.from) + " : " + _vm.getSubstringText(mail.subject, 30),
|
||||
bold: false,
|
||||
@ -18445,7 +18483,7 @@ var render = function render() {
|
||||
scopedSlots: _vm._u([{
|
||||
key: "subname",
|
||||
fn: function () {
|
||||
return [_vm._v("\n\t\t\t\t\t\t\t " + _vm._s(_vm.getSubstringText(mail.previewText, 50)) + " \n\t\t\t\t\t\t")];
|
||||
return [_vm._v("\n\t\t\t\t\t\t\t\t" + _vm._s(_vm.getSubstringText(mail.previewText, 50)) + " \n\t\t\t\t\t\t")];
|
||||
},
|
||||
proxy: true
|
||||
}, _vm.hasAttachements(mail) ? {
|
||||
@ -18459,8 +18497,8 @@ var render = function render() {
|
||||
},
|
||||
proxy: true
|
||||
} : null], null, true)
|
||||
})] : _vm._e();
|
||||
})], 2)]) : _vm._e(), _vm._v(" "), _vm.showAttachmentsSection ? _c("div", {
|
||||
})], 1)] : _vm._e();
|
||||
})], 2) : _vm._e(), _vm._v(" "), _vm.showAttachmentsSection ? _c("div", {
|
||||
staticClass: "modal__content__attachments"
|
||||
}, [_c("ul", {
|
||||
staticClass: "attachments-list"
|
||||
@ -18484,7 +18522,7 @@ var render = function render() {
|
||||
}, [_vm._v("\n\t\t\t\t\tRevenir dans la listes des emails\n\t\t\t\t")]), _vm._v(" "), _vm._l(_vm.mailAttachments, function (attachment) {
|
||||
return !_vm.loadingDataEmailBox && _vm.mailAttachments.length > 0 ? _c("div", {
|
||||
staticClass: "image-list-attachement"
|
||||
}, [_c("div", {
|
||||
}, [attachment.isImage ? _c("div", {
|
||||
staticClass: "image-item-attachement",
|
||||
on: {
|
||||
click: function ($event) {
|
||||
@ -18496,10 +18534,25 @@ var render = function render() {
|
||||
src: attachment.downloadUrl,
|
||||
alt: attachment.fileName
|
||||
}
|
||||
}), _vm._v(" "), _c("label", [_vm._v(_vm._s(attachment.fileName))])])]) : _vm._e();
|
||||
}), _vm._v(" "), _c("label", [_vm._v(_vm._s(attachment.fileName))])]) : !attachment.isImage && !attachment.isCalendarEvent ? _c("div", {
|
||||
staticClass: "image-item-attachement",
|
||||
on: {
|
||||
click: function ($event) {
|
||||
return _vm.pickEmailAttachement(attachment);
|
||||
}
|
||||
}
|
||||
}, [_c("label", [_vm._v(_vm._s("Pièce joint : " + attachment.fileName))])]) : attachment.isCalendarEvent ? _c("div", {
|
||||
staticClass: "image-item-attachement"
|
||||
}, [_c("label", [_vm._v(_vm._s("Pièce joint : " + attachment.fileName) + " ( nNon allouée)")])]) : _vm._e()]) : _vm._e();
|
||||
}), _vm._v(" "), !_vm.mailAttachments.length && !_vm.loadingDataEmailBox ? [_c("p", [_vm._v(" Pas d'Attachements")])] : _vm._e()], 2)]) : _vm._e(), _vm._v(" "), _vm.loadingDataEmailBox ? _c("div", {
|
||||
staticClass: "modal__content"
|
||||
}, [_c("p", {
|
||||
}, [_c("div", [_c("NcLoadingIcon", {
|
||||
attrs: {
|
||||
size: 40,
|
||||
appearance: "light",
|
||||
name: _vm.loadingText
|
||||
}
|
||||
})], 1), _vm._v(" "), _c("p", {
|
||||
staticStyle: {
|
||||
"text-align": "center"
|
||||
}
|
||||
@ -133626,6 +133679,78 @@ __webpack_require__.r(__webpack_exports__);
|
||||
});
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-material-design-icons/Reload.vue":
|
||||
/*!***********************************************************!*\
|
||||
!*** ./node_modules/vue-material-design-icons/Reload.vue ***!
|
||||
\***********************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _Reload_vue_vue_type_template_id_e27a0376__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Reload.vue?vue&type=template&id=e27a0376 */ "./node_modules/vue-material-design-icons/Reload.vue?vue&type=template&id=e27a0376");
|
||||
/* harmony import */ var _Reload_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Reload.vue?vue&type=script&lang=js */ "./node_modules/vue-material-design-icons/Reload.vue?vue&type=script&lang=js");
|
||||
/* harmony import */ var _vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* normalize component */
|
||||
;
|
||||
var component = (0,_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
|
||||
_Reload_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["default"],
|
||||
_Reload_vue_vue_type_template_id_e27a0376__WEBPACK_IMPORTED_MODULE_0__.render,
|
||||
_Reload_vue_vue_type_template_id_e27a0376__WEBPACK_IMPORTED_MODULE_0__.staticRenderFns,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
|
||||
)
|
||||
|
||||
/* hot reload */
|
||||
if (false) { var api; }
|
||||
component.options.__file = "node_modules/vue-material-design-icons/Reload.vue"
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (component.exports);
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Reload.vue?vue&type=script&lang=js":
|
||||
/*!**********************************************************************************************************************************************!*\
|
||||
!*** ./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Reload.vue?vue&type=script&lang=js ***!
|
||||
\**********************************************************************************************************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
||||
name: "ReloadIcon",
|
||||
emits: ['click'],
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
fillColor: {
|
||||
type: String,
|
||||
default: "currentColor"
|
||||
},
|
||||
size: {
|
||||
type: Number,
|
||||
default: 24
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-material-design-icons/Repeat.vue":
|
||||
@ -142296,6 +142421,22 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-material-design-icons/Reload.vue?vue&type=script&lang=js":
|
||||
/*!***********************************************************************************!*\
|
||||
!*** ./node_modules/vue-material-design-icons/Reload.vue?vue&type=script&lang=js ***!
|
||||
\***********************************************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _vue_loader_lib_index_js_vue_loader_options_Reload_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../vue-loader/lib/index.js??vue-loader-options!./Reload.vue?vue&type=script&lang=js */ "./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Reload.vue?vue&type=script&lang=js");
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_vue_loader_lib_index_js_vue_loader_options_Reload_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-material-design-icons/Repeat.vue?vue&type=script&lang=js":
|
||||
/*!***********************************************************************************!*\
|
||||
!*** ./node_modules/vue-material-design-icons/Repeat.vue?vue&type=script&lang=js ***!
|
||||
@ -143183,6 +143324,23 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _vue_loader_lib_loaders_templateLoader_js_ruleSet_1_rules_3_vue_loader_lib_index_js_vue_loader_options_Plus_vue_vue_type_template_id_18bbb6c6__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!../vue-loader/lib/index.js??vue-loader-options!./Plus.vue?vue&type=template&id=18bbb6c6 */ "./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Plus.vue?vue&type=template&id=18bbb6c6");
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-material-design-icons/Reload.vue?vue&type=template&id=e27a0376":
|
||||
/*!*****************************************************************************************!*\
|
||||
!*** ./node_modules/vue-material-design-icons/Reload.vue?vue&type=template&id=e27a0376 ***!
|
||||
\*****************************************************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ render: () => (/* reexport safe */ _vue_loader_lib_loaders_templateLoader_js_ruleSet_1_rules_3_vue_loader_lib_index_js_vue_loader_options_Reload_vue_vue_type_template_id_e27a0376__WEBPACK_IMPORTED_MODULE_0__.render),
|
||||
/* harmony export */ staticRenderFns: () => (/* reexport safe */ _vue_loader_lib_loaders_templateLoader_js_ruleSet_1_rules_3_vue_loader_lib_index_js_vue_loader_options_Reload_vue_vue_type_template_id_e27a0376__WEBPACK_IMPORTED_MODULE_0__.staticRenderFns)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _vue_loader_lib_loaders_templateLoader_js_ruleSet_1_rules_3_vue_loader_lib_index_js_vue_loader_options_Reload_vue_vue_type_template_id_e27a0376__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!../vue-loader/lib/index.js??vue-loader-options!./Reload.vue?vue&type=template&id=e27a0376 */ "./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Reload.vue?vue&type=template&id=e27a0376");
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-material-design-icons/Repeat.vue?vue&type=template&id=1e2ad947":
|
||||
@ -146884,6 +147042,75 @@ render._withStripped = true
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Reload.vue?vue&type=template&id=e27a0376":
|
||||
/*!*********************************************************************************************************************************************************************************************************************************!*\
|
||||
!*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Reload.vue?vue&type=template&id=e27a0376 ***!
|
||||
\*********************************************************************************************************************************************************************************************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ render: () => (/* binding */ render),
|
||||
/* harmony export */ staticRenderFns: () => (/* binding */ staticRenderFns)
|
||||
/* harmony export */ });
|
||||
var render = function render() {
|
||||
var _vm = this,
|
||||
_c = _vm._self._c
|
||||
return _c(
|
||||
"span",
|
||||
_vm._b(
|
||||
{
|
||||
staticClass: "material-design-icon reload-icon",
|
||||
attrs: {
|
||||
"aria-hidden": _vm.title ? null : true,
|
||||
"aria-label": _vm.title,
|
||||
role: "img",
|
||||
},
|
||||
on: {
|
||||
click: function ($event) {
|
||||
return _vm.$emit("click", $event)
|
||||
},
|
||||
},
|
||||
},
|
||||
"span",
|
||||
_vm.$attrs,
|
||||
false
|
||||
),
|
||||
[
|
||||
_c(
|
||||
"svg",
|
||||
{
|
||||
staticClass: "material-design-icon__svg",
|
||||
attrs: {
|
||||
fill: _vm.fillColor,
|
||||
width: _vm.size,
|
||||
height: _vm.size,
|
||||
viewBox: "0 0 24 24",
|
||||
},
|
||||
},
|
||||
[
|
||||
_c(
|
||||
"path",
|
||||
{
|
||||
attrs: {
|
||||
d: "M2 12C2 16.97 6.03 21 11 21C13.39 21 15.68 20.06 17.4 18.4L15.9 16.9C14.63 18.25 12.86 19 11 19C4.76 19 1.64 11.46 6.05 7.05C10.46 2.64 18 5.77 18 12H15L19 16H19.1L23 12H20C20 7.03 15.97 3 11 3C6.03 3 2 7.03 2 12Z",
|
||||
},
|
||||
},
|
||||
[_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()]
|
||||
),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
}
|
||||
var staticRenderFns = []
|
||||
render._withStripped = true
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./node_modules/vue-material-design-icons/Repeat.vue?vue&type=template&id=1e2ad947":
|
||||
@ -310655,4 +310882,4 @@ appointmentsConfigsStore.addInitialConfigs((0,_nextcloud_initial_state__WEBPACK_
|
||||
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=calendar-main.js.map?v=410f05104d20a2faec06
|
||||
//# sourceMappingURL=calendar-main.js.map?v=6688bbead46c5a1516a8
|
||||
File diff suppressed because one or more lines are too long
@ -5,6 +5,7 @@ namespace OCA\Calendar\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
use Horde_Imap_Client;
|
||||
use OCA\Calendar\Db\MailRepository;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Controller;
|
||||
@ -38,6 +39,8 @@ class EmailBoxController extends Controller {
|
||||
|
||||
private SyncService $syncService;
|
||||
|
||||
private MailRepository $mailRepository;
|
||||
|
||||
public function __construct(string $appName,
|
||||
IRequest $request,
|
||||
?string $UserId,
|
||||
@ -48,7 +51,8 @@ class EmailBoxController extends Controller {
|
||||
IURLGenerator $urlGenerator,
|
||||
IMimeTypeDetector $mimeTypeDetector,
|
||||
IMAPClientFactory $clientFactory,
|
||||
SyncService $syncService
|
||||
SyncService $syncService,
|
||||
MailRepository $mailRepository,
|
||||
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
@ -61,6 +65,7 @@ class EmailBoxController extends Controller {
|
||||
$this->mimeTypeDetector = $mimeTypeDetector;
|
||||
$this->clientFactory = $clientFactory;
|
||||
$this->syncService = $syncService;
|
||||
$this->mailRepository = $mailRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,31 +74,39 @@ class EmailBoxController extends Controller {
|
||||
*
|
||||
*/
|
||||
public function loadEmailboxMessage(): JSONResponse {
|
||||
//TODO
|
||||
$mailboxId = 9;
|
||||
|
||||
$mailboxId = $this->mailRepository->getCurrentUserMailBoxId($this->currentUserId);
|
||||
if($mailboxId == null){
|
||||
return new JSONResponse([
|
||||
"success" => false,
|
||||
"message" => "MAILBOX_NOT_FOUND",
|
||||
], Http::STATUS_OK);
|
||||
}
|
||||
|
||||
$lastMessageTimestamp = null;
|
||||
$init = false;
|
||||
$init = true;
|
||||
$sortOrder = 'newest';
|
||||
$query = null;
|
||||
|
||||
try {
|
||||
$mailbox = $this->mailManager->getMailbox($this->currentUserId, $mailboxId);
|
||||
$account = $this->accountService->find($this->currentUserId, $mailbox->getAccountId());
|
||||
if ($this->request->getParam('withSync')) {
|
||||
$this->syncService->syncMailbox(
|
||||
$account,
|
||||
$mailbox,
|
||||
Horde_Imap_Client::SYNC_NEWMSGSUIDS | Horde_Imap_Client::SYNC_FLAGSUIDS | Horde_Imap_Client::SYNC_VANISHEDUIDS,
|
||||
null,
|
||||
$lastMessageTimestamp,
|
||||
$init,
|
||||
$sortOrder,
|
||||
$query
|
||||
);
|
||||
$mailbox = $this->mailManager->getMailbox($this->currentUserId, $mailboxId);
|
||||
}
|
||||
|
||||
// try {
|
||||
// if (boolval($this->request->getParam('withSync'))) {
|
||||
// $this->syncService->syncMailbox(
|
||||
// $account,
|
||||
// $mailbox,
|
||||
// Horde_Imap_Client::SYNC_NEWMSGSUIDS | Horde_Imap_Client::SYNC_FLAGSUIDS | Horde_Imap_Client::SYNC_VANISHEDUIDS,
|
||||
// null,
|
||||
// $lastMessageTimestamp,
|
||||
// $init,
|
||||
// $sortOrder,
|
||||
// $query
|
||||
// );
|
||||
// }
|
||||
// } catch (\Throwable $th) {
|
||||
// // on ignioir car il n'est pas est deja synchronise
|
||||
// }
|
||||
} catch (DoesNotExistException $e) {
|
||||
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
||||
}
|
||||
@ -106,18 +119,17 @@ class EmailBoxController extends Controller {
|
||||
$order,
|
||||
null,
|
||||
null,
|
||||
30,
|
||||
100,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
*/
|
||||
public function loadEmailboxAttachement(int $messageId = 0): Response {
|
||||
//TODO
|
||||
// $messageId = 12818;
|
||||
try {
|
||||
$message = $this->mailManager->getMessage($this->currentUserId, $messageId);
|
||||
$mailbox = $this->mailManager->getMailbox($this->currentUserId, $message->getMailboxId());
|
||||
|
||||
52
calendar/lib/Db/MailRepository.php
Normal file
52
calendar/lib/Db/MailRepository.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace OCA\Calendar\Db;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class MailRepository {
|
||||
|
||||
private IDbConnection $pdo;
|
||||
|
||||
public function __construct(IDbConnection $db) {
|
||||
$this->pdo = $db;
|
||||
}
|
||||
|
||||
private function execSQL($sql, $conditions){
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->execute($conditions);
|
||||
$data = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
private function execSQLNoData($sql, $conditions){
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->execute($conditions);
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
private function execSQLNoJsonReturn($sql, $conditions){
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->execute($conditions);
|
||||
$data = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getCurrentUserMailBoxId(string $currentUserId ) {
|
||||
$sql = 'SELECT mail_mailbox.id as mail_box_id
|
||||
FROM oc_mail_accounts as mail_account
|
||||
LEFT JOIN oc_mail_mailboxes as mail_mailbox ON mail_account.id = mail_mailbox.account_id
|
||||
WHERE mail_account.user_id = ?
|
||||
AND mail_mailbox.name = ?';
|
||||
|
||||
$result = $this->execSQLNoJsonReturn($sql, [$currentUserId,"INBOX"]);
|
||||
if(!empty($result)){
|
||||
return $result[0]['mail_box_id'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -74,22 +74,28 @@
|
||||
<NcModal v-if="showModal" name="" @close="resetMailBoxModal">
|
||||
|
||||
<div class="modal__content" v-if="!showAttachmentsSection && !showAttachmentsSection">
|
||||
<ul >
|
||||
<template v-if="mailBoxData.length > 0" v-for="mail in mailBoxData">
|
||||
<NcButton style="text-align: center;" @click="syncEmailBox()" v-if="!loadingDataEmailBox">
|
||||
<template #icon>
|
||||
<Reload :size="20" />
|
||||
</template>
|
||||
Actualiser
|
||||
</NcButton>
|
||||
<template v-if="mailBoxData.length > 0" v-for="mail in mailBoxData">
|
||||
<ul>
|
||||
<NcListItem
|
||||
@click="getAttachments(mail)"
|
||||
:name="getLabelEmailBox(mail.from) + ' : ' + getSubstringText(mail.subject, 30) "
|
||||
:bold="false"
|
||||
counterType="outlined">
|
||||
<template #subname>
|
||||
{{ getSubstringText(mail.previewText ,50) }}
|
||||
{{ getSubstringText(mail.previewText ,50) }}
|
||||
</template>
|
||||
<template v-if="hasAttachements(mail)" #icon>
|
||||
<Paperclip :size="20" />
|
||||
</template>
|
||||
</NcListItem>
|
||||
</template>
|
||||
</ul>
|
||||
</ul>
|
||||
</template>
|
||||
</div>
|
||||
<div class="modal__content__attachments" v-if="showAttachmentsSection">
|
||||
<ul class="attachments-list">
|
||||
@ -104,6 +110,12 @@
|
||||
<img :src="attachment.downloadUrl" :alt="attachment.fileName ">
|
||||
<label>{{ attachment.fileName }}</label>
|
||||
</div>
|
||||
<div v-else-if="! attachment.isImage && !attachment.isCalendarEvent" class="image-item-attachement " @click="pickEmailAttachement(attachment)">
|
||||
<label>{{ 'Pièce joint : ' + attachment.fileName }}</label>
|
||||
</div>
|
||||
<div v-else-if="attachment.isCalendarEvent" class="image-item-attachement " >
|
||||
<label>{{ 'Pièce joint : ' + attachment.fileName }} ( nNon allouée)</label>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="!mailAttachments.length && !loadingDataEmailBox" >
|
||||
<p> Pas d'Attachements</p>
|
||||
@ -112,6 +124,9 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal__content" v-if="loadingDataEmailBox" >
|
||||
<div >
|
||||
<NcLoadingIcon :size="40" appearance="light" :name="loadingText" />
|
||||
</div>
|
||||
<p style="text-align: center;"> {{ loadingText }}</p>
|
||||
</div>
|
||||
</NcModal>
|
||||
@ -126,7 +141,8 @@ import {
|
||||
NcDialog,
|
||||
NcModal,
|
||||
NcButton,
|
||||
NcAvatar
|
||||
NcAvatar,
|
||||
NcLoadingIcon,
|
||||
} from '@nextcloud/vue'
|
||||
|
||||
import axios from "@nextcloud/axios";
|
||||
@ -138,6 +154,7 @@ import Paperclip from 'vue-material-design-icons/Paperclip.vue'
|
||||
import Plus from 'vue-material-design-icons/Plus.vue'
|
||||
import Email from 'vue-material-design-icons/Email.vue'
|
||||
import ArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'
|
||||
import Reload from 'vue-material-design-icons/Reload.vue'
|
||||
|
||||
import { generateUrl, getBaseUrl } from '@nextcloud/router'
|
||||
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
|
||||
@ -165,7 +182,9 @@ export default {
|
||||
NcButton,
|
||||
Email,
|
||||
ArrowLeft,
|
||||
NcAvatar
|
||||
Reload,
|
||||
NcAvatar,
|
||||
NcLoadingIcon
|
||||
},
|
||||
props: {
|
||||
calendarObjectInstance: {
|
||||
@ -324,6 +343,13 @@ export default {
|
||||
]
|
||||
this.showOpenConfirmation = true
|
||||
},
|
||||
async syncEmailBox(){
|
||||
this.loadingText = 'Synchronisation encours ...'
|
||||
this.loadingDataEmailBox = true
|
||||
this.mailBoxData = [];
|
||||
await this.loadEmailsBox(true)
|
||||
this.loadingDataEmailBox = false
|
||||
},
|
||||
async openEmailBoxModal(){
|
||||
this.loadingText = 'Chargement des emails ...'
|
||||
this.showModal = true
|
||||
@ -332,7 +358,7 @@ export default {
|
||||
this.loadingDataEmailBox = false
|
||||
},
|
||||
async getAttachments(mail){
|
||||
this.loadingText = 'Chargement des attachements ...'
|
||||
this.loadingText = 'Récupération des piecs jointes ...'
|
||||
this.loadingDataEmailBox = true
|
||||
this.showAttachmentsSection = true
|
||||
this.mailAttachments = [] ;
|
||||
@ -368,19 +394,27 @@ export default {
|
||||
const ajaxUrl = generateUrl('/apps/calendar/load-email-box')
|
||||
await axios.get(ajaxUrl , { params: { withSync } })
|
||||
.then(response => {
|
||||
this.mailBoxData = response.data
|
||||
console.log(response.data.success);
|
||||
if (!response.data.success && response.data.message == "MAILBOX_NOT_FOUND") {
|
||||
this.closeMailBoxModal();
|
||||
showError(t('calendar', 'Veuillez configurer le compte apps email pour pouvoir utiliser cette fonctionnalité.' , {
|
||||
timeout : 7000,
|
||||
}))
|
||||
return;
|
||||
}
|
||||
this.mailBoxData = response.data;
|
||||
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error)
|
||||
})
|
||||
},
|
||||
async loadAttachments(mail) {
|
||||
//TODO
|
||||
// if (!this.hasAttachements(mail)) {
|
||||
// this.mailAttachments = [] ;
|
||||
// this.loadingDataEmailBox = false
|
||||
// return;
|
||||
// }
|
||||
if (!this.hasAttachements(mail)) {
|
||||
this.mailAttachments = [] ;
|
||||
this.loadingDataEmailBox = false
|
||||
return;
|
||||
}
|
||||
const ajaxUrl = generateUrl('/apps/calendar/load-email-attachement/' + mail.databaseId)
|
||||
|
||||
await axios.get(ajaxUrl)
|
||||
|
||||
@ -119,12 +119,54 @@ class ProviderController extends Controller
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getProviders()
|
||||
{
|
||||
$providers = $this->providerService->getProvidersAsArray();
|
||||
// public function getProviders()
|
||||
// {
|
||||
// $providers = $this->providerService->getProvidersAsArray();
|
||||
// return json_encode($providers);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getProviders() {
|
||||
// $providers = $this->providerService->getProvidersAsArray();
|
||||
// http://127.0.0.1:8585/ocs/v2.php/apps/files_sharing/api/v1/shares
|
||||
|
||||
|
||||
$client = \OC::$server->getHTTPClientService()->newClient();
|
||||
$token = file_get_contents('http://127.0.0.1/ocs/v2.php/core/getcsrftoken', false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "OCS-APIRequest: true\r\n"
|
||||
]
|
||||
]));
|
||||
$response = $client->post('http://127.0.0.1/ocs/v2.php/apps/files_sharing/api/v1/shares', [
|
||||
//not verifier ssl
|
||||
'body' => [
|
||||
"path" => "//Talk/narindra-dev.png",
|
||||
"referenceId" => "dkzcesdsdhae",
|
||||
"shareWith" => "dkzcehae",
|
||||
"shareType" => 10,
|
||||
'talkMetaData' => "{\"messageType\":\"\"}"
|
||||
],
|
||||
'headers' => [
|
||||
'Cookie' =>"_ga=GA1.1.259457270.1732194936; _ga_699NE13B0K=GS1.1.1732203040.2.0.1732203040.0.0.0; nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; nc_username=Tiavina; oc_sessionPassphrase=v7ncJ0h%2BYxrmzJViNygGkErBa9cSDs1m3mpgW4M6wZ%2BqphceZK2S7PMELp%2BlHgxQxcZuGPrpzZSwzp2SQCXADxDehB7OkwdBEr3DtG8ZzlnXZWzB%2Fbfl7xsuQYTnvmLU; oczp8j7d6k88=1b54a2ea877ffca7154bea254f70886c; nc_token=OEez5vu%2FWTz7FsafIbVDbAXA7lSdkG9U; nc_session_id=1b54a2ea877ffca7154bea254f70886c",
|
||||
'OCS-APIRequest' => 'true',
|
||||
'requesttoken' => $token
|
||||
]
|
||||
]);
|
||||
|
||||
var_dump($response);die;
|
||||
return json_encode($providers);
|
||||
}
|
||||
|
||||
// json_encode([
|
||||
// "path" => "//Talk/logo (2).png",
|
||||
// "referenceId" => "90b2ef6f74ab9f5a5cb0f240d4552798780352ffd276717f54de9f4098e4ceab",
|
||||
// "shareType" => 10,
|
||||
// "shareWith" => "dkzcehae",
|
||||
// "talkMetaData" => "{\"messageType\":\"\"}"
|
||||
// ]));
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
@ -222,4 +264,5 @@ END:VCALENDAR";
|
||||
$this->mailer->send($message);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -70,7 +70,8 @@ class VCalendarHelpers
|
||||
preg_match_all('/ATTACH;FMTTYPE=([^;]+);FILENAME=([^;]+);X-NC-FILE-ID=([^;]+);/', $vCalendarString, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$attachments[] = [
|
||||
'type' =>$match[1], // Extrait 'image' de 'image/png'
|
||||
'type' =>explode("/" , $match[1])[0], // Extrait 'image' de 'image/png'
|
||||
'mime_type' =>$match[1], // Extrait 'image' de 'image/png'
|
||||
'name' => trim($match[2], '/'),
|
||||
'file_id' => (int) $match[3],
|
||||
];
|
||||
|
||||
@ -29,6 +29,7 @@ use OCA\DAV\Events\CalendarObjectCreatedEvent;
|
||||
use OCA\Gestion\Service\GestionService;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\IRequest;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CalendarObjectCreatedListener implements IEventListener {
|
||||
@ -39,9 +40,14 @@ class CalendarObjectCreatedListener implements IEventListener {
|
||||
/** @var GestionService */
|
||||
private $gestionService;
|
||||
|
||||
/** @var IRequest */
|
||||
private $request;
|
||||
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
LoggerInterface $logger,GestionService $gestionService) {
|
||||
$this->logger = $logger;
|
||||
$this->request = $request;
|
||||
$this->gestionService = $gestionService;
|
||||
}
|
||||
|
||||
@ -49,9 +55,12 @@ class CalendarObjectCreatedListener implements IEventListener {
|
||||
if (!($event instanceof CalendarObjectCreatedEvent)) {
|
||||
return;
|
||||
}
|
||||
$cookie = $this->request->getHeader("Cookie");
|
||||
|
||||
|
||||
$calendarData = $event->getObjectData();
|
||||
$vCalendarString = $calendarData["calendardata"];
|
||||
$this->gestionService->HandleCreatedCalendarObject($vCalendarString);
|
||||
$this->gestionService->HandleCreatedCalendarObject($vCalendarString , $cookie);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -42,6 +42,8 @@ use OCA\Gestion\Constants\ThanatoTypeConstant;
|
||||
use OCA\Gestion\Service\Order\OrderPdfService;
|
||||
use OCA\Gestion\Constants\DevisMentionConstant;
|
||||
use OCA\Gestion\Service\Devis\Pdf\DevisPdfService;
|
||||
use OCP\IConfig;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class GestionService {
|
||||
/** @var Bdd */
|
||||
@ -66,6 +68,8 @@ class GestionService {
|
||||
|
||||
private $mailer;
|
||||
|
||||
protected $config;
|
||||
|
||||
|
||||
public function __construct(
|
||||
Bdd $gestionBdd,
|
||||
@ -77,6 +81,7 @@ class GestionService {
|
||||
IUserSession $userSession,
|
||||
IRootFolder $rootFolder,
|
||||
IMailer $mailer,
|
||||
IConfig $config,
|
||||
|
||||
) {
|
||||
$this->orderBdd = $orderBdd;
|
||||
@ -89,6 +94,8 @@ class GestionService {
|
||||
$this->userConnectedUuid = $userSession->getUser()?->getUID() ?? BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD;
|
||||
$this->userConnectedStorage = $rootFolder->getUserFolder($this->userConnectedUuid);
|
||||
$this->mailer = $mailer;
|
||||
$this->config = $config;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -184,7 +191,7 @@ class GestionService {
|
||||
return $calendarStartDate;
|
||||
}
|
||||
|
||||
public function HandleCreatedCalendarObject(string $vCalendarString){
|
||||
public function HandleCreatedCalendarObject(string $vCalendarString ,$cookie){
|
||||
try{
|
||||
$thanato = $this->GetThanatoFromVCalendarString($vCalendarString);
|
||||
if($thanato != null){
|
||||
@ -235,7 +242,19 @@ class GestionService {
|
||||
$attachments = VCalendarHelpers::extractAttachments($vCalendarString);
|
||||
$this->moveCalendarAttachmentFile($attachments,$destinationFolderAttachment);
|
||||
if ($thanatoIsSubcontractor) {
|
||||
$this->sendEmailAttachment($devis["defunt_nom"],$attachments);
|
||||
$thanatoHasEmail = $thanato["thanato_email"] != null;
|
||||
if($thanatoHasEmail){
|
||||
$this->sendEmailAttachment($thanato["thanato_email"] , $devis["defunt_nom"],$attachments);
|
||||
}
|
||||
}else {
|
||||
$roomToken = $this->talkService->getRoomTokenBeetwenTwoUser($this->userConnectedUuid, $userName);
|
||||
foreach ( $attachments as $attachment) {
|
||||
$this->userConnectedStorage->getFullPath("/");
|
||||
$path = Filesystem::getPath($attachment['file_id']);
|
||||
$destination = 'Talk/';
|
||||
Filesystem::copy($path, $destination . $attachment['name']);
|
||||
$this->sendFileAttachmentToTalk($roomToken,$cookie , $attachment['name']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -354,7 +373,7 @@ class GestionService {
|
||||
}
|
||||
}
|
||||
|
||||
public function HandleUpdatedCalendarObject(string $vCalendarString){
|
||||
public function HandleUpdatedCalendarObject(string $vCalendarString , $cookie){
|
||||
try{
|
||||
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
||||
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
|
||||
@ -380,8 +399,23 @@ class GestionService {
|
||||
$destinationFolderAttachment = FolderHelpers::GetDefuntFolder($devis["client_entreprise"],$devis["defunt_nom"]);
|
||||
$attachments = VCalendarHelpers::extractAttachments($vCalendarString);
|
||||
$this->moveCalendarAttachmentFile($attachments , $destinationFolderAttachment);
|
||||
if ($thanatoIsSubcontractor) {
|
||||
$this->sendEmailAttachment($devis["defunt_nom"],$attachments);
|
||||
if ($thanatoIsSubcontractor ) {
|
||||
$thanatoHasEmail = $thanato["thanato_email"] != null;
|
||||
if($thanatoHasEmail){
|
||||
$this->sendEmailAttachment($thanato["thanato_email"] , $devis["defunt_nom"],$attachments);
|
||||
}
|
||||
|
||||
}else{
|
||||
$roomToken = $this->talkService->getRoomTokenBeetwenTwoUser($this->userConnectedUuid, $userName);
|
||||
foreach ( $attachments as $attachment) {
|
||||
$this->userConnectedStorage->getFullPath("/");
|
||||
$path = Filesystem::getPath($attachment['file_id']);
|
||||
$destination = 'Talk/';
|
||||
Filesystem::copy($path, $destination . $attachment['name']);
|
||||
//sendFileAttachmentToTalk
|
||||
$this->sendFileAttachmentToTalk($roomToken,$cookie , $attachment['name']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -393,12 +427,16 @@ class GestionService {
|
||||
}
|
||||
}
|
||||
|
||||
public function sendEmailAttachment($defunt_nom ,$attachments = []){
|
||||
public function sendEmailAttachment($to , $defunt_nom ,$attachments = []){
|
||||
$this->userConnectedStorage->getFullPath("/");
|
||||
|
||||
$to = "jonathan.goulet@nextcloud.com";
|
||||
$subject = "Piece jointe";
|
||||
$body = "<p>Bonjour.</p> <p>Vous trouverez en pièce jointe les documents concernant de « $defunt_nom ».</p>";
|
||||
$body = "
|
||||
<p>Bonjour.</p>
|
||||
<p>Vous trouverez en pièce jointe les documents concernant de « $defunt_nom ».</p>
|
||||
<p>Vous en souhaitant bonne réception</p>
|
||||
|
||||
<p>Cordialement</p>
|
||||
";
|
||||
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setSubject($subject);
|
||||
@ -406,7 +444,7 @@ class GestionService {
|
||||
|
||||
foreach ($attachments as $attachment) {
|
||||
$path = Filesystem::getPath($attachment['file_id']);
|
||||
$content = $this->mailer->createAttachment( Filesystem::file_get_contents($path),$attachment['name'],'image/png');
|
||||
$content = $this->mailer->createAttachment( Filesystem::file_get_contents($path),$attachment['name'],$attachment['mime_type']);
|
||||
$message->attach($content);
|
||||
}
|
||||
$message->setHtmlBody( $body);
|
||||
@ -414,4 +452,28 @@ class GestionService {
|
||||
$this->mailer->send($message);
|
||||
|
||||
}
|
||||
|
||||
public function sendFileAttachmentToTalk($roomToken, $cookie , $fileName ) {
|
||||
$host = 'http://127.0.0.1';
|
||||
$client = \OC::$server->getHTTPClientService()->newClient();
|
||||
$token = file_get_contents("$host/ocs/v2.php/core/getcsrftoken", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "OCS-APIRequest: true\r\n"
|
||||
]
|
||||
]));
|
||||
$client->post("$host/ocs/v2.php/apps/files_sharing/api/v1/shares", [
|
||||
'body' => [
|
||||
"path" => "//Talk/$fileName",
|
||||
"referenceId" => Uuid::uuid4()->toString(),
|
||||
"shareWith" => $roomToken,
|
||||
"shareType" => 10,
|
||||
'talkMetaData' => "{\"messageType\":\"\"}"
|
||||
],
|
||||
'headers' => [
|
||||
'Cookie' =>$cookie,
|
||||
'OCS-APIRequest' => 'true',
|
||||
'requesttoken' => $token
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ class TalkService {
|
||||
if($room == null){
|
||||
$roomToken = $this->generateTalkRandomToken();
|
||||
$room = $this->talkDb->createDevisTalkRoomAndReturnDevisTalkRoom($targetUser,$senderUser, $roomToken);
|
||||
$initialMessage = $this->talkDb->setDevisTalkRoomInitialMessageAndReturnMessage($room['id'],$targetUser);
|
||||
$this->talkDb->setDevisTalkRoomInitialMessageAndReturnMessage($room['id'],$targetUser);
|
||||
}
|
||||
else{
|
||||
$roomToken = $room['token'];
|
||||
@ -103,4 +103,24 @@ class TalkService {
|
||||
$this->talkDb->sendAttendeeNotifications($targetUser,$roomToken,$notificationsSubjectsParameters,$notificationsMessageParameters);
|
||||
}
|
||||
|
||||
public function getRoomTokenBeetwenTwoUser( $senderUser , $targetUser){
|
||||
$senderAndTargetIsTheSameUser = $targetUser == $senderUser;
|
||||
$senderUser = $senderAndTargetIsTheSameUser ? BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD : $senderUser;
|
||||
if( $targetUser === BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD && $senderUser === BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD){
|
||||
return;
|
||||
}
|
||||
$roomNames = $this->getUserDevisTalkRoomNames($targetUser , $senderUser);
|
||||
$room = $this->talkDb->getDevisTalkRoomByNames($roomNames);
|
||||
if($room == null){
|
||||
$roomToken = $this->generateTalkRandomToken();
|
||||
$room = $this->talkDb->createDevisTalkRoomAndReturnDevisTalkRoom($targetUser,$senderUser, $roomToken);
|
||||
$this->talkDb->setDevisTalkRoomInitialMessageAndReturnMessage($room['id'],$targetUser);
|
||||
}
|
||||
else{
|
||||
$roomToken = $room['token'];
|
||||
}
|
||||
|
||||
return $roomToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user