9168e006fcc113bc7058ec8cf1a2c8934286acf6
[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 _0xf18d=['update','createdAt','error','utf8mb4','lodash','../../config/logger','moment','bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','exports','body','FULLTEXT','get','toLowerCase','direction','out','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xf18d,0x199));var _0xdf18=function(_0x116dc2,_0x267c08){_0x116dc2=_0x116dc2-0x0;var _0x343382=_0xf18d[_0x116dc2];return _0x343382;};'use strict';var _=require(_0xdf18('0x0'));var util=require('util');var logger=require(_0xdf18('0x1'))('api');var moment=require(_0xdf18('0x2'));var BPromise=require(_0xdf18('0x3'));var rp=require(_0xdf18('0x4'));var fs=require('fs');var path=require(_0xdf18('0x5'));var rimraf=require(_0xdf18('0x6'));var config=require(_0xdf18('0x7'));var attributes=require(_0xdf18('0x8'));module[_0xdf18('0x9')]=function(_0x3afe18,_0x2faaec){return _0x3afe18['define']('ChatMessage',attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0xdf18('0xa')],'type':_0xdf18('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x551e41,_0x45258b,_0x3a16a0){var _0x5cc1aa=_0x3afe18['models'];var _0xe6745c=_0x551e41[_0xdf18('0xc')]({'plain':!![]});if(_0xe6745c['direction'][_0xdf18('0xd')]()==='in'||_0xe6745c[_0xdf18('0xe')][_0xdf18('0xd')]()===_0xdf18('0xf')&&!_0xe6745c[_0xdf18('0x10')]&&!_[_0xdf18('0x11')](_0xe6745c[_0xdf18('0x12')])){_0x5cc1aa[_0xdf18('0x13')][_0xdf18('0x14')]({'where':{'id':_0xe6745c[_0xdf18('0x15')]}})[_0xdf18('0x16')](function(_0x3d738b){if(_0x3d738b){_0x3d738b[_0xdf18('0x17')]({'lastMsgAt':_0xe6745c[_0xdf18('0x18')],'lastMsgDirection':_0xe6745c[_0xdf18('0xe')][_0xdf18('0xd')]()});}})['catch'](function(_0xcad1c){console[_0xdf18('0x19')](_0xcad1c);});}_0x3a16a0();}},'charset':_0xdf18('0x1a'),'collate':'utf8mb4_unicode_ci'});};