d279b111be7c591e0721265ce7ec5e55052e8dda
[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 _0xe379=['utf8mb4_unicode_ci','lodash','../../config/logger','api','moment','request-promise','path','rimraf','define','chat_messages','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','UserId','ChatInteraction','ChatInteractionId','then','update','createdAt','catch','error','utf8mb4'];(function(_0x2e0443,_0x7e5974){var _0x52d450=function(_0x3a9985){while(--_0x3a9985){_0x2e0443['push'](_0x2e0443['shift']());}};_0x52d450(++_0x7e5974);}(_0xe379,0x160));var _0x9e37=function(_0x3ea9bb,_0x4ca52d){_0x3ea9bb=_0x3ea9bb-0x0;var _0x28121d=_0xe379[_0x3ea9bb];return _0x28121d;};'use strict';var _=require(_0x9e37('0x0'));var util=require('util');var logger=require(_0x9e37('0x1'))(_0x9e37('0x2'));var moment=require(_0x9e37('0x3'));var BPromise=require('bluebird');var rp=require(_0x9e37('0x4'));var fs=require('fs');var path=require(_0x9e37('0x5'));var rimraf=require(_0x9e37('0x6'));var config=require('../../config/environment');var attributes=require('./chatMessage.attributes');module['exports']=function(_0x115cc6,_0x3cae30){return _0x115cc6[_0x9e37('0x7')]('ChatMessage',attributes,{'tableName':_0x9e37('0x8'),'paranoid':![],'indexes':[{'name':_0x9e37('0x9'),'fields':[_0x9e37('0xa')],'type':_0x9e37('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x73efcf,_0x482888,_0x3323ac){var _0x277a60=_0x115cc6[_0x9e37('0xc')];var _0x1094a3=_0x73efcf[_0x9e37('0xd')]({'plain':!![]});if(_0x1094a3[_0x9e37('0xe')][_0x9e37('0xf')]()==='in'||_0x1094a3[_0x9e37('0xe')]['toLowerCase']()===_0x9e37('0x10')&&!_0x1094a3['secret']&&!_['isNil'](_0x1094a3[_0x9e37('0x11')])){_0x277a60[_0x9e37('0x12')]['findOne']({'where':{'id':_0x1094a3[_0x9e37('0x13')]}})[_0x9e37('0x14')](function(_0x1fcdb4){if(_0x1fcdb4){_0x1fcdb4[_0x9e37('0x15')]({'lastMsgAt':_0x1094a3[_0x9e37('0x16')],'lastMsgDirection':_0x1094a3['direction']['toLowerCase']()});}})[_0x9e37('0x17')](function(_0x114cb7){console[_0x9e37('0x18')](_0x114cb7);});}_0x3323ac();}},'charset':_0x9e37('0x19'),'collate':_0x9e37('0x1a')});};