5e07a827d94b3cfed3b2dc52cf46a240d7fb3e68
[motion2.git] / server / api / user / user.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 _0xbf5b=['hook','events','User','setMaxListeners','update','remove','emit','hasOwnProperty'];(function(_0x477e2a,_0x1077c6){var _0xf05896=function(_0x151c36){while(--_0x151c36){_0x477e2a['push'](_0x477e2a['shift']());}};_0xf05896(++_0x1077c6);}(_0xbf5b,0x1c1));var _0xbbf5=function(_0x2c7618,_0x26be9c){_0x2c7618=_0x2c7618-0x0;var _0x5ce3f0=_0xbf5b[_0x2c7618];return _0x5ce3f0;};'use strict';var EventEmitter=require(_0xbbf5('0x0'));var User=require('../../mysqldb')['db'][_0xbbf5('0x1')];var UserEvents=new EventEmitter();UserEvents[_0xbbf5('0x2')](0x0);var events={'afterCreate':'save','afterUpdate':_0xbbf5('0x3'),'afterDestroy':_0xbbf5('0x4')};function emitEvent(_0x10b872){return function(_0x5c6a27,_0x13fa9c,_0x29aaf2){UserEvents['emit'](_0x10b872+':'+_0x5c6a27['id'],_0x5c6a27);UserEvents[_0xbbf5('0x5')](_0x10b872,_0x5c6a27);_0x29aaf2(null);};}for(var e in events){if(events[_0xbbf5('0x6')](e)){var event=events[e];User[_0xbbf5('0x7')](e,emitEvent(event));}}module['exports']=UserEvents;