5ce454408f6fd5f4638585f2165c25b5b3bf7189
[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 _0xf141=['./chatMessage.attributes','exports','ChatMessage','fti_chat_messages','body','FULLTEXT','models','direction','toLowerCase','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','createdAt','catch','error','utf8mb4','lodash','util','moment','bluebird','request-promise','rimraf','../../config/environment'];(function(_0x28f020,_0x5c971b){var _0x4d90a0=function(_0x5d67f7){while(--_0x5d67f7){_0x28f020['push'](_0x28f020['shift']());}};_0x4d90a0(++_0x5c971b);}(_0xf141,0xec));var _0x1f14=function(_0x41d947,_0x360fd9){_0x41d947=_0x41d947-0x0;var _0x15f848=_0xf141[_0x41d947];return _0x15f848;};'use strict';var _=require(_0x1f14('0x0'));var util=require(_0x1f14('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0x1f14('0x2'));var BPromise=require(_0x1f14('0x3'));var rp=require(_0x1f14('0x4'));var fs=require('fs');var path=require('path');var rimraf=require(_0x1f14('0x5'));var config=require(_0x1f14('0x6'));var attributes=require(_0x1f14('0x7'));module[_0x1f14('0x8')]=function(_0x271c51,_0x489a91){return _0x271c51['define'](_0x1f14('0x9'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0x1f14('0xa'),'fields':[_0x1f14('0xb')],'type':_0x1f14('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x427a5f,_0x3791a9,_0x1320cd){var _0x4998fc=_0x271c51[_0x1f14('0xd')];var _0x280ad5=_0x427a5f['get']({'plain':!![]});if(_0x280ad5[_0x1f14('0xe')]['toLowerCase']()==='in'||_0x280ad5[_0x1f14('0xe')][_0x1f14('0xf')]()==='out'&&!_0x280ad5[_0x1f14('0x10')]&&!_[_0x1f14('0x11')](_0x280ad5[_0x1f14('0x12')])){_0x4998fc[_0x1f14('0x13')][_0x1f14('0x14')]({'where':{'id':_0x280ad5[_0x1f14('0x15')]}})[_0x1f14('0x16')](function(_0x1452f9){if(_0x1452f9){_0x1452f9['update']({'lastMsgAt':_0x280ad5[_0x1f14('0x17')],'lastMsgDirection':_0x280ad5[_0x1f14('0xe')]['toLowerCase']()});}})[_0x1f14('0x18')](function(_0x5145c1){console[_0x1f14('0x19')](_0x5145c1);});}_0x1320cd();}},'charset':_0x1f14('0x1a'),'collate':'utf8mb4_unicode_ci'});};