Built motion from commit 14588770.|2.5.38
[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 _0x950a=['error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','request-promise','path','rimraf','./chatMessage.attributes','exports','define','fti_chat_messages','body','FULLTEXT','get','toLowerCase','direction','secret','UserId','ChatInteraction','findOne','then','update','catch'];(function(_0x3947c9,_0x4d6c97){var _0x2e7871=function(_0x1236cc){while(--_0x1236cc){_0x3947c9['push'](_0x3947c9['shift']());}};_0x2e7871(++_0x4d6c97);}(_0x950a,0x111));var _0xa950=function(_0x9e2e28,_0x34a5c4){_0x9e2e28=_0x9e2e28-0x0;var _0xc96456=_0x950a[_0x9e2e28];return _0xc96456;};'use strict';var _=require(_0xa950('0x0'));var util=require(_0xa950('0x1'));var logger=require(_0xa950('0x2'))(_0xa950('0x3'));var moment=require('moment');var BPromise=require(_0xa950('0x4'));var rp=require(_0xa950('0x5'));var fs=require('fs');var path=require(_0xa950('0x6'));var rimraf=require(_0xa950('0x7'));var config=require('../../config/environment');var attributes=require(_0xa950('0x8'));module[_0xa950('0x9')]=function(_0x512c0e,_0x14b4ac){return _0x512c0e[_0xa950('0xa')]('ChatMessage',attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':_0xa950('0xb'),'fields':[_0xa950('0xc')],'type':_0xa950('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2c77da,_0x274d9a,_0x1b4ec6){var _0x4e4700=_0x512c0e['models'];var _0x546c08=_0x2c77da[_0xa950('0xe')]({'plain':!![]});if(_0x546c08['direction'][_0xa950('0xf')]()==='in'||_0x546c08[_0xa950('0x10')][_0xa950('0xf')]()==='out'&&!_0x546c08[_0xa950('0x11')]&&!_['isNil'](_0x546c08[_0xa950('0x12')])){_0x4e4700[_0xa950('0x13')][_0xa950('0x14')]({'where':{'id':_0x546c08['ChatInteractionId']}})[_0xa950('0x15')](function(_0x2aed6a){if(_0x2aed6a){_0x2aed6a[_0xa950('0x16')]({'lastMsgAt':_0x546c08['createdAt'],'lastMsgDirection':_0x546c08[_0xa950('0x10')][_0xa950('0xf')]()});}})[_0xa950('0x17')](function(_0x5d5f4c){console[_0xa950('0x18')](_0x5d5f4c);});}_0x1b4ec6();}},'charset':_0xa950('0x19'),'collate':_0xa950('0x1a')});};