Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / chatMessage / chatMessage.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 _0x885f=['bluebird','request-promise','rimraf','../../config/environment','./chatMessage.attributes','define','ChatMessage','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger'];(function(_0x408c8f,_0x27989b){var _0x2e7fb1=function(_0x2666b3){while(--_0x2666b3){_0x408c8f['push'](_0x408c8f['shift']());}};_0x2e7fb1(++_0x27989b);}(_0x885f,0xa5));var _0xf885=function(_0x579a2f,_0x2a815a){_0x579a2f=_0x579a2f-0x0;var _0x5c9e93=_0x885f[_0x579a2f];return _0x5c9e93;};'use strict';var _=require(_0xf885('0x0'));var util=require(_0xf885('0x1'));var logger=require(_0xf885('0x2'))('api');var moment=require('moment');var BPromise=require(_0xf885('0x3'));var rp=require(_0xf885('0x4'));var fs=require('fs');var path=require('path');var rimraf=require(_0xf885('0x5'));var config=require(_0xf885('0x6'));var attributes=require(_0xf885('0x7'));module['exports']=function(_0x9be6dd,_0x22945b){return _0x9be6dd[_0xf885('0x8')](_0xf885('0x9'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0xf885('0xa'),'fields':[_0xf885('0xb')],'type':_0xf885('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x30f1de,_0x25585c,_0x4d2e89){var _0xc29066=_0x9be6dd[_0xf885('0xd')];var _0x4559da=_0x30f1de[_0xf885('0xe')]({'plain':!![]});if(_0x4559da[_0xf885('0xf')]['toLowerCase']()==='in'||_0x4559da['direction'][_0xf885('0x10')]()==='out'&&!_0x4559da[_0xf885('0x11')]&&!_[_0xf885('0x12')](_0x4559da[_0xf885('0x13')])){_0xc29066[_0xf885('0x14')][_0xf885('0x15')]({'where':{'id':_0x4559da[_0xf885('0x16')]}})[_0xf885('0x17')](function(_0x51b4d6){if(_0x51b4d6){_0x51b4d6[_0xf885('0x18')]({'lastMsgAt':_0x4559da['createdAt'],'lastMsgDirection':_0x4559da[_0xf885('0xf')][_0xf885('0x10')]()});}})['catch'](function(_0x16b1cb){console[_0xf885('0x19')](_0x16b1cb);});}_0x4d2e89();}},'charset':_0xf885('0x1a'),'collate':_0xf885('0x1b')});};