dec854c8dfe9084778baa085805c932dcd530aad
[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 _0xe726=['ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','models','get','direction','toLowerCase','secret','isNil'];(function(_0x5bd426,_0x4878e5){var _0x23a7eb=function(_0x594b42){while(--_0x594b42){_0x5bd426['push'](_0x5bd426['shift']());}};_0x23a7eb(++_0x4878e5);}(_0xe726,0xc3));var _0x6e72=function(_0x16b161,_0x5231ba){_0x16b161=_0x16b161-0x0;var _0x5a2c8e=_0xe726[_0x16b161];return _0x5a2c8e;};'use strict';var _=require(_0x6e72('0x0'));var util=require(_0x6e72('0x1'));var logger=require(_0x6e72('0x2'))(_0x6e72('0x3'));var moment=require(_0x6e72('0x4'));var BPromise=require(_0x6e72('0x5'));var rp=require(_0x6e72('0x6'));var fs=require('fs');var path=require(_0x6e72('0x7'));var rimraf=require(_0x6e72('0x8'));var config=require(_0x6e72('0x9'));var attributes=require(_0x6e72('0xa'));module[_0x6e72('0xb')]=function(_0x359964,_0x17d0ee){return _0x359964[_0x6e72('0xc')](_0x6e72('0xd'),attributes,{'tableName':_0x6e72('0xe'),'paranoid':![],'indexes':[{'name':_0x6e72('0xf'),'fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3fc3d4,_0x5275b1,_0x252fbb){var _0x4c50a4=_0x359964[_0x6e72('0x10')];var _0x5d0897=_0x3fc3d4[_0x6e72('0x11')]({'plain':!![]});if(_0x5d0897[_0x6e72('0x12')][_0x6e72('0x13')]()==='in'||_0x5d0897[_0x6e72('0x12')]['toLowerCase']()==='out'&&!_0x5d0897[_0x6e72('0x14')]&&!_[_0x6e72('0x15')](_0x5d0897['UserId'])){_0x4c50a4[_0x6e72('0x16')][_0x6e72('0x17')]({'where':{'id':_0x5d0897[_0x6e72('0x18')]}})[_0x6e72('0x19')](function(_0x8bea8c){if(_0x8bea8c){_0x8bea8c[_0x6e72('0x1a')]({'lastMsgAt':_0x5d0897[_0x6e72('0x1b')],'lastMsgDirection':_0x5d0897[_0x6e72('0x12')]['toLowerCase']()});}})['catch'](function(_0x2bb6ec){console[_0x6e72('0x1c')](_0x2bb6ec);});}_0x252fbb();}},'charset':_0x6e72('0x1d'),'collate':_0x6e72('0x1e')});};