Built motion from commit da617fac.|2.6.6
[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 _0x89c3=['direction','toLowerCase','out','UserId','ChatInteraction','findOne','then','update','createdAt','catch','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','../../config/environment','exports','define','fti_chat_messages','body','FULLTEXT','models'];(function(_0x25e350,_0x43988b){var _0x4391b8=function(_0x4beaa0){while(--_0x4beaa0){_0x25e350['push'](_0x25e350['shift']());}};_0x4391b8(++_0x43988b);}(_0x89c3,0xff));var _0x389c=function(_0x86e220,_0x3a8190){_0x86e220=_0x86e220-0x0;var _0x327dfe=_0x89c3[_0x86e220];return _0x327dfe;};'use strict';var _=require(_0x389c('0x0'));var util=require(_0x389c('0x1'));var logger=require(_0x389c('0x2'))(_0x389c('0x3'));var moment=require(_0x389c('0x4'));var BPromise=require(_0x389c('0x5'));var rp=require(_0x389c('0x6'));var fs=require('fs');var path=require(_0x389c('0x7'));var rimraf=require('rimraf');var config=require(_0x389c('0x8'));var attributes=require('./chatMessage.attributes');module[_0x389c('0x9')]=function(_0x4bece6,_0x51f5f5){return _0x4bece6[_0x389c('0xa')]('ChatMessage',attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0x389c('0xb'),'fields':[_0x389c('0xc')],'type':_0x389c('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2efa82,_0x41c92b,_0x1c574b){var _0x2a7d64=_0x4bece6[_0x389c('0xe')];var _0x13b41=_0x2efa82['get']({'plain':!![]});if(_0x13b41[_0x389c('0xf')][_0x389c('0x10')]()==='in'||_0x13b41[_0x389c('0xf')][_0x389c('0x10')]()===_0x389c('0x11')&&!_0x13b41['secret']&&!_['isNil'](_0x13b41[_0x389c('0x12')])){_0x2a7d64[_0x389c('0x13')][_0x389c('0x14')]({'where':{'id':_0x13b41['ChatInteractionId']}})[_0x389c('0x15')](function(_0x4bde6d){if(_0x4bde6d){_0x4bde6d[_0x389c('0x16')]({'lastMsgAt':_0x13b41[_0x389c('0x17')],'lastMsgDirection':_0x13b41['direction'][_0x389c('0x10')]()});}})[_0x389c('0x18')](function(_0x36c118){console['error'](_0x36c118);});}_0x1c574b();}},'charset':_0x389c('0x19'),'collate':_0x389c('0x1a')});};