7874b44d986f8ea48b5a377ecb5a38895c9360aa
[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 _0x55ca=['./chatMessage.attributes','exports','define','chat_messages','fti_chat_messages','FULLTEXT','models','get','direction','toLowerCase','out','secret','ChatInteraction','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','bluebird','request-promise','rimraf','../../config/environment'];(function(_0x5d2e9d,_0xf6d965){var _0x4e0a11=function(_0x419594){while(--_0x419594){_0x5d2e9d['push'](_0x5d2e9d['shift']());}};_0x4e0a11(++_0xf6d965);}(_0x55ca,0x126));var _0xa55c=function(_0x18f8ff,_0x257e95){_0x18f8ff=_0x18f8ff-0x0;var _0x18de97=_0x55ca[_0x18f8ff];return _0x18de97;};'use strict';var _=require(_0xa55c('0x0'));var util=require(_0xa55c('0x1'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0xa55c('0x2'));var rp=require(_0xa55c('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0xa55c('0x4'));var config=require(_0xa55c('0x5'));var attributes=require(_0xa55c('0x6'));module[_0xa55c('0x7')]=function(_0x3c97c8,_0x279caa){return _0x3c97c8[_0xa55c('0x8')]('ChatMessage',attributes,{'tableName':_0xa55c('0x9'),'paranoid':![],'indexes':[{'name':_0xa55c('0xa'),'fields':['body'],'type':_0xa55c('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x290d28,_0x52a3bc,_0x5849ad){var _0x473d0e=_0x3c97c8[_0xa55c('0xc')];var _0x381d07=_0x290d28[_0xa55c('0xd')]({'plain':!![]});if(_0x381d07[_0xa55c('0xe')][_0xa55c('0xf')]()==='in'||_0x381d07[_0xa55c('0xe')][_0xa55c('0xf')]()===_0xa55c('0x10')&&!_0x381d07[_0xa55c('0x11')]&&!_['isNil'](_0x381d07['UserId'])){_0x473d0e[_0xa55c('0x12')]['findOne']({'where':{'id':_0x381d07['ChatInteractionId']}})['then'](function(_0x18ee85){if(_0x18ee85){_0x18ee85[_0xa55c('0x13')]({'lastMsgAt':_0x381d07[_0xa55c('0x14')],'lastMsgDirection':_0x381d07[_0xa55c('0xe')][_0xa55c('0xf')]()});}})[_0xa55c('0x15')](function(_0x4e0b2f){console[_0xa55c('0x16')](_0x4e0b2f);});}_0x5849ad();}},'charset':_0xa55c('0x17'),'collate':_0xa55c('0x18')});};