1fcbd713e905a200a3f2b2b43963e8100e5cba64
[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 _0x40f1=['MailInteraction','mail_interactions','fti_mail_interactions','subject','FULLTEXT','substatusAt','format','YYYY-MM-DD\x20HH:mm:ss','closed','closedAt','substatus','changed','models','get','update','then','catch','utf8mb4','lodash','../../config/logger','api','moment','bluebird','path','rimraf','../../config/environment','./mailInteraction.attributes','define'];(function(_0x536919,_0x2d0c68){var _0x3694d9=function(_0xf21223){while(--_0xf21223){_0x536919['push'](_0x536919['shift']());}};_0x3694d9(++_0x2d0c68);}(_0x40f1,0x19a));var _0x140f=function(_0x3eb98f,_0x21ff2c){_0x3eb98f=_0x3eb98f-0x0;var _0x203792=_0x40f1[_0x3eb98f];return _0x203792;};'use strict';var _=require(_0x140f('0x0'));var util=require('util');var logger=require(_0x140f('0x1'))(_0x140f('0x2'));var moment=require(_0x140f('0x3'));var BPromise=require(_0x140f('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x140f('0x5'));var rimraf=require(_0x140f('0x6'));var config=require(_0x140f('0x7'));var attributes=require(_0x140f('0x8'));module['exports']=function(_0x565894,_0x27ef79){return _0x565894[_0x140f('0x9')](_0x140f('0xa'),attributes,{'tableName':_0x140f('0xb'),'paranoid':![],'indexes':[{'name':_0x140f('0xc'),'fields':[_0x140f('0xd'),'to'],'type':_0x140f('0xe')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x1a81ff,_0x2b9210,_0x40b5d7){if(_0x1a81ff['substatus']){_0x1a81ff[_0x140f('0xf')]=moment()[_0x140f('0x10')](_0x140f('0x11'));}if(_0x1a81ff[_0x140f('0x12')]){_0x1a81ff[_0x140f('0x13')]=moment()[_0x140f('0x10')](_0x140f('0x11'));}_0x40b5d7(null,_0x2b9210);},'beforeUpdate':function(_0xe2daaa,_0x1877a,_0x22444e){if(_0xe2daaa['changed'](_0x140f('0x14'))){_0xe2daaa['substatusAt']=_0xe2daaa[_0x140f('0x14')]?moment()[_0x140f('0x10')](_0x140f('0x11')):null;}if(_0xe2daaa[_0x140f('0x15')](_0x140f('0x12'))){_0xe2daaa[_0x140f('0x13')]=moment()[_0x140f('0x10')](_0x140f('0x11'));_0xe2daaa[_0x140f('0x14')]=null;_0xe2daaa['substatusAt']=null;}_0x22444e(null,_0xe2daaa);},'afterUpdate':function(_0x45bc9f,_0x58c190,_0x49900e){var _0x2b9b8c=_0x565894[_0x140f('0x16')];var _0x157d5c=_0x45bc9f[_0x140f('0x17')]({'plain':!![]});if(_0x157d5c[_0x140f('0x12')]){return _0x2b9b8c['MailMessage'][_0x140f('0x18')]({'read':!![]},{'where':{'MailInteractionId':_0x157d5c['id']}})[_0x140f('0x19')](function(){_0x49900e();})[_0x140f('0x1a')](function(_0x1a800c){_0x49900e(_0x1a800c);});}else{_0x49900e();}}},'charset':_0x140f('0x1b'),'collate':'utf8mb4_unicode_ci'});};