Built motion from commit 5ba5b610.|2.5.33
[motion2.git] / server / api / mailMessage / mailMessage.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xf1c5=['models','direction','toLowerCase','out','secret','isNil','UserId','MailInteraction','findOne','MailInteractionId','then','update','createdAt','catch','error','utf8mb4','lodash','util','../../config/logger','moment','bluebird','request-promise','html-to-text','path','rimraf','./mailMessage.attributes','exports','define','MailMessage','mail_messages','messageId','plainBody','subject','FULLTEXT','body'];(function(_0x44b7d6,_0x4a3f3f){var _0x5346f0=function(_0x35ac17){while(--_0x35ac17){_0x44b7d6['push'](_0x44b7d6['shift']());}};_0x5346f0(++_0x4a3f3f);}(_0xf1c5,0x1b4));var _0x5f1c=function(_0x4d79c3,_0x5e6a0b){_0x4d79c3=_0x4d79c3-0x0;var _0x2432b1=_0xf1c5[_0x4d79c3];return _0x2432b1;};'use strict';var _=require(_0x5f1c('0x0'));var util=require(_0x5f1c('0x1'));var logger=require(_0x5f1c('0x2'))('api');var moment=require(_0x5f1c('0x3'));var BPromise=require(_0x5f1c('0x4'));var rp=require(_0x5f1c('0x5'));var htmlToText=require(_0x5f1c('0x6'));var fs=require('fs');var path=require(_0x5f1c('0x7'));var rimraf=require(_0x5f1c('0x8'));var config=require('../../config/environment');var attributes=require(_0x5f1c('0x9'));module[_0x5f1c('0xa')]=function(_0x36ac27,_0x45a775){return _0x36ac27[_0x5f1c('0xb')](_0x5f1c('0xc'),attributes,{'tableName':_0x5f1c('0xd'),'paranoid':![],'indexes':[{'name':_0x5f1c('0xe'),'fields':['messageId']},{'name':'fti_mail_messages','fields':[_0x5f1c('0xf'),_0x5f1c('0x10')],'type':_0x5f1c('0x11')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x44327b,_0x540a46,_0x4ad1fd){if(_0x44327b['body']){_0x44327b['plainBody']=htmlToText['fromString'](_0x44327b[_0x5f1c('0x12')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x4ad1fd(null,_0x540a46);},'afterCreate':function(_0x56b25e,_0x4b19b7,_0xfbe744){var _0x56ce6c=_0x36ac27[_0x5f1c('0x13')];var _0x357110=_0x56b25e['get']({'plain':!![]});if(_0x357110[_0x5f1c('0x14')][_0x5f1c('0x15')]()==='in'||_0x357110[_0x5f1c('0x14')]['toLowerCase']()===_0x5f1c('0x16')&&!_0x357110[_0x5f1c('0x17')]&&!_[_0x5f1c('0x18')](_0x357110[_0x5f1c('0x19')])){_0x56ce6c[_0x5f1c('0x1a')][_0x5f1c('0x1b')]({'where':{'id':_0x357110[_0x5f1c('0x1c')]}})[_0x5f1c('0x1d')](function(_0x5db7f1){if(_0x5db7f1){_0x5db7f1[_0x5f1c('0x1e')]({'lastMsgAt':_0x357110[_0x5f1c('0x1f')],'lastMsgDirection':_0x357110[_0x5f1c('0x14')][_0x5f1c('0x15')]()});}})[_0x5f1c('0x20')](function(_0x3e0d14){console[_0x5f1c('0x21')](_0x3e0d14);});}_0xfbe744();}},'charset':_0x5f1c('0x22'),'collate':'utf8mb4_unicode_ci'});};