Built motion from commit (unavailable).|2.5.3
[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 _0x22c8=['ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','utf8mb4','utf8mb4_unicode_ci','lodash','bluebird','request-promise','../../config/environment','./chatMessage.attributes','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','UserId'];(function(_0x5becdc,_0x366503){var _0x2c5786=function(_0x2f9993){while(--_0x2f9993){_0x5becdc['push'](_0x5becdc['shift']());}};_0x2c5786(++_0x366503);}(_0x22c8,0x92));var _0x822c=function(_0x1dac7a,_0x1828ce){_0x1dac7a=_0x1dac7a-0x0;var _0x4cb363=_0x22c8[_0x1dac7a];return _0x4cb363;};'use strict';var _=require(_0x822c('0x0'));var util=require('util');var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0x822c('0x1'));var rp=require(_0x822c('0x2'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0x822c('0x3'));var attributes=require(_0x822c('0x4'));module['exports']=function(_0x5d32af,_0x4c0f94){return _0x5d32af['define']('ChatMessage',attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0x822c('0x5'),'fields':[_0x822c('0x6')],'type':_0x822c('0x7')}],'timestamps':!![],'hooks':{'afterCreate':function(_0xa050d3,_0x1a1ee4,_0x2fab88){var _0x4e7838=_0x5d32af[_0x822c('0x8')];var _0x28e9a2=_0xa050d3[_0x822c('0x9')]({'plain':!![]});if(_0x28e9a2[_0x822c('0xa')][_0x822c('0xb')]()==='in'||_0x28e9a2[_0x822c('0xa')][_0x822c('0xb')]()===_0x822c('0xc')&&!_0x28e9a2[_0x822c('0xd')]&&!_['isNil'](_0x28e9a2[_0x822c('0xe')])){_0x4e7838[_0x822c('0xf')][_0x822c('0x10')]({'where':{'id':_0x28e9a2[_0x822c('0x11')]}})[_0x822c('0x12')](function(_0x4b9702){if(_0x4b9702){_0x4b9702[_0x822c('0x13')]({'lastMsgAt':_0x28e9a2[_0x822c('0x14')],'lastMsgDirection':_0x28e9a2[_0x822c('0xa')][_0x822c('0xb')]()});}})['catch'](function(_0x17a8ee){console['error'](_0x17a8ee);});}_0x2fab88();}},'charset':_0x822c('0x15'),'collate':_0x822c('0x16')});};