Built motion from commit (unavailable).|2.5.6
[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 _0x4a69=['bluebird','request-promise','path','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','models','toLowerCase','direction','out','secret','isNil','UserId','ChatInteraction','ChatInteractionId','then','update','createdAt','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment'];(function(_0x1d4741,_0x4c4611){var _0x564448=function(_0x31b100){while(--_0x31b100){_0x1d4741['push'](_0x1d4741['shift']());}};_0x564448(++_0x4c4611);}(_0x4a69,0x8d));var _0x94a6=function(_0x3ed95e,_0x2d2d13){_0x3ed95e=_0x3ed95e-0x0;var _0x4ab531=_0x4a69[_0x3ed95e];return _0x4ab531;};'use strict';var _=require(_0x94a6('0x0'));var util=require(_0x94a6('0x1'));var logger=require('../../config/logger')(_0x94a6('0x2'));var moment=require(_0x94a6('0x3'));var BPromise=require(_0x94a6('0x4'));var rp=require(_0x94a6('0x5'));var fs=require('fs');var path=require(_0x94a6('0x6'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0x94a6('0x7'));module[_0x94a6('0x8')]=function(_0x5de883,_0x5b65ef){return _0x5de883[_0x94a6('0x9')](_0x94a6('0xa'),attributes,{'tableName':_0x94a6('0xb'),'paranoid':![],'indexes':[{'name':_0x94a6('0xc'),'fields':[_0x94a6('0xd')],'type':_0x94a6('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5d5250,_0x23b4c1,_0x3b9831){var _0x40f094=_0x5de883[_0x94a6('0xf')];var _0x1965e7=_0x5d5250['get']({'plain':!![]});if(_0x1965e7['direction'][_0x94a6('0x10')]()==='in'||_0x1965e7[_0x94a6('0x11')][_0x94a6('0x10')]()===_0x94a6('0x12')&&!_0x1965e7[_0x94a6('0x13')]&&!_[_0x94a6('0x14')](_0x1965e7[_0x94a6('0x15')])){_0x40f094[_0x94a6('0x16')]['findOne']({'where':{'id':_0x1965e7[_0x94a6('0x17')]}})[_0x94a6('0x18')](function(_0x18230f){if(_0x18230f){_0x18230f[_0x94a6('0x19')]({'lastMsgAt':_0x1965e7[_0x94a6('0x1a')],'lastMsgDirection':_0x1965e7[_0x94a6('0x11')]['toLowerCase']()});}})['catch'](function(_0x5a6ce0){console['error'](_0x5a6ce0);});}_0x3b9831();}},'charset':_0x94a6('0x1b'),'collate':_0x94a6('0x1c')});};