e777e97802773093f69c76077b77e56bfa3f9c14
[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 _0xb1c2=['bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','createdAt','catch','utf8mb4','util','../../config/logger','moment'];(function(_0x24ef77,_0x6ba836){var _0x7f7945=function(_0xcdff9c){while(--_0xcdff9c){_0x24ef77['push'](_0x24ef77['shift']());}};_0x7f7945(++_0x6ba836);}(_0xb1c2,0x1ce));var _0x2b1c=function(_0x37862a,_0x2bc98e){_0x37862a=_0x37862a-0x0;var _0x5b0104=_0xb1c2[_0x37862a];return _0x5b0104;};'use strict';var _=require('lodash');var util=require(_0x2b1c('0x0'));var logger=require(_0x2b1c('0x1'))('api');var moment=require(_0x2b1c('0x2'));var BPromise=require(_0x2b1c('0x3'));var rp=require(_0x2b1c('0x4'));var fs=require('fs');var path=require(_0x2b1c('0x5'));var rimraf=require(_0x2b1c('0x6'));var config=require(_0x2b1c('0x7'));var attributes=require(_0x2b1c('0x8'));module[_0x2b1c('0x9')]=function(_0x531473,_0x4dc6dd){return _0x531473[_0x2b1c('0xa')](_0x2b1c('0xb'),attributes,{'tableName':_0x2b1c('0xc'),'paranoid':![],'indexes':[{'name':_0x2b1c('0xd'),'fields':[_0x2b1c('0xe')],'type':_0x2b1c('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x430a7f,_0x109c67,_0x5016b1){var _0x26ddcd=_0x531473[_0x2b1c('0x10')];var _0x203538=_0x430a7f[_0x2b1c('0x11')]({'plain':!![]});if(_0x203538[_0x2b1c('0x12')][_0x2b1c('0x13')]()==='in'||_0x203538[_0x2b1c('0x12')]['toLowerCase']()===_0x2b1c('0x14')&&!_0x203538[_0x2b1c('0x15')]&&!_[_0x2b1c('0x16')](_0x203538[_0x2b1c('0x17')])){_0x26ddcd[_0x2b1c('0x18')][_0x2b1c('0x19')]({'where':{'id':_0x203538[_0x2b1c('0x1a')]}})[_0x2b1c('0x1b')](function(_0x4dd521){if(_0x4dd521){_0x4dd521['update']({'lastMsgAt':_0x203538[_0x2b1c('0x1c')],'lastMsgDirection':_0x203538['direction']['toLowerCase']()});}})[_0x2b1c('0x1d')](function(_0x486273){console['error'](_0x486273);});}_0x5016b1();}},'charset':_0x2b1c('0x1e'),'collate':'utf8mb4_unicode_ci'});};