Built motion from commit (unavailable).|2.5.15
[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 _0x4f73=['closed','closedAt','format','substatus','changed','models','get','update','then','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','path','../../config/environment','./mailInteraction.attributes','exports','mail_interactions','fti_mail_interactions','subject','FULLTEXT','substatusAt','YYYY-MM-DD\x20HH:mm:ss'];(function(_0x43b1d7,_0x3b4654){var _0x1a973f=function(_0x49e487){while(--_0x49e487){_0x43b1d7['push'](_0x43b1d7['shift']());}};_0x1a973f(++_0x3b4654);}(_0x4f73,0x10f));var _0x34f7=function(_0x3522c8,_0x1e7c82){_0x3522c8=_0x3522c8-0x0;var _0x22f498=_0x4f73[_0x3522c8];return _0x22f498;};'use strict';var _=require(_0x34f7('0x0'));var util=require(_0x34f7('0x1'));var logger=require(_0x34f7('0x2'))(_0x34f7('0x3'));var moment=require('moment');var BPromise=require(_0x34f7('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x34f7('0x5'));var rimraf=require('rimraf');var config=require(_0x34f7('0x6'));var attributes=require(_0x34f7('0x7'));module[_0x34f7('0x8')]=function(_0x3125aa,_0x27053f){return _0x3125aa['define']('MailInteraction',attributes,{'tableName':_0x34f7('0x9'),'paranoid':![],'indexes':[{'name':_0x34f7('0xa'),'fields':[_0x34f7('0xb'),'to'],'type':_0x34f7('0xc')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x21a735,_0x2fabed,_0x50fc1b){if(_0x21a735['substatus']){_0x21a735[_0x34f7('0xd')]=moment()['format'](_0x34f7('0xe'));}if(_0x21a735[_0x34f7('0xf')]){_0x21a735[_0x34f7('0x10')]=moment()[_0x34f7('0x11')](_0x34f7('0xe'));}_0x50fc1b(null,_0x2fabed);},'beforeUpdate':function(_0x28ff6d,_0x27adb7,_0x28c93b){if(_0x28ff6d['changed'](_0x34f7('0x12'))){_0x28ff6d[_0x34f7('0xd')]=_0x28ff6d['substatus']?moment()[_0x34f7('0x11')](_0x34f7('0xe')):null;}if(_0x28ff6d[_0x34f7('0x13')](_0x34f7('0xf'))){_0x28ff6d[_0x34f7('0x10')]=moment()['format'](_0x34f7('0xe'));_0x28ff6d[_0x34f7('0x12')]=null;_0x28ff6d[_0x34f7('0xd')]=null;}_0x28c93b(null,_0x28ff6d);},'afterUpdate':function(_0x2e829b,_0x447271,_0x4eae4d){var _0x3460b4=_0x3125aa[_0x34f7('0x14')];var _0x58f582=_0x2e829b[_0x34f7('0x15')]({'plain':!![]});if(_0x58f582[_0x34f7('0xf')]){return _0x3460b4['MailMessage'][_0x34f7('0x16')]({'read':!![]},{'where':{'MailInteractionId':_0x58f582['id']}})[_0x34f7('0x17')](function(){_0x4eae4d();})['catch'](function(_0x594b6b){_0x4eae4d(_0x594b6b);});}else{_0x4eae4d();}}},'charset':_0x34f7('0x18'),'collate':_0x34f7('0x19')});};