Built motion from commit d5e4af8c.|2.6.23
[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 _0xc30d=['rimraf','./chatMessage.attributes','exports','define','ChatMessage','fti_chat_messages','body','FULLTEXT','models','direction','toLowerCase','out','secret','isNil','UserId','ChatInteraction','ChatInteractionId','then','update','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','api','moment','bluebird','request-promise'];(function(_0xd0be97,_0x570fd5){var _0x2ad2f8=function(_0x5aaccc){while(--_0x5aaccc){_0xd0be97['push'](_0xd0be97['shift']());}};_0x2ad2f8(++_0x570fd5);}(_0xc30d,0x6e));var _0xdc30=function(_0x2d7a4b,_0xa36b04){_0x2d7a4b=_0x2d7a4b-0x0;var _0x603707=_0xc30d[_0x2d7a4b];return _0x603707;};'use strict';var _=require(_0xdc30('0x0'));var util=require('util');var logger=require(_0xdc30('0x1'))(_0xdc30('0x2'));var moment=require(_0xdc30('0x3'));var BPromise=require(_0xdc30('0x4'));var rp=require(_0xdc30('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0xdc30('0x6'));var config=require('../../config/environment');var attributes=require(_0xdc30('0x7'));module[_0xdc30('0x8')]=function(_0x1d2db4,_0x3e480e){return _0x1d2db4[_0xdc30('0x9')](_0xdc30('0xa'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0xdc30('0xb'),'fields':[_0xdc30('0xc')],'type':_0xdc30('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0xad8d18,_0x1a9c5f,_0x65f596){var _0x38b6fc=_0x1d2db4[_0xdc30('0xe')];var _0x2c4fe1=_0xad8d18['get']({'plain':!![]});if(_0x2c4fe1['direction']['toLowerCase']()==='in'||_0x2c4fe1[_0xdc30('0xf')][_0xdc30('0x10')]()===_0xdc30('0x11')&&!_0x2c4fe1[_0xdc30('0x12')]&&!_[_0xdc30('0x13')](_0x2c4fe1[_0xdc30('0x14')])){_0x38b6fc[_0xdc30('0x15')]['findOne']({'where':{'id':_0x2c4fe1[_0xdc30('0x16')]}})[_0xdc30('0x17')](function(_0x2220e3){if(_0x2220e3){_0x2220e3[_0xdc30('0x18')]({'lastMsgAt':_0x2c4fe1['createdAt'],'lastMsgDirection':_0x2c4fe1[_0xdc30('0xf')][_0xdc30('0x10')]()});}})[_0xdc30('0x19')](function(_0x553b45){console[_0xdc30('0x1a')](_0x553b45);});}_0x65f596();}},'charset':_0xdc30('0x1b'),'collate':_0xdc30('0x1c')});};