1 // *************************************************************************
3 // * xCALLY Motion - The Omnichannel Contact Center *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved *
6 // *************************************************************************
8 // * Email: info@xcally.com *
9 // * Website: https://www.xcally.com *
11 // *************************************************************************
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. *
17 // *************************************************************************
18 var _0xbffb=['ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','toLowerCase','catch','error','utf8mb4','lodash','util','moment','bluebird','request-promise','./chatMessage.attributes','exports','define','fti_chat_messages','body','models','direction','out','isNil','UserId'];(function(_0xfae23b,_0x2be4ba){var _0x200640=function(_0x4ae258){while(--_0x4ae258){_0xfae23b['push'](_0xfae23b['shift']());}};_0x200640(++_0x2be4ba);}(_0xbffb,0x104));var _0xbbff=function(_0x165360,_0x4f734e){_0x165360=_0x165360-0x0;var _0x568311=_0xbffb[_0x165360];return _0x568311;};'use strict';var _=require(_0xbbff('0x0'));var util=require(_0xbbff('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0xbbff('0x2'));var BPromise=require(_0xbbff('0x3'));var rp=require(_0xbbff('0x4'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0xbbff('0x5'));module[_0xbbff('0x6')]=function(_0x1b3668,_0x413f98){return _0x1b3668[_0xbbff('0x7')]('ChatMessage',attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0xbbff('0x8'),'fields':[_0xbbff('0x9')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3c773a,_0x53438e,_0x47829d){var _0x470f74=_0x1b3668[_0xbbff('0xa')];var _0x2c34df=_0x3c773a['get']({'plain':!![]});if(_0x2c34df[_0xbbff('0xb')]['toLowerCase']()==='in'||_0x2c34df[_0xbbff('0xb')]['toLowerCase']()===_0xbbff('0xc')&&!_0x2c34df['secret']&&!_[_0xbbff('0xd')](_0x2c34df[_0xbbff('0xe')])){_0x470f74[_0xbbff('0xf')][_0xbbff('0x10')]({'where':{'id':_0x2c34df[_0xbbff('0x11')]}})[_0xbbff('0x12')](function(_0xecc49a){if(_0xecc49a){_0xecc49a[_0xbbff('0x13')]({'lastMsgAt':_0x2c34df[_0xbbff('0x14')],'lastMsgDirection':_0x2c34df['direction'][_0xbbff('0x15')]()});}})[_0xbbff('0x16')](function(_0x60574){console[_0xbbff('0x17')](_0x60574);});}_0x47829d();}},'charset':_0xbbff('0x18'),'collate':'utf8mb4_unicode_ci'});};