Built motion from commit ddca4d0d.|2.5.47
[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 _0xd7e5=['MailInteractionId','update','createdAt','error','lodash','util','bluebird','html-to-text','path','../../config/environment','./mailMessage.attributes','exports','define','MailMessage','mail_messages','messageId','fti_mail_messages','body','plainBody','models','get','direction','toLowerCase','out','secret','isNil','findOne'];(function(_0x2a0738,_0x3c0bc5){var _0x159679=function(_0x9c9ec7){while(--_0x9c9ec7){_0x2a0738['push'](_0x2a0738['shift']());}};_0x159679(++_0x3c0bc5);}(_0xd7e5,0x199));var _0x5d7e=function(_0xaf96a8,_0x215de2){_0xaf96a8=_0xaf96a8-0x0;var _0x49f5cf=_0xd7e5[_0xaf96a8];return _0x49f5cf;};'use strict';var _=require(_0x5d7e('0x0'));var util=require(_0x5d7e('0x1'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0x5d7e('0x2'));var rp=require('request-promise');var htmlToText=require(_0x5d7e('0x3'));var fs=require('fs');var path=require(_0x5d7e('0x4'));var rimraf=require('rimraf');var config=require(_0x5d7e('0x5'));var attributes=require(_0x5d7e('0x6'));module[_0x5d7e('0x7')]=function(_0x291515,_0x378265){return _0x291515[_0x5d7e('0x8')](_0x5d7e('0x9'),attributes,{'tableName':_0x5d7e('0xa'),'paranoid':![],'indexes':[{'name':'messageId','fields':[_0x5d7e('0xb')]},{'name':_0x5d7e('0xc'),'fields':['plainBody','subject'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x3ae3fa,_0x1cb4eb,_0x3a2888){if(_0x3ae3fa[_0x5d7e('0xd')]){_0x3ae3fa[_0x5d7e('0xe')]=htmlToText['fromString'](_0x3ae3fa[_0x5d7e('0xd')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x3a2888(null,_0x1cb4eb);},'afterCreate':function(_0x2784f1,_0x3768d5,_0x8bb258){var _0x5dd174=_0x291515[_0x5d7e('0xf')];var _0x2f56ae=_0x2784f1[_0x5d7e('0x10')]({'plain':!![]});if(_0x2f56ae[_0x5d7e('0x11')][_0x5d7e('0x12')]()==='in'||_0x2f56ae[_0x5d7e('0x11')][_0x5d7e('0x12')]()===_0x5d7e('0x13')&&!_0x2f56ae[_0x5d7e('0x14')]&&!_[_0x5d7e('0x15')](_0x2f56ae['UserId'])){_0x5dd174['MailInteraction'][_0x5d7e('0x16')]({'where':{'id':_0x2f56ae[_0x5d7e('0x17')]}})['then'](function(_0x51f40d){if(_0x51f40d){_0x51f40d[_0x5d7e('0x18')]({'lastMsgAt':_0x2f56ae[_0x5d7e('0x19')],'lastMsgDirection':_0x2f56ae[_0x5d7e('0x11')][_0x5d7e('0x12')]()});}})['catch'](function(_0x4824dc){console[_0x5d7e('0x1a')](_0x4824dc);});}_0x8bb258();}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};