7799392e61a92bb077a90a9fbb4f55ff2a1195d9
[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 _0x546c=['path','rimraf','../../config/environment','./chatMessage.attributes','chat_messages','fti_chat_messages','body','models','get','direction','toLowerCase','out','secret','isNil','UserId','findOne','then','update','createdAt','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise'];(function(_0x3c07ee,_0x40550a){var _0x5b14ed=function(_0x5d6e9d){while(--_0x5d6e9d){_0x3c07ee['push'](_0x3c07ee['shift']());}};_0x5b14ed(++_0x40550a);}(_0x546c,0x1c9));var _0xc546=function(_0xeb2904,_0x5ce11d){_0xeb2904=_0xeb2904-0x0;var _0x4a781e=_0x546c[_0xeb2904];return _0x4a781e;};'use strict';var _=require(_0xc546('0x0'));var util=require(_0xc546('0x1'));var logger=require(_0xc546('0x2'))(_0xc546('0x3'));var moment=require(_0xc546('0x4'));var BPromise=require(_0xc546('0x5'));var rp=require(_0xc546('0x6'));var fs=require('fs');var path=require(_0xc546('0x7'));var rimraf=require(_0xc546('0x8'));var config=require(_0xc546('0x9'));var attributes=require(_0xc546('0xa'));module['exports']=function(_0x3fd5d6,_0x4755e6){return _0x3fd5d6['define']('ChatMessage',attributes,{'tableName':_0xc546('0xb'),'paranoid':![],'indexes':[{'name':_0xc546('0xc'),'fields':[_0xc546('0xd')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x46a3e7,_0x192667,_0x55dc6f){var _0x5cfa47=_0x3fd5d6[_0xc546('0xe')];var _0x41adda=_0x46a3e7[_0xc546('0xf')]({'plain':!![]});if(_0x41adda[_0xc546('0x10')]['toLowerCase']()==='in'||_0x41adda[_0xc546('0x10')][_0xc546('0x11')]()===_0xc546('0x12')&&!_0x41adda[_0xc546('0x13')]&&!_[_0xc546('0x14')](_0x41adda[_0xc546('0x15')])){_0x5cfa47['ChatInteraction'][_0xc546('0x16')]({'where':{'id':_0x41adda['ChatInteractionId']}})[_0xc546('0x17')](function(_0x6001d6){if(_0x6001d6){_0x6001d6[_0xc546('0x18')]({'lastMsgAt':_0x41adda[_0xc546('0x19')],'lastMsgDirection':_0x41adda[_0xc546('0x10')][_0xc546('0x11')]()});}})['catch'](function(_0x35d037){console[_0xc546('0x1a')](_0x35d037);});}_0x55dc6f();}},'charset':_0xc546('0x1b'),'collate':_0xc546('0x1c')});};