Built motion from commit (unavailable).|2.5.13
[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 _0xcf70=['ChatMessage','chat_messages','body','models','get','toLowerCase','direction','out','secret','isNil','ChatInteraction','findOne','ChatInteractionId','update','createdAt','error','utf8mb4','lodash','moment','bluebird','request-promise','path','rimraf','../../config/environment','exports'];(function(_0x8b4966,_0x1f4ec3){var _0x4e3470=function(_0x3edd92){while(--_0x3edd92){_0x8b4966['push'](_0x8b4966['shift']());}};_0x4e3470(++_0x1f4ec3);}(_0xcf70,0x188));var _0x0cf7=function(_0xc69329,_0x34dc28){_0xc69329=_0xc69329-0x0;var _0xc7a63b=_0xcf70[_0xc69329];return _0xc7a63b;};'use strict';var _=require(_0x0cf7('0x0'));var util=require('util');var logger=require('../../config/logger')('api');var moment=require(_0x0cf7('0x1'));var BPromise=require(_0x0cf7('0x2'));var rp=require(_0x0cf7('0x3'));var fs=require('fs');var path=require(_0x0cf7('0x4'));var rimraf=require(_0x0cf7('0x5'));var config=require(_0x0cf7('0x6'));var attributes=require('./chatMessage.attributes');module[_0x0cf7('0x7')]=function(_0x179cf6,_0x4f8c2b){return _0x179cf6['define'](_0x0cf7('0x8'),attributes,{'tableName':_0x0cf7('0x9'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0x0cf7('0xa')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2869da,_0x4d1e71,_0x354a5e){var _0x2fc146=_0x179cf6[_0x0cf7('0xb')];var _0x5166f3=_0x2869da[_0x0cf7('0xc')]({'plain':!![]});if(_0x5166f3['direction'][_0x0cf7('0xd')]()==='in'||_0x5166f3[_0x0cf7('0xe')][_0x0cf7('0xd')]()===_0x0cf7('0xf')&&!_0x5166f3[_0x0cf7('0x10')]&&!_[_0x0cf7('0x11')](_0x5166f3['UserId'])){_0x2fc146[_0x0cf7('0x12')][_0x0cf7('0x13')]({'where':{'id':_0x5166f3[_0x0cf7('0x14')]}})['then'](function(_0x4b8b7b){if(_0x4b8b7b){_0x4b8b7b[_0x0cf7('0x15')]({'lastMsgAt':_0x5166f3[_0x0cf7('0x16')],'lastMsgDirection':_0x5166f3[_0x0cf7('0xe')][_0x0cf7('0xd')]()});}})['catch'](function(_0x148ee3){console[_0x0cf7('0x17')](_0x148ee3);});}_0x354a5e();}},'charset':_0x0cf7('0x18'),'collate':'utf8mb4_unicode_ci'});};