e391a87f007c69a627f47b44d3eacef72a367230
[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 _0xcc08=['request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','fti_chat_messages','body','FULLTEXT','models','toLowerCase','direction','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','catch','error','lodash','../../config/logger','api','moment','bluebird'];(function(_0x34a2aa,_0x51846f){var _0x4ea6ec=function(_0x1e0865){while(--_0x1e0865){_0x34a2aa['push'](_0x34a2aa['shift']());}};_0x4ea6ec(++_0x51846f);}(_0xcc08,0xe3));var _0x8cc0=function(_0x2fc012,_0x503e5b){_0x2fc012=_0x2fc012-0x0;var _0x2891f9=_0xcc08[_0x2fc012];return _0x2891f9;};'use strict';var _=require(_0x8cc0('0x0'));var util=require('util');var logger=require(_0x8cc0('0x1'))(_0x8cc0('0x2'));var moment=require(_0x8cc0('0x3'));var BPromise=require(_0x8cc0('0x4'));var rp=require(_0x8cc0('0x5'));var fs=require('fs');var path=require(_0x8cc0('0x6'));var rimraf=require(_0x8cc0('0x7'));var config=require(_0x8cc0('0x8'));var attributes=require(_0x8cc0('0x9'));module[_0x8cc0('0xa')]=function(_0x14bf1c,_0x842217){return _0x14bf1c[_0x8cc0('0xb')](_0x8cc0('0xc'),attributes,{'tableName':_0x8cc0('0xd'),'paranoid':![],'indexes':[{'name':_0x8cc0('0xe'),'fields':[_0x8cc0('0xf')],'type':_0x8cc0('0x10')}],'timestamps':!![],'hooks':{'afterCreate':function(_0xb0af7f,_0x504906,_0x57030a){var _0x514dbd=_0x14bf1c[_0x8cc0('0x11')];var _0x158802=_0xb0af7f['get']({'plain':!![]});if(_0x158802['direction'][_0x8cc0('0x12')]()==='in'||_0x158802[_0x8cc0('0x13')][_0x8cc0('0x12')]()==='out'&&!_0x158802['secret']&&!_['isNil'](_0x158802[_0x8cc0('0x14')])){_0x514dbd[_0x8cc0('0x15')][_0x8cc0('0x16')]({'where':{'id':_0x158802[_0x8cc0('0x17')]}})[_0x8cc0('0x18')](function(_0x570145){if(_0x570145){_0x570145[_0x8cc0('0x19')]({'lastMsgAt':_0x158802[_0x8cc0('0x1a')],'lastMsgDirection':_0x158802[_0x8cc0('0x13')]['toLowerCase']()});}})[_0x8cc0('0x1b')](function(_0x5d9efd){console[_0x8cc0('0x1c')](_0x5d9efd);});}_0x57030a();}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};