Built motion from commit (unavailable).|2.5.30
[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 _0x56a6=['utf8mb4_unicode_ci','lodash','util','../../config/logger','api','request-promise','path','rimraf','./chatMessage.attributes','exports','define','ChatMessage','chat_messages','body','models','get','direction','toLowerCase','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','update','createdAt','catch','error'];(function(_0x7d2272,_0x41f365){var _0x5bc56e=function(_0x3974af){while(--_0x3974af){_0x7d2272['push'](_0x7d2272['shift']());}};_0x5bc56e(++_0x41f365);}(_0x56a6,0x17b));var _0x656a=function(_0x2dc119,_0xd0e5f6){_0x2dc119=_0x2dc119-0x0;var _0x3ae925=_0x56a6[_0x2dc119];return _0x3ae925;};'use strict';var _=require(_0x656a('0x0'));var util=require(_0x656a('0x1'));var logger=require(_0x656a('0x2'))(_0x656a('0x3'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0x656a('0x4'));var fs=require('fs');var path=require(_0x656a('0x5'));var rimraf=require(_0x656a('0x6'));var config=require('../../config/environment');var attributes=require(_0x656a('0x7'));module[_0x656a('0x8')]=function(_0x1ce536,_0x529aac){return _0x1ce536[_0x656a('0x9')](_0x656a('0xa'),attributes,{'tableName':_0x656a('0xb'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0x656a('0xc')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x524116,_0x147192,_0x11c10f){var _0x380aa8=_0x1ce536[_0x656a('0xd')];var _0x4d9f32=_0x524116[_0x656a('0xe')]({'plain':!![]});if(_0x4d9f32[_0x656a('0xf')][_0x656a('0x10')]()==='in'||_0x4d9f32[_0x656a('0xf')]['toLowerCase']()==='out'&&!_0x4d9f32['secret']&&!_[_0x656a('0x11')](_0x4d9f32[_0x656a('0x12')])){_0x380aa8[_0x656a('0x13')][_0x656a('0x14')]({'where':{'id':_0x4d9f32[_0x656a('0x15')]}})['then'](function(_0x30e0ab){if(_0x30e0ab){_0x30e0ab[_0x656a('0x16')]({'lastMsgAt':_0x4d9f32[_0x656a('0x17')],'lastMsgDirection':_0x4d9f32[_0x656a('0xf')][_0x656a('0x10')]()});}})[_0x656a('0x18')](function(_0x55ed){console[_0x656a('0x19')](_0x55ed);});}_0x11c10f();}},'charset':'utf8mb4','collate':_0x656a('0x1a')});};