Built motion from commit 3c2ce842.|2.6.31
[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 _0x4a25=['exports','ChatMessage','chat_messages','fti_chat_messages','get','toLowerCase','direction','out','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','moment','bluebird','request-promise','path','../../config/environment','./chatMessage.attributes'];(function(_0x45d55e,_0x2fede3){var _0x29812a=function(_0x3c6830){while(--_0x3c6830){_0x45d55e['push'](_0x45d55e['shift']());}};_0x29812a(++_0x2fede3);}(_0x4a25,0x1d4));var _0x54a2=function(_0x2353fe,_0x4b0bca){_0x2353fe=_0x2353fe-0x0;var _0x4d43f6=_0x4a25[_0x2353fe];return _0x4d43f6;};'use strict';var _=require(_0x54a2('0x0'));var util=require('util');var logger=require(_0x54a2('0x1'))('api');var moment=require(_0x54a2('0x2'));var BPromise=require(_0x54a2('0x3'));var rp=require(_0x54a2('0x4'));var fs=require('fs');var path=require(_0x54a2('0x5'));var rimraf=require('rimraf');var config=require(_0x54a2('0x6'));var attributes=require(_0x54a2('0x7'));module[_0x54a2('0x8')]=function(_0x3ecde5,_0x472eed){return _0x3ecde5['define'](_0x54a2('0x9'),attributes,{'tableName':_0x54a2('0xa'),'paranoid':![],'indexes':[{'name':_0x54a2('0xb'),'fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3d0334,_0x5db8dc,_0x466c88){var _0x28655c=_0x3ecde5['models'];var _0x38a9f5=_0x3d0334[_0x54a2('0xc')]({'plain':!![]});if(_0x38a9f5['direction'][_0x54a2('0xd')]()==='in'||_0x38a9f5[_0x54a2('0xe')]['toLowerCase']()===_0x54a2('0xf')&&!_0x38a9f5[_0x54a2('0x10')]&&!_[_0x54a2('0x11')](_0x38a9f5[_0x54a2('0x12')])){_0x28655c[_0x54a2('0x13')][_0x54a2('0x14')]({'where':{'id':_0x38a9f5[_0x54a2('0x15')]}})[_0x54a2('0x16')](function(_0x5e5786){if(_0x5e5786){_0x5e5786[_0x54a2('0x17')]({'lastMsgAt':_0x38a9f5['createdAt'],'lastMsgDirection':_0x38a9f5[_0x54a2('0xe')][_0x54a2('0xd')]()});}})[_0x54a2('0x18')](function(_0x1fcc41){console[_0x54a2('0x19')](_0x1fcc41);});}_0x466c88();}},'charset':_0x54a2('0x1a'),'collate':_0x54a2('0x1b')});};