Built motion from commit (unavailable).|2.5.31
[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 _0x6fc4=['isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','catch','error','utf8mb4_unicode_ci','lodash','util','moment','rimraf','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','body','FULLTEXT','models','direction','toLowerCase','out','secret'];(function(_0x3861f7,_0x995b22){var _0x50879f=function(_0x3003f1){while(--_0x3003f1){_0x3861f7['push'](_0x3861f7['shift']());}};_0x50879f(++_0x995b22);}(_0x6fc4,0x1a0));var _0x46fc=function(_0x46647b,_0x4e8678){_0x46647b=_0x46647b-0x0;var _0x2bef5d=_0x6fc4[_0x46647b];return _0x2bef5d;};'use strict';var _=require(_0x46fc('0x0'));var util=require(_0x46fc('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0x46fc('0x2'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x46fc('0x3'));var config=require(_0x46fc('0x4'));var attributes=require(_0x46fc('0x5'));module[_0x46fc('0x6')]=function(_0x3f4e43,_0x7656d9){return _0x3f4e43[_0x46fc('0x7')](_0x46fc('0x8'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0x46fc('0x9')],'type':_0x46fc('0xa')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x306eb9,_0x4594c1,_0x5ef080){var _0x51d875=_0x3f4e43[_0x46fc('0xb')];var _0xa1283a=_0x306eb9['get']({'plain':!![]});if(_0xa1283a[_0x46fc('0xc')]['toLowerCase']()==='in'||_0xa1283a[_0x46fc('0xc')][_0x46fc('0xd')]()===_0x46fc('0xe')&&!_0xa1283a[_0x46fc('0xf')]&&!_[_0x46fc('0x10')](_0xa1283a[_0x46fc('0x11')])){_0x51d875[_0x46fc('0x12')][_0x46fc('0x13')]({'where':{'id':_0xa1283a[_0x46fc('0x14')]}})[_0x46fc('0x15')](function(_0x34a019){if(_0x34a019){_0x34a019[_0x46fc('0x16')]({'lastMsgAt':_0xa1283a[_0x46fc('0x17')],'lastMsgDirection':_0xa1283a[_0x46fc('0xc')][_0x46fc('0xd')]()});}})[_0x46fc('0x18')](function(_0x246499){console[_0x46fc('0x19')](_0x246499);});}_0x5ef080();}},'charset':'utf8mb4','collate':_0x46fc('0x1a')});};