a991738d68b237ac6fce7ad84e16f4663a1f7b16
[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 _0x3e99=['direction','toLowerCase','out','isNil','UserId','MailInteraction','findOne','MailInteractionId','then','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','request-promise','html-to-text','path','rimraf','../../config/environment','exports','define','MailMessage','mail_messages','messageId','fti_mail_messages','subject','FULLTEXT','body','get'];(function(_0x33e79c,_0x25648d){var _0x5e00c6=function(_0x3443d5){while(--_0x3443d5){_0x33e79c['push'](_0x33e79c['shift']());}};_0x5e00c6(++_0x25648d);}(_0x3e99,0x78));var _0x93e9=function(_0x499992,_0x45b862){_0x499992=_0x499992-0x0;var _0x2130cd=_0x3e99[_0x499992];return _0x2130cd;};'use strict';var _=require(_0x93e9('0x0'));var util=require(_0x93e9('0x1'));var logger=require(_0x93e9('0x2'))(_0x93e9('0x3'));var moment=require('moment');var BPromise=require(_0x93e9('0x4'));var rp=require(_0x93e9('0x5'));var htmlToText=require(_0x93e9('0x6'));var fs=require('fs');var path=require(_0x93e9('0x7'));var rimraf=require(_0x93e9('0x8'));var config=require(_0x93e9('0x9'));var attributes=require('./mailMessage.attributes');module[_0x93e9('0xa')]=function(_0x27a634,_0xa14aa5){return _0x27a634[_0x93e9('0xb')](_0x93e9('0xc'),attributes,{'tableName':_0x93e9('0xd'),'paranoid':![],'indexes':[{'name':_0x93e9('0xe'),'fields':[_0x93e9('0xe')]},{'name':_0x93e9('0xf'),'fields':['plainBody',_0x93e9('0x10')],'type':_0x93e9('0x11')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x238554,_0x1e4a3b,_0x42adc1){if(_0x238554['body']){_0x238554['plainBody']=htmlToText['fromString'](_0x238554[_0x93e9('0x12')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x42adc1(null,_0x1e4a3b);},'afterCreate':function(_0x53b419,_0x408d2f,_0x5efacc){var _0x2c527f=_0x27a634['models'];var _0x3f903f=_0x53b419[_0x93e9('0x13')]({'plain':!![]});if(_0x3f903f[_0x93e9('0x14')]['toLowerCase']()==='in'||_0x3f903f[_0x93e9('0x14')][_0x93e9('0x15')]()===_0x93e9('0x16')&&!_0x3f903f['secret']&&!_[_0x93e9('0x17')](_0x3f903f[_0x93e9('0x18')])){_0x2c527f[_0x93e9('0x19')][_0x93e9('0x1a')]({'where':{'id':_0x3f903f[_0x93e9('0x1b')]}})[_0x93e9('0x1c')](function(_0x5bf69b){if(_0x5bf69b){_0x5bf69b[_0x93e9('0x1d')]({'lastMsgAt':_0x3f903f[_0x93e9('0x1e')],'lastMsgDirection':_0x3f903f[_0x93e9('0x14')][_0x93e9('0x15')]()});}})[_0x93e9('0x1f')](function(_0x190230){console[_0x93e9('0x20')](_0x190230);});}_0x5efacc();}},'charset':_0x93e9('0x21'),'collate':_0x93e9('0x22')});};