Built motion from commit (unavailable).|2.3.92
[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 _0x3940=['get','direction','toLowerCase','out','secret','isNil','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','body','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','bluebird','request-promise','exports','define','chat_messages','models'];(function(_0x1fabd7,_0x25b63f){var _0x6bbade=function(_0x5976d0){while(--_0x5976d0){_0x1fabd7['push'](_0x1fabd7['shift']());}};_0x6bbade(++_0x25b63f);}(_0x3940,0xa6));var _0x0394=function(_0x471dbb,_0x50a0ed){_0x471dbb=_0x471dbb-0x0;var _0x16911f=_0x3940[_0x471dbb];return _0x16911f;};'use strict';var _=require(_0x0394('0x0'));var util=require(_0x0394('0x1'));var logger=require('../../config/logger')(_0x0394('0x2'));var moment=require('moment');var BPromise=require(_0x0394('0x3'));var rp=require(_0x0394('0x4'));var attributes=require('./chatMessage.attributes');module[_0x0394('0x5')]=function(_0x5697bd,_0x2f6ecb){return _0x5697bd[_0x0394('0x6')]('ChatMessage',attributes,{'tableName':_0x0394('0x7'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x2f503c,_0x510b8d,_0x187637){var _0x4f6faa=_0x5697bd[_0x0394('0x8')];var _0x9b3b2f=_0x2f503c[_0x0394('0x9')]({'plain':!![]});if(_0x9b3b2f[_0x0394('0xa')][_0x0394('0xb')]()==='in'||_0x9b3b2f[_0x0394('0xa')][_0x0394('0xb')]()===_0x0394('0xc')&&!_0x9b3b2f[_0x0394('0xd')]&&!_[_0x0394('0xe')](_0x9b3b2f['UserId'])){_0x4f6faa[_0x0394('0xf')][_0x0394('0x10')]({'where':{'id':_0x9b3b2f[_0x0394('0x11')]}})[_0x0394('0x12')](function(_0x56fe9a){if(_0x56fe9a){_0x56fe9a[_0x0394('0x13')]({'lastMsgAt':_0x9b3b2f[_0x0394('0x14')],'lastMsgDirection':_0x9b3b2f[_0x0394('0xa')]['toLowerCase'](),'lastMsgBody':_0x9b3b2f[_0x0394('0x15')]});}})['catch'](function(_0x461257){console[_0x0394('0x16')](_0x461257);});}_0x187637();}},'charset':_0x0394('0x17'),'collate':_0x0394('0x18')});};