Built motion from commit 1fa89557.|2.6.10
[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 _0x6c70=['get','toLowerCase','direction','secret','UserId','findOne','ChatInteractionId','then','update','createdAt','catch','error','utf8mb4_unicode_ci','util','api','moment','bluebird','request-promise','path','../../config/environment','./chatMessage.attributes','exports','chat_messages'];(function(_0x2fc32c,_0x3a2c62){var _0x35f0f2=function(_0x2d9b81){while(--_0x2d9b81){_0x2fc32c['push'](_0x2fc32c['shift']());}};_0x35f0f2(++_0x3a2c62);}(_0x6c70,0x1f0));var _0x06c7=function(_0x376b45,_0x5964fb){_0x376b45=_0x376b45-0x0;var _0x2341b3=_0x6c70[_0x376b45];return _0x2341b3;};'use strict';var _=require('lodash');var util=require(_0x06c7('0x0'));var logger=require('../../config/logger')(_0x06c7('0x1'));var moment=require(_0x06c7('0x2'));var BPromise=require(_0x06c7('0x3'));var rp=require(_0x06c7('0x4'));var fs=require('fs');var path=require(_0x06c7('0x5'));var rimraf=require('rimraf');var config=require(_0x06c7('0x6'));var attributes=require(_0x06c7('0x7'));module[_0x06c7('0x8')]=function(_0x1751b0,_0x4e2070){return _0x1751b0['define']('ChatMessage',attributes,{'tableName':_0x06c7('0x9'),'paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5caedf,_0xfd0a3b,_0x3e9b1e){var _0x5f5dc3=_0x1751b0['models'];var _0x30acd0=_0x5caedf[_0x06c7('0xa')]({'plain':!![]});if(_0x30acd0['direction'][_0x06c7('0xb')]()==='in'||_0x30acd0[_0x06c7('0xc')][_0x06c7('0xb')]()==='out'&&!_0x30acd0[_0x06c7('0xd')]&&!_['isNil'](_0x30acd0[_0x06c7('0xe')])){_0x5f5dc3['ChatInteraction'][_0x06c7('0xf')]({'where':{'id':_0x30acd0[_0x06c7('0x10')]}})[_0x06c7('0x11')](function(_0x33fd6c){if(_0x33fd6c){_0x33fd6c[_0x06c7('0x12')]({'lastMsgAt':_0x30acd0[_0x06c7('0x13')],'lastMsgDirection':_0x30acd0[_0x06c7('0xc')][_0x06c7('0xb')]()});}})[_0x06c7('0x14')](function(_0x3851d1){console[_0x06c7('0x15')](_0x3851d1);});}_0x3e9b1e();}},'charset':'utf8mb4','collate':_0x06c7('0x16')});};