Built motion from commit 896e83a8.|2.6.30
[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 _0x9e93=['then','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','moment','bluebird','rimraf','../../config/environment','./chatMessage.attributes','exports','ChatMessage','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','UserId','ChatInteraction','findOne'];(function(_0x51ddfe,_0x63fe43){var _0x17c2da=function(_0x124196){while(--_0x124196){_0x51ddfe['push'](_0x51ddfe['shift']());}};_0x17c2da(++_0x63fe43);}(_0x9e93,0xca));var _0x39e9=function(_0x22cc16,_0x1f4fa2){_0x22cc16=_0x22cc16-0x0;var _0x399b70=_0x9e93[_0x22cc16];return _0x399b70;};'use strict';var _=require(_0x39e9('0x0'));var util=require('util');var logger=require(_0x39e9('0x1'))('api');var moment=require(_0x39e9('0x2'));var BPromise=require(_0x39e9('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x39e9('0x4'));var config=require(_0x39e9('0x5'));var attributes=require(_0x39e9('0x6'));module[_0x39e9('0x7')]=function(_0x4edb6,_0x4b8aa4){return _0x4edb6['define'](_0x39e9('0x8'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0x39e9('0x9'),'fields':[_0x39e9('0xa')],'type':_0x39e9('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x58848f,_0xc4e8b0,_0x5d824f){var _0x46ce34=_0x4edb6[_0x39e9('0xc')];var _0x2a2607=_0x58848f[_0x39e9('0xd')]({'plain':!![]});if(_0x2a2607[_0x39e9('0xe')][_0x39e9('0xf')]()==='in'||_0x2a2607['direction'][_0x39e9('0xf')]()===_0x39e9('0x10')&&!_0x2a2607[_0x39e9('0x11')]&&!_[_0x39e9('0x12')](_0x2a2607[_0x39e9('0x13')])){_0x46ce34[_0x39e9('0x14')][_0x39e9('0x15')]({'where':{'id':_0x2a2607['ChatInteractionId']}})[_0x39e9('0x16')](function(_0x3f87a4){if(_0x3f87a4){_0x3f87a4['update']({'lastMsgAt':_0x2a2607[_0x39e9('0x17')],'lastMsgDirection':_0x2a2607[_0x39e9('0xe')]['toLowerCase']()});}})[_0x39e9('0x18')](function(_0x46e593){console[_0x39e9('0x19')](_0x46e593);});}_0x5d824f();}},'charset':_0x39e9('0x1a'),'collate':_0x39e9('0x1b')});};