Built motion from commit (unavailable).|2.5.31
[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 _0x374c=['then','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','util','../../config/logger','api','moment','bluebird','path','../../config/environment','./chatMessage.attributes','define','ChatMessage','chat_messages','body','models','get','direction','toLowerCase','out','secret','UserId','ChatInteraction','findOne'];(function(_0x40e8b1,_0x36bf73){var _0x40250c=function(_0x596c37){while(--_0x596c37){_0x40e8b1['push'](_0x40e8b1['shift']());}};_0x40250c(++_0x36bf73);}(_0x374c,0x1e3));var _0xc374=function(_0x2763f2,_0x416af8){_0x2763f2=_0x2763f2-0x0;var _0x3ef471=_0x374c[_0x2763f2];return _0x3ef471;};'use strict';var _=require('lodash');var util=require(_0xc374('0x0'));var logger=require(_0xc374('0x1'))(_0xc374('0x2'));var moment=require(_0xc374('0x3'));var BPromise=require(_0xc374('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xc374('0x5'));var rimraf=require('rimraf');var config=require(_0xc374('0x6'));var attributes=require(_0xc374('0x7'));module['exports']=function(_0x129aff,_0x422047){return _0x129aff[_0xc374('0x8')](_0xc374('0x9'),attributes,{'tableName':_0xc374('0xa'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0xc374('0xb')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5bbfeb,_0x1c85eb,_0x221944){var _0x4e3f30=_0x129aff[_0xc374('0xc')];var _0x589651=_0x5bbfeb[_0xc374('0xd')]({'plain':!![]});if(_0x589651[_0xc374('0xe')][_0xc374('0xf')]()==='in'||_0x589651['direction'][_0xc374('0xf')]()===_0xc374('0x10')&&!_0x589651[_0xc374('0x11')]&&!_['isNil'](_0x589651[_0xc374('0x12')])){_0x4e3f30[_0xc374('0x13')][_0xc374('0x14')]({'where':{'id':_0x589651['ChatInteractionId']}})[_0xc374('0x15')](function(_0x47a7bf){if(_0x47a7bf){_0x47a7bf[_0xc374('0x16')]({'lastMsgAt':_0x589651[_0xc374('0x17')],'lastMsgDirection':_0x589651['direction'][_0xc374('0xf')]()});}})[_0xc374('0x18')](function(_0x4109ec){console[_0xc374('0x19')](_0x4109ec);});}_0x221944();}},'charset':_0xc374('0x1a'),'collate':_0xc374('0x1b')});};