Built motion from commit da617fac.|2.6.6
[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 _0xe5f4=['YYYY-MM-DD\x20HH:mm:ss','closedAt','changed','models','closed','then','lodash','util','../../config/logger','api','moment','bluebird','request-promise','rimraf','../../config/environment','./mailInteraction.attributes','exports','define','mail_interactions','fti_mail_interactions','FULLTEXT','substatus','substatusAt','format'];(function(_0x39b9cd,_0x1ac76a){var _0x441cf4=function(_0x4687b4){while(--_0x4687b4){_0x39b9cd['push'](_0x39b9cd['shift']());}};_0x441cf4(++_0x1ac76a);}(_0xe5f4,0x10e));var _0x4e5f=function(_0x2d0b84,_0x34682d){_0x2d0b84=_0x2d0b84-0x0;var _0x8d0088=_0xe5f4[_0x2d0b84];return _0x8d0088;};'use strict';var _=require(_0x4e5f('0x0'));var util=require(_0x4e5f('0x1'));var logger=require(_0x4e5f('0x2'))(_0x4e5f('0x3'));var moment=require(_0x4e5f('0x4'));var BPromise=require(_0x4e5f('0x5'));var rp=require(_0x4e5f('0x6'));var fs=require('fs');var path=require('path');var rimraf=require(_0x4e5f('0x7'));var config=require(_0x4e5f('0x8'));var attributes=require(_0x4e5f('0x9'));module[_0x4e5f('0xa')]=function(_0x355c05,_0x392eb5){return _0x355c05[_0x4e5f('0xb')]('MailInteraction',attributes,{'tableName':_0x4e5f('0xc'),'paranoid':![],'indexes':[{'name':_0x4e5f('0xd'),'fields':['subject','to'],'type':_0x4e5f('0xe')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x88afcd,_0x330484,_0x5f0a04){if(_0x88afcd[_0x4e5f('0xf')]){_0x88afcd[_0x4e5f('0x10')]=moment()[_0x4e5f('0x11')](_0x4e5f('0x12'));}if(_0x88afcd['closed']){_0x88afcd[_0x4e5f('0x13')]=moment()[_0x4e5f('0x11')](_0x4e5f('0x12'));}_0x5f0a04(null,_0x330484);},'beforeUpdate':function(_0x5a974e,_0x2ea7a5,_0x314894){if(_0x5a974e[_0x4e5f('0x14')](_0x4e5f('0xf'))){_0x5a974e[_0x4e5f('0x10')]=_0x5a974e['substatus']?moment()[_0x4e5f('0x11')]('YYYY-MM-DD\x20HH:mm:ss'):null;}if(_0x5a974e[_0x4e5f('0x14')]('closed')){_0x5a974e['closedAt']=moment()[_0x4e5f('0x11')](_0x4e5f('0x12'));_0x5a974e[_0x4e5f('0xf')]=null;_0x5a974e['substatusAt']=null;}_0x314894(null,_0x5a974e);},'afterUpdate':function(_0x4820f1,_0x43af5a,_0x32a1e5){var _0x4e2cc6=_0x355c05[_0x4e5f('0x15')];var _0x5c5cc7=_0x4820f1['get']({'plain':!![]});if(_0x5c5cc7[_0x4e5f('0x16')]){return _0x4e2cc6['MailMessage']['update']({'read':!![]},{'where':{'MailInteractionId':_0x5c5cc7['id']}})[_0x4e5f('0x17')](function(){_0x32a1e5();})['catch'](function(_0x3ec219){_0x32a1e5(_0x3ec219);});}else{_0x32a1e5();}}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};