de79d346112f42bd68ddad131cccda5ce5485cd2
[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 _0x9d4e=['then','update','createdAt','catch','error','utf8mb4','../../config/logger','moment','request-promise','path','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','models','get','direction','toLowerCase','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId'];(function(_0x1cf016,_0xd1c4fb){var _0x235b2c=function(_0x114196){while(--_0x114196){_0x1cf016['push'](_0x1cf016['shift']());}};_0x235b2c(++_0xd1c4fb);}(_0x9d4e,0x17f));var _0xe9d4=function(_0x30d3c1,_0xa3da89){_0x30d3c1=_0x30d3c1-0x0;var _0x571ee9=_0x9d4e[_0x30d3c1];return _0x571ee9;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xe9d4('0x0'))('api');var moment=require(_0xe9d4('0x1'));var BPromise=require('bluebird');var rp=require(_0xe9d4('0x2'));var fs=require('fs');var path=require(_0xe9d4('0x3'));var rimraf=require('rimraf');var config=require(_0xe9d4('0x4'));var attributes=require(_0xe9d4('0x5'));module[_0xe9d4('0x6')]=function(_0x435a2f,_0x48a7ad){return _0x435a2f[_0xe9d4('0x7')](_0xe9d4('0x8'),attributes,{'tableName':_0xe9d4('0x9'),'paranoid':![],'indexes':[{'name':_0xe9d4('0xa'),'fields':[_0xe9d4('0xb')],'type':_0xe9d4('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x55a08c,_0x1f4ed7,_0xd84270){var _0x28e3c5=_0x435a2f[_0xe9d4('0xd')];var _0x7c345a=_0x55a08c[_0xe9d4('0xe')]({'plain':!![]});if(_0x7c345a[_0xe9d4('0xf')][_0xe9d4('0x10')]()==='in'||_0x7c345a['direction']['toLowerCase']()==='out'&&!_0x7c345a[_0xe9d4('0x11')]&&!_[_0xe9d4('0x12')](_0x7c345a[_0xe9d4('0x13')])){_0x28e3c5[_0xe9d4('0x14')][_0xe9d4('0x15')]({'where':{'id':_0x7c345a[_0xe9d4('0x16')]}})[_0xe9d4('0x17')](function(_0x4f80f8){if(_0x4f80f8){_0x4f80f8[_0xe9d4('0x18')]({'lastMsgAt':_0x7c345a[_0xe9d4('0x19')],'lastMsgDirection':_0x7c345a[_0xe9d4('0xf')]['toLowerCase']()});}})[_0xe9d4('0x1a')](function(_0x2ecd4e){console[_0xe9d4('0x1b')](_0x2ecd4e);});}_0xd84270();}},'charset':_0xe9d4('0x1c'),'collate':'utf8mb4_unicode_ci'});};