Built motion from commit d5e4af8c.|2.6.23
[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 _0x4a5e=['bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','define','ChatMessage','chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','UserId','findOne','ChatInteractionId','then','update','createdAt','error','lodash','util','../../config/logger','moment'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0x4a5e,0x158));var _0xe4a5=function(_0xe6f4ef,_0x4e34cc){_0xe6f4ef=_0xe6f4ef-0x0;var _0x4f3447=_0x4a5e[_0xe6f4ef];return _0x4f3447;};'use strict';var _=require(_0xe4a5('0x0'));var util=require(_0xe4a5('0x1'));var logger=require(_0xe4a5('0x2'))('api');var moment=require(_0xe4a5('0x3'));var BPromise=require(_0xe4a5('0x4'));var rp=require(_0xe4a5('0x5'));var fs=require('fs');var path=require(_0xe4a5('0x6'));var rimraf=require(_0xe4a5('0x7'));var config=require(_0xe4a5('0x8'));var attributes=require(_0xe4a5('0x9'));module['exports']=function(_0x3781a3,_0x13640d){return _0x3781a3[_0xe4a5('0xa')](_0xe4a5('0xb'),attributes,{'tableName':_0xe4a5('0xc'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0xe4a5('0xd')],'type':_0xe4a5('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5630f5,_0x398baa,_0x25773d){var _0x5dca12=_0x3781a3[_0xe4a5('0xf')];var _0x1a279c=_0x5630f5[_0xe4a5('0x10')]({'plain':!![]});if(_0x1a279c[_0xe4a5('0x11')][_0xe4a5('0x12')]()==='in'||_0x1a279c[_0xe4a5('0x11')]['toLowerCase']()===_0xe4a5('0x13')&&!_0x1a279c[_0xe4a5('0x14')]&&!_[_0xe4a5('0x15')](_0x1a279c[_0xe4a5('0x16')])){_0x5dca12['ChatInteraction'][_0xe4a5('0x17')]({'where':{'id':_0x1a279c[_0xe4a5('0x18')]}})[_0xe4a5('0x19')](function(_0x402b54){if(_0x402b54){_0x402b54[_0xe4a5('0x1a')]({'lastMsgAt':_0x1a279c[_0xe4a5('0x1b')],'lastMsgDirection':_0x1a279c[_0xe4a5('0x11')][_0xe4a5('0x12')]()});}})['catch'](function(_0x1ac77d){console[_0xe4a5('0x1c')](_0x1ac77d);});}_0x25773d();}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};