Built motion from commit (unavailable).|2.5.11
[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 _0x64b6=['UserId','ChatInteraction','ChatInteractionId','then','update','createdAt','catch','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','bluebird','rimraf','../../config/environment','./chatMessage.attributes','define','ChatMessage','chat_messages','models','direction','toLowerCase','secret'];(function(_0x3a6c31,_0xd178e2){var _0xf99bc9=function(_0x38b90a){while(--_0x38b90a){_0x3a6c31['push'](_0x3a6c31['shift']());}};_0xf99bc9(++_0xd178e2);}(_0x64b6,0x13d));var _0x664b=function(_0x7a6aed,_0x335e68){_0x7a6aed=_0x7a6aed-0x0;var _0x9dbabf=_0x64b6[_0x7a6aed];return _0x9dbabf;};'use strict';var _=require(_0x664b('0x0'));var util=require('util');var logger=require(_0x664b('0x1'))('api');var moment=require('moment');var BPromise=require(_0x664b('0x2'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x664b('0x3'));var config=require(_0x664b('0x4'));var attributes=require(_0x664b('0x5'));module['exports']=function(_0x268a35,_0x268e73){return _0x268a35[_0x664b('0x6')](_0x664b('0x7'),attributes,{'tableName':_0x664b('0x8'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3949e0,_0x993dad,_0x356727){var _0x53a28a=_0x268a35[_0x664b('0x9')];var _0x916a3c=_0x3949e0['get']({'plain':!![]});if(_0x916a3c[_0x664b('0xa')][_0x664b('0xb')]()==='in'||_0x916a3c['direction'][_0x664b('0xb')]()==='out'&&!_0x916a3c[_0x664b('0xc')]&&!_['isNil'](_0x916a3c[_0x664b('0xd')])){_0x53a28a[_0x664b('0xe')]['findOne']({'where':{'id':_0x916a3c[_0x664b('0xf')]}})[_0x664b('0x10')](function(_0x5f2ec1){if(_0x5f2ec1){_0x5f2ec1[_0x664b('0x11')]({'lastMsgAt':_0x916a3c[_0x664b('0x12')],'lastMsgDirection':_0x916a3c['direction']['toLowerCase']()});}})[_0x664b('0x13')](function(_0x56e0fa){console['error'](_0x56e0fa);});}_0x356727();}},'charset':_0x664b('0x14'),'collate':_0x664b('0x15')});};