62fb4a12c258b57581178251a590a154f0a5699b
[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 _0xf417=['Plugin','setMaxListeners','update','hasOwnProperty','exports','../../mysqldb'];(function(_0x3947c9,_0x4d6c97){var _0x2e7871=function(_0x1236cc){while(--_0x1236cc){_0x3947c9['push'](_0x3947c9['shift']());}};_0x2e7871(++_0x4d6c97);}(_0xf417,0x8f));var _0x7f41=function(_0x371d83,_0x49a0ce){_0x371d83=_0x371d83-0x0;var _0x27a8b8=_0xf417[_0x371d83];return _0x27a8b8;};'use strict';var EventEmitter=require('events');var Plugin=require(_0x7f41('0x0'))['db'][_0x7f41('0x1')];var PluginEvents=new EventEmitter();PluginEvents[_0x7f41('0x2')](0x0);var events={'afterCreate':'save','afterUpdate':_0x7f41('0x3'),'afterDestroy':'remove'};function emitEvent(_0x4c7081){return function(_0x2b7d4c,_0x5170ec,_0x51b0cb){PluginEvents['emit'](_0x4c7081+':'+_0x2b7d4c['id'],_0x2b7d4c);PluginEvents['emit'](_0x4c7081,_0x2b7d4c);_0x51b0cb(null);};}for(var e in events){if(events[_0x7f41('0x4')](e)){var event=events[e];Plugin['hook'](e,emitEvent(event));}}module[_0x7f41('0x5')]=PluginEvents;