Built motion from commit b0a9a629.|2.6.33
[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 _0xd745=['ChatInteractionId','update','createdAt','direction','catch','error','utf8mb4','utf8mb4_unicode_ci','util','moment','bluebird','path','../../config/environment','./chatMessage.attributes','exports','chat_messages','fti_chat_messages','models','get','toLowerCase','out','secret','isNil','UserId','findOne'];(function(_0x42c317,_0x243256){var _0x2624d9=function(_0x5e4a13){while(--_0x5e4a13){_0x42c317['push'](_0x42c317['shift']());}};_0x2624d9(++_0x243256);}(_0xd745,0x9e));var _0x5d74=function(_0x41d65e,_0x479047){_0x41d65e=_0x41d65e-0x0;var _0x16841a=_0xd745[_0x41d65e];return _0x16841a;};'use strict';var _=require('lodash');var util=require(_0x5d74('0x0'));var logger=require('../../config/logger')('api');var moment=require(_0x5d74('0x1'));var BPromise=require(_0x5d74('0x2'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x5d74('0x3'));var rimraf=require('rimraf');var config=require(_0x5d74('0x4'));var attributes=require(_0x5d74('0x5'));module[_0x5d74('0x6')]=function(_0x32ed6e,_0x343fdb){return _0x32ed6e['define']('ChatMessage',attributes,{'tableName':_0x5d74('0x7'),'paranoid':![],'indexes':[{'name':_0x5d74('0x8'),'fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x28e2b7,_0x5421dd,_0x44ea8c){var _0x25b99d=_0x32ed6e[_0x5d74('0x9')];var _0x261316=_0x28e2b7[_0x5d74('0xa')]({'plain':!![]});if(_0x261316['direction'][_0x5d74('0xb')]()==='in'||_0x261316['direction'][_0x5d74('0xb')]()===_0x5d74('0xc')&&!_0x261316[_0x5d74('0xd')]&&!_[_0x5d74('0xe')](_0x261316[_0x5d74('0xf')])){_0x25b99d['ChatInteraction'][_0x5d74('0x10')]({'where':{'id':_0x261316[_0x5d74('0x11')]}})['then'](function(_0x363b3e){if(_0x363b3e){_0x363b3e[_0x5d74('0x12')]({'lastMsgAt':_0x261316[_0x5d74('0x13')],'lastMsgDirection':_0x261316[_0x5d74('0x14')]['toLowerCase']()});}})[_0x5d74('0x15')](function(_0x3c66f6){console[_0x5d74('0x16')](_0x3c66f6);});}_0x44ea8c();}},'charset':_0x5d74('0x17'),'collate':_0x5d74('0x18')});};