36359d02ff8db438e3f8b17c815c033a3507065f
[motion2.git] / server / api / faxInteraction / faxInteraction.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 _0x535b=['length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','FaxInteraction','FaxMessage','save','update','remove','getUsers','then','setDataValue','Users','map','findAll','unreadMessages'];(function(_0x58ee7f,_0x1728ae){var _0x25ac11=function(_0x2eaf7a){while(--_0x2eaf7a){_0x58ee7f['push'](_0x58ee7f['shift']());}};_0x25ac11(++_0x1728ae);}(_0x535b,0x1aa));var _0xb535=function(_0x34d69d,_0x4506e9){_0x34d69d=_0x34d69d-0x0;var _0x2d0931=_0x535b[_0x34d69d];return _0x2d0931;};'use strict';var EventEmitter=require(_0xb535('0x0'));var FaxInteraction=require(_0xb535('0x1'))['db'][_0xb535('0x2')];var FaxMessage=require(_0xb535('0x1'))['db'][_0xb535('0x3')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xb535('0x4'),'afterUpdate':_0xb535('0x5'),'afterDestroy':_0xb535('0x6')};function emitEvent(_0x345f77){return function(_0x49177e,_0x5b22d4,_0x5c3c87){_0x49177e[_0xb535('0x7')]({'attributes':['id'],'raw':!![]})[_0xb535('0x8')](function(_0x5c56cf){_0x49177e[_0xb535('0x9')](_0xb535('0xa'),_0x5c56cf[_0xb535('0xb')](function(_0x9a189c){return{'id':_0x9a189c['id']};}));return FaxMessage[_0xb535('0xc')]({'where':{'FaxInteractionId':_0x49177e['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x254c10){_0x49177e[_0xb535('0x9')](_0xb535('0xd'),_0x254c10[_0xb535('0xe')]);FaxInteractionEvents[_0xb535('0xf')](_0x345f77+':'+_0x49177e['id'],_0x49177e);FaxInteractionEvents[_0xb535('0xf')](_0x345f77,_0x49177e);_0x5c3c87(null);})[_0xb535('0x10')](_0x5c3c87(null));};}for(var e in events){if(events[_0xb535('0x11')](e)){var event=events[e];FaxInteraction[_0xb535('0x12')](e,emitEvent(event));}}module[_0xb535('0x13')]=FaxInteractionEvents;