Built motion from commit (unavailable).|2.4.21
[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 _0x26a4=['util','api','moment','request-promise','html-to-text','path','rimraf','../../config/environment','./mailMessage.attributes','define','mail_messages','messageId','fti_mail_messages','plainBody','subject','FULLTEXT','body','models','get','toLowerCase','out','UserId','findOne','update','createdAt','direction','catch','error','utf8mb4'];(function(_0x43cea0,_0x316617){var _0x372c0c=function(_0x50af92){while(--_0x50af92){_0x43cea0['push'](_0x43cea0['shift']());}};_0x372c0c(++_0x316617);}(_0x26a4,0x122));var _0x426a=function(_0x4e49f0,_0x574f2e){_0x4e49f0=_0x4e49f0-0x0;var _0x37e2ea=_0x26a4[_0x4e49f0];return _0x37e2ea;};'use strict';var _=require('lodash');var util=require(_0x426a('0x0'));var logger=require('../../config/logger')(_0x426a('0x1'));var moment=require(_0x426a('0x2'));var BPromise=require('bluebird');var rp=require(_0x426a('0x3'));var htmlToText=require(_0x426a('0x4'));var fs=require('fs');var path=require(_0x426a('0x5'));var rimraf=require(_0x426a('0x6'));var config=require(_0x426a('0x7'));var attributes=require(_0x426a('0x8'));module['exports']=function(_0x46f316,_0x5ef972){return _0x46f316[_0x426a('0x9')]('MailMessage',attributes,{'tableName':_0x426a('0xa'),'paranoid':![],'indexes':[{'name':_0x426a('0xb'),'fields':[_0x426a('0xb')]},{'name':_0x426a('0xc'),'fields':[_0x426a('0xd'),_0x426a('0xe')],'type':_0x426a('0xf')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x24c334,_0x204e82,_0x210704){if(_0x24c334[_0x426a('0x10')]){_0x24c334['plainBody']=htmlToText['fromString'](_0x24c334[_0x426a('0x10')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x210704(null,_0x204e82);},'afterCreate':function(_0x192f42,_0x16cb14,_0x4b7ec8){var _0x1ad50b=_0x46f316[_0x426a('0x11')];var _0x5bcc1c=_0x192f42[_0x426a('0x12')]({'plain':!![]});if(_0x5bcc1c['direction'][_0x426a('0x13')]()==='in'||_0x5bcc1c['direction']['toLowerCase']()===_0x426a('0x14')&&!_0x5bcc1c['secret']&&!_['isNil'](_0x5bcc1c[_0x426a('0x15')])){_0x1ad50b['MailInteraction'][_0x426a('0x16')]({'where':{'id':_0x5bcc1c['MailInteractionId']}})['then'](function(_0x2b7a51){if(_0x2b7a51){_0x2b7a51[_0x426a('0x17')]({'lastMsgAt':_0x5bcc1c[_0x426a('0x18')],'lastMsgDirection':_0x5bcc1c[_0x426a('0x19')]['toLowerCase'](),'lastMsgBody':_0x5bcc1c[_0x426a('0x10')]});}})[_0x426a('0x1a')](function(_0x4d6bd4){console[_0x426a('0x1b')](_0x4d6bd4);});}_0x4b7ec8();}},'charset':_0x426a('0x1c'),'collate':'utf8mb4_unicode_ci'});};