Built motion from commit (unavailable).|2.5.11
[motion2.git] / server / api / whatsappInteraction / whatsappInteraction.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 _0xfc56=['unreadMessages','length','emit','hasOwnProperty','exports','../../mysqldb','WhatsappInteraction','WhatsappMessage','setMaxListeners','update','remove','getUsers','then','setDataValue','Users'];(function(_0xcbb8db,_0x1f0a12){var _0x2fdcac=function(_0x2eedc9){while(--_0x2eedc9){_0xcbb8db['push'](_0xcbb8db['shift']());}};_0x2fdcac(++_0x1f0a12);}(_0xfc56,0xd7));var _0x6fc5=function(_0x549d39,_0x939965){_0x549d39=_0x549d39-0x0;var _0x2478e8=_0xfc56[_0x549d39];return _0x2478e8;};'use strict';var EventEmitter=require('events');var WhatsappInteraction=require(_0x6fc5('0x0'))['db'][_0x6fc5('0x1')];var WhatsappMessage=require(_0x6fc5('0x0'))['db'][_0x6fc5('0x2')];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents[_0x6fc5('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x6fc5('0x4'),'afterDestroy':_0x6fc5('0x5')};function emitEvent(_0x2e3075){return function(_0x25d1da,_0x47ccb9,_0x519723){_0x25d1da[_0x6fc5('0x6')]({'attributes':['id'],'raw':!![]})[_0x6fc5('0x7')](function(_0x498547){_0x25d1da[_0x6fc5('0x8')](_0x6fc5('0x9'),_0x498547['map'](function(_0x4cc1b0){return{'id':_0x4cc1b0['id']};}));return WhatsappMessage['findAll']({'where':{'WhatsappInteractionId':_0x25d1da['id'],'direction':'in','read':![]},'raw':!![]});})[_0x6fc5('0x7')](function(_0x56f36d){_0x25d1da[_0x6fc5('0x8')](_0x6fc5('0xa'),_0x56f36d[_0x6fc5('0xb')]);WhatsappInteractionEvents[_0x6fc5('0xc')](_0x2e3075+':'+_0x25d1da['id'],_0x25d1da);WhatsappInteractionEvents[_0x6fc5('0xc')](_0x2e3075,_0x25d1da);_0x519723(null);})['catch'](_0x519723(null));};}for(var e in events){if(events[_0x6fc5('0xd')](e)){var event=events[e];WhatsappInteraction['hook'](e,emitEvent(event));}}module[_0x6fc5('0xe')]=WhatsappInteractionEvents;