Built motion from commit 10af8726.|2.6.34
[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 _0xbf4b=['./chatMessage.attributes','define','ChatMessage','chat_messages','body','FULLTEXT','models','get','direction','UserId','findOne','ChatInteractionId','update','createdAt','toLowerCase','catch','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment'];(function(_0x288f5e,_0x205edd){var _0x476cc9=function(_0x796f53){while(--_0x796f53){_0x288f5e['push'](_0x288f5e['shift']());}};_0x476cc9(++_0x205edd);}(_0xbf4b,0x99));var _0xbbf4=function(_0x2b3c36,_0x2692e1){_0x2b3c36=_0x2b3c36-0x0;var _0x1c1840=_0xbf4b[_0x2b3c36];return _0x1c1840;};'use strict';var _=require(_0xbbf4('0x0'));var util=require(_0xbbf4('0x1'));var logger=require('../../config/logger')(_0xbbf4('0x2'));var moment=require(_0xbbf4('0x3'));var BPromise=require(_0xbbf4('0x4'));var rp=require(_0xbbf4('0x5'));var fs=require('fs');var path=require(_0xbbf4('0x6'));var rimraf=require(_0xbbf4('0x7'));var config=require(_0xbbf4('0x8'));var attributes=require(_0xbbf4('0x9'));module['exports']=function(_0x21d4bf,_0x31ecac){return _0x21d4bf[_0xbbf4('0xa')](_0xbbf4('0xb'),attributes,{'tableName':_0xbbf4('0xc'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0xbbf4('0xd')],'type':_0xbbf4('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5798a2,_0x5c2583,_0x771f6){var _0x307009=_0x21d4bf[_0xbbf4('0xf')];var _0x4bcd78=_0x5798a2[_0xbbf4('0x10')]({'plain':!![]});if(_0x4bcd78[_0xbbf4('0x11')]['toLowerCase']()==='in'||_0x4bcd78[_0xbbf4('0x11')]['toLowerCase']()==='out'&&!_0x4bcd78['secret']&&!_['isNil'](_0x4bcd78[_0xbbf4('0x12')])){_0x307009['ChatInteraction'][_0xbbf4('0x13')]({'where':{'id':_0x4bcd78[_0xbbf4('0x14')]}})['then'](function(_0x50d260){if(_0x50d260){_0x50d260[_0xbbf4('0x15')]({'lastMsgAt':_0x4bcd78[_0xbbf4('0x16')],'lastMsgDirection':_0x4bcd78[_0xbbf4('0x11')][_0xbbf4('0x17')]()});}})[_0xbbf4('0x18')](function(_0x3576e3){console['error'](_0x3576e3);});}_0x771f6();}},'charset':_0xbbf4('0x19'),'collate':_0xbbf4('0x1a')});};