Built motion from commit (unavailable).|2.5.28
[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 _0xce1a=['ChatInteraction','findOne','update','createdAt','catch','error','utf8mb4','lodash','moment','bluebird','request-promise','path','rimraf','./chatMessage.attributes','define','ChatMessage','chat_messages','FULLTEXT','models','get','direction','toLowerCase','UserId'];(function(_0x272394,_0x226305){var _0x211a06=function(_0x5d2c6d){while(--_0x5d2c6d){_0x272394['push'](_0x272394['shift']());}};_0x211a06(++_0x226305);}(_0xce1a,0xbf));var _0xace1=function(_0xd3606f,_0x38bdc9){_0xd3606f=_0xd3606f-0x0;var _0x561ed4=_0xce1a[_0xd3606f];return _0x561ed4;};'use strict';var _=require(_0xace1('0x0'));var util=require('util');var logger=require('../../config/logger')('api');var moment=require(_0xace1('0x1'));var BPromise=require(_0xace1('0x2'));var rp=require(_0xace1('0x3'));var fs=require('fs');var path=require(_0xace1('0x4'));var rimraf=require(_0xace1('0x5'));var config=require('../../config/environment');var attributes=require(_0xace1('0x6'));module['exports']=function(_0x4becaf,_0x55bc3e){return _0x4becaf[_0xace1('0x7')](_0xace1('0x8'),attributes,{'tableName':_0xace1('0x9'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':['body'],'type':_0xace1('0xa')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x4a5b7c,_0x3c8579,_0x3d34c){var _0x13f8ac=_0x4becaf[_0xace1('0xb')];var _0x56d3e3=_0x4a5b7c[_0xace1('0xc')]({'plain':!![]});if(_0x56d3e3[_0xace1('0xd')]['toLowerCase']()==='in'||_0x56d3e3[_0xace1('0xd')][_0xace1('0xe')]()==='out'&&!_0x56d3e3['secret']&&!_['isNil'](_0x56d3e3[_0xace1('0xf')])){_0x13f8ac[_0xace1('0x10')][_0xace1('0x11')]({'where':{'id':_0x56d3e3['ChatInteractionId']}})['then'](function(_0x4e8389){if(_0x4e8389){_0x4e8389[_0xace1('0x12')]({'lastMsgAt':_0x56d3e3[_0xace1('0x13')],'lastMsgDirection':_0x56d3e3[_0xace1('0xd')][_0xace1('0xe')]()});}})[_0xace1('0x14')](function(_0x303080){console[_0xace1('0x15')](_0x303080);});}_0x3d34c();}},'charset':_0xace1('0x16'),'collate':'utf8mb4_unicode_ci'});};