f5925696bb8941723505a3a92c8b7e5bbc2be33c
[motion2.git] / server / api / plugin / plugin.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 _0x3c94=['save','update','remove','emit','hasOwnProperty','hook','exports','events','../../mysqldb','Plugin','setMaxListeners'];(function(_0x2fb866,_0x59bc0c){var _0x5d310f=function(_0x13bf75){while(--_0x13bf75){_0x2fb866['push'](_0x2fb866['shift']());}};_0x5d310f(++_0x59bc0c);}(_0x3c94,0xcd));var _0x43c9=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x3c94[_0x3dd15e];return _0x231fd0;};'use strict';var EventEmitter=require(_0x43c9('0x0'));var Plugin=require(_0x43c9('0x1'))['db'][_0x43c9('0x2')];var PluginEvents=new EventEmitter();PluginEvents[_0x43c9('0x3')](0x0);var events={'afterCreate':_0x43c9('0x4'),'afterUpdate':_0x43c9('0x5'),'afterDestroy':_0x43c9('0x6')};function emitEvent(_0x18159f){return function(_0x170a0d,_0x44fc3,_0x15ef71){PluginEvents[_0x43c9('0x7')](_0x18159f+':'+_0x170a0d['id'],_0x170a0d);PluginEvents['emit'](_0x18159f,_0x170a0d);_0x15ef71(null);};}for(var e in events){if(events[_0x43c9('0x8')](e)){var event=events[e];Plugin[_0x43c9('0x9')](e,emitEvent(event));}}module[_0x43c9('0xa')]=PluginEvents;