89fc5250b3ee89e0d5e5b09543282501cb95dae2
[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 _0xc026=['../../config/environment','./chatMessage.attributes','define','ChatMessage','fti_chat_messages','body','FULLTEXT','get','direction','toLowerCase','out','secret','isNil','UserId','findOne','then','update','createdAt','utf8mb4','utf8mb4_unicode_ci','util','../../config/logger','api','moment','bluebird','path','rimraf'];(function(_0x5a6a50,_0x57abcc){var _0x387841=function(_0xf9eec9){while(--_0xf9eec9){_0x5a6a50['push'](_0x5a6a50['shift']());}};_0x387841(++_0x57abcc);}(_0xc026,0x1df));var _0x6c02=function(_0x33611d,_0x48c2b5){_0x33611d=_0x33611d-0x0;var _0x4db2c2=_0xc026[_0x33611d];return _0x4db2c2;};'use strict';var _=require('lodash');var util=require(_0x6c02('0x0'));var logger=require(_0x6c02('0x1'))(_0x6c02('0x2'));var moment=require(_0x6c02('0x3'));var BPromise=require(_0x6c02('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x6c02('0x5'));var rimraf=require(_0x6c02('0x6'));var config=require(_0x6c02('0x7'));var attributes=require(_0x6c02('0x8'));module['exports']=function(_0x9439c3,_0x380f01){return _0x9439c3[_0x6c02('0x9')](_0x6c02('0xa'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0x6c02('0xb'),'fields':[_0x6c02('0xc')],'type':_0x6c02('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x7bddc0,_0x2dcb60,_0x420072){var _0x40fecd=_0x9439c3['models'];var _0x1afc5f=_0x7bddc0[_0x6c02('0xe')]({'plain':!![]});if(_0x1afc5f[_0x6c02('0xf')][_0x6c02('0x10')]()==='in'||_0x1afc5f['direction'][_0x6c02('0x10')]()===_0x6c02('0x11')&&!_0x1afc5f[_0x6c02('0x12')]&&!_[_0x6c02('0x13')](_0x1afc5f[_0x6c02('0x14')])){_0x40fecd['ChatInteraction'][_0x6c02('0x15')]({'where':{'id':_0x1afc5f['ChatInteractionId']}})[_0x6c02('0x16')](function(_0x2bbbc0){if(_0x2bbbc0){_0x2bbbc0[_0x6c02('0x17')]({'lastMsgAt':_0x1afc5f[_0x6c02('0x18')],'lastMsgDirection':_0x1afc5f[_0x6c02('0xf')][_0x6c02('0x10')]()});}})['catch'](function(_0x590ed9){console['error'](_0x590ed9);});}_0x420072();}},'charset':_0x6c02('0x19'),'collate':_0x6c02('0x1a')});};