dc3ccc6fee26082342ece79d2a0c83c62d7bf196
[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 _0xdec1=['ChatInteractionId','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','secret','isNil','UserId','ChatInteraction','findOne'];(function(_0x26073a,_0x4652df){var _0x2ab2ad=function(_0x4a378e){while(--_0x4a378e){_0x26073a['push'](_0x26073a['shift']());}};_0x2ab2ad(++_0x4652df);}(_0xdec1,0x11d));var _0x1dec=function(_0x2c2784,_0x36faed){_0x2c2784=_0x2c2784-0x0;var _0x1a8b32=_0xdec1[_0x2c2784];return _0x1a8b32;};'use strict';var _=require(_0x1dec('0x0'));var util=require('util');var logger=require(_0x1dec('0x1'))(_0x1dec('0x2'));var moment=require(_0x1dec('0x3'));var BPromise=require(_0x1dec('0x4'));var rp=require(_0x1dec('0x5'));var fs=require('fs');var path=require(_0x1dec('0x6'));var rimraf=require(_0x1dec('0x7'));var config=require(_0x1dec('0x8'));var attributes=require(_0x1dec('0x9'));module[_0x1dec('0xa')]=function(_0x8f8be1,_0x108f91){return _0x8f8be1[_0x1dec('0xb')](_0x1dec('0xc'),attributes,{'tableName':_0x1dec('0xd'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0x1dec('0xe')],'type':_0x1dec('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x49420c,_0x2eca5c,_0x12f4ef){var _0x3aa428=_0x8f8be1[_0x1dec('0x10')];var _0x4c1222=_0x49420c[_0x1dec('0x11')]({'plain':!![]});if(_0x4c1222[_0x1dec('0x12')][_0x1dec('0x13')]()==='in'||_0x4c1222[_0x1dec('0x12')][_0x1dec('0x13')]()==='out'&&!_0x4c1222[_0x1dec('0x14')]&&!_[_0x1dec('0x15')](_0x4c1222[_0x1dec('0x16')])){_0x3aa428[_0x1dec('0x17')][_0x1dec('0x18')]({'where':{'id':_0x4c1222[_0x1dec('0x19')]}})['then'](function(_0x3c1fa5){if(_0x3c1fa5){_0x3c1fa5['update']({'lastMsgAt':_0x4c1222[_0x1dec('0x1a')],'lastMsgDirection':_0x4c1222[_0x1dec('0x12')][_0x1dec('0x13')]()});}})[_0x1dec('0x1b')](function(_0x22656d){console[_0x1dec('0x1c')](_0x22656d);});}_0x12f4ef();}},'charset':_0x1dec('0x1d'),'collate':_0x1dec('0x1e')});};