Built motion from commit (unavailable).|2.5.8
[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 _0xe7ca=['FULLTEXT','toLowerCase','direction','out','secret','isNil','UserId','findOne','ChatInteractionId','then','catch','error','utf8mb4','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./chatMessage.attributes','define','ChatMessage','chat_messages','fti_chat_messages','body'];(function(_0x298808,_0x5ad237){var _0x287524=function(_0x57fd9c){while(--_0x57fd9c){_0x298808['push'](_0x298808['shift']());}};_0x287524(++_0x5ad237);}(_0xe7ca,0x151));var _0xae7c=function(_0x27e45d,_0x4865ff){_0x27e45d=_0x27e45d-0x0;var _0x4e3fe9=_0xe7ca[_0x27e45d];return _0x4e3fe9;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xae7c('0x0'))(_0xae7c('0x1'));var moment=require(_0xae7c('0x2'));var BPromise=require(_0xae7c('0x3'));var rp=require(_0xae7c('0x4'));var fs=require('fs');var path=require(_0xae7c('0x5'));var rimraf=require(_0xae7c('0x6'));var config=require(_0xae7c('0x7'));var attributes=require(_0xae7c('0x8'));module['exports']=function(_0x365fc7,_0x535a63){return _0x365fc7[_0xae7c('0x9')](_0xae7c('0xa'),attributes,{'tableName':_0xae7c('0xb'),'paranoid':![],'indexes':[{'name':_0xae7c('0xc'),'fields':[_0xae7c('0xd')],'type':_0xae7c('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x168032,_0x1fa0c5,_0x1aea2f){var _0x20fb46=_0x365fc7['models'];var _0x5eab6b=_0x168032['get']({'plain':!![]});if(_0x5eab6b['direction'][_0xae7c('0xf')]()==='in'||_0x5eab6b[_0xae7c('0x10')]['toLowerCase']()===_0xae7c('0x11')&&!_0x5eab6b[_0xae7c('0x12')]&&!_[_0xae7c('0x13')](_0x5eab6b[_0xae7c('0x14')])){_0x20fb46['ChatInteraction'][_0xae7c('0x15')]({'where':{'id':_0x5eab6b[_0xae7c('0x16')]}})[_0xae7c('0x17')](function(_0x420e50){if(_0x420e50){_0x420e50['update']({'lastMsgAt':_0x5eab6b['createdAt'],'lastMsgDirection':_0x5eab6b[_0xae7c('0x10')][_0xae7c('0xf')]()});}})[_0xae7c('0x18')](function(_0x449d90){console[_0xae7c('0x19')](_0x449d90);});}_0x1aea2f();}},'charset':_0xae7c('0x1a'),'collate':'utf8mb4_unicode_ci'});};