2a195cc3b9c7d793b05a9a5fb63028ac9002abab
[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 _0x280b=['define','ChatMessage','fti_chat_messages','body','FULLTEXT','get','direction','toLowerCase','out','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','catch','utf8mb4','lodash','util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','exports'];(function(_0x2a4a99,_0x64b4a){var _0x1cef2f=function(_0x43beef){while(--_0x43beef){_0x2a4a99['push'](_0x2a4a99['shift']());}};_0x1cef2f(++_0x64b4a);}(_0x280b,0xce));var _0xb280=function(_0x465028,_0x4570ac){_0x465028=_0x465028-0x0;var _0xb783d4=_0x280b[_0x465028];return _0xb783d4;};'use strict';var _=require(_0xb280('0x0'));var util=require(_0xb280('0x1'));var logger=require('../../config/logger')(_0xb280('0x2'));var moment=require(_0xb280('0x3'));var BPromise=require(_0xb280('0x4'));var rp=require(_0xb280('0x5'));var fs=require('fs');var path=require(_0xb280('0x6'));var rimraf=require(_0xb280('0x7'));var config=require(_0xb280('0x8'));var attributes=require(_0xb280('0x9'));module[_0xb280('0xa')]=function(_0x5d1991,_0x4d1b2e){return _0x5d1991[_0xb280('0xb')](_0xb280('0xc'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0xb280('0xd'),'fields':[_0xb280('0xe')],'type':_0xb280('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0xc26ade,_0x2322ff,_0xde790d){var _0x36ae93=_0x5d1991['models'];var _0x5dd4c8=_0xc26ade[_0xb280('0x10')]({'plain':!![]});if(_0x5dd4c8[_0xb280('0x11')]['toLowerCase']()==='in'||_0x5dd4c8[_0xb280('0x11')][_0xb280('0x12')]()===_0xb280('0x13')&&!_0x5dd4c8[_0xb280('0x14')]&&!_[_0xb280('0x15')](_0x5dd4c8[_0xb280('0x16')])){_0x36ae93[_0xb280('0x17')][_0xb280('0x18')]({'where':{'id':_0x5dd4c8[_0xb280('0x19')]}})[_0xb280('0x1a')](function(_0x1a52df){if(_0x1a52df){_0x1a52df[_0xb280('0x1b')]({'lastMsgAt':_0x5dd4c8[_0xb280('0x1c')],'lastMsgDirection':_0x5dd4c8[_0xb280('0x11')][_0xb280('0x12')]()});}})[_0xb280('0x1d')](function(_0x15b4c0){console['error'](_0x15b4c0);});}_0xde790d();}},'charset':_0xb280('0x1e'),'collate':'utf8mb4_unicode_ci'});};