32f24b2afa7496e7180488ae67d6bef413bf3729
[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 _0xb581=['./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','error','utf8mb4_unicode_ci','lodash','../../config/logger','api','moment','bluebird','path','../../config/environment'];(function(_0x41788b,_0x541a16){var _0x4ae3ef=function(_0x3c1c4f){while(--_0x3c1c4f){_0x41788b['push'](_0x41788b['shift']());}};_0x4ae3ef(++_0x541a16);}(_0xb581,0x71));var _0x1b58=function(_0x144588,_0x1064a4){_0x144588=_0x144588-0x0;var _0x2b00a3=_0xb581[_0x144588];return _0x2b00a3;};'use strict';var _=require(_0x1b58('0x0'));var util=require('util');var logger=require(_0x1b58('0x1'))(_0x1b58('0x2'));var moment=require(_0x1b58('0x3'));var BPromise=require(_0x1b58('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x1b58('0x5'));var rimraf=require('rimraf');var config=require(_0x1b58('0x6'));var attributes=require(_0x1b58('0x7'));module[_0x1b58('0x8')]=function(_0x48670f,_0x5af6f9){return _0x48670f[_0x1b58('0x9')](_0x1b58('0xa'),attributes,{'tableName':_0x1b58('0xb'),'paranoid':![],'indexes':[{'name':_0x1b58('0xc'),'fields':[_0x1b58('0xd')],'type':_0x1b58('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0xce64cf,_0x323a7f,_0x535f87){var _0x572be6=_0x48670f[_0x1b58('0xf')];var _0xa09326=_0xce64cf[_0x1b58('0x10')]({'plain':!![]});if(_0xa09326[_0x1b58('0x11')][_0x1b58('0x12')]()==='in'||_0xa09326[_0x1b58('0x11')][_0x1b58('0x12')]()===_0x1b58('0x13')&&!_0xa09326[_0x1b58('0x14')]&&!_[_0x1b58('0x15')](_0xa09326['UserId'])){_0x572be6[_0x1b58('0x16')][_0x1b58('0x17')]({'where':{'id':_0xa09326[_0x1b58('0x18')]}})[_0x1b58('0x19')](function(_0x3b8389){if(_0x3b8389){_0x3b8389[_0x1b58('0x1a')]({'lastMsgAt':_0xa09326[_0x1b58('0x1b')],'lastMsgDirection':_0xa09326[_0x1b58('0x11')][_0x1b58('0x12')]()});}})['catch'](function(_0x5e8a5f){console[_0x1b58('0x1c')](_0x5e8a5f);});}_0x535f87();}},'charset':'utf8mb4','collate':_0x1b58('0x1d')});};