Built motion from commit (unavailable).|2.4.21
[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 _0x88d7=['moment','bluebird','request-promise','path','exports','chat_messages','fti_chat_messages','body','models','direction','toLowerCase','out','secret','isNil','UserId','ChatInteraction','ChatInteractionId','then','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api'];(function(_0x265e81,_0x514eff){var _0x55b6b7=function(_0x2e3207){while(--_0x2e3207){_0x265e81['push'](_0x265e81['shift']());}};_0x55b6b7(++_0x514eff);}(_0x88d7,0x14c));var _0x788d=function(_0x4c2038,_0x38e445){_0x4c2038=_0x4c2038-0x0;var _0x365914=_0x88d7[_0x4c2038];return _0x365914;};'use strict';var _=require(_0x788d('0x0'));var util=require(_0x788d('0x1'));var logger=require(_0x788d('0x2'))(_0x788d('0x3'));var moment=require(_0x788d('0x4'));var BPromise=require(_0x788d('0x5'));var rp=require(_0x788d('0x6'));var fs=require('fs');var path=require(_0x788d('0x7'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require('./chatMessage.attributes');module[_0x788d('0x8')]=function(_0x4aa8ed,_0x24dcee){return _0x4aa8ed['define']('ChatMessage',attributes,{'tableName':_0x788d('0x9'),'paranoid':![],'indexes':[{'name':_0x788d('0xa'),'fields':[_0x788d('0xb')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5a6fbd,_0x4fe7c5,_0x19eb26){var _0x1c0065=_0x4aa8ed[_0x788d('0xc')];var _0x4174dc=_0x5a6fbd['get']({'plain':!![]});if(_0x4174dc[_0x788d('0xd')]['toLowerCase']()==='in'||_0x4174dc[_0x788d('0xd')][_0x788d('0xe')]()===_0x788d('0xf')&&!_0x4174dc[_0x788d('0x10')]&&!_[_0x788d('0x11')](_0x4174dc[_0x788d('0x12')])){_0x1c0065[_0x788d('0x13')]['findOne']({'where':{'id':_0x4174dc[_0x788d('0x14')]}})[_0x788d('0x15')](function(_0x490e10){if(_0x490e10){_0x490e10[_0x788d('0x16')]({'lastMsgAt':_0x4174dc[_0x788d('0x17')],'lastMsgDirection':_0x4174dc[_0x788d('0xd')]['toLowerCase']()});}})[_0x788d('0x18')](function(_0x417687){console[_0x788d('0x19')](_0x417687);});}_0x19eb26();}},'charset':_0x788d('0x1a'),'collate':_0x788d('0x1b')});};