9482472e0a6b069726cab1174f350fc6dceb3172
[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 _0x4e6a=['body','FULLTEXT','models','get','direction','toLowerCase','out','secret','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','define','ChatMessage'];(function(_0x278380,_0x42ffbb){var _0x145f90=function(_0x324ece){while(--_0x324ece){_0x278380['push'](_0x278380['shift']());}};_0x145f90(++_0x42ffbb);}(_0x4e6a,0xc0));var _0xa4e6=function(_0x307006,_0x5693aa){_0x307006=_0x307006-0x0;var _0x59a93f=_0x4e6a[_0x307006];return _0x59a93f;};'use strict';var _=require(_0xa4e6('0x0'));var util=require('util');var logger=require('../../config/logger')(_0xa4e6('0x1'));var moment=require(_0xa4e6('0x2'));var BPromise=require(_0xa4e6('0x3'));var rp=require(_0xa4e6('0x4'));var fs=require('fs');var path=require(_0xa4e6('0x5'));var rimraf=require(_0xa4e6('0x6'));var config=require(_0xa4e6('0x7'));var attributes=require(_0xa4e6('0x8'));module['exports']=function(_0x1c2853,_0x5eee47){return _0x1c2853[_0xa4e6('0x9')](_0xa4e6('0xa'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0xa4e6('0xb')],'type':_0xa4e6('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x319b36,_0x1bb7ec,_0x48eee4){var _0x499aa1=_0x1c2853[_0xa4e6('0xd')];var _0x35fbdc=_0x319b36[_0xa4e6('0xe')]({'plain':!![]});if(_0x35fbdc[_0xa4e6('0xf')][_0xa4e6('0x10')]()==='in'||_0x35fbdc[_0xa4e6('0xf')][_0xa4e6('0x10')]()===_0xa4e6('0x11')&&!_0x35fbdc[_0xa4e6('0x12')]&&!_['isNil'](_0x35fbdc['UserId'])){_0x499aa1[_0xa4e6('0x13')][_0xa4e6('0x14')]({'where':{'id':_0x35fbdc[_0xa4e6('0x15')]}})[_0xa4e6('0x16')](function(_0xb91575){if(_0xb91575){_0xb91575[_0xa4e6('0x17')]({'lastMsgAt':_0x35fbdc[_0xa4e6('0x18')],'lastMsgDirection':_0x35fbdc[_0xa4e6('0xf')][_0xa4e6('0x10')]()});}})[_0xa4e6('0x19')](function(_0x5d1f41){console[_0xa4e6('0x1a')](_0x5d1f41);});}_0x48eee4();}},'charset':_0xa4e6('0x1b'),'collate':_0xa4e6('0x1c')});};