34786fdb6497b5612ebdc13ca8334025a3dc0d82
[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 _0xcf09=['request-promise','path','rimraf','../../config/environment','exports','define','ChatMessage','chat_messages','fti_chat_messages','FULLTEXT','models','get','direction','toLowerCase','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','error','utf8mb4','utf8mb4_unicode_ci','lodash','api','moment','bluebird'];(function(_0xbca1b1,_0x33f0ce){var _0x4e1686=function(_0x58a80c){while(--_0x58a80c){_0xbca1b1['push'](_0xbca1b1['shift']());}};_0x4e1686(++_0x33f0ce);}(_0xcf09,0x1f4));var _0x9cf0=function(_0x35f8d6,_0x2e1116){_0x35f8d6=_0x35f8d6-0x0;var _0x3a9c28=_0xcf09[_0x35f8d6];return _0x3a9c28;};'use strict';var _=require(_0x9cf0('0x0'));var util=require('util');var logger=require('../../config/logger')(_0x9cf0('0x1'));var moment=require(_0x9cf0('0x2'));var BPromise=require(_0x9cf0('0x3'));var rp=require(_0x9cf0('0x4'));var fs=require('fs');var path=require(_0x9cf0('0x5'));var rimraf=require(_0x9cf0('0x6'));var config=require(_0x9cf0('0x7'));var attributes=require('./chatMessage.attributes');module[_0x9cf0('0x8')]=function(_0x4bdd94,_0x24b9c7){return _0x4bdd94[_0x9cf0('0x9')](_0x9cf0('0xa'),attributes,{'tableName':_0x9cf0('0xb'),'paranoid':![],'indexes':[{'name':_0x9cf0('0xc'),'fields':['body'],'type':_0x9cf0('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x575b7e,_0x5c7211,_0x1473d2){var _0x422377=_0x4bdd94[_0x9cf0('0xe')];var _0x49e5e2=_0x575b7e[_0x9cf0('0xf')]({'plain':!![]});if(_0x49e5e2[_0x9cf0('0x10')]['toLowerCase']()==='in'||_0x49e5e2[_0x9cf0('0x10')][_0x9cf0('0x11')]()==='out'&&!_0x49e5e2['secret']&&!_['isNil'](_0x49e5e2[_0x9cf0('0x12')])){_0x422377[_0x9cf0('0x13')][_0x9cf0('0x14')]({'where':{'id':_0x49e5e2[_0x9cf0('0x15')]}})[_0x9cf0('0x16')](function(_0x2c4220){if(_0x2c4220){_0x2c4220[_0x9cf0('0x17')]({'lastMsgAt':_0x49e5e2[_0x9cf0('0x18')],'lastMsgDirection':_0x49e5e2[_0x9cf0('0x10')][_0x9cf0('0x11')]()});}})['catch'](function(_0x4787ac){console[_0x9cf0('0x19')](_0x4787ac);});}_0x1473d2();}},'charset':_0x9cf0('0x1a'),'collate':_0x9cf0('0x1b')});};