Built motion from commit (unavailable).|2.5.2
[motion2.git] / server / api / chatInteraction / chatInteraction.events.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 _0x0acc=['ChatMessage','save','update','remove','getUsers','setDataValue','Users','findAll','then','length','emit','hasOwnProperty','hook','exports','../../mysqldb'];(function(_0x92c450,_0x41f1e3){var _0x2a9599=function(_0x4f27df){while(--_0x4f27df){_0x92c450['push'](_0x92c450['shift']());}};_0x2a9599(++_0x41f1e3);}(_0x0acc,0x158));var _0xc0ac=function(_0x98459f,_0x4dfb55){_0x98459f=_0x98459f-0x0;var _0x128f94=_0x0acc[_0x98459f];return _0x128f94;};'use strict';var EventEmitter=require('events');var ChatInteraction=require(_0xc0ac('0x0'))['db']['ChatInteraction'];var ChatMessage=require(_0xc0ac('0x0'))['db'][_0xc0ac('0x1')];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xc0ac('0x2'),'afterUpdate':_0xc0ac('0x3'),'afterDestroy':_0xc0ac('0x4')};function emitEvent(_0x2d5436){return function(_0x12959b,_0x420b9c,_0x45eb29){_0x12959b[_0xc0ac('0x5')]({'attributes':['id'],'raw':!![]})['then'](function(_0x2c9ae1){_0x12959b[_0xc0ac('0x6')](_0xc0ac('0x7'),_0x2c9ae1['map'](function(_0x3fc177){return{'id':_0x3fc177['id']};}));return ChatMessage[_0xc0ac('0x8')]({'where':{'ChatInteractionId':_0x12959b['id'],'direction':'in','read':![]},'raw':!![]});})[_0xc0ac('0x9')](function(_0x4df911){_0x12959b[_0xc0ac('0x6')]('unreadMessages',_0x4df911[_0xc0ac('0xa')]);ChatInteractionEvents[_0xc0ac('0xb')](_0x2d5436+':'+_0x12959b['id'],_0x12959b);ChatInteractionEvents[_0xc0ac('0xb')](_0x2d5436,_0x12959b);_0x45eb29(null);})['catch'](_0x45eb29(null));};}for(var e in events){if(events[_0xc0ac('0xc')](e)){var event=events[e];ChatInteraction[_0xc0ac('0xd')](e,emitEvent(event));}}module[_0xc0ac('0xe')]=ChatInteractionEvents;