Built motion from commit eddce310.|2.6.12
[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 _0xf51e=['then','update','createdAt','utf8mb4_unicode_ci','util','../../config/logger','api','moment','bluebird','request-promise','path','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId'];(function(_0x2d1b29,_0xab7afe){var _0x285792=function(_0x1e4bf4){while(--_0x1e4bf4){_0x2d1b29['push'](_0x2d1b29['shift']());}};_0x285792(++_0xab7afe);}(_0xf51e,0x9a));var _0xef51=function(_0x35358a,_0x49ba11){_0x35358a=_0x35358a-0x0;var _0x2c50e4=_0xf51e[_0x35358a];return _0x2c50e4;};'use strict';var _=require('lodash');var util=require(_0xef51('0x0'));var logger=require(_0xef51('0x1'))(_0xef51('0x2'));var moment=require(_0xef51('0x3'));var BPromise=require(_0xef51('0x4'));var rp=require(_0xef51('0x5'));var fs=require('fs');var path=require(_0xef51('0x6'));var rimraf=require('rimraf');var config=require(_0xef51('0x7'));var attributes=require(_0xef51('0x8'));module[_0xef51('0x9')]=function(_0x1f13f0,_0x4b159f){return _0x1f13f0[_0xef51('0xa')](_0xef51('0xb'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0xef51('0xc'),'fields':[_0xef51('0xd')],'type':_0xef51('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x371a77,_0x9b44d,_0x5a0922){var _0x18abee=_0x1f13f0[_0xef51('0xf')];var _0x42d01e=_0x371a77[_0xef51('0x10')]({'plain':!![]});if(_0x42d01e[_0xef51('0x11')][_0xef51('0x12')]()==='in'||_0x42d01e['direction']['toLowerCase']()===_0xef51('0x13')&&!_0x42d01e[_0xef51('0x14')]&&!_[_0xef51('0x15')](_0x42d01e[_0xef51('0x16')])){_0x18abee[_0xef51('0x17')][_0xef51('0x18')]({'where':{'id':_0x42d01e[_0xef51('0x19')]}})[_0xef51('0x1a')](function(_0x9efe16){if(_0x9efe16){_0x9efe16[_0xef51('0x1b')]({'lastMsgAt':_0x42d01e[_0xef51('0x1c')],'lastMsgDirection':_0x42d01e[_0xef51('0x11')][_0xef51('0x12')]()});}})['catch'](function(_0x5a10f5){console['error'](_0x5a10f5);});}_0x5a0922();}},'charset':'utf8mb4','collate':_0xef51('0x1d')});};