Built motion from commit (unavailable).|2.3.4
[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 _0x9f17=['toLowerCase','out','isNil','UserId','ChatInteraction','findOne','then','createdAt','body','utf8mb4','lodash','../../config/logger','api','moment','bluebird','request-promise','./chatMessage.attributes','define','ChatMessage','models','direction'];(function(_0x59d472,_0x29b606){var _0x2e6e12=function(_0x564e10){while(--_0x564e10){_0x59d472['push'](_0x59d472['shift']());}};_0x2e6e12(++_0x29b606);}(_0x9f17,0x73));var _0x79f1=function(_0x1d6b97,_0x5a2b5b){_0x1d6b97=_0x1d6b97-0x0;var _0x5342b2=_0x9f17[_0x1d6b97];return _0x5342b2;};'use strict';var _=require(_0x79f1('0x0'));var util=require('util');var logger=require(_0x79f1('0x1'))(_0x79f1('0x2'));var moment=require(_0x79f1('0x3'));var BPromise=require(_0x79f1('0x4'));var rp=require(_0x79f1('0x5'));var attributes=require(_0x79f1('0x6'));module['exports']=function(_0xec7cca,_0xdce80f){return _0xec7cca[_0x79f1('0x7')](_0x79f1('0x8'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x18b0d5,_0x12ce9e,_0x33a7bc){var _0x1804af=_0xec7cca[_0x79f1('0x9')];var _0x11c45b=_0x18b0d5['get']({'plain':!![]});if(_0x11c45b[_0x79f1('0xa')][_0x79f1('0xb')]()==='in'||_0x11c45b[_0x79f1('0xa')]['toLowerCase']()===_0x79f1('0xc')&&!_0x11c45b['secret']&&!_[_0x79f1('0xd')](_0x11c45b[_0x79f1('0xe')])){_0x1804af[_0x79f1('0xf')][_0x79f1('0x10')]({'where':{'id':_0x11c45b['ChatInteractionId']}})[_0x79f1('0x11')](function(_0x1ed2a4){if(_0x1ed2a4){_0x1ed2a4['update']({'lastMsgAt':_0x11c45b[_0x79f1('0x12')],'lastMsgDirection':_0x11c45b[_0x79f1('0xa')][_0x79f1('0xb')](),'lastMsgBody':_0x11c45b[_0x79f1('0x13')]});}})['catch'](function(_0x349d81){console['error'](_0x349d81);});}_0x33a7bc();}},'charset':_0x79f1('0x14'),'collate':'utf8mb4_unicode_ci'});};