Built motion from commit (unavailable).|2.5.14
[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 _0x3e22=['ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','get','direction','toLowerCase','secret','isNil','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','catch','utf8mb4','lodash','util','../../config/logger','api','request-promise','path','rimraf','../../config/environment','exports','define'];(function(_0x86fa97,_0x31346d){var _0x3e34a0=function(_0x362cc7){while(--_0x362cc7){_0x86fa97['push'](_0x86fa97['shift']());}};_0x3e34a0(++_0x31346d);}(_0x3e22,0xd6));var _0x23e2=function(_0xa6d252,_0xf664a8){_0xa6d252=_0xa6d252-0x0;var _0x498d25=_0x3e22[_0xa6d252];return _0x498d25;};'use strict';var _=require(_0x23e2('0x0'));var util=require(_0x23e2('0x1'));var logger=require(_0x23e2('0x2'))(_0x23e2('0x3'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0x23e2('0x4'));var fs=require('fs');var path=require(_0x23e2('0x5'));var rimraf=require(_0x23e2('0x6'));var config=require(_0x23e2('0x7'));var attributes=require('./chatMessage.attributes');module[_0x23e2('0x8')]=function(_0x8165c6,_0x19a1a3){return _0x8165c6[_0x23e2('0x9')](_0x23e2('0xa'),attributes,{'tableName':_0x23e2('0xb'),'paranoid':![],'indexes':[{'name':_0x23e2('0xc'),'fields':[_0x23e2('0xd')],'type':_0x23e2('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2e70b4,_0xcdefb0,_0x205fa5){var _0x1d3c34=_0x8165c6['models'];var _0x91d3cd=_0x2e70b4[_0x23e2('0xf')]({'plain':!![]});if(_0x91d3cd[_0x23e2('0x10')][_0x23e2('0x11')]()==='in'||_0x91d3cd[_0x23e2('0x10')][_0x23e2('0x11')]()==='out'&&!_0x91d3cd[_0x23e2('0x12')]&&!_[_0x23e2('0x13')](_0x91d3cd['UserId'])){_0x1d3c34[_0x23e2('0x14')][_0x23e2('0x15')]({'where':{'id':_0x91d3cd[_0x23e2('0x16')]}})[_0x23e2('0x17')](function(_0x125ce3){if(_0x125ce3){_0x125ce3[_0x23e2('0x18')]({'lastMsgAt':_0x91d3cd[_0x23e2('0x19')],'lastMsgDirection':_0x91d3cd[_0x23e2('0x10')]['toLowerCase']()});}})[_0x23e2('0x1a')](function(_0x44b3ee){console['error'](_0x44b3ee);});}_0x205fa5();}},'charset':_0x23e2('0x1b'),'collate':'utf8mb4_unicode_ci'});};