e9a69fe20b32021d4a8ab349bf4b328508319a15
[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 _0x3515=['exports','define','ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','models','direction','toLowerCase','out','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','moment','bluebird','request-promise','./chatMessage.attributes'];(function(_0x1f6112,_0x170dd9){var _0x1f696f=function(_0x191634){while(--_0x191634){_0x1f6112['push'](_0x1f6112['shift']());}};_0x1f696f(++_0x170dd9);}(_0x3515,0x1d9));var _0x5351=function(_0x468364,_0x1c9285){_0x468364=_0x468364-0x0;var _0x29efeb=_0x3515[_0x468364];return _0x29efeb;};'use strict';var _=require(_0x5351('0x0'));var util=require(_0x5351('0x1'));var logger=require(_0x5351('0x2'))('api');var moment=require(_0x5351('0x3'));var BPromise=require(_0x5351('0x4'));var rp=require(_0x5351('0x5'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0x5351('0x6'));module[_0x5351('0x7')]=function(_0x6ae49,_0x3973df){return _0x6ae49[_0x5351('0x8')](_0x5351('0x9'),attributes,{'tableName':_0x5351('0xa'),'paranoid':![],'indexes':[{'name':_0x5351('0xb'),'fields':[_0x5351('0xc')],'type':_0x5351('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3677c9,_0xdb7118,_0x1a05dd){var _0x4c70c3=_0x6ae49[_0x5351('0xe')];var _0xe4fc91=_0x3677c9['get']({'plain':!![]});if(_0xe4fc91[_0x5351('0xf')]['toLowerCase']()==='in'||_0xe4fc91[_0x5351('0xf')][_0x5351('0x10')]()===_0x5351('0x11')&&!_0xe4fc91[_0x5351('0x12')]&&!_[_0x5351('0x13')](_0xe4fc91[_0x5351('0x14')])){_0x4c70c3[_0x5351('0x15')][_0x5351('0x16')]({'where':{'id':_0xe4fc91[_0x5351('0x17')]}})[_0x5351('0x18')](function(_0xc0ad54){if(_0xc0ad54){_0xc0ad54['update']({'lastMsgAt':_0xe4fc91[_0x5351('0x19')],'lastMsgDirection':_0xe4fc91[_0x5351('0xf')][_0x5351('0x10')]()});}})[_0x5351('0x1a')](function(_0x29133b){console[_0x5351('0x1b')](_0x29133b);});}_0x1a05dd();}},'charset':_0x5351('0x1c'),'collate':_0x5351('0x1d')});};