Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / services / ami / model / agent.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 _0xbc70=['lodash','util','moment','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','email','accountcode','fullname','state','unknown','status','address','phone','mobile','interface','online','voiceStatus','voiceStatusQueue','onhold','toLowerCase','not_inuse','idle','inuse','talking','statePause','voiceStatusTime','toNumber','format','stringify','emit','exports'];(function(_0x176e8b,_0x555a80){var _0x35fd87=function(_0xc213cf){while(--_0xc213cf){_0x176e8b['push'](_0x176e8b['shift']());}};_0x35fd87(++_0x555a80);}(_0xbc70,0x120));var _0x0bc7=function(_0xa6073c,_0x48b4c7){_0xa6073c=_0xa6073c-0x0;var _0x1e44e9=_0xbc70[_0xa6073c];return _0x1e44e9;};'use strict';var _=require(_0x0bc7('0x0'));var util=require(_0x0bc7('0x1'));var moment=require(_0x0bc7('0x2'));var md5=require(_0x0bc7('0x3'));var Redis=require(_0x0bc7('0x4'));var config=require(_0x0bc7('0x5'));config[_0x0bc7('0x6')]=_[_0x0bc7('0x7')](config[_0x0bc7('0x6')],{'host':'localhost','port':0x18eb});var io=require(_0x0bc7('0x8'))(new Redis(config[_0x0bc7('0x6')]));function Agent(_0x3b95a1){this['id']=_0x3b95a1['id']||0x0;this[_0x0bc7('0x9')]=_0x3b95a1[_0x0bc7('0x9')]||'';this[_0x0bc7('0xa')]=_0x3b95a1[_0x0bc7('0xa')]||'';this[_0x0bc7('0xb')]=_0x3b95a1[_0x0bc7('0xb')]||'';this['fullname']=_0x3b95a1[_0x0bc7('0xc')]||'';this[_0x0bc7('0xd')]=_0x0bc7('0xe');this['stateTime']=0x0;this[_0x0bc7('0xf')]=_0x0bc7('0xe');this[_0x0bc7('0x10')]='';this[_0x0bc7('0x11')]='';this[_0x0bc7('0x12')]='';this[_0x0bc7('0x13')]='';this[_0x0bc7('0x14')]=_0x3b95a1[_0x0bc7('0x14')]||![];this[_0x0bc7('0x15')]='unknown';this['voiceStatusTime']=0x0;this['voiceStatusCallerIdNumber']='';this[_0x0bc7('0x16')]='';this[_0x0bc7('0x17')]=![];this['local']=![];this[_0x0bc7('0x3')]='';}Agent['prototype']['updateStatusRealtime']=function(_0x55d71e){var _0x5d584e;if(_0x55d71e&&_0x55d71e[_0x0bc7('0xd')]){_0x5d584e=_0x55d71e[_0x0bc7('0xd')][_0x0bc7('0x18')]();switch(_0x5d584e){case _0x0bc7('0x19'):_0x5d584e=_0x0bc7('0x1a');break;case _0x0bc7('0x1b'):_0x5d584e=_0x0bc7('0x1c');break;}}if(_0x5d584e&&this[_0x0bc7('0x15')]!==_0x5d584e||_0x55d71e[_0x0bc7('0x1d')]){this[_0x0bc7('0x1e')]=_[_0x0bc7('0x1f')](moment()[_0x0bc7('0x20')]('x'));}if(_0x5d584e){this[_0x0bc7('0x15')]=_0x5d584e;}var _0x4abe2a={'id':this['id'],'name':this[_0x0bc7('0x9')],'email':this[_0x0bc7('0xa')],'accountcode':this['accountcode'],'fullname':this['fullname'],'state':this['state'],'stateTime':this['stateTime'],'status':this[_0x0bc7('0xf')],'address':this[_0x0bc7('0x10')],'online':this[_0x0bc7('0x14')],'voiceStatus':this[_0x0bc7('0x15')],'voiceStatusTime':this['voiceStatusTime'],'voiceStatusCallerIdNumber':this['voiceStatusCallerIdNumber'],'voiceStatusQueue':this['voiceStatusQueue'],'interface':this[_0x0bc7('0x13')],'onhold':this[_0x0bc7('0x17')]};var _0x4e581d=md5(JSON[_0x0bc7('0x21')](_0x4abe2a));if(this[_0x0bc7('0x3')]!==_0x4e581d){this[_0x0bc7('0x3')]=_0x4e581d;io['to'](util[_0x0bc7('0x20')]('user:%s',_0x4abe2a[_0x0bc7('0x9')]))[_0x0bc7('0x22')]('user:save',_0x4abe2a);}};module[_0x0bc7('0x23')]=Agent;