Built motion from commit da617fac.|2.6.6
[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 _0x048f=['isNil','ChatInteraction','findOne','ChatInteractionId','then','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','FULLTEXT','models','toLowerCase','direction','out'];(function(_0x21322f,_0x483b21){var _0x33e9d1=function(_0x24b3c5){while(--_0x24b3c5){_0x21322f['push'](_0x21322f['shift']());}};_0x33e9d1(++_0x483b21);}(_0x048f,0xcd));var _0xf048=function(_0x3d91a1,_0x35073a){_0x3d91a1=_0x3d91a1-0x0;var _0x1c2f8f=_0x048f[_0x3d91a1];return _0x1c2f8f;};'use strict';var _=require(_0xf048('0x0'));var util=require(_0xf048('0x1'));var logger=require(_0xf048('0x2'))(_0xf048('0x3'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xf048('0x4'));var fs=require('fs');var path=require(_0xf048('0x5'));var rimraf=require(_0xf048('0x6'));var config=require(_0xf048('0x7'));var attributes=require(_0xf048('0x8'));module[_0xf048('0x9')]=function(_0x766333,_0xa9a18b){return _0x766333[_0xf048('0xa')](_0xf048('0xb'),attributes,{'tableName':_0xf048('0xc'),'paranoid':![],'indexes':[{'name':_0xf048('0xd'),'fields':['body'],'type':_0xf048('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x513f6c,_0x3faa04,_0x2a160c){var _0x477835=_0x766333[_0xf048('0xf')];var _0x34e4f9=_0x513f6c['get']({'plain':!![]});if(_0x34e4f9['direction'][_0xf048('0x10')]()==='in'||_0x34e4f9[_0xf048('0x11')][_0xf048('0x10')]()===_0xf048('0x12')&&!_0x34e4f9['secret']&&!_[_0xf048('0x13')](_0x34e4f9['UserId'])){_0x477835[_0xf048('0x14')][_0xf048('0x15')]({'where':{'id':_0x34e4f9[_0xf048('0x16')]}})[_0xf048('0x17')](function(_0x202932){if(_0x202932){_0x202932['update']({'lastMsgAt':_0x34e4f9['createdAt'],'lastMsgDirection':_0x34e4f9['direction'][_0xf048('0x10')]()});}})[_0xf048('0x18')](function(_0x53f2a5){console[_0xf048('0x19')](_0x53f2a5);});}_0x2a160c();}},'charset':_0xf048('0x1a'),'collate':_0xf048('0x1b')});};