bdf09fc7a4a06325a0383c4318b081663be78cb1
[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 _0x349e=['bluebird','request-promise','path','rimraf','./chatMessage.attributes','exports','define','chat_messages','fti_chat_messages','body','FULLTEXT','get','direction','toLowerCase','out','secret','isNil','UserId','then','createdAt','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','api'];(function(_0x421cb4,_0x4392b0){var _0x1683ce=function(_0x2c74e5){while(--_0x2c74e5){_0x421cb4['push'](_0x421cb4['shift']());}};_0x1683ce(++_0x4392b0);}(_0x349e,0x19d));var _0xe349=function(_0x1c0747,_0xacdd4c){_0x1c0747=_0x1c0747-0x0;var _0x48fd22=_0x349e[_0x1c0747];return _0x48fd22;};'use strict';var _=require(_0xe349('0x0'));var util=require(_0xe349('0x1'));var logger=require('../../config/logger')(_0xe349('0x2'));var moment=require('moment');var BPromise=require(_0xe349('0x3'));var rp=require(_0xe349('0x4'));var fs=require('fs');var path=require(_0xe349('0x5'));var rimraf=require(_0xe349('0x6'));var config=require('../../config/environment');var attributes=require(_0xe349('0x7'));module[_0xe349('0x8')]=function(_0x4af791,_0x413ce0){return _0x4af791[_0xe349('0x9')]('ChatMessage',attributes,{'tableName':_0xe349('0xa'),'paranoid':![],'indexes':[{'name':_0xe349('0xb'),'fields':[_0xe349('0xc')],'type':_0xe349('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2762e4,_0x372f8e,_0xf30fe6){var _0x323857=_0x4af791['models'];var _0x4585ae=_0x2762e4[_0xe349('0xe')]({'plain':!![]});if(_0x4585ae[_0xe349('0xf')][_0xe349('0x10')]()==='in'||_0x4585ae[_0xe349('0xf')][_0xe349('0x10')]()===_0xe349('0x11')&&!_0x4585ae[_0xe349('0x12')]&&!_[_0xe349('0x13')](_0x4585ae[_0xe349('0x14')])){_0x323857['ChatInteraction']['findOne']({'where':{'id':_0x4585ae['ChatInteractionId']}})[_0xe349('0x15')](function(_0x3d5d0e){if(_0x3d5d0e){_0x3d5d0e['update']({'lastMsgAt':_0x4585ae[_0xe349('0x16')],'lastMsgDirection':_0x4585ae[_0xe349('0xf')]['toLowerCase']()});}})['catch'](function(_0x4239c5){console[_0xe349('0x17')](_0x4239c5);});}_0xf30fe6();}},'charset':_0xe349('0x18'),'collate':_0xe349('0x19')});};