579806327f91f6e4ebef7755103c44d9f218ee1b
[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 _0xebea=['fti_chat_messages','models','direction','toLowerCase','secret','isNil','ChatInteraction','findOne','then','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','request-promise','rimraf','../../config/environment','./chatMessage.attributes','exports','ChatMessage','chat_messages'];(function(_0x368bba,_0x1f625b){var _0x409f8f=function(_0x463373){while(--_0x463373){_0x368bba['push'](_0x368bba['shift']());}};_0x409f8f(++_0x1f625b);}(_0xebea,0x7b));var _0xaebe=function(_0x49379c,_0x46c068){_0x49379c=_0x49379c-0x0;var _0x130f03=_0xebea[_0x49379c];return _0x130f03;};'use strict';var _=require(_0xaebe('0x0'));var util=require(_0xaebe('0x1'));var logger=require(_0xaebe('0x2'))(_0xaebe('0x3'));var moment=require('moment');var BPromise=require(_0xaebe('0x4'));var rp=require(_0xaebe('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0xaebe('0x6'));var config=require(_0xaebe('0x7'));var attributes=require(_0xaebe('0x8'));module[_0xaebe('0x9')]=function(_0x330192,_0x117179){return _0x330192['define'](_0xaebe('0xa'),attributes,{'tableName':_0xaebe('0xb'),'paranoid':![],'indexes':[{'name':_0xaebe('0xc'),'fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5d2302,_0xfab557,_0x1be3ee){var _0x5f4ae0=_0x330192[_0xaebe('0xd')];var _0x4d3552=_0x5d2302['get']({'plain':!![]});if(_0x4d3552[_0xaebe('0xe')][_0xaebe('0xf')]()==='in'||_0x4d3552['direction'][_0xaebe('0xf')]()==='out'&&!_0x4d3552[_0xaebe('0x10')]&&!_[_0xaebe('0x11')](_0x4d3552['UserId'])){_0x5f4ae0[_0xaebe('0x12')][_0xaebe('0x13')]({'where':{'id':_0x4d3552['ChatInteractionId']}})[_0xaebe('0x14')](function(_0x512d9b){if(_0x512d9b){_0x512d9b[_0xaebe('0x15')]({'lastMsgAt':_0x4d3552[_0xaebe('0x16')],'lastMsgDirection':_0x4d3552[_0xaebe('0xe')][_0xaebe('0xf')]()});}})[_0xaebe('0x17')](function(_0x12cd39){console[_0xaebe('0x18')](_0x12cd39);});}_0x1be3ee();}},'charset':_0xaebe('0x19'),'collate':_0xaebe('0x1a')});};