Built motion from commit 616d3211.|2.6.4
[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 _0x7a57=['toLowerCase','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','direction','catch','lodash','../../config/logger','api','moment','request-promise','path','rimraf','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','get'];(function(_0x5f49c1,_0x5065cf){var _0x2e85d6=function(_0x21a1a5){while(--_0x21a1a5){_0x5f49c1['push'](_0x5f49c1['shift']());}};_0x2e85d6(++_0x5065cf);}(_0x7a57,0x1d6));var _0x77a5=function(_0x3a4a62,_0xcb727a){_0x3a4a62=_0x3a4a62-0x0;var _0x554e29=_0x7a57[_0x3a4a62];return _0x554e29;};'use strict';var _=require(_0x77a5('0x0'));var util=require('util');var logger=require(_0x77a5('0x1'))(_0x77a5('0x2'));var moment=require(_0x77a5('0x3'));var BPromise=require('bluebird');var rp=require(_0x77a5('0x4'));var fs=require('fs');var path=require(_0x77a5('0x5'));var rimraf=require(_0x77a5('0x6'));var config=require('../../config/environment');var attributes=require(_0x77a5('0x7'));module[_0x77a5('0x8')]=function(_0x540ed9,_0x53db95){return _0x540ed9[_0x77a5('0x9')](_0x77a5('0xa'),attributes,{'tableName':_0x77a5('0xb'),'paranoid':![],'indexes':[{'name':_0x77a5('0xc'),'fields':[_0x77a5('0xd')],'type':_0x77a5('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x16fc64,_0x4a03bc,_0x1649da){var _0xe382fd=_0x540ed9['models'];var _0x3a0a21=_0x16fc64[_0x77a5('0xf')]({'plain':!![]});if(_0x3a0a21['direction']['toLowerCase']()==='in'||_0x3a0a21['direction'][_0x77a5('0x10')]()==='out'&&!_0x3a0a21['secret']&&!_[_0x77a5('0x11')](_0x3a0a21[_0x77a5('0x12')])){_0xe382fd[_0x77a5('0x13')][_0x77a5('0x14')]({'where':{'id':_0x3a0a21[_0x77a5('0x15')]}})[_0x77a5('0x16')](function(_0x40e056){if(_0x40e056){_0x40e056[_0x77a5('0x17')]({'lastMsgAt':_0x3a0a21[_0x77a5('0x18')],'lastMsgDirection':_0x3a0a21[_0x77a5('0x19')]['toLowerCase']()});}})[_0x77a5('0x1a')](function(_0x70532d){console['error'](_0x70532d);});}_0x1649da();}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};