Built motion from commit (unavailable).|2.5.18
[motion2.git] / server / api / mailInteraction / mailInteraction.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 _0x16e4=['YYYY-MM-DD\x20HH:mm:ss','closedAt','changed','substatus','closed','models','get','update','then','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','path','../../config/environment','./mailInteraction.attributes','define','MailInteraction','mail_interactions','fti_mail_interactions','subject','FULLTEXT','substatusAt','format'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x16e4,0x97));var _0x416e=function(_0x26568a,_0x553e1c){_0x26568a=_0x26568a-0x0;var _0x23775a=_0x16e4[_0x26568a];return _0x23775a;};'use strict';var _=require(_0x416e('0x0'));var util=require(_0x416e('0x1'));var logger=require(_0x416e('0x2'))(_0x416e('0x3'));var moment=require(_0x416e('0x4'));var BPromise=require(_0x416e('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x416e('0x6'));var rimraf=require('rimraf');var config=require(_0x416e('0x7'));var attributes=require(_0x416e('0x8'));module['exports']=function(_0x1dad5d,_0x2f7484){return _0x1dad5d[_0x416e('0x9')](_0x416e('0xa'),attributes,{'tableName':_0x416e('0xb'),'paranoid':![],'indexes':[{'name':_0x416e('0xc'),'fields':[_0x416e('0xd'),'to'],'type':_0x416e('0xe')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x3b5877,_0x47bd90,_0x86c7f2){if(_0x3b5877['substatus']){_0x3b5877[_0x416e('0xf')]=moment()[_0x416e('0x10')](_0x416e('0x11'));}if(_0x3b5877['closed']){_0x3b5877[_0x416e('0x12')]=moment()[_0x416e('0x10')](_0x416e('0x11'));}_0x86c7f2(null,_0x47bd90);},'beforeUpdate':function(_0x5ca749,_0x27cf66,_0x4b31db){if(_0x5ca749[_0x416e('0x13')](_0x416e('0x14'))){_0x5ca749[_0x416e('0xf')]=_0x5ca749[_0x416e('0x14')]?moment()['format'](_0x416e('0x11')):null;}if(_0x5ca749[_0x416e('0x13')](_0x416e('0x15'))){_0x5ca749[_0x416e('0x12')]=moment()[_0x416e('0x10')](_0x416e('0x11'));_0x5ca749[_0x416e('0x14')]=null;_0x5ca749[_0x416e('0xf')]=null;}_0x4b31db(null,_0x5ca749);},'afterUpdate':function(_0x36069b,_0x5624ab,_0x5c555b){var _0x5d8852=_0x1dad5d[_0x416e('0x16')];var _0x3f8b53=_0x36069b[_0x416e('0x17')]({'plain':!![]});if(_0x3f8b53[_0x416e('0x15')]){return _0x5d8852['MailMessage'][_0x416e('0x18')]({'read':!![]},{'where':{'MailInteractionId':_0x3f8b53['id']}})[_0x416e('0x19')](function(){_0x5c555b();})['catch'](function(_0x2ce23e){_0x5c555b(_0x2ce23e);});}else{_0x5c555b();}}},'charset':_0x416e('0x1a'),'collate':_0x416e('0x1b')});};