From 5cda53885960a0566ebf5222a59df5301c5f5f78 Mon Sep 17 00:00:00 2001 From: Motion Team Date: Mon, 11 Jan 2016 20:22:29 +0100 Subject: [PATCH] Built motion from commit 22bc4a4.|0.0.19 --- package.json | 3 +- release-notes/changelog_0.0.18.txt | 27 - release-notes/changelog_0.0.19.txt | 26 + server/api/agent/agent.controller.js | 280 +---- server/api/agent/agent.socket.js | 34 +- server/api/agent/agent.spec.js | 21 +- server/api/agent/index.js | 22 +- server/api/ami/ami.ami.js | 38 +- server/api/ami/ami.controller.js | 102 +-- server/api/ami/ami.socket.js | 25 +- server/api/ami/ami.spec.js | 21 +- server/api/ami/index.js | 17 +- server/api/automation/automation.controller.js | 169 +--- server/api/automation/automation.socket.js | 25 +- server/api/automation/automation.spec.js | 21 +- server/api/automation/index.js | 18 +- .../business_action/business_action.controller.js | 95 +-- .../api/business_action/business_action.socket.js | 25 +- server/api/business_action/business_action.spec.js | 21 +- server/api/business_action/index.js | 16 +- .../business_condition.controller.js | 94 +-- .../business_condition.socket.js | 25 +- .../business_condition/business_condition.spec.js | 21 +- server/api/business_condition/index.js | 16 +- .../chat_application.controller.js | 106 +-- .../chat_application/chat_application.socket.js | 25 +- .../api/chat_application/chat_application.spec.js | 21 +- server/api/chat_application/index.js | 16 +- server/api/chat_enquiry/enquiry.controller.js | 100 +-- server/api/chat_enquiry/enquiry.socket.js | 25 +- server/api/chat_enquiry/index.js | 16 +- server/api/chat_message/chat_message.controller.js | 268 +---- server/api/chat_message/chat_message.socket.js | 60 +- server/api/chat_message/chat_message.spec.js | 21 +- server/api/chat_message/index.js | 17 +- server/api/chat_queue/chat_queue.controller.js | 227 +---- server/api/chat_queue/chat_queue.socket.js | 25 +- server/api/chat_queue/chat_queue.spec.js | 21 +- server/api/chat_queue/index.js | 21 +- server/api/chat_room/chat_room.controller.js | 456 +------- server/api/chat_room/chat_room.socket.js | 31 +- server/api/chat_room/chat_room.spec.js | 21 +- server/api/chat_room/index.js | 21 +- server/api/chat_visitor/chat_visitor.controller.js | 95 +-- server/api/chat_visitor/chat_visitor.socket.js | 28 +- server/api/chat_visitor/chat_visitor.spec.js | 21 +- server/api/chat_visitor/index.js | 16 +- server/api/chat_website/chat_website.controller.js | 270 +---- server/api/chat_website/chat_website.socket.js | 25 +- server/api/chat_website/chat_website.spec.js | 21 +- server/api/chat_website/index.js | 20 +- server/api/company/company.controller.js | 210 +--- server/api/company/company.socket.js | 25 +- server/api/company/company.spec.js | 21 +- server/api/company/index.js | 19 +- server/api/contact/contact.controller.js | 86 +-- server/api/contact/contact.model.js | 14 +- server/api/contact/contact.socket.js | 25 +- server/api/contact/contact.spec.js | 21 +- server/api/contact/index.js | 16 +- .../contact_manager/contact_manager.controller.js | 517 +-------- .../api/contact_manager/contact_manager.socket.js | 25 +- server/api/contact_manager/contact_manager.spec.js | 21 +- server/api/contact_manager/index.js | 21 +- server/api/custom_field/custom_field.controller.js | 224 +---- server/api/custom_field/custom_field.socket.js | 30 +- server/api/custom_field/custom_field.spec.js | 21 +- server/api/custom_field/index.js | 20 +- .../api/custom_report/custom_report.controller.js | 161 +--- server/api/custom_report/custom_report.socket.js | 25 +- server/api/custom_report/custom_report.spec.js | 21 +- server/api/custom_report/index.js | 16 +- server/api/dashboard/dashboard.controller.js | 179 +--- server/api/dashboard/dashboard.socket.js | 28 +- server/api/dashboard/dashboard.spec.js | 21 +- server/api/dashboard/index.js | 19 +- .../default_report/default_report.controller.js | 160 +--- server/api/default_report/default_report.socket.js | 25 +- server/api/default_report/default_report.spec.js | 21 +- server/api/default_report/index.js | 16 +- server/api/desk_account/desk_account.controller.js | 257 +---- server/api/desk_account/desk_account.socket.js | 25 +- server/api/desk_account/desk_account.spec.js | 21 +- server/api/desk_account/index.js | 20 +- .../desk_configuration.controller.js | 146 +--- .../desk_configuration.socket.js | 25 +- server/api/desk_configuration/index.js | 20 +- server/api/desk_configuration/index.spec.js | 98 +-- server/api/desk_field/desk_field.controller.js | 105 +-- server/api/desk_field/desk_field.socket.js | 25 +- server/api/desk_field/index.js | 19 +- server/api/desk_field/index.spec.js | 98 +-- server/api/event/event.controller.js | 120 +-- server/api/event/event.socket.js | 37 +- server/api/event/event.spec.js | 21 +- server/api/event/index.js | 17 +- server/api/fax_account/fax_account.controller.js | 375 +------ server/api/fax_account/fax_account.socket.js | 25 +- server/api/fax_account/fax_account.spec.js | 21 +- server/api/fax_account/index.js | 18 +- .../fax_application/fax_application.controller.js | 95 +-- .../api/fax_application/fax_application.socket.js | 25 +- server/api/fax_application/fax_application.spec.js | 21 +- server/api/fax_application/index.js | 16 +- .../fax_business_automation.controller.js | 205 +--- .../fax_business_automation.socket.js | 28 +- .../fax_business_automation.spec.js | 21 +- server/api/fax_business_automation/index.js | 16 +- server/api/fax_message/fax_message.ami.js | 65 +- server/api/fax_message/fax_message.controller.js | 423 +------ server/api/fax_message/fax_message.socket.js | 86 +-- server/api/fax_message/fax_message.spec.js | 21 +- server/api/fax_message/index.js | 17 +- server/api/fax_queue/fax_queue.controller.js | 223 +---- server/api/fax_queue/fax_queue.socket.js | 25 +- server/api/fax_queue/fax_queue.spec.js | 21 +- server/api/fax_queue/index.js | 19 +- server/api/fax_room/fax_room.controller.js | 152 +--- server/api/fax_room/fax_room.kue.js | 65 +- server/api/fax_room/fax_room.socket.js | 25 +- server/api/fax_room/fax_room.spec.js | 21 +- server/api/fax_room/index.js | 17 +- .../freshdesk_account.controller.js | 240 +---- .../freshdesk_account/freshdesk_account.socket.js | 25 +- server/api/freshdesk_account/index.js | 22 +- server/api/freshdesk_account/index.spec.js | 98 +-- .../freshdesk_configuration.controller.js | 147 +--- .../freshdesk_configuration.socket.js | 25 +- server/api/freshdesk_configuration/index.js | 20 +- server/api/freshdesk_configuration/index.spec.js | 98 +-- .../freshdesk_field/freshdesk_field.controller.js | 105 +-- .../api/freshdesk_field/freshdesk_field.socket.js | 25 +- server/api/freshdesk_field/index.js | 19 +- server/api/freshdesk_field/index.spec.js | 98 +-- server/api/integration/index.js | 16 +- server/api/integration/integration.controller.js | 180 +--- server/api/integration/integration.socket.js | 28 +- server/api/integration/integration.spec.js | 21 +- server/api/interval/index.js | 19 +- server/api/interval/interval.controller.js | 325 +----- server/api/interval/interval.socket.js | 32 +- server/api/interval/interval.spec.js | 21 +- server/api/mail_account/index.js | 19 +- server/api/mail_account/mail_account.controller.js | 292 +----- server/api/mail_account/mail_account.socket.js | 28 +- server/api/mail_account/mail_account.spec.js | 21 +- server/api/mail_application/index.js | 16 +- .../mail_application.controller.js | 112 +-- .../mail_application/mail_application.socket.js | 25 +- .../api/mail_application/mail_application.spec.js | 21 +- server/api/mail_attachment/index.js | 16 +- .../mail_attachment/mail_attachment.controller.js | 88 +-- .../api/mail_attachment/mail_attachment.socket.js | 25 +- server/api/mail_attachment/mail_attachment.spec.js | 21 +- server/api/mail_business_automation/index.js | 17 +- .../mail_business_automation.controller.js | 219 +---- .../mail_business_automation.socket.js | 28 +- .../mail_business_automation.spec.js | 21 +- server/api/mail_message/index.js | 20 +- server/api/mail_message/mail_message.controller.js | 212 +--- server/api/mail_message/mail_message.socket.js | 30 +- server/api/mail_queue/index.js | 19 +- server/api/mail_queue/mail_queue.controller.js | 212 +--- server/api/mail_queue/mail_queue.socket.js | 25 +- server/api/mail_queue/mail_queue.spec.js | 21 +- server/api/mail_room/index.js | 19 +- server/api/mail_room/mail_room.controller.js | 206 +--- server/api/mail_room/mail_room.socket.js | 48 +- server/api/mail_server_in/index.js | 16 +- .../mail_server_in/mail_server_in.controller.js | 99 +-- server/api/mail_server_in/mail_server_in.socket.js | 28 +- server/api/mail_server_out/index.js | 19 +- .../mail_server_out/mail_server_out.controller.js | 166 +--- .../api/mail_server_out/mail_server_out.socket.js | 27 +- server/api/mail_template/index.js | 16 +- .../api/mail_template/mail_template.controller.js | 151 +--- server/api/mail_template/mail_template.socket.js | 25 +- server/api/metric/index.js | 19 +- server/api/metric/metric.controller.js | 221 +---- server/api/metric/metric.socket.js | 25 +- server/api/metric/metric.spec.js | 21 +- server/api/module/index.js | 16 +- server/api/module/module.controller.js | 93 +-- server/api/module/module.socket.js | 25 +- server/api/module/module.spec.js | 21 +- server/api/module/setting/index.js | 16 +- server/api/module/setting/setting.controller.js | 111 +-- server/api/module/setting/setting.socket.js | 25 +- server/api/module/setting/setting.spec.js | 21 +- server/api/motionbar/index.js | 12 +- server/api/motionbar/motionbar.controller.js | 33 +- server/api/motionbar/motionbar.socket.js | 28 +- server/api/motionbar/motionbar.spec.js | 21 +- server/api/report_agent/index.js | 16 +- server/api/report_agent/report_agent.controller.js | 94 +-- server/api/report_agent/report_agent.socket.js | 51 +- server/api/report_chat/index.js | 16 +- server/api/report_chat/report_chat.controller.js | 97 +-- server/api/report_chat/report_chat.socket.js | 40 +- server/api/report_chat/report_chat.spec.js | 21 +- server/api/report_chat_session/index.js | 16 +- .../report_chat_session.controller.js | 94 +-- .../report_chat_session.socket.js | 28 +- .../report_chat_session.spec.js | 21 +- server/api/report_integration/index.js | 16 +- .../report_integration.controller.js | 94 +-- .../report_integration.socket.js | 21 +- server/api/report_mail/index.js | 16 +- server/api/report_mail/report_mail.controller.js | 94 +-- server/api/report_mail/report_mail.socket.js | 36 +- server/api/report_mail/report_mail.spec.js | 21 +- server/api/report_mail_session/index.js | 16 +- .../report_mail_session.controller.js | 94 +-- .../report_mail_session.socket.js | 28 +- .../report_mail_session.spec.js | 21 +- server/api/report_queue/index.js | 16 +- server/api/report_queue/report_queue.controller.js | 94 +-- server/api/report_queue/report_queue.socket.js | 30 +- server/api/report_tree/index.js | 13 +- server/api/report_tree/report_tree.controller.js | 47 +- server/api/report_tree/report_tree.socket.js | 28 +- server/api/report_tree/report_tree.spec.js | 21 +- server/api/salesforce_account/index.js | 22 +- server/api/salesforce_account/index.spec.js | 98 +-- .../salesforce_account.controller.js | 254 +---- .../salesforce_account.socket.js | 25 +- server/api/salesforce_configuration/index.js | 19 +- server/api/salesforce_configuration/index.spec.js | 98 +-- .../salesforce_configuration.controller.js | 148 +--- .../salesforce_configuration.socket.js | 25 +- server/api/salesforce_field/index.js | 19 +- server/api/salesforce_field/index.spec.js | 98 +-- .../salesforce_field.controller.js | 105 +-- .../salesforce_field/salesforce_field.socket.js | 25 +- server/api/setting/index.js | 19 +- server/api/setting/setting.controller.js | 153 +--- server/api/setting/setting.socket.js | 25 +- server/api/setting/setting.spec.js | 21 +- server/api/square_odbc/index.js | 18 +- server/api/square_odbc/square_odbc.controller.js | 210 +--- server/api/square_odbc/square_odbc.socket.js | 25 +- server/api/square_odbc/square_odbc.spec.js | 21 +- server/api/square_project/index.js | 20 +- .../square_project/square_project.controller.js | 212 +--- server/api/square_project/square_project.socket.js | 28 +- server/api/square_project/square_project.spec.js | 21 +- server/api/sugarcrm_account/index.js | 22 +- server/api/sugarcrm_account/index.spec.js | 98 +-- .../sugarcrm_account.controller.js | 260 +---- .../sugarcrm_account/sugarcrm_account.socket.js | 25 +- server/api/sugarcrm_configuration/index.js | 19 +- server/api/sugarcrm_configuration/index.spec.js | 98 +-- .../sugarcrm_configuration.controller.js | 146 +--- .../sugarcrm_configuration.socket.js | 25 +- server/api/sugarcrm_field/index.js | 19 +- server/api/sugarcrm_field/index.spec.js | 98 +-- .../sugarcrm_field/sugarcrm_field.controller.js | 105 +-- server/api/sugarcrm_field/sugarcrm_field.socket.js | 25 +- server/api/tag/index.js | 19 +- server/api/tag/tag.controller.js | 211 +--- server/api/tag/tag.socket.js | 25 +- server/api/tag/tag.spec.js | 21 +- server/api/team/index.js | 20 +- server/api/team/team.controller.js | 233 +---- server/api/team/team.socket.js | 28 +- server/api/team/team.spec.js | 21 +- server/api/thing/index.js | 16 +- server/api/thing/thing.controller.js | 99 +-- server/api/thing/thing.socket.js | 28 +- server/api/thing/thing.spec.js | 21 +- server/api/trigger/index.js | 18 +- server/api/trigger/trigger.controller.js | 169 +--- server/api/trigger/trigger.socket.js | 25 +- server/api/trigger/trigger.spec.js | 21 +- server/api/trunk/index.js | 19 +- server/api/trunk/trunk.ami.js | 91 +-- server/api/trunk/trunk.controller.js | 299 +----- server/api/trunk/trunk.socket.js | 25 +- server/api/trunk/trunk.spec.js | 21 +- server/api/update/index.js | 19 +- server/api/update/update.controller.js | 128 +-- server/api/update/update.js | 12 +- server/api/update/update.socket.js | 25 +- server/api/update/update.spec.js | 21 +- server/api/upload/index.js | 18 +- server/api/upload/upload.controller.js | 270 +---- server/api/upload/upload.socket.js | 25 +- server/api/upload/upload.spec.js | 21 +- server/api/user/index.js | 26 +- server/api/user/user.ami.js | 76 +-- server/api/user/user.controller.js | 448 +------- server/api/user/user.socket.js | 32 +- server/api/user/user.spec.js | 21 +- server/api/user_has_chat_queue/index.js | 16 +- .../user_has_chat_queue.controller.js | 104 +-- .../user_has_chat_queue.socket.js | 25 +- .../user_has_chat_queue.spec.js | 21 +- server/api/user_has_chat_room/index.js | 17 +- .../user_has_chat_room.controller.js | 97 +-- .../user_has_chat_room.socket.js | 59 +- .../user_has_chat_room/user_has_chat_room.spec.js | 21 +- server/api/user_has_fax_queue/index.js | 16 +- .../user_has_fax_queue.controller.js | 104 +-- .../user_has_fax_queue.socket.js | 31 +- .../user_has_fax_queue/user_has_fax_queue.spec.js | 21 +- server/api/user_has_mail_queue/index.js | 16 +- .../user_has_mail_queue.controller.js | 96 +-- .../user_has_mail_queue.socket.js | 25 +- .../user_has_mail_queue.spec.js | 21 +- server/api/user_has_team/index.js | 16 +- .../api/user_has_team/user_has_team.controller.js | 97 +-- server/api/user_has_team/user_has_team.model.js | 14 +- server/api/user_has_team/user_has_team.socket.js | 25 +- server/api/user_has_team/user_has_team.spec.js | 21 +- server/api/user_has_voice_queue/index.js | 16 +- .../user_has_voice_queue.controller.js | 99 +-- .../user_has_voice_queue.socket.js | 42 +- .../user_has_voice_queue.spec.js | 21 +- server/api/variable/index.js | 19 +- server/api/variable/variable.controller.js | 221 +---- server/api/variable/variable.socket.js | 25 +- server/api/variable/variable.spec.js | 21 +- server/api/voice_context/index.js | 17 +- server/api/voice_context/voice_context.ami.js | 72 +- .../api/voice_context/voice_context.controller.js | 283 +---- server/api/voice_context/voice_context.socket.js | 25 +- server/api/voice_context/voice_context.spec.js | 21 +- server/api/voice_extension/index.js | 23 +- .../voice_extension/voice_extension.controller.js | 1349 +------------------- .../api/voice_extension/voice_extension.socket.js | 35 +- server/api/voice_extension/voice_extension.spec.js | 21 +- server/api/voice_musiconhold/index.js | 22 +- .../voice_musiconhold.controller.js | 358 +------ .../voice_musiconhold/voice_musiconhold.socket.js | 25 +- .../voice_musiconhold/voice_musiconhold.spec.js | 21 +- server/api/voice_queue/index.js | 20 +- server/api/voice_queue/voice_queue.controller.js | 340 +----- server/api/voice_queue/voice_queue.socket.js | 25 +- server/api/voice_queue/voice_queue.spec.js | 21 +- server/api/voice_voicemail/index.js | 22 +- .../voice_voicemail/voice_voicemail.controller.js | 299 +----- .../api/voice_voicemail/voice_voicemail.socket.js | 40 +- server/api/voice_voicemail/voice_voicemail.spec.js | 21 +- server/api/widget/index.js | 20 +- server/api/widget/widget.controller.js | 182 +--- server/api/widget/widget.spec.js | 21 +- server/api/xchatty/index.js | 30 +- server/api/xchatty/xchatty.controller.js | 567 +-------- server/api/xchatty/xchatty.socket.js | 25 +- server/api/zendesk_account/index.js | 21 +- .../zendesk_account/zendesk_account.controller.js | 254 +---- .../api/zendesk_account/zendesk_account.socket.js | 25 +- server/api/zendesk_account/zendesk_account.spec.js | 21 +- server/api/zendesk_configuration/index.js | 17 +- .../zendesk_configuration.controller.js | 163 +--- .../zendesk_configuration.socket.js | 25 +- .../zendesk_configuration.spec.js | 21 +- server/api/zendesk_field/index.js | 16 +- .../api/zendesk_field/zendesk_field.controller.js | 94 +-- server/api/zendesk_field/zendesk_field.socket.js | 25 +- server/api/zendesk_field/zendesk_field.spec.js | 21 +- server/app.js | 13 +- server/auth/auth.service.js | 91 +-- server/auth/facebook/index.js | 22 +- server/auth/facebook/passport.js | 38 +- server/auth/google/index.js | 25 +- server/auth/google/passport.js | 34 +- server/auth/index.js | 23 +- server/auth/local/index.js | 93 +-- server/auth/local/local.ami.js | 52 +- server/auth/local/passport.js | 97 +-- server/auth/twitter/index.js | 21 +- server/auth/twitter/passport.js | 36 +- server/config/agi.js | 1176 +----------------- server/config/ami/acw.js | 119 +-- server/config/ami/agent.js | 96 +-- server/config/ami/call.js | 22 +- server/config/ami/dial.js | 42 +- server/config/ami/index.js | 172 +--- server/config/ami/member.js | 107 +-- server/config/ami/queue_caller.js | 58 +- server/config/ami/queue_member.js | 60 +- server/config/analytics.js | 1 + server/config/autodialer/index.js | 126 +-- server/config/autodialer/process.js | 27 +- server/config/automations/fax.js | 172 +--- server/config/automations/mail.js | 170 +--- server/config/environment/development.js | 14 +- server/config/environment/index.js | 79 +-- server/config/environment/production.js | 14 +- server/config/environment/test.js | 14 +- server/config/express.js | 73 +-- server/config/fax.js | 241 +---- server/config/history.js | 319 +----- server/config/imap/imap.js | 552 +-------- server/config/imap/index.js | 31 +- server/config/integration.js | 25 +- server/config/kue.chat.js | 561 +-------- server/config/kue.fax.js | 317 +----- server/config/kue.mail.js | 517 +-------- server/config/local.env.sample.js | 24 +- server/config/logger.js | 121 +-- server/config/seed.js | 1073 +---------------- server/config/smtp/index.js | 25 +- server/config/smtp/smtp.js | 429 +------- server/config/socketio.js | 196 +--- server/config/triggers/chat.js | 72 +- server/config/triggers/cm.js | 69 +- server/config/triggers/index.js | 98 +-- server/config/triggers/mail.js | 49 +- server/config/triggers/util.js | 98 +-- server/config/triggers/voice.js | 8 +- server/files/integrations/zendesk/app.js | 6 +- server/migrations/20151202190300-test.js | 35 +- server/models/asterisk_manager.js | 20 +- server/models/asterisk_manager_interface.js | 25 +- server/models/autodialer_contact.js | 16 +- server/models/autodialer_process.js | 54 +- server/models/automation.js | 25 +- server/models/business_action.js | 30 +- server/models/business_condition.js | 36 +- server/models/channel.js | 47 +- server/models/chat_application.js | 31 +- server/models/chat_enquiry.js | 24 +- server/models/chat_message.js | 26 +- server/models/chat_queue.js | 31 +- server/models/chat_room.js | 39 +- server/models/chat_visitor.js | 41 +- server/models/chat_website.js | 98 +-- server/models/company.js | 31 +- server/models/contact.js | 44 +- server/models/contact_email.js | 33 +- server/models/contact_has_custom_field.js | 17 +- server/models/contact_phone.js | 33 +- server/models/custom_field.js | 29 +- server/models/custom_report.js | 15 +- server/models/dashboard.js | 63 +- server/models/default_report.js | 15 +- server/models/desk_account.js | 37 +- server/models/desk_configuration.js | 28 +- server/models/desk_field.js | 27 +- server/models/event.js | 46 +- server/models/fax_account.js | 41 +- server/models/fax_application.js | 34 +- server/models/fax_business_automation.js | 33 +- server/models/fax_message.js | 64 +- server/models/fax_queue.js | 33 +- server/models/fax_room.js | 26 +- server/models/freshdesk_account.js | 25 +- server/models/freshdesk_configuration.js | 28 +- server/models/freshdesk_field.js | 27 +- server/models/history/report_agent_history.js | 68 +- server/models/history/report_call_history.js | 57 +- server/models/history/report_dial_history.js | 43 +- .../models/history/report_integration_history.js | 85 +-- .../models/history/report_mail_session_history.js | 32 +- server/models/history/report_member_history.js | 24 +- server/models/history/report_queue_history.js | 40 +- server/models/index.js | 97 +-- server/models/integration.js | 63 +- server/models/interval.js | 662 +---------- server/models/mail_account.js | 33 +- server/models/mail_application.js | 31 +- server/models/mail_attachment.js | 25 +- server/models/mail_automation.js | 24 +- server/models/mail_business_automation.js | 33 +- server/models/mail_message.js | 57 +- server/models/mail_queue.js | 31 +- server/models/mail_room.js | 32 +- server/models/mail_room_status.js | 15 +- server/models/mail_server_in.js | 42 +- server/models/mail_server_out.js | 35 +- server/models/mail_template.js | 25 +- server/models/mail_trigger.js | 24 +- server/models/metric.js | 22 +- server/models/module.js | 28 +- server/models/motionbar.js | 33 +- server/models/report_agent.js | 72 +- server/models/report_call.js | 56 +- server/models/report_chat.js | 49 +- server/models/report_chat_session.js | 33 +- server/models/report_dial.js | 45 +- server/models/report_integration.js | 84 +-- server/models/report_mail.js | 50 +- server/models/report_mail_session.js | 31 +- server/models/report_member.js | 26 +- server/models/report_queue.js | 42 +- server/models/report_square.js | 90 +-- server/models/report_square_detail.js | 26 +- server/models/report_tree.js | 13 +- server/models/salesforce_account.js | 25 +- server/models/salesforce_configuration.js | 28 +- server/models/salesforce_field.js | 23 +- server/models/settings.js | 53 +- server/models/square_odbc.js | 24 +- server/models/square_project.js | 29 +- server/models/sugarcrm_account.js | 21 +- server/models/sugarcrm_configuration.js | 28 +- server/models/sugarcrm_field.js | 23 +- server/models/tag.js | 23 +- server/models/team.js | 33 +- server/models/trigger.js | 25 +- server/models/trunk.js | 342 +----- server/models/update.js | 14 +- server/models/upload.js | 39 +- server/models/user.js | 580 +--------- server/models/user_has_chat_queue.js | 15 +- server/models/user_has_chat_room.js | 20 +- server/models/user_has_fax_queue.js | 15 +- server/models/user_has_mail_queue.js | 15 +- server/models/user_has_team.js | 15 +- server/models/user_has_voice_queue.js | 117 +-- server/models/variable.js | 28 +- server/models/voice_context.js | 26 +- server/models/voice_extension.js | 165 +--- server/models/voice_musiconhold.js | 65 +- server/models/voice_queue.js | 295 +----- server/models/voice_voicemail.js | 145 +--- server/models/voice_voicemail_messages.js | 68 +- server/models/zendesk_account.js | 34 +- server/models/zendesk_configuration.js | 32 +- server/models/zendesk_field.js | 27 +- server/routes.js | 144 +--- 523 files changed, 548 insertions(+), 38711 deletions(-) delete mode 100644 release-notes/changelog_0.0.18.txt create mode 100644 release-notes/changelog_0.0.19.txt diff --git a/package.json b/package.json index 497d188..381fdd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "motion", - "version": "0.0.19", + "version": "0.0.20", "main": "server/app.js", "dependencies": { "accept-language-parser": "^1.0.2", @@ -111,6 +111,7 @@ "grunt-version": "^1.0.0", "grunt-wiredep": "~2.0.0", "jit-grunt": "^0.9.1", + "js-obfuscator": "^0.1.1", "jshint-stylish": "~2.0.1", "karma": "~0.13.2", "karma-chrome-launcher": "~0.2.0", diff --git a/release-notes/changelog_0.0.18.txt b/release-notes/changelog_0.0.18.txt deleted file mode 100644 index 2be4f73..0000000 --- a/release-notes/changelog_0.0.18.txt +++ /dev/null @@ -1,27 +0,0 @@ -# xCALLY MOTION Changelog - -- * 96837d8 - 2016-01-11: Asterisk Configuration File -- * 9626622 - 2016-01-11: fixed back compatibility languages -- * 4143fce - 2016-01-11: Updated reports APIs. -- * 7d148f3 - 2016-01-11: bower.json -- * d7331e9 - 2016-01-11: server side .yo-rc.json -- * d375539 - 2016-01-11: server side app.js + routes.js -- * e70d044 - 2016-01-11: server side models -- * 5127ffe - 2016-01-11: server side config -- * b773540 - 2016-01-11: server side API -- * 00f85ce - 2016-01-11: client side components -- * 6c68dbd - 2016-01-11: client side assets -- * a42a9fa - 2016-01-11: client side app modules -- * 8025ad7 - 2016-01-11: client components sidebar templates path -- * d804d0a - 2016-01-11: languages update -- * cc4abc0 - 2016-01-11: package.son -- * 77404a1 - 2016-01-08: Updated ReportTree seed -- * c342b5f - 2016-01-08: Report section tree view -- * 2ea412c - 2016-01-08: add integration action for voice trigger -- * 5ce445c - 2016-01-08: change foreign key to handle AccountId column for each integration -- * 0974ad1 - 2016-01-08: add random percentage for "market" -- * 2f5d1bc - 2016-01-05: Market update (item disposition) -- * 41cb71c - 2016-01-05: Update integration: model, route Update market: fake market only with our integrations Add mocha as dev dependencies -- * fa560ae - 2016-01-05: add danger notification (xAlert) -- * ce14827 - 2016-01-04: Ui grid table with remote sorting, filtering and grouping for reports. - diff --git a/release-notes/changelog_0.0.19.txt b/release-notes/changelog_0.0.19.txt new file mode 100644 index 0000000..c95dcc5 --- /dev/null +++ b/release-notes/changelog_0.0.19.txt @@ -0,0 +1,26 @@ +# xCALLY MOTION Changelog + +- * 96837d8 - 2016-01-11: Asterisk Configuration File +- * 9626622 - 2016-01-11: fixed back compatibility languages +- * 4143fce - 2016-01-11: Updated reports APIs. +- * 7d148f3 - 2016-01-11: bower.json +- * d7331e9 - 2016-01-11: server side .yo-rc.json +- * d375539 - 2016-01-11: server side app.js + routes.js +- * e70d044 - 2016-01-11: server side models +- * 5127ffe - 2016-01-11: server side config +- * b773540 - 2016-01-11: server side API +- * 00f85ce - 2016-01-11: client side components +- * 6c68dbd - 2016-01-11: client side assets +- * a42a9fa - 2016-01-11: client side app modules +- * 8025ad7 - 2016-01-11: client components sidebar templates path +- * d804d0a - 2016-01-11: languages update +- * cc4abc0 - 2016-01-11: package.son +- * 77404a1 - 2016-01-08: Updated ReportTree seed +- * c342b5f - 2016-01-08: Report section tree view +- * 2ea412c - 2016-01-08: add integration action for voice trigger +- * 5ce445c - 2016-01-08: change foreign key to handle AccountId column for each integration +- * 0974ad1 - 2016-01-08: add random percentage for "market" +- * 2f5d1bc - 2016-01-05: Market update (item disposition) +- * 41cb71c - 2016-01-05: Update integration: model, route Update market: fake market only with our integrations Add mocha as dev dependencies +- * fa560ae - 2016-01-05: add danger notification (xAlert) + diff --git a/server/api/agent/agent.controller.js b/server/api/agent/agent.controller.js index a85f147..21b3367 100644 --- a/server/api/agent/agent.controller.js +++ b/server/api/agent/agent.controller.js @@ -1,279 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var Agent = require('../../models').User; -var Team = require('../../models').Team; - -// Get list of agents -exports.index = function(req, res, next) { - - var attributes = ['fullname', 'name', 'email']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: { - role: 'agent' - }, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Agent - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single agent -exports.show = function(req, res) { - Agent - .findById(req.params.id) - .then(function(agent) { - if (!agent) { - return res.sendStatus(404); - } - return res.send(agent); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Validate the existence of an internal number -exports.internalValidation = function(req, res) { - Agent - .findAll({ - where: { - internal: req.body.internal - } - }) - .then(function(internals) { - if (!internals) { - return res.sendStatus(404); - } - return res.send(internals); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new agent in the DB. -exports.create = function(req, res) { - Agent - .create(req.body) - .then(function(agent) { - Team - .findOne({ - where: { - defaultEntry: true - } - }) - .then(function(team) { - team - .addUser(agent.id) - .then(function() { - return res.status(201).send(agent); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); -}; - -// Updates an existing agent in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Agent - .findById(req.params.id) - .then(function(agent) { - if (!agent) { - return res.sendStatus(404); - } - var updated = _.merge(agent, req.body); - updated - .save() - .then(function() { - return res.status(200).send(agent); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.destroy = function(req, res) { - Agent - .findById(req.params.id) - .then(function(agent) { - if (!agent) { - return res.sendStatus(404); - } - agent.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function(req, res) { - Agent - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -/** - * Change an agent password - */ -exports.changePassword = function(req, res, next) { - console.log(req.body); - var agentId = req.user.id; - var oldPass = String(req.body.oldPassword); - var newPass = String(req.body.newPassword); - Agent - .findById(agentId) - .then(function(agent) { - if (agent.authenticate(oldPass)) { - agent.password = newPass; - agent.save() - .then(function() { - res.status(200).send(agent); - }) - .catch(function(err) { - return next(err); - }); - } else { - res.sendStatus(403); - } - }); -}; - -/** - * Change an agent password by admin - */ -exports.resetPassword = function(req, res, next) { - var newPass = String(req.body.newPassword); - Agent - .findById(req.params.id) - .then(function(user) { - user.password = newPass; - user.save() - .then(function() { - res.status(200).send(user); - }) - .catch(function(err) { - return handleError(res, err); - }); - }); -}; - -exports.agentValidation = function(req, res) { - var where = {}; - where[req.params.field] = req.body.value; - Agent - .findAndCountAll({ - where: where - }) - .then(function(result) { - if (result.count) { - return res.status(200).send({ - isValid: false, - value: req.body.value - }); - } - return res.status(200).send({ - isValid: true, - value: req.body.value - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x8a18=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x54\x65\x61\x6D","\x69\x6E\x64\x65\x78","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x61\x67\x65\x6E\x74","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x69\x6E\x74\x65\x72\x6E\x61\x6C\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x62\x6F\x64\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x6C\x6F\x67","\x61\x64\x64\x55\x73\x65\x72","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x63\x68\x61\x6E\x67\x65\x50\x61\x73\x73\x77\x6F\x72\x64","\x75\x73\x65\x72","\x6F\x6C\x64\x50\x61\x73\x73\x77\x6F\x72\x64","\x6E\x65\x77\x50\x61\x73\x73\x77\x6F\x72\x64","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x72\x65\x73\x65\x74\x50\x61\x73\x73\x77\x6F\x72\x64","\x61\x67\x65\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65"];_0x8a18[0];var _=require(_0x8a18[1]);var util=require(_0x8a18[2]);var Agent=require(_0x8a18[4])[_0x8a18[3]];var Team=require(_0x8a18[4])[_0x8a18[5]];exports[_0x8a18[6]]=function(_0x8e9cx5,_0x8e9cx6,_0x8e9cx7){var _0x8e9cx8=[_0x8a18[7],_0x8a18[8],_0x8a18[9]];var _0x8e9cx9=_0x8e9cx5[_0x8a18[11]][_0x8a18[10]]?parseInt(_0x8e9cx5[_0x8a18[11]][_0x8a18[10]],10):100;var _0x8e9cxa=_0x8e9cx5[_0x8a18[11]][_0x8a18[12]]?parseInt(_0x8e9cx5[_0x8a18[11]][_0x8a18[12]],10):0;var _0x8e9cxb={where:{role:_0x8a18[13]},limit:_0x8e9cx9,offset:_0x8e9cxa*_0x8e9cx9};_[_0x8a18[27]](_0x8e9cx5[_0x8a18[11]],function(_0x8e9cxc,_0x8e9cxd){switch(_0x8e9cxd){case _0x8a18[10]:;case _0x8a18[12]:break ;;case _0x8a18[16]:_0x8e9cxb[_0x8a18[14]]=util[_0x8a18[19]](_0x8a18[15],_0x8e9cx5[_0x8a18[11]][_0x8a18[16]],_0x8e9cx5[_0x8a18[11]][_0x8a18[17]]||_0x8a18[18])||null;break ;;case _0x8a18[17]:break ;;case _0x8a18[25]:_0x8e9cxb[_0x8a18[21]][_0x8a18[20]]=[];_0x8e9cx8[_0x8a18[24]](function(_0x8e9cxe){var _0x8e9cxf={};_0x8e9cxf[_0x8e9cxe]={$like:_0x8a18[22]+_0x8e9cxc+_0x8a18[22]};_0x8e9cxb[_0x8a18[21]][_0x8a18[20]][_0x8a18[23]](_0x8e9cxf);});break ;;default:_0x8e9cxb[_0x8a18[21]][_0x8e9cxd]={$like:{}};_0x8e9cxb[_0x8a18[21]][_0x8e9cxd][_0x8a18[26]]=_0x8a18[22]+_0x8e9cxc+_0x8a18[22];;}});Agent[_0x8a18[42]](_0x8e9cxb)[_0x8a18[41]](function(_0x8e9cx11){var _0x8e9cx12=Math[_0x8a18[33]](_0x8e9cx11[_0x8a18[32]]/_0x8e9cx9);var _0x8e9cx13=_0x8e9cx12>(_0x8e9cxb[_0x8a18[34]]+1)?util[_0x8a18[19]](_0x8a18[35],_0x8e9cx5[_0x8a18[36]],_0x8e9cx5[_0x8a18[38]][_0x8a18[37]],_0x8e9cx5[_0x8a18[39]],_0x8e9cxa+1):null;var _0x8e9cx14=_0x8e9cxa>0?util[_0x8a18[19]](_0x8a18[35],_0x8e9cx5[_0x8a18[36]],_0x8e9cx5[_0x8a18[38]][_0x8a18[37]],_0x8e9cx5[_0x8a18[39]],_0x8e9cxa-1):null;_0x8e9cx6[_0x8a18[30]](200)[_0x8a18[29]]({count:_0x8e9cx11[_0x8a18[32]],rows:_0x8e9cx11[_0x8a18[40]],next_page:_0x8e9cx13,previous_page:_0x8e9cx14,total_pages:_0x8e9cx12});})[_0x8a18[31]](function(_0x8e9cx10){_0x8e9cx6[_0x8a18[30]](500)[_0x8a18[29]]({error:_0x8a18[28]})});};exports[_0x8a18[43]]=function(_0x8e9cx5,_0x8e9cx6){Agent[_0x8a18[47]](_0x8e9cx5[_0x8a18[46]][_0x8a18[45]])[_0x8a18[41]](function(_0x8e9cx15){if(!_0x8e9cx15){return _0x8e9cx6[_0x8a18[44]](404)};return _0x8e9cx6[_0x8a18[29]](_0x8e9cx15);})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)})};exports[_0x8a18[48]]=function(_0x8e9cx5,_0x8e9cx6){Agent[_0x8a18[51]]({where:{internal:_0x8e9cx5[_0x8a18[50]][_0x8a18[49]]}})[_0x8a18[41]](function(_0x8e9cx16){if(!_0x8e9cx16){return _0x8e9cx6[_0x8a18[44]](404)};return _0x8e9cx6[_0x8a18[29]](_0x8e9cx16);})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)})};exports[_0x8a18[52]]=function(_0x8e9cx5,_0x8e9cx6){Agent[_0x8a18[52]](_0x8e9cx5[_0x8a18[50]])[_0x8a18[41]](function(_0x8e9cx15){Team[_0x8a18[55]]({where:{defaultEntry:true}})[_0x8a18[41]](function(_0x8e9cx17){_0x8e9cx17[_0x8a18[54]](_0x8e9cx15[_0x8a18[45]])[_0x8a18[41]](function(){return _0x8e9cx6[_0x8a18[30]](201)[_0x8a18[29]](_0x8e9cx15)})[_0x8a18[31]](function(_0x8e9cx10){console[_0x8a18[53]](_0x8e9cx10);return handleError(_0x8e9cx6,_0x8e9cx10);})})[_0x8a18[31]](function(_0x8e9cx10){console[_0x8a18[53]](_0x8e9cx10);return handleError(_0x8e9cx6,_0x8e9cx10);})})[_0x8a18[31]](function(_0x8e9cx10){console[_0x8a18[53]](_0x8e9cx10);return handleError(_0x8e9cx6,_0x8e9cx10);})};exports[_0x8a18[56]]=function(_0x8e9cx5,_0x8e9cx6){if(_0x8e9cx5[_0x8a18[50]][_0x8a18[45]]){delete _0x8e9cx5[_0x8a18[50]][_0x8a18[45]]};Agent[_0x8a18[47]](_0x8e9cx5[_0x8a18[46]][_0x8a18[45]])[_0x8a18[41]](function(_0x8e9cx15){if(!_0x8e9cx15){return _0x8e9cx6[_0x8a18[44]](404)};var _0x8e9cx18=_[_0x8a18[57]](_0x8e9cx15,_0x8e9cx5[_0x8a18[50]]);_0x8e9cx18[_0x8a18[58]]()[_0x8a18[41]](function(){return _0x8e9cx6[_0x8a18[30]](200)[_0x8a18[29]](_0x8e9cx15)})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)});})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)});};exports[_0x8a18[59]]=function(_0x8e9cx5,_0x8e9cx6){Agent[_0x8a18[47]](_0x8e9cx5[_0x8a18[46]][_0x8a18[45]])[_0x8a18[41]](function(_0x8e9cx15){if(!_0x8e9cx15){return _0x8e9cx6[_0x8a18[44]](404)};_0x8e9cx15[_0x8a18[59]]()[_0x8a18[41]](function(){return _0x8e9cx6[_0x8a18[44]](204)})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)});})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)})};exports[_0x8a18[60]]=function(_0x8e9cx5,_0x8e9cx6){Agent[_0x8a18[59]]({where:{id:_0x8e9cx5[_0x8a18[11]][_0x8a18[45]]},individualHooks:true})[_0x8a18[41]](function(){return _0x8e9cx6[_0x8a18[44]](204)})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)})};exports[_0x8a18[61]]=function(_0x8e9cx5,_0x8e9cx6,_0x8e9cx7){console[_0x8a18[53]](_0x8e9cx5[_0x8a18[50]]);var _0x8e9cx19=_0x8e9cx5[_0x8a18[62]][_0x8a18[45]];var _0x8e9cx1a=String(_0x8e9cx5[_0x8a18[50]][_0x8a18[63]]);var _0x8e9cx1b=String(_0x8e9cx5[_0x8a18[50]][_0x8a18[64]]);Agent[_0x8a18[47]](_0x8e9cx19)[_0x8a18[41]](function(_0x8e9cx15){if(_0x8e9cx15[_0x8a18[65]](_0x8e9cx1a)){_0x8e9cx15[_0x8a18[66]]=_0x8e9cx1b;_0x8e9cx15[_0x8a18[58]]()[_0x8a18[41]](function(){_0x8e9cx6[_0x8a18[30]](200)[_0x8a18[29]](_0x8e9cx15)})[_0x8a18[31]](function(_0x8e9cx10){return _0x8e9cx7(_0x8e9cx10)});}else {_0x8e9cx6[_0x8a18[44]](403)}});};exports[_0x8a18[67]]=function(_0x8e9cx5,_0x8e9cx6,_0x8e9cx7){var _0x8e9cx1b=String(_0x8e9cx5[_0x8a18[50]][_0x8a18[64]]);Agent[_0x8a18[47]](_0x8e9cx5[_0x8a18[46]][_0x8a18[45]])[_0x8a18[41]](function(_0x8e9cx1c){_0x8e9cx1c[_0x8a18[66]]=_0x8e9cx1b;_0x8e9cx1c[_0x8a18[58]]()[_0x8a18[41]](function(){_0x8e9cx6[_0x8a18[30]](200)[_0x8a18[29]](_0x8e9cx1c)})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)});});};exports[_0x8a18[68]]=function(_0x8e9cx5,_0x8e9cx6){var _0x8e9cx1d={};_0x8e9cx1d[_0x8e9cx5[_0x8a18[46]][_0x8a18[69]]]=_0x8e9cx5[_0x8a18[50]][_0x8a18[70]];Agent[_0x8a18[42]]({where:_0x8e9cx1d})[_0x8a18[41]](function(_0x8e9cx11){if(_0x8e9cx11[_0x8a18[32]]){return _0x8e9cx6[_0x8a18[30]](200)[_0x8a18[29]]({isValid:false,value:_0x8e9cx5[_0x8a18[50]][_0x8a18[70]]})};return _0x8e9cx6[_0x8a18[30]](200)[_0x8a18[29]]({isValid:true,value:_0x8e9cx5[_0x8a18[50]][_0x8a18[70]]});})[_0x8a18[31]](function(_0x8e9cx10){return handleError(_0x8e9cx6,_0x8e9cx10)});};function handleError(_0x8e9cx6,_0x8e9cx10){return _0x8e9cx6[_0x8a18[30]](500)[_0x8a18[29]](_0x8e9cx10)} \ No newline at end of file diff --git a/server/api/agent/agent.socket.js b/server/api/agent/agent.socket.js index 5535cb7..4cc1c99 100644 --- a/server/api/agent/agent.socket.js +++ b/server/api/agent/agent.socket.js @@ -1,33 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var agent = require('../../models').User; - -exports.register = function(socket) { - agent.afterCreate(function(doc) { - if (doc.role === 'agent') { - onSave(socket, doc); - } - }); - agent.afterUpdate(function(doc) { - if (doc.role === 'agent') { - onSave(socket, doc); - } - }); - agent.afterDestroy(function(doc) { - if (doc.role === 'agent') { - onRemove(socket, doc); - } - }); -} - -function onSave(socket, doc, cb) { - socket.emit('agent:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('agent:remove', doc); -} +var _0x9af2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x72\x6F\x6C\x65","\x61\x67\x65\x6E\x74","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x67\x65\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x61\x67\x65\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x9af2[0];var agent=require(_0x9af2[2])[_0x9af2[1]];exports[_0x9af2[3]]=function(_0x5600x2){agent[_0x9af2[6]](function(_0x5600x3){if(_0x5600x3[_0x9af2[4]]===_0x9af2[5]){onSave(_0x5600x2,_0x5600x3)}});agent[_0x9af2[7]](function(_0x5600x3){if(_0x5600x3[_0x9af2[4]]===_0x9af2[5]){onSave(_0x5600x2,_0x5600x3)}});agent[_0x9af2[8]](function(_0x5600x3){if(_0x5600x3[_0x9af2[4]]===_0x9af2[5]){onRemove(_0x5600x2,_0x5600x3)}});};function onSave(_0x5600x2,_0x5600x3,_0x5600x5){_0x5600x2[_0x9af2[10]](_0x9af2[9],_0x5600x3)}function onRemove(_0x5600x2,_0x5600x3,_0x5600x5){_0x5600x2[_0x9af2[10]](_0x9af2[11],_0x5600x3)} \ No newline at end of file diff --git a/server/api/agent/agent.spec.js b/server/api/agent/agent.spec.js index e6c4651..52fb972 100644 --- a/server/api/agent/agent.spec.js +++ b/server/api/agent/agent.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/agents', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/agents') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x8028=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x61\x67\x65\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x61\x67\x65\x6E\x74\x73","\x67\x65\x74"];_0x8028[0];var should=require(_0x8028[1]);var app=require(_0x8028[2]);var request=require(_0x8028[3]);describe(_0x8028[4],function(){it(_0x8028[5],function(_0xab5ex4){request(app)[_0x8028[13]](_0x8028[12])[_0x8028[11]](200)[_0x8028[11]](_0x8028[10],/json/)[_0x8028[9]](function(_0xab5ex5,_0xab5ex6){if(_0xab5ex5){return _0xab5ex4(_0xab5ex5)};_0xab5ex6[_0x8028[8]][_0x8028[1]][_0x8028[7]][_0x8028[6]](Array);_0xab5ex4();})})}); \ No newline at end of file diff --git a/server/api/agent/index.js b/server/api/agent/index.js index f2a2a93..0210262 100644 --- a/server/api/agent/index.js +++ b/server/api/agent/index.js @@ -1,21 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./agent.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/validate/:field', auth.isAuthenticated(), controller.agentValidation); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.internalValidation); -router.put('/password', auth.isAuthenticated(), controller.changePassword); -router.put('/password/:id/reset', auth.isAuthenticated(), auth.hasRole('admin'), controller.resetPassword); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0xe742=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x61\x67\x65\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65\x2F\x3A\x66\x69\x65\x6C\x64","\x61\x67\x65\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x63\x72\x65\x61\x74\x65","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x69\x6E\x74\x65\x72\x6E\x61\x6C\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x2F\x70\x61\x73\x73\x77\x6F\x72\x64","\x63\x68\x61\x6E\x67\x65\x50\x61\x73\x73\x77\x6F\x72\x64","\x70\x75\x74","\x2F\x70\x61\x73\x73\x77\x6F\x72\x64\x2F\x3A\x69\x64\x2F\x72\x65\x73\x65\x74","\x61\x64\x6D\x69\x6E","\x68\x61\x73\x52\x6F\x6C\x65","\x72\x65\x73\x65\x74\x50\x61\x73\x73\x77\x6F\x72\x64","\x75\x70\x64\x61\x74\x65","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xe742[0];var express=require(_0xe742[1]);var controller=require(_0xe742[2]);var auth=require(_0xe742[3]);var router=express.Router();router[_0xe742[7]](_0xe742[4],auth[_0xe742[5]](),controller[_0xe742[6]]);router[_0xe742[7]](_0xe742[8],auth[_0xe742[5]](),controller[_0xe742[9]]);router[_0xe742[12]](_0xe742[10],auth[_0xe742[5]](),controller[_0xe742[11]]);router[_0xe742[12]](_0xe742[4],auth[_0xe742[5]](),controller[_0xe742[13]]);router[_0xe742[12]](_0xe742[14],auth[_0xe742[5]](),controller[_0xe742[15]]);router[_0xe742[18]](_0xe742[16],auth[_0xe742[5]](),controller[_0xe742[17]]);router[_0xe742[18]](_0xe742[19],auth[_0xe742[5]](),auth[_0xe742[21]](_0xe742[20]),controller[_0xe742[22]]);router[_0xe742[18]](_0xe742[8],auth[_0xe742[5]](),controller[_0xe742[23]]);router[_0xe742[24]](_0xe742[8],auth[_0xe742[5]](),controller[_0xe742[23]]);router[_0xe742[26]](_0xe742[4],auth[_0xe742[5]](),controller[_0xe742[25]]);router[_0xe742[26]](_0xe742[8],auth[_0xe742[5]](),controller[_0xe742[27]]);module[_0xe742[28]]=router; \ No newline at end of file diff --git a/server/api/ami/ami.ami.js b/server/api/ami/ami.ami.js index 2684197..344bfaa 100644 --- a/server/api/ami/ami.ami.js +++ b/server/api/ami/ami.ami.js @@ -1,37 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Ami = require('../../models').Ami; -var async = require('async'); -var _ = require('lodash'); - -var ami = null; - -exports.register = function(ami) { - this.ami = ami; -} - -exports.action = function(action, cb) { - if (this.ami && this.ami.isConnected()) { - this.ami.action(action, function(err, res) { - if (err) { - cb(err); - } - var data = _.merge(res, action); - Ami - .create(data) - .then(function(ami) { - cb(null, ami) - }) - .catch(function(err) { - return cb(err); - }); - - }); - } else { - cb(new Error('Asterisk Manager disconnected..')); - } -} +var _0xd08a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x41\x6D\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x61\x73\x79\x6E\x63","\x6C\x6F\x64\x61\x73\x68","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x6D\x69","\x61\x63\x74\x69\x6F\x6E","\x69\x73\x43\x6F\x6E\x6E\x65\x63\x74\x65\x64","\x6D\x65\x72\x67\x65","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x63\x72\x65\x61\x74\x65","\x41\x73\x74\x65\x72\x69\x73\x6B\x20\x4D\x61\x6E\x61\x67\x65\x72\x20\x64\x69\x73\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x2E\x2E"];_0xd08a[0];var Ami=require(_0xd08a[2])[_0xd08a[1]];var async=require(_0xd08a[3]);var _=require(_0xd08a[4]);var ami=null;exports[_0xd08a[5]]=function(ami){this[_0xd08a[6]]=ami};exports[_0xd08a[7]]=function(_0x8a3dx5,_0x8a3dx6){if(this[_0xd08a[6]]&&this[_0xd08a[6]][_0xd08a[8]]()){this[_0xd08a[6]][_0xd08a[7]](_0x8a3dx5,function(_0x8a3dx7,_0x8a3dx8){if(_0x8a3dx7){_0x8a3dx6(_0x8a3dx7)};var _0x8a3dx9=_[_0xd08a[9]](_0x8a3dx8,_0x8a3dx5);Ami[_0xd08a[12]](_0x8a3dx9)[_0xd08a[11]](function(ami){_0x8a3dx6(null,ami)})[_0xd08a[10]](function(_0x8a3dx7){return _0x8a3dx6(_0x8a3dx7)});})}else {_0x8a3dx6( new Error(_0xd08a[13]))}}; \ No newline at end of file diff --git a/server/api/ami/ami.controller.js b/server/api/ami/ami.controller.js index dc409ab..cb6f135 100644 --- a/server/api/ami/ami.controller.js +++ b/server/api/ami/ami.controller.js @@ -1,101 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Ami = require('../../models').Ami; - -// Get list of amis -exports.index = function(req, res) { - Ami - .findAll() - .then(function(amis) { - return res.status(200).send(amis); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single ami -exports.show = function(req, res) { - Ami - .findById(req.params.id) - .then(function(ami) { - if (!ami) { - return res.sendStatus(404); - } - return res.send(ami); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new ami in the DB. -exports.create = function(req, res) { - - req.body.data = JSON.stringify(req.body); - req.body.UserId = req.user.id; - - require('./ami.ami').action(req.body, function(err, result) { - if (err) { - handleError(res, err); - } else { - return res.status(201).send(result); - } - }); - -}; - -// Updates an existing ami in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Ami - .findById(req.params.id) - .then(function(ami) { - if (!ami) { - return res.sendStatus(404); - } - var updated = _.merge(ami, req.body); - updated.save() - .then(function() { - return res.status(200).send(ami); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a ami from the DB. -exports.destroy = function(req, res) { - Ami - .find({ - where: { - id: req.params.id - } - }) - .then(function(ami) { - if (!ami) { - return res.sendStatus(404); - } - ami.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x8d58=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x41\x6D\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x64\x61\x74\x61","\x62\x6F\x64\x79","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x55\x73\x65\x72\x49\x64","\x75\x73\x65\x72","\x61\x63\x74\x69\x6F\x6E","\x2E\x2F\x61\x6D\x69\x2E\x61\x6D\x69","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64"];_0x8d58[0];var _=require(_0x8d58[1]);var Ami=require(_0x8d58[3])[_0x8d58[2]];exports[_0x8d58[4]]=function(_0x2536x3,_0x2536x4){Ami[_0x8d58[9]]()[_0x8d58[8]](function(_0x2536x6){return _0x2536x4[_0x8d58[7]](200)[_0x8d58[6]](_0x2536x6)})[_0x8d58[5]](function(_0x2536x5){return handleError(_0x2536x4,_0x2536x5)})};exports[_0x8d58[10]]=function(_0x2536x3,_0x2536x4){Ami[_0x8d58[14]](_0x2536x3[_0x8d58[13]][_0x8d58[12]])[_0x8d58[8]](function(_0x2536x7){if(!_0x2536x7){return _0x2536x4[_0x8d58[11]](404)};return _0x2536x4[_0x8d58[6]](_0x2536x7);})[_0x8d58[5]](function(_0x2536x5){return handleError(_0x2536x4,_0x2536x5)})};exports[_0x8d58[15]]=function(_0x2536x3,_0x2536x4){_0x2536x3[_0x8d58[17]][_0x8d58[16]]=JSON[_0x8d58[18]](_0x2536x3[_0x8d58[17]]);_0x2536x3[_0x8d58[17]][_0x8d58[19]]=_0x2536x3[_0x8d58[20]][_0x8d58[12]];require(_0x8d58[22])[_0x8d58[21]](_0x2536x3[_0x8d58[17]],function(_0x2536x5,_0x2536x8){if(_0x2536x5){handleError(_0x2536x4,_0x2536x5)}else {return _0x2536x4[_0x8d58[7]](201)[_0x8d58[6]](_0x2536x8)}});};exports[_0x8d58[23]]=function(_0x2536x3,_0x2536x4){if(_0x2536x3[_0x8d58[17]][_0x8d58[12]]){delete _0x2536x3[_0x8d58[17]][_0x8d58[12]]};Ami[_0x8d58[14]](_0x2536x3[_0x8d58[13]][_0x8d58[12]])[_0x8d58[8]](function(_0x2536x7){if(!_0x2536x7){return _0x2536x4[_0x8d58[11]](404)};var _0x2536x9=_[_0x8d58[24]](_0x2536x7,_0x2536x3[_0x8d58[17]]);_0x2536x9[_0x8d58[25]]()[_0x8d58[8]](function(){return _0x2536x4[_0x8d58[7]](200)[_0x8d58[6]](_0x2536x7)})[_0x8d58[5]](function(_0x2536x5){return handleError(_0x2536x4,_0x2536x5)});})[_0x8d58[5]](function(_0x2536x5){return handleError(_0x2536x4,_0x2536x5)});};exports[_0x8d58[26]]=function(_0x2536x3,_0x2536x4){Ami[_0x8d58[27]]({where:{id:_0x2536x3[_0x8d58[13]][_0x8d58[12]]}})[_0x8d58[8]](function(_0x2536x7){if(!_0x2536x7){return _0x2536x4[_0x8d58[11]](404)};_0x2536x7[_0x8d58[26]]()[_0x8d58[8]](function(){return _0x2536x4[_0x8d58[11]](204)})[_0x8d58[5]](function(_0x2536x5){return handleError(_0x2536x4,_0x2536x5)});})[_0x8d58[5]](function(_0x2536x5){return handleError(_0x2536x4,_0x2536x5)})};function handleError(_0x2536x4,_0x2536x5){return _0x2536x4[_0x8d58[7]](500)[_0x8d58[6]](_0x2536x5)} \ No newline at end of file diff --git a/server/api/ami/ami.socket.js b/server/api/ami/ami.socket.js index 6047274..f0d79f2 100644 --- a/server/api/ami/ami.socket.js +++ b/server/api/ami/ami.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Ami = require('../../models').Ami; - -exports.register = function(socket) { - Ami.afterCreate(function (doc) { - onSave(socket, doc); - }); - Ami.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('ami:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('ami:remove', doc); -} +var _0x3f1e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x41\x6D\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x6D\x69\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x61\x6D\x69\x3A\x72\x65\x6D\x6F\x76\x65"];_0x3f1e[0];var Ami=require(_0x3f1e[2])[_0x3f1e[1]];exports[_0x3f1e[3]]=function(_0x322ax2){Ami[_0x3f1e[4]](function(_0x322ax3){onSave(_0x322ax2,_0x322ax3)});Ami[_0x3f1e[5]](function(_0x322ax3){onRemove(_0x322ax2,_0x322ax3)});};function onSave(_0x322ax2,_0x322ax3,_0x322ax5){_0x322ax2[_0x3f1e[7]](_0x3f1e[6],_0x322ax3)}function onRemove(_0x322ax2,_0x322ax3,_0x322ax5){_0x322ax2[_0x3f1e[7]](_0x3f1e[8],_0x322ax3)} \ No newline at end of file diff --git a/server/api/ami/ami.spec.js b/server/api/ami/ami.spec.js index a7502d7..3be4e4e 100644 --- a/server/api/ami/ami.spec.js +++ b/server/api/ami/ami.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/ami', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/ami') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x1504=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x61\x6D\x69","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x61\x6D\x69","\x67\x65\x74"];_0x1504[0];var should=require(_0x1504[1]);var app=require(_0x1504[2]);var request=require(_0x1504[3]);describe(_0x1504[4],function(){it(_0x1504[5],function(_0x2d49x4){request(app)[_0x1504[13]](_0x1504[12])[_0x1504[11]](200)[_0x1504[11]](_0x1504[10],/json/)[_0x1504[9]](function(_0x2d49x5,_0x2d49x6){if(_0x2d49x5){return _0x2d49x4(_0x2d49x5)};_0x2d49x6[_0x1504[8]][_0x1504[1]][_0x1504[7]][_0x1504[6]](Array);_0x2d49x4();})})}); \ No newline at end of file diff --git a/server/api/ami/index.js b/server/api/ami/index.js index b926b75..636474e 100644 --- a/server/api/ami/index.js +++ b/server/api/ami/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./ami.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -// router.get('/:id', controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -// router.put('/:id', controller.update); -// router.patch('/:id', controller.update); -// router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xc11c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x61\x6D\x69\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x65\x78\x70\x6F\x72\x74\x73"];_0xc11c[0];var express=require(_0xc11c[1]);var controller=require(_0xc11c[2]);var auth=require(_0xc11c[3]);var router=express.Router();router[_0xc11c[7]](_0xc11c[4],auth[_0xc11c[5]](),controller[_0xc11c[6]]);router[_0xc11c[9]](_0xc11c[4],auth[_0xc11c[5]](),controller[_0xc11c[8]]);module[_0xc11c[10]]=router; \ No newline at end of file diff --git a/server/api/automation/automation.controller.js b/server/api/automation/automation.controller.js index dc50214..a3315fc 100644 --- a/server/api/automation/automation.controller.js +++ b/server/api/automation/automation.controller.js @@ -1,168 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var Automation = require('../../models').Automation; - -// Get list of agents -exports.index = function(req, res, next) { - - var attributes = ['fullname', 'name', 'email']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Automation - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single Automation -exports.show = function(req, res) { - Automation - .findById(req.params.id) - .then(function(Automation) { - if (!Automation) { - return res.sendStatus(404); - } - return res.send(Automation); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new Automation in the DB. -exports.create = function(req, res, next) { - Automation - .create(req.body) - .then(function() { - return res.sendStatus(201); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing Automation in the DB. -exports.update = function(req, res, next) { - if (req.body.id) { - delete req.body.id; - } - Automation - .findById(req.params.id) - .then(function(Automation) { - if (!Automation) { - return res.sendStatus(404); - } - var updated = _.merge(Automation, req.body); - updated - .save() - .then(function() { - return res.status(200).send(Automation); - }) - .catch(function(err) { - // return handleError(res, err); - return next(err); - - }); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Deletes a Automation from the DB. -exports.destroy = function(req, res) { - Automation - .findById(req.params.id) - .then(function(Automation) { - if (!Automation) { - return res.sendStatus(404); - } - Automation.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -} - -exports.bulkDestroy = function(req, res) { - Automation - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x986f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x986f[0];var _=require(_0x986f[1]);var util=require(_0x986f[2]);var Automation=require(_0x986f[4])[_0x986f[3]];exports[_0x986f[5]]=function(_0xebd4x4,_0xebd4x5,_0xebd4x6){var _0xebd4x7=[_0x986f[6],_0x986f[7],_0x986f[8]];var _0xebd4x8=_0xebd4x4[_0x986f[10]][_0x986f[9]]?parseInt(_0xebd4x4[_0x986f[10]][_0x986f[9]],10):100;var _0xebd4x9=_0xebd4x4[_0x986f[10]][_0x986f[11]]?parseInt(_0xebd4x4[_0x986f[10]][_0x986f[11]],10):0;var _0xebd4xa={where:{},limit:_0xebd4x8,offset:_0xebd4x9*_0xebd4x8};_[_0x986f[25]](_0xebd4x4[_0x986f[10]],function(_0xebd4xb,_0xebd4xc){switch(_0xebd4xc){case _0x986f[9]:;case _0x986f[11]:break ;;case _0x986f[14]:_0xebd4xa[_0x986f[12]]=util[_0x986f[17]](_0x986f[13],_0xebd4x4[_0x986f[10]][_0x986f[14]],_0xebd4x4[_0x986f[10]][_0x986f[15]]||_0x986f[16])||null;break ;;case _0x986f[15]:break ;;case _0x986f[23]:_0xebd4xa[_0x986f[19]][_0x986f[18]]=[];_0xebd4x7[_0x986f[22]](function(_0xebd4xd){var _0xebd4xe={};_0xebd4xe[_0xebd4xd]={$like:_0x986f[20]+_0xebd4xb+_0x986f[20]};_0xebd4xa[_0x986f[19]][_0x986f[18]][_0x986f[21]](_0xebd4xe);});break ;;default:_0xebd4xa[_0x986f[19]][_0xebd4xc]={$like:{}};_0xebd4xa[_0x986f[19]][_0xebd4xc][_0x986f[24]]=_0x986f[20]+_0xebd4xb+_0x986f[20];;}});Automation[_0x986f[40]](_0xebd4xa)[_0x986f[39]](function(_0xebd4x10){var _0xebd4x11=Math[_0x986f[31]](_0xebd4x10[_0x986f[30]]/_0xebd4x8);var _0xebd4x12=_0xebd4x11>(_0xebd4xa[_0x986f[32]]+1)?util[_0x986f[17]](_0x986f[33],_0xebd4x4[_0x986f[34]],_0xebd4x4[_0x986f[36]][_0x986f[35]],_0xebd4x4[_0x986f[37]],_0xebd4x9+1):null;var _0xebd4x13=_0xebd4x9>0?util[_0x986f[17]](_0x986f[33],_0xebd4x4[_0x986f[34]],_0xebd4x4[_0x986f[36]][_0x986f[35]],_0xebd4x4[_0x986f[37]],_0xebd4x9-1):null;_0xebd4x5[_0x986f[28]](200)[_0x986f[27]]({count:_0xebd4x10[_0x986f[30]],rows:_0xebd4x10[_0x986f[38]],next_page:_0xebd4x12,previous_page:_0xebd4x13,total_pages:_0xebd4x11});})[_0x986f[29]](function(_0xebd4xf){_0xebd4x5[_0x986f[28]](500)[_0x986f[27]]({error:_0x986f[26]})});};exports[_0x986f[41]]=function(_0xebd4x4,_0xebd4x5){Automation[_0x986f[45]](_0xebd4x4[_0x986f[44]][_0x986f[43]])[_0x986f[39]](function(Automation){if(!Automation){return _0xebd4x5[_0x986f[42]](404)};return _0xebd4x5[_0x986f[27]](Automation);})[_0x986f[29]](function(_0xebd4xf){return handleError(_0xebd4x5,_0xebd4xf)})};exports[_0x986f[46]]=function(_0xebd4x4,_0xebd4x5,_0xebd4x6){Automation[_0x986f[46]](_0xebd4x4[_0x986f[47]])[_0x986f[39]](function(){return _0xebd4x5[_0x986f[42]](201)})[_0x986f[29]](function(_0xebd4xf){return handleError(_0xebd4x5,_0xebd4xf)})};exports[_0x986f[48]]=function(_0xebd4x4,_0xebd4x5,_0xebd4x6){if(_0xebd4x4[_0x986f[47]][_0x986f[43]]){delete _0xebd4x4[_0x986f[47]][_0x986f[43]]};Automation[_0x986f[45]](_0xebd4x4[_0x986f[44]][_0x986f[43]])[_0x986f[39]](function(Automation){if(!Automation){return _0xebd4x5[_0x986f[42]](404)};var _0xebd4x14=_[_0x986f[49]](Automation,_0xebd4x4[_0x986f[47]]);_0xebd4x14[_0x986f[50]]()[_0x986f[39]](function(){return _0xebd4x5[_0x986f[28]](200)[_0x986f[27]](Automation)})[_0x986f[29]](function(_0xebd4xf){return _0xebd4x6(_0xebd4xf)});})[_0x986f[29]](function(_0xebd4xf){return _0xebd4x6(_0xebd4xf)});};exports[_0x986f[51]]=function(_0xebd4x4,_0xebd4x5){Automation[_0x986f[45]](_0xebd4x4[_0x986f[44]][_0x986f[43]])[_0x986f[39]](function(Automation){if(!Automation){return _0xebd4x5[_0x986f[42]](404)};Automation[_0x986f[51]]()[_0x986f[39]](function(){return _0xebd4x5[_0x986f[42]](204)})[_0x986f[29]](function(_0xebd4xf){return handleError(_0xebd4x5,_0xebd4xf)});})[_0x986f[29]](function(_0xebd4xf){return handleError(_0xebd4x5,_0xebd4xf)})};exports[_0x986f[52]]=function(_0xebd4x4,_0xebd4x5){Automation[_0x986f[51]]({where:{id:_0xebd4x4[_0x986f[10]][_0x986f[43]]},individualHooks:true})[_0x986f[39]](function(){return _0xebd4x5[_0x986f[42]](204)})[_0x986f[29]](function(_0xebd4xf){return handleError(_0xebd4x5,_0xebd4xf)})};function handleError(_0xebd4x5,_0xebd4xf){return _0xebd4x5[_0x986f[28]](500)[_0x986f[27]](_0xebd4xf)} \ No newline at end of file diff --git a/server/api/automation/automation.socket.js b/server/api/automation/automation.socket.js index 2c55b60..b27b737 100644 --- a/server/api/automation/automation.socket.js +++ b/server/api/automation/automation.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Automation = require('../../models').Automation; - -exports.register = function(socket) { - Automation.afterCreate(function(doc) { - onSave(socket, doc); - }); - Automation.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('automation:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('automation:remove', doc); -} +var _0x59fa=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x59fa[0];var Automation=require(_0x59fa[2])[_0x59fa[1]];exports[_0x59fa[3]]=function(_0x3db3x2){Automation[_0x59fa[4]](function(_0x3db3x3){onSave(_0x3db3x2,_0x3db3x3)});Automation[_0x59fa[5]](function(_0x3db3x3){onRemove(_0x3db3x2,_0x3db3x3)});};function onSave(_0x3db3x2,_0x3db3x3,_0x3db3x5){_0x3db3x2[_0x59fa[7]](_0x59fa[6],_0x3db3x3)}function onRemove(_0x3db3x2,_0x3db3x3,_0x3db3x5){_0x3db3x2[_0x59fa[7]](_0x59fa[8],_0x3db3x3)} \ No newline at end of file diff --git a/server/api/automation/automation.spec.js b/server/api/automation/automation.spec.js index ab8c5b4..de6ef55 100644 --- a/server/api/automation/automation.spec.js +++ b/server/api/automation/automation.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/automations', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/automations') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x3eca=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0x3eca[0];var should=require(_0x3eca[1]);var app=require(_0x3eca[2]);var request=require(_0x3eca[3]);describe(_0x3eca[4],function(){it(_0x3eca[5],function(_0xd31ax4){request(app)[_0x3eca[13]](_0x3eca[12])[_0x3eca[11]](200)[_0x3eca[11]](_0x3eca[10],/json/)[_0x3eca[9]](function(_0xd31ax5,_0xd31ax6){if(_0xd31ax5){return _0xd31ax4(_0xd31ax5)};_0xd31ax6[_0x3eca[8]][_0x3eca[1]][_0x3eca[7]][_0x3eca[6]](Array);_0xd31ax4();})})}); \ No newline at end of file diff --git a/server/api/automation/index.js b/server/api/automation/index.js index 98acf5a..9179c75 100644 --- a/server/api/automation/index.js +++ b/server/api/automation/index.js @@ -1,17 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./automation.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); - -module.exports = router; +var _0x4d4a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x4d4a[0];var express=require(_0x4d4a[1]);var controller=require(_0x4d4a[2]);var auth=require(_0x4d4a[3]);var router=express.Router();router[_0x4d4a[7]](_0x4d4a[4],auth[_0x4d4a[5]](),controller[_0x4d4a[6]]);router[_0x4d4a[7]](_0x4d4a[8],auth[_0x4d4a[5]](),controller[_0x4d4a[9]]);router[_0x4d4a[11]](_0x4d4a[4],auth[_0x4d4a[5]](),controller[_0x4d4a[10]]);router[_0x4d4a[13]](_0x4d4a[8],auth[_0x4d4a[5]](),controller[_0x4d4a[12]]);router[_0x4d4a[14]](_0x4d4a[8],auth[_0x4d4a[5]](),controller[_0x4d4a[12]]);router[_0x4d4a[16]](_0x4d4a[8],auth[_0x4d4a[5]](),controller[_0x4d4a[15]]);router[_0x4d4a[16]](_0x4d4a[4],auth[_0x4d4a[5]](),controller[_0x4d4a[17]]);module[_0x4d4a[18]]=router; \ No newline at end of file diff --git a/server/api/business_action/business_action.controller.js b/server/api/business_action/business_action.controller.js index 53338c4..fcc6f67 100644 --- a/server/api/business_action/business_action.controller.js +++ b/server/api/business_action/business_action.controller.js @@ -1,94 +1 @@ -'use strict'; - -var _ = require('lodash'); -var BusinessAction = require('../../models').BusinessAction; - -// Get list of business_actions -exports.index = function(req, res) { - BusinessAction - .findAll() - .then(function(business_actions) { - return res.status(200).send(business_actions); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single businessAction -exports.show = function(req, res) { - BusinessAction - .findById(req.params.id) - .then(function(businessAction) { - if (!businessAction) { - return res.sendStatus(404); - } - return res.send(businessAction); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new businessAction in the DB. -exports.create = function(req, res) { - BusinessAction - .create(req.body) - .then(function(businessAction) { - return res.status(201).send(businessAction); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing businessAction in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - BusinessAction - .findById(req.params.id) - .then(function(businessAction) { - if (!businessAction) { - return res.sendStatus(404); - } - var updated = _.merge(businessAction, req.body); - updated.save() - .then(function() { - return res.status(200).send(businessAction); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a businessAction from the DB. -exports.destroy = function(req, res) { - BusinessAction - .findById(req.params.id) - .then(function(businessAction) { - if (!businessAction) { - return res.sendStatus(404); - } - businessAction - .destroy() - .then(function() { - return res.status(200).send(businessAction); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x90e2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x63\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x90e2[0];var _=require(_0x90e2[1]);var BusinessAction=require(_0x90e2[3])[_0x90e2[2]];exports[_0x90e2[4]]=function(_0x556fx3,_0x556fx4){BusinessAction[_0x90e2[9]]()[_0x90e2[8]](function(_0x556fx6){return _0x556fx4[_0x90e2[7]](200)[_0x90e2[6]](_0x556fx6)})[_0x90e2[5]](function(_0x556fx5){return handleError(_0x556fx4,_0x556fx5)})};exports[_0x90e2[10]]=function(_0x556fx3,_0x556fx4){BusinessAction[_0x90e2[14]](_0x556fx3[_0x90e2[13]][_0x90e2[12]])[_0x90e2[8]](function(_0x556fx7){if(!_0x556fx7){return _0x556fx4[_0x90e2[11]](404)};return _0x556fx4[_0x90e2[6]](_0x556fx7);})[_0x90e2[5]](function(_0x556fx5){return handleError(_0x556fx4,_0x556fx5)})};exports[_0x90e2[15]]=function(_0x556fx3,_0x556fx4){BusinessAction[_0x90e2[15]](_0x556fx3[_0x90e2[16]])[_0x90e2[8]](function(_0x556fx7){return _0x556fx4[_0x90e2[7]](201)[_0x90e2[6]](_0x556fx7)})[_0x90e2[5]](function(_0x556fx5){return handleError(_0x556fx4,_0x556fx5)})};exports[_0x90e2[17]]=function(_0x556fx3,_0x556fx4){if(_0x556fx3[_0x90e2[16]][_0x90e2[12]]){delete _0x556fx3[_0x90e2[16]][_0x90e2[12]]};BusinessAction[_0x90e2[14]](_0x556fx3[_0x90e2[13]][_0x90e2[12]])[_0x90e2[8]](function(_0x556fx7){if(!_0x556fx7){return _0x556fx4[_0x90e2[11]](404)};var _0x556fx8=_[_0x90e2[18]](_0x556fx7,_0x556fx3[_0x90e2[16]]);_0x556fx8[_0x90e2[19]]()[_0x90e2[8]](function(){return _0x556fx4[_0x90e2[7]](200)[_0x90e2[6]](_0x556fx7)})[_0x90e2[5]](function(_0x556fx5){return handleError(_0x556fx4,_0x556fx5)});})[_0x90e2[5]](function(_0x556fx5){return handleError(_0x556fx4,_0x556fx5)});};exports[_0x90e2[20]]=function(_0x556fx3,_0x556fx4){BusinessAction[_0x90e2[14]](_0x556fx3[_0x90e2[13]][_0x90e2[12]])[_0x90e2[8]](function(_0x556fx7){if(!_0x556fx7){return _0x556fx4[_0x90e2[11]](404)};_0x556fx7[_0x90e2[20]]()[_0x90e2[8]](function(){return _0x556fx4[_0x90e2[7]](200)[_0x90e2[6]](_0x556fx7)})[_0x90e2[5]](function(_0x556fx5){return handleError(_0x556fx4,_0x556fx5)});})[_0x90e2[5]](function(_0x556fx5){return handleError(_0x556fx4,_0x556fx5)})};function handleError(_0x556fx4,_0x556fx5){return _0x556fx4[_0x90e2[7]](500)[_0x90e2[6]](_0x556fx5)} \ No newline at end of file diff --git a/server/api/business_action/business_action.socket.js b/server/api/business_action/business_action.socket.js index 3fecc0c..cf16d67 100644 --- a/server/api/business_action/business_action.socket.js +++ b/server/api/business_action/business_action.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var BusinessAction = require('../../models').BusinessAction; - -exports.register = function(socket) { - BusinessAction.afterCreate(function (doc) { - onSave(socket, doc); - }); - BusinessAction.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('business_action:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('business_action:remove', doc); -} +var _0x1c01=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x63\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x63\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x63\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x1c01[0];var BusinessAction=require(_0x1c01[2])[_0x1c01[1]];exports[_0x1c01[3]]=function(_0x4043x2){BusinessAction[_0x1c01[4]](function(_0x4043x3){onSave(_0x4043x2,_0x4043x3)});BusinessAction[_0x1c01[5]](function(_0x4043x3){onRemove(_0x4043x2,_0x4043x3)});};function onSave(_0x4043x2,_0x4043x3,_0x4043x5){_0x4043x2[_0x1c01[7]](_0x1c01[6],_0x4043x3)}function onRemove(_0x4043x2,_0x4043x3,_0x4043x5){_0x4043x2[_0x1c01[7]](_0x1c01[8],_0x4043x3)} \ No newline at end of file diff --git a/server/api/business_action/business_action.spec.js b/server/api/business_action/business_action.spec.js index 4b677be..7862254 100644 --- a/server/api/business_action/business_action.spec.js +++ b/server/api/business_action/business_action.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/business/actions', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/business/actions') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xb157=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x63\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x63\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0xb157[0];var should=require(_0xb157[1]);var app=require(_0xb157[2]);var request=require(_0xb157[3]);describe(_0xb157[4],function(){it(_0xb157[5],function(_0x9038x4){request(app)[_0xb157[13]](_0xb157[12])[_0xb157[11]](200)[_0xb157[11]](_0xb157[10],/json/)[_0xb157[9]](function(_0x9038x5,_0x9038x6){if(_0x9038x5){return _0x9038x4(_0x9038x5)};_0x9038x6[_0xb157[8]][_0xb157[1]][_0xb157[7]][_0xb157[6]](Array);_0x9038x4();})})}); \ No newline at end of file diff --git a/server/api/business_action/index.js b/server/api/business_action/index.js index 3545d75..96596ca 100644 --- a/server/api/business_action/index.js +++ b/server/api/business_action/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./business_action.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xce45=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x63\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xce45[0];var express=require(_0xce45[1]);var controller=require(_0xce45[2]);var router=express.Router();router[_0xce45[5]](_0xce45[3],controller[_0xce45[4]]);router[_0xce45[5]](_0xce45[6],controller[_0xce45[7]]);router[_0xce45[9]](_0xce45[3],controller[_0xce45[8]]);router[_0xce45[11]](_0xce45[6],controller[_0xce45[10]]);router[_0xce45[12]](_0xce45[6],controller[_0xce45[10]]);router[_0xce45[14]](_0xce45[6],controller[_0xce45[13]]);module[_0xce45[15]]=router; \ No newline at end of file diff --git a/server/api/business_condition/business_condition.controller.js b/server/api/business_condition/business_condition.controller.js index d480f8e..8a1ada0 100644 --- a/server/api/business_condition/business_condition.controller.js +++ b/server/api/business_condition/business_condition.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var BusinessCondition = require('../../models').BusinessCondition; - -// Get list of business_conditions -exports.index = function(req, res) { - BusinessCondition - .findAll() - .then(function (business_conditions) { - return res.status(200).send(business_conditions); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single business_condition -exports.show = function(req, res) { - BusinessCondition - .findById(req.params.id) - .then(function (business_condition) { - if(!business_condition) { return res.sendStatus(404); } - return res.send(business_condition); - }) - .catch(function(err){ - return handleError(res, err); - }); -}; - -// Creates a new business_condition in the DB. -exports.create = function(req, res) { - BusinessCondition - .create(req.body) - .then(function(business_condition) { - return res.status(201).send(business_condition); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing business_condition in the DB. -exports.update = function(req, res) { - if(req.body.id) { delete req.body.id; } - BusinessCondition - .find({ - where: { - id: req.params.id - } - }) - .then(function (business_condition) { - if(!business_condition) { return res.sendStatus(404); } - var updated = _.merge(business_condition, req.body); - updated.save() - .then(function () { - return res.status(200).send(business_condition); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a business_condition from the DB. -exports.destroy = function(req, res) { - BusinessCondition - .find({ - where: { - id: req.params.id - } - }) - .then(function (business_condition) { - if(!business_condition) { return res.sendStatus(404); } - business_condition.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x7e73=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x7e73[0];var _=require(_0x7e73[1]);var BusinessCondition=require(_0x7e73[3])[_0x7e73[2]];exports[_0x7e73[4]]=function(_0xb36ax3,_0xb36ax4){BusinessCondition[_0x7e73[9]]()[_0x7e73[8]](function(_0xb36ax6){return _0xb36ax4[_0x7e73[7]](200)[_0x7e73[6]](_0xb36ax6)})[_0x7e73[5]](function(_0xb36ax5){return handleError(_0xb36ax4,_0xb36ax5)})};exports[_0x7e73[10]]=function(_0xb36ax3,_0xb36ax4){BusinessCondition[_0x7e73[14]](_0xb36ax3[_0x7e73[13]][_0x7e73[12]])[_0x7e73[8]](function(_0xb36ax7){if(!_0xb36ax7){return _0xb36ax4[_0x7e73[11]](404)};return _0xb36ax4[_0x7e73[6]](_0xb36ax7);})[_0x7e73[5]](function(_0xb36ax5){return handleError(_0xb36ax4,_0xb36ax5)})};exports[_0x7e73[15]]=function(_0xb36ax3,_0xb36ax4){BusinessCondition[_0x7e73[15]](_0xb36ax3[_0x7e73[16]])[_0x7e73[8]](function(_0xb36ax7){return _0xb36ax4[_0x7e73[7]](201)[_0x7e73[6]](_0xb36ax7)})[_0x7e73[5]](function(_0xb36ax5){return handleError(_0xb36ax4,_0xb36ax5)})};exports[_0x7e73[17]]=function(_0xb36ax3,_0xb36ax4){if(_0xb36ax3[_0x7e73[16]][_0x7e73[12]]){delete _0xb36ax3[_0x7e73[16]][_0x7e73[12]]};BusinessCondition[_0x7e73[20]]({where:{id:_0xb36ax3[_0x7e73[13]][_0x7e73[12]]}})[_0x7e73[8]](function(_0xb36ax7){if(!_0xb36ax7){return _0xb36ax4[_0x7e73[11]](404)};var _0xb36ax8=_[_0x7e73[18]](_0xb36ax7,_0xb36ax3[_0x7e73[16]]);_0xb36ax8[_0x7e73[19]]()[_0x7e73[8]](function(){return _0xb36ax4[_0x7e73[7]](200)[_0x7e73[6]](_0xb36ax7)})[_0x7e73[5]](function(_0xb36ax5){return handleError(_0xb36ax4,_0xb36ax5)});})[_0x7e73[5]](function(_0xb36ax5){return handleError(_0xb36ax4,_0xb36ax5)});};exports[_0x7e73[21]]=function(_0xb36ax3,_0xb36ax4){BusinessCondition[_0x7e73[20]]({where:{id:_0xb36ax3[_0x7e73[13]][_0x7e73[12]]}})[_0x7e73[8]](function(_0xb36ax7){if(!_0xb36ax7){return _0xb36ax4[_0x7e73[11]](404)};_0xb36ax7[_0x7e73[21]]()[_0x7e73[8]](function(){return _0xb36ax4[_0x7e73[11]](204)})[_0x7e73[5]](function(_0xb36ax5){return handleError(_0xb36ax4,_0xb36ax5)});})[_0x7e73[5]](function(_0xb36ax5){return handleError(_0xb36ax4,_0xb36ax5)})};function handleError(_0xb36ax4,_0xb36ax5){return _0xb36ax4[_0x7e73[7]](500)[_0x7e73[6]](_0xb36ax5)} \ No newline at end of file diff --git a/server/api/business_condition/business_condition.socket.js b/server/api/business_condition/business_condition.socket.js index c904ed1..d9f53a0 100644 --- a/server/api/business_condition/business_condition.socket.js +++ b/server/api/business_condition/business_condition.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var BusinessCondition = require('../../models').BusinessCondition; - -exports.register = function(socket) { - BusinessCondition.afterCreate(function (doc) { - onSave(socket, doc); - }); - BusinessCondition.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('business_condition:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('business_condition:remove', doc); -} +var _0xb7f2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xb7f2[0];var BusinessCondition=require(_0xb7f2[2])[_0xb7f2[1]];exports[_0xb7f2[3]]=function(_0xf647x2){BusinessCondition[_0xb7f2[4]](function(_0xf647x3){onSave(_0xf647x2,_0xf647x3)});BusinessCondition[_0xb7f2[5]](function(_0xf647x3){onRemove(_0xf647x2,_0xf647x3)});};function onSave(_0xf647x2,_0xf647x3,_0xf647x5){_0xf647x2[_0xb7f2[7]](_0xb7f2[6],_0xf647x3)}function onRemove(_0xf647x2,_0xf647x3,_0xf647x5){_0xf647x2[_0xb7f2[7]](_0xb7f2[8],_0xf647x3)} \ No newline at end of file diff --git a/server/api/business_condition/business_condition.spec.js b/server/api/business_condition/business_condition.spec.js index 76ad269..4777bce 100644 --- a/server/api/business_condition/business_condition.spec.js +++ b/server/api/business_condition/business_condition.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/business/conditions', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/business/conditions') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x1d04=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0x1d04[0];var should=require(_0x1d04[1]);var app=require(_0x1d04[2]);var request=require(_0x1d04[3]);describe(_0x1d04[4],function(){it(_0x1d04[5],function(_0x5960x4){request(app)[_0x1d04[13]](_0x1d04[12])[_0x1d04[11]](200)[_0x1d04[11]](_0x1d04[10],/json/)[_0x1d04[9]](function(_0x5960x5,_0x5960x6){if(_0x5960x5){return _0x5960x4(_0x5960x5)};_0x5960x6[_0x1d04[8]][_0x1d04[1]][_0x1d04[7]][_0x1d04[6]](Array);_0x5960x4();})})}); \ No newline at end of file diff --git a/server/api/business_condition/index.js b/server/api/business_condition/index.js index 71a1e3f..262d540 100644 --- a/server/api/business_condition/index.js +++ b/server/api/business_condition/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./business_condition.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xf25b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xf25b[0];var express=require(_0xf25b[1]);var controller=require(_0xf25b[2]);var router=express.Router();router[_0xf25b[5]](_0xf25b[3],controller[_0xf25b[4]]);router[_0xf25b[5]](_0xf25b[6],controller[_0xf25b[7]]);router[_0xf25b[9]](_0xf25b[3],controller[_0xf25b[8]]);router[_0xf25b[11]](_0xf25b[6],controller[_0xf25b[10]]);router[_0xf25b[12]](_0xf25b[6],controller[_0xf25b[10]]);router[_0xf25b[14]](_0xf25b[6],controller[_0xf25b[13]]);module[_0xf25b[15]]=router; \ No newline at end of file diff --git a/server/api/chat_application/chat_application.controller.js b/server/api/chat_application/chat_application.controller.js index 9c2085d..4950dda 100644 --- a/server/api/chat_application/chat_application.controller.js +++ b/server/api/chat_application/chat_application.controller.js @@ -1,105 +1 @@ -'use strict'; -var _ = require('lodash'); -var ChatApplication = require('../../models').ChatApplication; -// Get list of chat_applications -exports.index = function(req, res) { - ChatApplication - .findAll({ - where: req.query, - order: 'priority', - include: [{ - all: true - }] - }) - .then(function(chat_applications) { - return res.status(200).send(chat_applications); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Get a single chat_application -exports.show = function(req, res) { - ChatApplication - .findById(req.params.id) - .then(function(chat_application) { - if (!chat_application) { - return res.sendStatus(404); - } - return res.send(chat_application); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Creates a new chat_application in the DB. -exports.create = function(req, res, next) { - ChatApplication.max('priority', { - where: { - ChatWebsiteId: req.body.ChatWebsiteId - } - }).then(function(max) { - // SET PRIORITY - req.body.priority = max ? ++max : 1; - ChatApplication - .create(req.body) - .then(function(mailApplication) { - return res.status(201).send(mailApplication); - }) - .catch(function(err) { - return next(err); - }); - }).catch(function(err) { - next(err); - }); -}; -// Updates an existing chat_application in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ChatApplication - .findById(req.params.id) - .then(function(chat_application) { - if (!chat_application) { - return res.sendStatus(404); - } - var updated = _.merge(chat_application, req.body); - updated - .save() - .then(function() { - return res.status(200).send(chat_application); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Deletes a chat_application from the DB. -exports.destroy = function(req, res) { - ChatApplication - .findById(req.params.id) - .then(function(chat_application) { - if (!chat_application) { - return res.sendStatus(404); - } - chat_application - .destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x61e8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x70\x72\x69\x6F\x72\x69\x74\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x49\x64","\x6D\x61\x78","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x61e8[0];var _=require(_0x61e8[1]);var ChatApplication=require(_0x61e8[3])[_0x61e8[2]];exports[_0x61e8[4]]=function(_0x79b2x3,_0x79b2x4){ChatApplication[_0x61e8[11]]({where:_0x79b2x3[_0x61e8[9]],order:_0x61e8[10],include:[{all:true}]})[_0x61e8[8]](function(_0x79b2x6){return _0x79b2x4[_0x61e8[7]](200)[_0x61e8[6]](_0x79b2x6)})[_0x61e8[5]](function(_0x79b2x5){return handleError(_0x79b2x4,_0x79b2x5)})};exports[_0x61e8[12]]=function(_0x79b2x3,_0x79b2x4){ChatApplication[_0x61e8[16]](_0x79b2x3[_0x61e8[15]][_0x61e8[14]])[_0x61e8[8]](function(_0x79b2x7){if(!_0x79b2x7){return _0x79b2x4[_0x61e8[13]](404)};return _0x79b2x4[_0x61e8[6]](_0x79b2x7);})[_0x61e8[5]](function(_0x79b2x5){return handleError(_0x79b2x4,_0x79b2x5)})};exports[_0x61e8[17]]=function(_0x79b2x3,_0x79b2x4,_0x79b2x8){ChatApplication[_0x61e8[20]](_0x61e8[10],{where:{ChatWebsiteId:_0x79b2x3[_0x61e8[18]][_0x61e8[19]]}})[_0x61e8[8]](function(_0x79b2x9){_0x79b2x3[_0x61e8[18]][_0x61e8[10]]=_0x79b2x9?++_0x79b2x9:1;ChatApplication[_0x61e8[17]](_0x79b2x3[_0x61e8[18]])[_0x61e8[8]](function(_0x79b2xa){return _0x79b2x4[_0x61e8[7]](201)[_0x61e8[6]](_0x79b2xa)})[_0x61e8[5]](function(_0x79b2x5){return _0x79b2x8(_0x79b2x5)});})[_0x61e8[5]](function(_0x79b2x5){_0x79b2x8(_0x79b2x5)})};exports[_0x61e8[21]]=function(_0x79b2x3,_0x79b2x4){if(_0x79b2x3[_0x61e8[18]][_0x61e8[14]]){delete _0x79b2x3[_0x61e8[18]][_0x61e8[14]]};ChatApplication[_0x61e8[16]](_0x79b2x3[_0x61e8[15]][_0x61e8[14]])[_0x61e8[8]](function(_0x79b2x7){if(!_0x79b2x7){return _0x79b2x4[_0x61e8[13]](404)};var _0x79b2xb=_[_0x61e8[22]](_0x79b2x7,_0x79b2x3[_0x61e8[18]]);_0x79b2xb[_0x61e8[23]]()[_0x61e8[8]](function(){return _0x79b2x4[_0x61e8[7]](200)[_0x61e8[6]](_0x79b2x7)})[_0x61e8[5]](function(_0x79b2x5){return handleError(_0x79b2x4,_0x79b2x5)});})[_0x61e8[5]](function(_0x79b2x5){return handleError(_0x79b2x4,_0x79b2x5)});};exports[_0x61e8[24]]=function(_0x79b2x3,_0x79b2x4){ChatApplication[_0x61e8[16]](_0x79b2x3[_0x61e8[15]][_0x61e8[14]])[_0x61e8[8]](function(_0x79b2x7){if(!_0x79b2x7){return _0x79b2x4[_0x61e8[13]](404)};_0x79b2x7[_0x61e8[24]]()[_0x61e8[8]](function(){return _0x79b2x4[_0x61e8[13]](204)})[_0x61e8[5]](function(_0x79b2x5){return handleError(_0x79b2x4,_0x79b2x5)});})[_0x61e8[5]](function(_0x79b2x5){return handleError(_0x79b2x4,_0x79b2x5)})};function handleError(_0x79b2x4,_0x79b2x5){return _0x79b2x4[_0x61e8[7]](500)[_0x61e8[6]](_0x79b2x5)} \ No newline at end of file diff --git a/server/api/chat_application/chat_application.socket.js b/server/api/chat_application/chat_application.socket.js index 8776f3a..3b74ac7 100644 --- a/server/api/chat_application/chat_application.socket.js +++ b/server/api/chat_application/chat_application.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ChatApplication = require('../../models').ChatApplication; - -exports.register = function(socket) { - ChatApplication.afterCreate(function (doc) { - onSave(socket, doc); - }); - ChatApplication.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('chat_application:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('chat_application:remove', doc); -} +var _0xf041=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x68\x61\x74\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x68\x61\x74\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xf041[0];var ChatApplication=require(_0xf041[2])[_0xf041[1]];exports[_0xf041[3]]=function(_0xb200x2){ChatApplication[_0xf041[4]](function(_0xb200x3){onSave(_0xb200x2,_0xb200x3)});ChatApplication[_0xf041[5]](function(_0xb200x3){onRemove(_0xb200x2,_0xb200x3)});};function onSave(_0xb200x2,_0xb200x3,_0xb200x5){_0xb200x2[_0xf041[7]](_0xf041[6],_0xb200x3)}function onRemove(_0xb200x2,_0xb200x3,_0xb200x5){_0xb200x2[_0xf041[7]](_0xf041[8],_0xb200x3)} \ No newline at end of file diff --git a/server/api/chat_application/chat_application.spec.js b/server/api/chat_application/chat_application.spec.js index 215f533..dcb3245 100644 --- a/server/api/chat_application/chat_application.spec.js +++ b/server/api/chat_application/chat_application.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/applications', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/applications') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xe0de=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0xe0de[0];var should=require(_0xe0de[1]);var app=require(_0xe0de[2]);var request=require(_0xe0de[3]);describe(_0xe0de[4],function(){it(_0xe0de[5],function(_0x55d3x4){request(app)[_0xe0de[13]](_0xe0de[12])[_0xe0de[11]](200)[_0xe0de[11]](_0xe0de[10],/json/)[_0xe0de[9]](function(_0x55d3x5,_0x55d3x6){if(_0x55d3x5){return _0x55d3x4(_0x55d3x5)};_0x55d3x6[_0xe0de[8]][_0xe0de[1]][_0xe0de[7]][_0xe0de[6]](Array);_0x55d3x4();})})}); \ No newline at end of file diff --git a/server/api/chat_application/index.js b/server/api/chat_application/index.js index d85a510..f6af931 100644 --- a/server/api/chat_application/index.js +++ b/server/api/chat_application/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./chat_application.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xe027=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x68\x61\x74\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xe027[0];var express=require(_0xe027[1]);var controller=require(_0xe027[2]);var router=express.Router();router[_0xe027[5]](_0xe027[3],controller[_0xe027[4]]);router[_0xe027[5]](_0xe027[6],controller[_0xe027[7]]);router[_0xe027[9]](_0xe027[3],controller[_0xe027[8]]);router[_0xe027[11]](_0xe027[6],controller[_0xe027[10]]);router[_0xe027[12]](_0xe027[6],controller[_0xe027[10]]);router[_0xe027[14]](_0xe027[6],controller[_0xe027[13]]);module[_0xe027[15]]=router; \ No newline at end of file diff --git a/server/api/chat_enquiry/enquiry.controller.js b/server/api/chat_enquiry/enquiry.controller.js index 17edcbc..8a4fabd 100644 --- a/server/api/chat_enquiry/enquiry.controller.js +++ b/server/api/chat_enquiry/enquiry.controller.js @@ -1,99 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ChatEnquiry = require('../../models').ChatEnquiry; -var ChatVisitor = require('../../models').ChatVisitor; - -// Get list of enquirys -exports.index = function(req, res) { - ChatEnquiry - .findAll() - .then(function(enquirys) { - return res.status(200).send(enquirys); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single enquiry -exports.show = function(req, res) { - ChatEnquiry - .findOne({ - where: { - id: req.params.id - }, - include: [ChatVisitor] - }) - .then(function(enquiry) { - if (!enquiry) { - return res.sendStatus(404); - } - return res.send(enquiry); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new enquiry in the DB. -exports.create = function(req, res) { - ChatEnquiry - .create(req.body) - .then(function(enquiry) { - return res.status(201).send(enquiry); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing enquiry in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ChatEnquiry - .findById(req.params.id) - .then(function(enquiry) { - if (!enquiry) { - return res.sendStatus(404); - } - var updated = _.merge(enquiry, req.body); - updated.save() - .then(function() { - return res.status(200).send(enquiry); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a enquiry from the DB. -exports.destroy = function(req, res) { - ChatEnquiry - .findById(req.params.id) - .then(function(enquiry) { - if (!enquiry) { - return res.sendStatus(404); - } - enquiry.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x6932=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x68\x61\x74\x45\x6E\x71\x75\x69\x72\x79","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x4F\x6E\x65","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x6932[0];var _=require(_0x6932[1]);var ChatEnquiry=require(_0x6932[3])[_0x6932[2]];var ChatVisitor=require(_0x6932[3])[_0x6932[4]];exports[_0x6932[5]]=function(_0x6dccx4,_0x6dccx5){ChatEnquiry[_0x6932[10]]()[_0x6932[9]](function(_0x6dccx7){return _0x6dccx5[_0x6932[8]](200)[_0x6932[7]](_0x6dccx7)})[_0x6932[6]](function(_0x6dccx6){return handleError(_0x6dccx5,_0x6dccx6)})};exports[_0x6932[11]]=function(_0x6dccx4,_0x6dccx5){ChatEnquiry[_0x6932[15]]({where:{id:_0x6dccx4[_0x6932[14]][_0x6932[13]]},include:[ChatVisitor]})[_0x6932[9]](function(_0x6dccx8){if(!_0x6dccx8){return _0x6dccx5[_0x6932[12]](404)};return _0x6dccx5[_0x6932[7]](_0x6dccx8);})[_0x6932[6]](function(_0x6dccx6){return handleError(_0x6dccx5,_0x6dccx6)})};exports[_0x6932[16]]=function(_0x6dccx4,_0x6dccx5){ChatEnquiry[_0x6932[16]](_0x6dccx4[_0x6932[17]])[_0x6932[9]](function(_0x6dccx8){return _0x6dccx5[_0x6932[8]](201)[_0x6932[7]](_0x6dccx8)})[_0x6932[6]](function(_0x6dccx6){return handleError(_0x6dccx5,_0x6dccx6)})};exports[_0x6932[18]]=function(_0x6dccx4,_0x6dccx5){if(_0x6dccx4[_0x6932[17]][_0x6932[13]]){delete _0x6dccx4[_0x6932[17]][_0x6932[13]]};ChatEnquiry[_0x6932[21]](_0x6dccx4[_0x6932[14]][_0x6932[13]])[_0x6932[9]](function(_0x6dccx8){if(!_0x6dccx8){return _0x6dccx5[_0x6932[12]](404)};var _0x6dccx9=_[_0x6932[19]](_0x6dccx8,_0x6dccx4[_0x6932[17]]);_0x6dccx9[_0x6932[20]]()[_0x6932[9]](function(){return _0x6dccx5[_0x6932[8]](200)[_0x6932[7]](_0x6dccx8)})[_0x6932[6]](function(_0x6dccx6){return handleError(_0x6dccx5,_0x6dccx6)});})[_0x6932[6]](function(_0x6dccx6){return handleError(_0x6dccx5,_0x6dccx6)});};exports[_0x6932[22]]=function(_0x6dccx4,_0x6dccx5){ChatEnquiry[_0x6932[21]](_0x6dccx4[_0x6932[14]][_0x6932[13]])[_0x6932[9]](function(_0x6dccx8){if(!_0x6dccx8){return _0x6dccx5[_0x6932[12]](404)};_0x6dccx8[_0x6932[22]]()[_0x6932[9]](function(){return _0x6dccx5[_0x6932[12]](204)})[_0x6932[6]](function(_0x6dccx6){return handleError(_0x6dccx5,_0x6dccx6)});})[_0x6932[6]](function(_0x6dccx6){return handleError(_0x6dccx5,_0x6dccx6)})};function handleError(_0x6dccx5,_0x6dccx6){return _0x6dccx5[_0x6932[8]](500)[_0x6932[7]](_0x6dccx6)} \ No newline at end of file diff --git a/server/api/chat_enquiry/enquiry.socket.js b/server/api/chat_enquiry/enquiry.socket.js index b7b69e1..da30681 100644 --- a/server/api/chat_enquiry/enquiry.socket.js +++ b/server/api/chat_enquiry/enquiry.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var enquiry = require('../../models').ChatEnquiry; - -exports.register = function(socket) { - enquiry.afterCreate(function (doc) { - onSave(socket, doc); - }); - enquiry.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('enquiry:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('enquiry:remove', doc); -} +var _0xe946=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x68\x61\x74\x45\x6E\x71\x75\x69\x72\x79","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x65\x6E\x71\x75\x69\x72\x79\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x65\x6E\x71\x75\x69\x72\x79\x3A\x72\x65\x6D\x6F\x76\x65"];_0xe946[0];var enquiry=require(_0xe946[2])[_0xe946[1]];exports[_0xe946[3]]=function(_0x2ac0x2){enquiry[_0xe946[4]](function(_0x2ac0x3){onSave(_0x2ac0x2,_0x2ac0x3)});enquiry[_0xe946[5]](function(_0x2ac0x3){onRemove(_0x2ac0x2,_0x2ac0x3)});};function onSave(_0x2ac0x2,_0x2ac0x3,_0x2ac0x5){_0x2ac0x2[_0xe946[7]](_0xe946[6],_0x2ac0x3)}function onRemove(_0x2ac0x2,_0x2ac0x3,_0x2ac0x5){_0x2ac0x2[_0xe946[7]](_0xe946[8],_0x2ac0x3)} \ No newline at end of file diff --git a/server/api/chat_enquiry/index.js b/server/api/chat_enquiry/index.js index 547b695..f0383d4 100644 --- a/server/api/chat_enquiry/index.js +++ b/server/api/chat_enquiry/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./enquiry.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x7114=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x65\x6E\x71\x75\x69\x72\x79\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x7114[0];var express=require(_0x7114[1]);var controller=require(_0x7114[2]);var router=express.Router();router[_0x7114[5]](_0x7114[3],controller[_0x7114[4]]);router[_0x7114[5]](_0x7114[6],controller[_0x7114[7]]);router[_0x7114[9]](_0x7114[3],controller[_0x7114[8]]);router[_0x7114[11]](_0x7114[6],controller[_0x7114[10]]);router[_0x7114[12]](_0x7114[6],controller[_0x7114[10]]);router[_0x7114[14]](_0x7114[6],controller[_0x7114[13]]);module[_0x7114[15]]=router; \ No newline at end of file diff --git a/server/api/chat_message/chat_message.controller.js b/server/api/chat_message/chat_message.controller.js index 958ca19..fa657c4 100644 --- a/server/api/chat_message/chat_message.controller.js +++ b/server/api/chat_message/chat_message.controller.js @@ -1,267 +1 @@ -'use strict'; - -var _ = require('lodash'); -var md5 = require('md5'); - -var User = require('../../models').User; -var ChatRoom = require('../../models').ChatRoom; -var ChatMessage = require('../../models').ChatMessage; -var ChatVisitor = require('../../models').ChatVisitor; - -// Get list of chat_messages -exports.index = function (req, res) { - ChatMessage - .findAll() - .then(function (chat_messages) { - return res.status(200).send(chat_messages); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single chatMessage -exports.show = function (req, res) { - ChatMessage - .findById(req.params.id) - .then(function (chatMessage) { - if (!chatMessage) { - return res.sendStatus(404); - } - return res.send(chatMessage); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new chatMessage in the DB. -exports.create = function (req, res, next) { - // if (req.body.ChatRoomId && req.body.to) { - // return handleError(res, new Error('Select ChatRoomId or to')); - // } else if (req.body.to) { - // - // switch (req.body.type) { - // case 'internal': - // User - // .findOne({ - // where: { - // $or: [{ - // id: { - // $like: req.body.to - // } - // }, { - // name: req.body.to - // }] - // } - // }) - // .then(function(user) { - // if (user) { - // - // var users = _.sortBy([user, req.user], 'id'); - // var participants = { - // users: { - // ids: [users[0].id, users[1].id] - // }, - // visitors: { - // ids: [] - // } - // }; - // - // var token = md5(JSON.stringify(participants)).toString( - // 'base64'); - // - // participants.users.fullnames = [users[0].fullname, users[1].fullname]; - // participants.visitors.fullnames = []; - // - // ChatRoom - // .findOrCreate({ - // where: { - // token: token - // }, - // defaults: { - // type: req.body.type, - // token: token, - // participants: JSON.stringify(participants) - // } - // }) - // .spread(function(chatRoom, created) { - // - // chatRoom - // .updateAttributes({ - // participants: JSON.stringify(participants) - // }); - // - // ChatMessage - // .create({ - // body: req.body.body, - // fullname: req.user.fullname, - // email: req.user.email, - // ChatRoomId: chatRoom.id, - // userId: req.user.id - // }) - // .then(function(chatMessage) { - // return res.status(201).send(chatMessage); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // }); - // - // } else { - // return handleError(res, new Error('User not found')); - // } - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // - // break; - // case 'external': - // ChatVisitor - // .findOne({ - // where: { - // $or: [{ - // id: { - // $like: req.body.to - // } - // }, { - // fullname: req.body.to - // }] - // } - // }) - // .then(function(chatVisitor) { - // if (chatVisitor) { - // - // var participants = { - // users: { - // ids: [req.user.id] - // }, - // visitors: { - // ids: [chatVisitor.id] - // } - // }; - // - // var token = md5(JSON.stringify(participants)).toString( - // 'base64'); - // - // participants.users.fullnames = [req.user.fullname]; - // participants.visitors.fullnames = [chatVisitor.fullname]; - // - // ChatRoom - // .findOrCreate({ - // where: { - // token: token - // }, - // defaults: { - // type: req.body.type, - // token: token, - // participants: JSON.stringify(participants) - // } - // }) - // .spread(function(chatRoom, created) { - // - // chatRoom - // .updateAttributes({ - // participants: JSON.stringify(participants) - // }); - // - // ChatMessage - // .create({ - // body: req.body.body, - // fullname: req.user.fullname, - // email: req.user.email, - // ChatRoomId: chatRoom.id, - // userId: req.user.id - // }) - // .then(function(chatMessage) { - // return res.status(201).send(chatMessage); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // }); - // } - // }); - // break; - // default: - // return handleError(res, new Error('Room type unsupported')); - // } - // - // - // } else if (req.body.ChatRoomId) { - // - // ChatMessage - // .create(_.merge({ - // userId: req.user.id, - // email: req.user.email, - // fullname: req.user.fullname - // }, req.body)) - // .then(function(chatMessage) { - // return res.status(201).send(chatMessage); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // } else { - // return handleError(res, new Error('Select ChatRoomId or to')); - // } - ChatMessage - .create(_.merge(req.body, { - UserId: req.user.id - })) - .then(function (chatMessage) { - return res.status(201).send(chatMessage); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing chatMessage in the DB. -exports.update = function (req, res) { - if (req.body.id) { - delete req.body.id; - } - - return ChatMessage - .findById(req.params.id) - .then(function (chatMessage) { - if (!chatMessage) { - return res.sendStatus(404); - } - var updated = _.merge(chatMessage, req.body); - return updated.save(); - }) - .then(function (chatMessage) { - return res.status(200).send(chatMessage); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a chatMessage from the DB. -exports.destroy = function (req, res) { - ChatMessage - .findById(req.params.id) - .then(function (chatMessage) { - if (!chatMessage) { - return res.sendStatus(404); - } - chatMessage.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xc33c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x64\x35","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x73\x65\x72","\x6D\x65\x72\x67\x65","\x75\x70\x64\x61\x74\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xc33c[0];var _=require(_0xc33c[1]);var md5=require(_0xc33c[2]);var User=require(_0xc33c[4])[_0xc33c[3]];var ChatRoom=require(_0xc33c[4])[_0xc33c[5]];var ChatMessage=require(_0xc33c[4])[_0xc33c[6]];var ChatVisitor=require(_0xc33c[4])[_0xc33c[7]];exports[_0xc33c[8]]=function(_0x831cx7,_0x831cx8){ChatMessage[_0xc33c[13]]()[_0xc33c[12]](function(_0x831cxa){return _0x831cx8[_0xc33c[11]](200)[_0xc33c[10]](_0x831cxa)})[_0xc33c[9]](function(_0x831cx9){return handleError(_0x831cx8,_0x831cx9)})};exports[_0xc33c[14]]=function(_0x831cx7,_0x831cx8){ChatMessage[_0xc33c[18]](_0x831cx7[_0xc33c[17]][_0xc33c[16]])[_0xc33c[12]](function(_0x831cxb){if(!_0x831cxb){return _0x831cx8[_0xc33c[15]](404)};return _0x831cx8[_0xc33c[10]](_0x831cxb);})[_0xc33c[9]](function(_0x831cx9){return handleError(_0x831cx8,_0x831cx9)})};exports[_0xc33c[19]]=function(_0x831cx7,_0x831cx8,_0x831cxc){ChatMessage[_0xc33c[19]](_[_0xc33c[22]](_0x831cx7[_0xc33c[20]],{UserId:_0x831cx7[_0xc33c[21]][_0xc33c[16]]}))[_0xc33c[12]](function(_0x831cxb){return _0x831cx8[_0xc33c[11]](201)[_0xc33c[10]](_0x831cxb)})[_0xc33c[9]](function(_0x831cx9){return handleError(_0x831cx8,_0x831cx9)})};exports[_0xc33c[23]]=function(_0x831cx7,_0x831cx8){if(_0x831cx7[_0xc33c[20]][_0xc33c[16]]){delete _0x831cx7[_0xc33c[20]][_0xc33c[16]]};return ChatMessage[_0xc33c[18]](_0x831cx7[_0xc33c[17]][_0xc33c[16]])[_0xc33c[12]](function(_0x831cxb){if(!_0x831cxb){return _0x831cx8[_0xc33c[15]](404)};var _0x831cxd=_[_0xc33c[22]](_0x831cxb,_0x831cx7[_0xc33c[20]]);return _0x831cxd[_0xc33c[24]]();})[_0xc33c[12]](function(_0x831cxb){return _0x831cx8[_0xc33c[11]](200)[_0xc33c[10]](_0x831cxb)})[_0xc33c[9]](function(_0x831cx9){return handleError(_0x831cx8,_0x831cx9)});};exports[_0xc33c[25]]=function(_0x831cx7,_0x831cx8){ChatMessage[_0xc33c[18]](_0x831cx7[_0xc33c[17]][_0xc33c[16]])[_0xc33c[12]](function(_0x831cxb){if(!_0x831cxb){return _0x831cx8[_0xc33c[15]](404)};_0x831cxb[_0xc33c[25]]()[_0xc33c[12]](function(){return _0x831cx8[_0xc33c[15]](204)})[_0xc33c[9]](function(_0x831cx9){return handleError(_0x831cx8,_0x831cx9)});})[_0xc33c[9]](function(_0x831cx9){return handleError(_0x831cx8,_0x831cx9)})};function handleError(_0x831cx8,_0x831cx9){return _0x831cx8[_0xc33c[11]](500)[_0xc33c[10]](_0x831cx9)} \ No newline at end of file diff --git a/server/api/chat_message/chat_message.socket.js b/server/api/chat_message/chat_message.socket.js index dccab23..ea231f4 100644 --- a/server/api/chat_message/chat_message.socket.js +++ b/server/api/chat_message/chat_message.socket.js @@ -1,59 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var chat_message = require('../../models').ChatMessage; -var _ = require('lodash'); - -exports.register = function (socket) { - chat_message.afterCreate(function (doc) { - onSave(socket, doc); - }); - chat_message.afterUpdate(function (doc) { - onSave(socket, doc); - }); - chat_message.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - return doc - .getChatRoom() - .then(function (chatRoom) { - return [chatRoom - .getUsers({ - attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal'], - raw: true - }), chatRoom - .getChatVisitor({ - attributes: ['id', 'fullname', 'email'], - raw: true - }) - ]; - }) - .spread(function (users, visitor) { - var sender = _.find(users, { - id: doc.UserId - }); - - users.forEach(function (user) { - // SOCKET FILTER - if (socket.userId == user.id && (sender || visitor)) { - socket.emit('chat_message:save', _.merge(doc.dataValues, { - User: sender, // TODO modify to sender - ChatVisitor: visitor // TODO modify to visitor - })); - } - }); - }) - .catch(function (err) { - console.error(err); - }); -} - -function onRemove(socket, doc, cb) { - socket.emit('chat_message:remove', doc); -} +var _0x333a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x6C\x6F\x64\x61\x73\x68","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x55\x73\x65\x72\x49\x64","\x66\x69\x6E\x64","\x75\x73\x65\x72\x49\x64","\x69\x64","\x63\x68\x61\x74\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x73\x61\x76\x65","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x6D\x65\x72\x67\x65","\x65\x6D\x69\x74","\x66\x6F\x72\x45\x61\x63\x68","\x73\x70\x72\x65\x61\x64","\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x72\x6F\x6C\x65","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x67\x65\x74\x55\x73\x65\x72\x73","\x67\x65\x74\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x74\x68\x65\x6E","\x67\x65\x74\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x63\x68\x61\x74\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x333a[0];var chat_message=require(_0x333a[2])[_0x333a[1]];var _=require(_0x333a[3]);exports[_0x333a[4]]=function(_0x7d2fx3){chat_message[_0x333a[5]](function(_0x7d2fx4){onSave(_0x7d2fx3,_0x7d2fx4)});chat_message[_0x333a[6]](function(_0x7d2fx4){onSave(_0x7d2fx3,_0x7d2fx4)});chat_message[_0x333a[7]](function(_0x7d2fx4){onRemove(_0x7d2fx3,_0x7d2fx4)});};function onSave(_0x7d2fx3,_0x7d2fx4,_0x7d2fx6){return _0x7d2fx4[_0x333a[28]]()[_0x333a[27]](function(_0x7d2fxc){return [_0x7d2fxc[_0x333a[25]]({attributes:[_0x333a[13],_0x333a[20],_0x333a[21],_0x333a[22],_0x333a[23],_0x333a[24]],raw:true}),_0x7d2fxc[_0x333a[26]]({attributes:[_0x333a[13],_0x333a[21],_0x333a[22]],raw:true})]})[_0x333a[19]](function(_0x7d2fx8,_0x7d2fx9){var _0x7d2fxa=_[_0x333a[11]](_0x7d2fx8,{id:_0x7d2fx4[_0x333a[10]]});_0x7d2fx8[_0x333a[18]](function(_0x7d2fxb){if(_0x7d2fx3[_0x333a[12]]==_0x7d2fxb[_0x333a[13]]&&(_0x7d2fxa||_0x7d2fx9)){_0x7d2fx3[_0x333a[17]](_0x333a[14],_[_0x333a[16]](_0x7d2fx4[_0x333a[15]],{User:_0x7d2fxa,ChatVisitor:_0x7d2fx9}))}});})[_0x333a[9]](function(_0x7d2fx7){console[_0x333a[8]](_0x7d2fx7)})}function onRemove(_0x7d2fx3,_0x7d2fx4,_0x7d2fx6){_0x7d2fx3[_0x333a[17]](_0x333a[29],_0x7d2fx4)} \ No newline at end of file diff --git a/server/api/chat_message/chat_message.spec.js b/server/api/chat_message/chat_message.spec.js index f646838..d003cce 100644 --- a/server/api/chat_message/chat_message.spec.js +++ b/server/api/chat_message/chat_message.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/messages', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/messages') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x2c61=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x67\x65\x74"];_0x2c61[0];var should=require(_0x2c61[1]);var app=require(_0x2c61[2]);var request=require(_0x2c61[3]);describe(_0x2c61[4],function(){it(_0x2c61[5],function(_0x8661x4){request(app)[_0x2c61[13]](_0x2c61[12])[_0x2c61[11]](200)[_0x2c61[11]](_0x2c61[10],/json/)[_0x2c61[9]](function(_0x8661x5,_0x8661x6){if(_0x8661x5){return _0x8661x4(_0x8661x5)};_0x8661x6[_0x2c61[8]][_0x2c61[1]][_0x2c61[7]][_0x2c61[6]](Array);_0x8661x4();})})}); \ No newline at end of file diff --git a/server/api/chat_message/index.js b/server/api/chat_message/index.js index 8de80e3..d1d36fc 100644 --- a/server/api/chat_message/index.js +++ b/server/api/chat_message/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./chat_message.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', controller.update); -// router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xbe65=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x68\x61\x74\x5F\x6D\x65\x73\x73\x61\x67\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xbe65[0];var express=require(_0xbe65[1]);var controller=require(_0xbe65[2]);var auth=require(_0xbe65[3]);var router=express.Router();router[_0xbe65[6]](_0xbe65[4],controller[_0xbe65[5]]);router[_0xbe65[6]](_0xbe65[7],controller[_0xbe65[8]]);router[_0xbe65[11]](_0xbe65[4],auth[_0xbe65[9]](),controller[_0xbe65[10]]);router[_0xbe65[13]](_0xbe65[7],controller[_0xbe65[12]]);router[_0xbe65[15]](_0xbe65[7],controller[_0xbe65[14]]);module[_0xbe65[16]]=router; \ No newline at end of file diff --git a/server/api/chat_queue/chat_queue.controller.js b/server/api/chat_queue/chat_queue.controller.js index a2eaab3..eb17d84 100644 --- a/server/api/chat_queue/chat_queue.controller.js +++ b/server/api/chat_queue/chat_queue.controller.js @@ -1,226 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var ChatQueue = require('../../models').ChatQueue; -var UserHasChatQueue = require('../../models').UserHasChatQueue; - -// Get list of mailQueues -exports.index = function (req, res) { - - var attributes = ['description', 'name', 'timeout', 'strategy']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page, - include: [{ - all: true - }] - }; - - _.forIn(req.query, function (value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function (attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - ChatQueue - .findAndCountAll(query) - .then(function (result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get list of my chat_rooms -exports.me = function (req, res, next) { - UserHasChatQueue - .findAll({ - where: { - UserId: req.user.id - } - }) - .then(function (userHasChatQueues) { - return res.status(200).send(userHasChatQueues); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single chat_queue -exports.show = function (req, res) { - ChatQueue - .findById(req.params.id) - .then(function (chat_queue) { - if (!chat_queue) { - return res.sendStatus(404); - } - return res.send(chat_queue); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new chat_queue in the DB. -exports.create = function (req, res) { - ChatQueue - .create(req.body) - .then(function (chat_queue) { - return res.status(201).send(chat_queue); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing chat_queue in the DB. -exports.update = function (req, res) { - if (req.body.id) { - delete req.body.id; - } - ChatQueue - .findById(req.params.id) - .then(function (chat_queue) { - if (!chat_queue) { - return res.sendStatus(404); - } - var updated = _.merge(chat_queue, req.body); - updated.save() - .then(function () { - return res.status(200).send(chat_queue); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing user_has_chatQueue in the DB. -exports.addAgents = function (req, res, next) { - return ChatQueue - .findById(req.params.id) - .then(function (chatQueue) { - if (chatQueue) { - return chatQueue - .addUsers(req.body.agents, { - individualHooks: true - }); - } else { - throw new Error('No mail queue found'); - } - }) - .then(function () { - return res.sendStatus(200); - }) - .catch(function (err) { - return next(err); - }); -}; - -exports.removeAgents = function (req, res, next) { - return ChatQueue - .findById(req.params.id) - .then(function (chatQueue) { - if (chatQueue) { - return chatQueue - .removeUsers(req.body.agents, { - individualHooks: true - }); - } else { - throw new Error('no mail queue found'); - } - }) - .then(function () { - return res.sendStatus(200); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Deletes a chat_queue from the DB. -exports.destroy = function (req, res) { - ChatQueue - .findById(req.params.id) - .then(function (chat_queue) { - if (!chat_queue) { - return res.sendStatus(404); - } - chat_queue.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function (req, res) { - ChatQueue - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x5e1e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x74\x69\x6D\x65\x6F\x75\x74","\x73\x74\x72\x61\x74\x65\x67\x79","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x6D\x65","\x69\x64","\x75\x73\x65\x72","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x55\x73\x65\x72\x73","\x4E\x6F\x20\x6D\x61\x69\x6C\x20\x71\x75\x65\x75\x65\x20\x66\x6F\x75\x6E\x64","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x55\x73\x65\x72\x73","\x6E\x6F\x20\x6D\x61\x69\x6C\x20\x71\x75\x65\x75\x65\x20\x66\x6F\x75\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x5e1e[0];var _=require(_0x5e1e[1]);var util=require(_0x5e1e[2]);var ChatQueue=require(_0x5e1e[4])[_0x5e1e[3]];var UserHasChatQueue=require(_0x5e1e[4])[_0x5e1e[5]];exports[_0x5e1e[6]]=function(_0x6fe6x5,_0x6fe6x6){var _0x6fe6x7=[_0x5e1e[7],_0x5e1e[8],_0x5e1e[9],_0x5e1e[10]];var _0x6fe6x8=_0x6fe6x5[_0x5e1e[12]][_0x5e1e[11]]?parseInt(_0x6fe6x5[_0x5e1e[12]][_0x5e1e[11]],10):100;var _0x6fe6x9=_0x6fe6x5[_0x5e1e[12]][_0x5e1e[13]]?parseInt(_0x6fe6x5[_0x5e1e[12]][_0x5e1e[13]],10):0;var _0x6fe6xa={where:{},limit:_0x6fe6x8,offset:_0x6fe6x9*_0x6fe6x8,include:[{all:true}]};_[_0x5e1e[27]](_0x6fe6x5[_0x5e1e[12]],function(_0x6fe6xb,_0x6fe6xc){switch(_0x6fe6xc){case _0x5e1e[11]:;case _0x5e1e[13]:break ;;case _0x5e1e[16]:_0x6fe6xa[_0x5e1e[14]]=util[_0x5e1e[19]](_0x5e1e[15],_0x6fe6x5[_0x5e1e[12]][_0x5e1e[16]],_0x6fe6x5[_0x5e1e[12]][_0x5e1e[17]]||_0x5e1e[18])||null;break ;;case _0x5e1e[17]:break ;;case _0x5e1e[25]:_0x6fe6xa[_0x5e1e[21]][_0x5e1e[20]]=[];_0x6fe6x7[_0x5e1e[24]](function(_0x6fe6xd){var _0x6fe6xe={};_0x6fe6xe[_0x6fe6xd]={$like:_0x5e1e[22]+_0x6fe6xb+_0x5e1e[22]};_0x6fe6xa[_0x5e1e[21]][_0x5e1e[20]][_0x5e1e[23]](_0x6fe6xe);});break ;;default:_0x6fe6xa[_0x5e1e[21]][_0x6fe6xc]={$like:{}};_0x6fe6xa[_0x5e1e[21]][_0x6fe6xc][_0x5e1e[26]]=_0x5e1e[22]+_0x6fe6xb+_0x5e1e[22];;}});ChatQueue[_0x5e1e[41]](_0x6fe6xa)[_0x5e1e[40]](function(_0x6fe6x10){var _0x6fe6x11=Math[_0x5e1e[30]](_0x6fe6x10[_0x5e1e[29]]/_0x6fe6x8);var _0x6fe6x12=_0x6fe6x11>(_0x6fe6xa[_0x5e1e[31]]+1)?util[_0x5e1e[19]](_0x5e1e[32],_0x6fe6x5[_0x5e1e[33]],_0x6fe6x5[_0x5e1e[35]][_0x5e1e[34]],_0x6fe6x5[_0x5e1e[36]],_0x6fe6x9+1):null;var _0x6fe6x13=_0x6fe6x9>0?util[_0x5e1e[19]](_0x5e1e[32],_0x6fe6x5[_0x5e1e[33]],_0x6fe6x5[_0x5e1e[35]][_0x5e1e[34]],_0x6fe6x5[_0x5e1e[36]],_0x6fe6x9-1):null;_0x6fe6x6[_0x5e1e[39]](200)[_0x5e1e[38]]({count:_0x6fe6x10[_0x5e1e[29]],rows:_0x6fe6x10[_0x5e1e[37]],next_page:_0x6fe6x12,previous_page:_0x6fe6x13,total_pages:_0x6fe6x11});})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)});};exports[_0x5e1e[42]]=function(_0x6fe6x5,_0x6fe6x6,_0x6fe6x14){UserHasChatQueue[_0x5e1e[45]]({where:{UserId:_0x6fe6x5[_0x5e1e[44]][_0x5e1e[43]]}})[_0x5e1e[40]](function(_0x6fe6x15){return _0x6fe6x6[_0x5e1e[39]](200)[_0x5e1e[38]](_0x6fe6x15)})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)})};exports[_0x5e1e[46]]=function(_0x6fe6x5,_0x6fe6x6){ChatQueue[_0x5e1e[49]](_0x6fe6x5[_0x5e1e[48]][_0x5e1e[43]])[_0x5e1e[40]](function(_0x6fe6x16){if(!_0x6fe6x16){return _0x6fe6x6[_0x5e1e[47]](404)};return _0x6fe6x6[_0x5e1e[38]](_0x6fe6x16);})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)})};exports[_0x5e1e[50]]=function(_0x6fe6x5,_0x6fe6x6){ChatQueue[_0x5e1e[50]](_0x6fe6x5[_0x5e1e[51]])[_0x5e1e[40]](function(_0x6fe6x16){return _0x6fe6x6[_0x5e1e[39]](201)[_0x5e1e[38]](_0x6fe6x16)})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)})};exports[_0x5e1e[52]]=function(_0x6fe6x5,_0x6fe6x6){if(_0x6fe6x5[_0x5e1e[51]][_0x5e1e[43]]){delete _0x6fe6x5[_0x5e1e[51]][_0x5e1e[43]]};ChatQueue[_0x5e1e[49]](_0x6fe6x5[_0x5e1e[48]][_0x5e1e[43]])[_0x5e1e[40]](function(_0x6fe6x16){if(!_0x6fe6x16){return _0x6fe6x6[_0x5e1e[47]](404)};var _0x6fe6x17=_[_0x5e1e[53]](_0x6fe6x16,_0x6fe6x5[_0x5e1e[51]]);_0x6fe6x17[_0x5e1e[54]]()[_0x5e1e[40]](function(){return _0x6fe6x6[_0x5e1e[39]](200)[_0x5e1e[38]](_0x6fe6x16)})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)});})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)});};exports[_0x5e1e[55]]=function(_0x6fe6x5,_0x6fe6x6,_0x6fe6x14){return ChatQueue[_0x5e1e[49]](_0x6fe6x5[_0x5e1e[48]][_0x5e1e[43]])[_0x5e1e[40]](function(_0x6fe6x18){if(_0x6fe6x18){return _0x6fe6x18[_0x5e1e[57]](_0x6fe6x5[_0x5e1e[51]][_0x5e1e[56]],{individualHooks:true})}else {throw new Error(_0x5e1e[58])}})[_0x5e1e[40]](function(){return _0x6fe6x6[_0x5e1e[47]](200)})[_0x5e1e[28]](function(_0x6fe6xf){return _0x6fe6x14(_0x6fe6xf)})};exports[_0x5e1e[59]]=function(_0x6fe6x5,_0x6fe6x6,_0x6fe6x14){return ChatQueue[_0x5e1e[49]](_0x6fe6x5[_0x5e1e[48]][_0x5e1e[43]])[_0x5e1e[40]](function(_0x6fe6x18){if(_0x6fe6x18){return _0x6fe6x18[_0x5e1e[60]](_0x6fe6x5[_0x5e1e[51]][_0x5e1e[56]],{individualHooks:true})}else {throw new Error(_0x5e1e[61])}})[_0x5e1e[40]](function(){return _0x6fe6x6[_0x5e1e[47]](200)})[_0x5e1e[28]](function(_0x6fe6xf){return _0x6fe6x14(_0x6fe6xf)})};exports[_0x5e1e[62]]=function(_0x6fe6x5,_0x6fe6x6){ChatQueue[_0x5e1e[49]](_0x6fe6x5[_0x5e1e[48]][_0x5e1e[43]])[_0x5e1e[40]](function(_0x6fe6x16){if(!_0x6fe6x16){return _0x6fe6x6[_0x5e1e[47]](404)};_0x6fe6x16[_0x5e1e[62]]()[_0x5e1e[40]](function(){return _0x6fe6x6[_0x5e1e[47]](204)})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)});})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)})};exports[_0x5e1e[63]]=function(_0x6fe6x5,_0x6fe6x6){ChatQueue[_0x5e1e[62]]({where:{id:_0x6fe6x5[_0x5e1e[12]][_0x5e1e[43]]},individualHooks:true})[_0x5e1e[40]](function(){return _0x6fe6x6[_0x5e1e[47]](204)})[_0x5e1e[28]](function(_0x6fe6xf){return handleError(_0x6fe6x6,_0x6fe6xf)})};function handleError(_0x6fe6x6,_0x6fe6xf){return _0x6fe6x6[_0x5e1e[39]](500)[_0x5e1e[38]](_0x6fe6xf)} \ No newline at end of file diff --git a/server/api/chat_queue/chat_queue.socket.js b/server/api/chat_queue/chat_queue.socket.js index 2e7f5d4..ed889f6 100644 --- a/server/api/chat_queue/chat_queue.socket.js +++ b/server/api/chat_queue/chat_queue.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var chatQueue = require('../../models').ChatQueue; - -exports.register = function (socket) { - chatQueue.afterCreate(function (doc) { - onSave(socket, doc); - }); - chatQueue.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('chat_queue:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('chat_queue:remove', doc); -} +var _0x2030=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x2030[0];var chatQueue=require(_0x2030[2])[_0x2030[1]];exports[_0x2030[3]]=function(_0x932fx2){chatQueue[_0x2030[4]](function(_0x932fx3){onSave(_0x932fx2,_0x932fx3)});chatQueue[_0x2030[5]](function(_0x932fx3){onRemove(_0x932fx2,_0x932fx3)});};function onSave(_0x932fx2,_0x932fx3,_0x932fx5){_0x932fx2[_0x2030[7]](_0x2030[6],_0x932fx3)}function onRemove(_0x932fx2,_0x932fx3,_0x932fx5){_0x932fx2[_0x2030[7]](_0x2030[8],_0x932fx3)} \ No newline at end of file diff --git a/server/api/chat_queue/chat_queue.spec.js b/server/api/chat_queue/chat_queue.spec.js index 172be01..b0b5a91 100644 --- a/server/api/chat_queue/chat_queue.spec.js +++ b/server/api/chat_queue/chat_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x7371=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0x7371[0];var should=require(_0x7371[1]);var app=require(_0x7371[2]);var request=require(_0x7371[3]);describe(_0x7371[4],function(){it(_0x7371[5],function(_0xebf8x4){request(app)[_0x7371[13]](_0x7371[12])[_0x7371[11]](200)[_0x7371[11]](_0x7371[10],/json/)[_0x7371[9]](function(_0xebf8x5,_0xebf8x6){if(_0xebf8x5){return _0xebf8x4(_0xebf8x5)};_0xebf8x6[_0x7371[8]][_0x7371[1]][_0x7371[7]][_0x7371[6]](Array);_0xebf8x4();})})}); \ No newline at end of file diff --git a/server/api/chat_queue/index.js b/server/api/chat_queue/index.js index ab30e8c..da3c642 100644 --- a/server/api/chat_queue/index.js +++ b/server/api/chat_queue/index.js @@ -1,20 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./chat_queue.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/me', auth.isAuthenticated(), controller.me); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.post('/:id/agents', controller.addAgents); -router.put('/:id', controller.update); -router.put('/:id/agents', controller.removeAgents); -router.patch('/:id', controller.update); -router.delete('/', controller.bulkDestroy); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x38e1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x6D\x65","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x6D\x65","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x3A\x69\x64\x2F\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x38e1[0];var express=require(_0x38e1[1]);var controller=require(_0x38e1[2]);var auth=require(_0x38e1[3]);var router=express.Router();router[_0x38e1[6]](_0x38e1[4],controller[_0x38e1[5]]);router[_0x38e1[6]](_0x38e1[7],auth[_0x38e1[8]](),controller[_0x38e1[9]]);router[_0x38e1[6]](_0x38e1[10],controller[_0x38e1[11]]);router[_0x38e1[13]](_0x38e1[4],controller[_0x38e1[12]]);router[_0x38e1[13]](_0x38e1[14],controller[_0x38e1[15]]);router[_0x38e1[17]](_0x38e1[10],controller[_0x38e1[16]]);router[_0x38e1[17]](_0x38e1[14],controller[_0x38e1[18]]);router[_0x38e1[19]](_0x38e1[10],controller[_0x38e1[16]]);router[_0x38e1[21]](_0x38e1[4],controller[_0x38e1[20]]);router[_0x38e1[21]](_0x38e1[10],controller[_0x38e1[22]]);module[_0x38e1[23]]=router; \ No newline at end of file diff --git a/server/api/chat_room/chat_room.controller.js b/server/api/chat_room/chat_room.controller.js index e423038..589c37d 100644 --- a/server/api/chat_room/chat_room.controller.js +++ b/server/api/chat_room/chat_room.controller.js @@ -1,455 +1 @@ -'use strict'; - -var _ = require('lodash'); -var md5 = require('md5'); -var moment = require('moment'); - -var User = require('../../models').User; -var ChatRoom = require('../../models').ChatRoom; -var ChatMessage = require('../../models').ChatMessage; -var ChatVisitor = require('../../models').ChatVisitor; -var UserHasChatRoom = require('../../models').UserHasChatRoom; - - -// Get list of chat_rooms -exports.index = function (req, res) { - return ChatRoom - .findAll({ - include: [User, ChatMessage, ChatVisitor] - }) - .then(function (chat_rooms) { - return res.status(200).send(chat_rooms); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get list of my chat_rooms -exports.me = function (req, res) { - return User - .findById(req.user.id) - .then(function (user) { - return user - .getChatRooms({ - include: [{ - model: ChatVisitor, - attributes: ['id', 'fullname', 'email'] - }, { - model: User, - attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal'] - }] - }); - }) - .then(function (chatRooms) { - if (!chatRooms) { - return res.sendStatus(404); - } - return res.send(chatRooms); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single chatRoom -exports.show = function (req, res) { - return ChatRoom - .findById(req.params.id, { - include: [{ - model: ChatMessage, - include: [{ - model: ChatVisitor, - attributes: ['id', 'email', 'fullname'] - }, { - model: User, - attributes: ['id', 'email', 'name', 'fullname'] - }] - }, { - model: User, - attributes: ['id', 'email', 'name', 'fullname'] - }] - }) - .then(function (chatRoom) { - if (!chatRoom) { - return res.sendStatus(404); - } - return res.send(chatRoom); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single chatRoom by users -exports.getRoomByUsers = function (req, res, next) { - - var _chatRoom; - - return ChatRoom - .findOrCreate({ - where: { - token: md5(JSON.stringify(req.query.users.sort())).toString('base64') - }, - defaults: { - type: 'internal', - token: md5(JSON.stringify(req.query.users.sort())).toString('base64'), - status: 'open' - }, - include: [{ - model: ChatMessage, - include: [{ - model: ChatVisitor, - attributes: ['id', 'email', 'fullname'] - }, { - model: User, - attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal'] - }] - }, { - model: User, - attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal'] - }] - }) - .spread(function (chatRoom, created) { - _chatRoom = chatRoom; - // _chatRoom.dataValues.ChatMessages = []; - if (created) { - return _chatRoom - .setUsers(req.query.users); - } else { - return; - } - }) - .then(function () { - return _chatRoom - .getUsers(); - }) - .then(function (users) { - return res.status(200).send(_.merge(_chatRoom.dataValues, { - Users: users - })); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single chatRoom -exports.getRoomByType = function (req, res) { - User - .findById(req.user.id) - .then(function (user) { - user - .getChatRooms({ - where: { - type: req.params.type - }, - include: [{ - model: ChatVisitor, - attributes: ['id', 'fullname', 'email'] - }] - }) - .then(function (chatRooms) { - if (!chatRooms) { - return res.sendStatus(404); - } - return res.send(chatRooms); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single chatRoom -exports.getRoomGroups = function (req, res) { - User - .findById(req.user.id) - .then(function (user) { - user - .getChatRooms({ - include: [{ - model: ChatVisitor, - attributes: ['id', 'fullname', 'email'] - }, { - model: User, - attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal'] - }] - }) - .then(function (chatRooms) { - if (!chatRooms) { - return res.sendStatus(404); - } - return res.send(chatRooms); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new chatRoom in the DB. -exports.create = function (req, res) { - // if (req.body.to) { - // - // var token; - // var participants = { - // users: { - // ids: [] - // }, - // visitor: {} - // }; - // - // switch (req.body.type) { - // case 'internal': - // - // if (!req.body.to.isArray) { - // req.body.to = [parseInt(req.body.to, 10)]; - // } - // - // participants.users.ids = req.body.to; - // - // if (!_.contains(req.body.to, req.user.id)) { - // participants.users.ids.push(req.user.id); - // } - // - // participants.users.ids.sort(); - // - // token = md5(JSON.stringify(participants)).toString( - // 'base64'); - // - // participants.users.fullnames = []; - // - // User - // .findAll({ - // where: { - // id: { - // $in: req.body.to - // } - // }, - // attributes: ['id', 'fullname'] - // }) - // .then(function(users) { - // - // _.sortBy(users, 'id').forEach(function(item, index) { - // participants.users.fullnames.push(item.fullname); - // }); - // - // ChatRoom - // .findOrCreate({ - // where: { - // token: token - // }, - // defaults: _.merge({ - // token: token, - // participants: JSON.stringify(participants) - // }, req.body), - // include: [{ - // model: ChatMessage - // }] - // }) - // .spread(function(chatRoom, created) { - // - // if (created) { - // chatRoom - // .setUsers(participants.users.ids) - // .then(function() { - // return res.status(201).send(chatRoom); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // } else { - // return res.status(201).send(chatRoom); - // } - // - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // - // break; - // case 'external': - // - // participants.visitor.id = req.body.to; - // participants.users.ids.push(req.user.id); - // participants.users.ids.sort(); - // - // token = md5(JSON.stringify(participants)).toString('base64'); - // - // participants.users.fullnames = [req.user.fullname]; - // - // ChatVisitor - // .findById(req.body.to, { - // attributes: ['id', 'fullname', 'email', 'referer'] - // }) - // .then(function(chatVisitor) { - // participants.visitor.fullname = chatVisitor.fullname; - // participants.visitor.referer = chatVisitor.referer; - // participants.visitor.email = chatVisitor.email; - // - // ChatRoom - // .findOrCreate({ - // where: { - // token: token - // }, - // defaults: _.merge({ - // token: token, - // participants: JSON.stringify(participants) - // }, req.body), - // include: [{ - // model: ChatMessage - // }, { - // model: ChatVisitor - // }, { - // model: User, - // }] - // }) - // .spread(function(chatRoom, created) { - // if (created) { - // - // chatRoom - // .setUsers(participants.users.ids, { - // individualHooks: true - // }) - // .then(function() { - // chatRoom - // .setChatVisitor(participants.visitor.id) - // .then(function() { - // return res.status(201).send(chatRoom); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // } else { - // return res.status(201).send(chatRoom); - // } - // - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - // - // break; - // default: - // } - // } else { - // return handleError(res, new Error('field "to" omitted')); - // } -}; - -// Updates an existing chatRoom in the DB. -exports.update = function (req, res) { - if (req.body.id) { - delete req.body.id; - } - - ChatRoom - .findById(req.params.id) - .then(function (chatRoom) { - if (!chatRoom) { - return res.sendStatus(404); - } - var updated = _.merge(chatRoom, req.body); - updated - .save() - .then(function () { - return res.status(200).send(chatRoom); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing chatRoom in the DB. -exports.updateUsers = function (req, res) { - var _chatRoom; - - if (req.body.id) { - delete req.body.id; - } - - return ChatRoom - .findById(req.params.id) - .then(function (chatRoom) { - if (!chatRoom || !req.body.users) { - return res.sendStatus(404); - } - return chatRoom; - }) - .then(function (chatRoom) { - return chatRoom - .update({ - token: md5(JSON.stringify(req.body.users.sort())).toString('base64') - }); - }) - .then(function (chatRoom) { - _chatRoom = chatRoom; - return chatRoom - .setUsers(req.body.users.sort(), { - individualHooks: true - }); - }) - .then(function () { - return _chatRoom - .getUsers(); - }) - .then(function (users) { - return res.status(200).send(_.merge(_chatRoom.dataValues, { - Users: users, - ChatMessages: [] - })); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a chatRoom from the DB. -exports.destroy = function (req, res) { - ChatRoom - .findById(req.params.id) - .then(function (chatRoom) { - if (!chatRoom) { - return res.sendStatus(404); - } - - chatRoom - .destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xea50=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x64\x35","\x6D\x6F\x6D\x65\x6E\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x6D\x65","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x6E\x61\x6D\x65","\x72\x6F\x6C\x65","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x67\x65\x74\x43\x68\x61\x74\x52\x6F\x6F\x6D\x73","\x75\x73\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x73\x68\x6F\x77","\x70\x61\x72\x61\x6D\x73","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x55\x73\x65\x72\x73","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x6D\x65\x72\x67\x65","\x67\x65\x74\x55\x73\x65\x72\x73","\x75\x73\x65\x72\x73","\x71\x75\x65\x72\x79","\x73\x65\x74\x55\x73\x65\x72\x73","\x73\x70\x72\x65\x61\x64","\x62\x61\x73\x65\x36\x34","\x73\x6F\x72\x74","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x6F\x70\x65\x6E","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x54\x79\x70\x65","\x74\x79\x70\x65","\x67\x65\x74\x52\x6F\x6F\x6D\x47\x72\x6F\x75\x70\x73","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x62\x6F\x64\x79","\x73\x61\x76\x65","\x75\x70\x64\x61\x74\x65\x55\x73\x65\x72\x73","\x64\x65\x73\x74\x72\x6F\x79"];_0xea50[0];var _=require(_0xea50[1]);var md5=require(_0xea50[2]);var moment=require(_0xea50[3]);var User=require(_0xea50[5])[_0xea50[4]];var ChatRoom=require(_0xea50[5])[_0xea50[6]];var ChatMessage=require(_0xea50[5])[_0xea50[7]];var ChatVisitor=require(_0xea50[5])[_0xea50[8]];var UserHasChatRoom=require(_0xea50[5])[_0xea50[9]];exports[_0xea50[10]]=function(_0x9fbax9,_0x9fbaxa){return ChatRoom[_0xea50[15]]({include:[User,ChatMessage,ChatVisitor]})[_0xea50[14]](function(_0x9fbaxc){return _0x9fbaxa[_0xea50[13]](200)[_0xea50[12]](_0x9fbaxc)})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})};exports[_0xea50[16]]=function(_0x9fbax9,_0x9fbaxa){return User[_0xea50[26]](_0x9fbax9[_0xea50[25]][_0xea50[18]])[_0xea50[14]](function(_0x9fbaxe){return _0x9fbaxe[_0xea50[24]]({include:[{model:ChatVisitor,attributes:[_0xea50[18],_0xea50[19],_0xea50[20]]},{model:User,attributes:[_0xea50[18],_0xea50[21],_0xea50[19],_0xea50[20],_0xea50[22],_0xea50[23]]}]})})[_0xea50[14]](function(_0x9fbaxd){if(!_0x9fbaxd){return _0x9fbaxa[_0xea50[17]](404)};return _0x9fbaxa[_0xea50[12]](_0x9fbaxd);})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})};exports[_0xea50[27]]=function(_0x9fbax9,_0x9fbaxa){return ChatRoom[_0xea50[26]](_0x9fbax9[_0xea50[28]][_0xea50[18]],{include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0xea50[18],_0xea50[20],_0xea50[19]]},{model:User,attributes:[_0xea50[18],_0xea50[20],_0xea50[21],_0xea50[19]]}]},{model:User,attributes:[_0xea50[18],_0xea50[20],_0xea50[21],_0xea50[19]]}]})[_0xea50[14]](function(_0x9fbaxf){if(!_0x9fbaxf){return _0x9fbaxa[_0xea50[17]](404)};return _0x9fbaxa[_0xea50[12]](_0x9fbaxf);})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})};exports[_0xea50[29]]=function(_0x9fbax9,_0x9fbaxa,_0x9fbax10){var _0x9fbax11;return ChatRoom[_0xea50[41]]({where:{token:md5(JSON[_0xea50[39]](_0x9fbax9[_0xea50[34]][_0xea50[33]][_0xea50[38]]())).toString(_0xea50[37])},defaults:{type:_0xea50[23],token:md5(JSON[_0xea50[39]](_0x9fbax9[_0xea50[34]][_0xea50[33]][_0xea50[38]]())).toString(_0xea50[37]),status:_0xea50[40]},include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0xea50[18],_0xea50[20],_0xea50[19]]},{model:User,attributes:[_0xea50[18],_0xea50[21],_0xea50[19],_0xea50[20],_0xea50[22],_0xea50[23]]}]},{model:User,attributes:[_0xea50[18],_0xea50[21],_0xea50[19],_0xea50[20],_0xea50[22],_0xea50[23]]}]})[_0xea50[36]](function(_0x9fbaxf,_0x9fbax13){_0x9fbax11=_0x9fbaxf;if(_0x9fbax13){return _0x9fbax11[_0xea50[35]](_0x9fbax9[_0xea50[34]][_0xea50[33]])}else {return };})[_0xea50[14]](function(){return _0x9fbax11[_0xea50[32]]()})[_0xea50[14]](function(_0x9fbax12){return _0x9fbaxa[_0xea50[13]](200)[_0xea50[12]](_[_0xea50[31]](_0x9fbax11[_0xea50[30]],{Users:_0x9fbax12}))})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)});};exports[_0xea50[42]]=function(_0x9fbax9,_0x9fbaxa){User[_0xea50[26]](_0x9fbax9[_0xea50[25]][_0xea50[18]])[_0xea50[14]](function(_0x9fbaxe){_0x9fbaxe[_0xea50[24]]({where:{type:_0x9fbax9[_0xea50[28]][_0xea50[43]]},include:[{model:ChatVisitor,attributes:[_0xea50[18],_0xea50[19],_0xea50[20]]}]})[_0xea50[14]](function(_0x9fbaxd){if(!_0x9fbaxd){return _0x9fbaxa[_0xea50[17]](404)};return _0x9fbaxa[_0xea50[12]](_0x9fbaxd);})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})};exports[_0xea50[44]]=function(_0x9fbax9,_0x9fbaxa){User[_0xea50[26]](_0x9fbax9[_0xea50[25]][_0xea50[18]])[_0xea50[14]](function(_0x9fbaxe){_0x9fbaxe[_0xea50[24]]({include:[{model:ChatVisitor,attributes:[_0xea50[18],_0xea50[19],_0xea50[20]]},{model:User,attributes:[_0xea50[18],_0xea50[21],_0xea50[19],_0xea50[20],_0xea50[22],_0xea50[23]]}]})[_0xea50[14]](function(_0x9fbaxd){if(!_0x9fbaxd){return _0x9fbaxa[_0xea50[17]](404)};return _0x9fbaxa[_0xea50[12]](_0x9fbaxd);})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})};exports[_0xea50[45]]=function(_0x9fbax9,_0x9fbaxa){};exports[_0xea50[46]]=function(_0x9fbax9,_0x9fbaxa){if(_0x9fbax9[_0xea50[47]][_0xea50[18]]){delete _0x9fbax9[_0xea50[47]][_0xea50[18]]};ChatRoom[_0xea50[26]](_0x9fbax9[_0xea50[28]][_0xea50[18]])[_0xea50[14]](function(_0x9fbaxf){if(!_0x9fbaxf){return _0x9fbaxa[_0xea50[17]](404)};var _0x9fbax14=_[_0xea50[31]](_0x9fbaxf,_0x9fbax9[_0xea50[47]]);_0x9fbax14[_0xea50[48]]()[_0xea50[14]](function(){return _0x9fbaxa[_0xea50[13]](200)[_0xea50[12]](_0x9fbaxf)})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)});})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)});};exports[_0xea50[49]]=function(_0x9fbax9,_0x9fbaxa){var _0x9fbax11;if(_0x9fbax9[_0xea50[47]][_0xea50[18]]){delete _0x9fbax9[_0xea50[47]][_0xea50[18]]};return ChatRoom[_0xea50[26]](_0x9fbax9[_0xea50[28]][_0xea50[18]])[_0xea50[14]](function(_0x9fbaxf){if(!_0x9fbaxf||!_0x9fbax9[_0xea50[47]][_0xea50[33]]){return _0x9fbaxa[_0xea50[17]](404)};return _0x9fbaxf;})[_0xea50[14]](function(_0x9fbaxf){return _0x9fbaxf[_0xea50[46]]({token:md5(JSON[_0xea50[39]](_0x9fbax9[_0xea50[47]][_0xea50[33]][_0xea50[38]]())).toString(_0xea50[37])})})[_0xea50[14]](function(_0x9fbaxf){_0x9fbax11=_0x9fbaxf;return _0x9fbaxf[_0xea50[35]](_0x9fbax9[_0xea50[47]][_0xea50[33]][_0xea50[38]](),{individualHooks:true});})[_0xea50[14]](function(){return _0x9fbax11[_0xea50[32]]()})[_0xea50[14]](function(_0x9fbax12){return _0x9fbaxa[_0xea50[13]](200)[_0xea50[12]](_[_0xea50[31]](_0x9fbax11[_0xea50[30]],{Users:_0x9fbax12,ChatMessages:[]}))})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)});};exports[_0xea50[50]]=function(_0x9fbax9,_0x9fbaxa){ChatRoom[_0xea50[26]](_0x9fbax9[_0xea50[28]][_0xea50[18]])[_0xea50[14]](function(_0x9fbaxf){if(!_0x9fbaxf){return _0x9fbaxa[_0xea50[17]](404)};_0x9fbaxf[_0xea50[50]]()[_0xea50[14]](function(){return _0x9fbaxa[_0xea50[17]](204)})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)});})[_0xea50[11]](function(_0x9fbaxb){return handleError(_0x9fbaxa,_0x9fbaxb)})};function handleError(_0x9fbaxa,_0x9fbaxb){return _0x9fbaxa[_0xea50[13]](500)[_0xea50[12]](_0x9fbaxb)} \ No newline at end of file diff --git a/server/api/chat_room/chat_room.socket.js b/server/api/chat_room/chat_room.socket.js index 2f75a98..a8724a6 100644 --- a/server/api/chat_room/chat_room.socket.js +++ b/server/api/chat_room/chat_room.socket.js @@ -1,30 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var User = require('../../models').User; -var ChatRoom = require('../../models').ChatRoom; -var ChatMessage = require('../../models').ChatMessage; -var ChatVisitor = require('../../models').ChatVisitor; - -exports.register = function (socket) { - ChatRoom.afterCreate(function (doc) { - onSave(socket, doc); - }); - ChatRoom.afterUpdate(function (doc) { - onSave(socket, doc); - }); - ChatRoom.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('chat_room:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('chat_room:remove', doc); -} +var _0x5055=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x3A\x72\x65\x6D\x6F\x76\x65"];_0x5055[0];var User=require(_0x5055[2])[_0x5055[1]];var ChatRoom=require(_0x5055[2])[_0x5055[3]];var ChatMessage=require(_0x5055[2])[_0x5055[4]];var ChatVisitor=require(_0x5055[2])[_0x5055[5]];exports[_0x5055[6]]=function(_0xa510x5){ChatRoom[_0x5055[7]](function(_0xa510x6){onSave(_0xa510x5,_0xa510x6)});ChatRoom[_0x5055[8]](function(_0xa510x6){onSave(_0xa510x5,_0xa510x6)});ChatRoom[_0x5055[9]](function(_0xa510x6){onRemove(_0xa510x5,_0xa510x6)});};function onSave(_0xa510x5,_0xa510x6,_0xa510x8){_0xa510x5[_0x5055[11]](_0x5055[10],_0xa510x6)}function onRemove(_0xa510x5,_0xa510x6,_0xa510x8){_0xa510x5[_0x5055[11]](_0x5055[12],_0xa510x6)} \ No newline at end of file diff --git a/server/api/chat_room/chat_room.spec.js b/server/api/chat_room/chat_room.spec.js index c76c928..99b7d41 100644 --- a/server/api/chat_room/chat_room.spec.js +++ b/server/api/chat_room/chat_room.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/rooms', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/rooms') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x2a1e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x72\x6F\x6F\x6D\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x72\x6F\x6F\x6D\x73","\x67\x65\x74"];_0x2a1e[0];var should=require(_0x2a1e[1]);var app=require(_0x2a1e[2]);var request=require(_0x2a1e[3]);describe(_0x2a1e[4],function(){it(_0x2a1e[5],function(_0x5855x4){request(app)[_0x2a1e[13]](_0x2a1e[12])[_0x2a1e[11]](200)[_0x2a1e[11]](_0x2a1e[10],/json/)[_0x2a1e[9]](function(_0x5855x5,_0x5855x6){if(_0x5855x5){return _0x5855x4(_0x5855x5)};_0x5855x6[_0x2a1e[8]][_0x2a1e[1]][_0x2a1e[7]][_0x2a1e[6]](Array);_0x5855x4();})})}); \ No newline at end of file diff --git a/server/api/chat_room/index.js b/server/api/chat_room/index.js index 9c38043..6fb946b 100644 --- a/server/api/chat_room/index.js +++ b/server/api/chat_room/index.js @@ -1,20 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./chat_room.controller'); -var auth = require('../../auth/auth.service'); -var router = express.Router(); - -router.get('/', controller.index); -router.get('/me', auth.isAuthenticated(), controller.me); -router.get('/users', auth.isAuthenticated(), controller.getRoomByUsers); -router.get('/groups', auth.isAuthenticated(), controller.getRoomGroups); -router.get('/type/:type', auth.isAuthenticated(), controller.getRoomByType); -router.get('/:id', controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', controller.update); -router.put('/:id/users', controller.updateUsers); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x9c63=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x6D\x65","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x6D\x65","\x2F\x75\x73\x65\x72\x73","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x55\x73\x65\x72\x73","\x2F\x67\x72\x6F\x75\x70\x73","\x67\x65\x74\x52\x6F\x6F\x6D\x47\x72\x6F\x75\x70\x73","\x2F\x74\x79\x70\x65\x2F\x3A\x74\x79\x70\x65","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x54\x79\x70\x65","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x3A\x69\x64\x2F\x75\x73\x65\x72\x73","\x75\x70\x64\x61\x74\x65\x55\x73\x65\x72\x73","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x9c63[0];var express=require(_0x9c63[1]);var controller=require(_0x9c63[2]);var auth=require(_0x9c63[3]);var router=express.Router();router[_0x9c63[6]](_0x9c63[4],controller[_0x9c63[5]]);router[_0x9c63[6]](_0x9c63[7],auth[_0x9c63[8]](),controller[_0x9c63[9]]);router[_0x9c63[6]](_0x9c63[10],auth[_0x9c63[8]](),controller[_0x9c63[11]]);router[_0x9c63[6]](_0x9c63[12],auth[_0x9c63[8]](),controller[_0x9c63[13]]);router[_0x9c63[6]](_0x9c63[14],auth[_0x9c63[8]](),controller[_0x9c63[15]]);router[_0x9c63[6]](_0x9c63[16],controller[_0x9c63[17]]);router[_0x9c63[19]](_0x9c63[4],auth[_0x9c63[8]](),controller[_0x9c63[18]]);router[_0x9c63[21]](_0x9c63[16],controller[_0x9c63[20]]);router[_0x9c63[21]](_0x9c63[22],controller[_0x9c63[23]]);router[_0x9c63[24]](_0x9c63[16],controller[_0x9c63[20]]);router[_0x9c63[26]](_0x9c63[16],controller[_0x9c63[25]]);module[_0x9c63[27]]=router; \ No newline at end of file diff --git a/server/api/chat_visitor/chat_visitor.controller.js b/server/api/chat_visitor/chat_visitor.controller.js index 4297f32..b3f60d7 100644 --- a/server/api/chat_visitor/chat_visitor.controller.js +++ b/server/api/chat_visitor/chat_visitor.controller.js @@ -1,94 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ChatVisitor = require('../../models').ChatVisitor; - -// Get list of chat_visitors -exports.index = function(req, res) { - ChatVisitor - .findAll() - .then(function(chat_visitors) { - return res.status(200).send(chat_visitors); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single chat_visitor -exports.show = function(req, res) { - ChatVisitor - .findById(req.params.id) - .then(function(chat_visitor) { - if (!chat_visitor) { - return res.sendStatus(404); - } - return res.send(chat_visitor); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new chat_visitor in the DB. -exports.create = function(req, res) { - - ChatVisitor - .create(req.body) - .then(function(chat_visitor) { - return res.status(201).send(chat_visitor); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing chat_visitor in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ChatVisitor - .findById(req.params.id) - .then(function(chat_visitor) { - if (!chat_visitor) { - return res.sendStatus(404); - } - var updated = _.merge(chat_visitor, req.body); - updated.save() - .then(function() { - return res.status(200).send(chat_visitor); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a chat_visitor from the DB. -exports.destroy = function(req, res) { - ChatVisitor - .findById(req.params.id) - .then(function(chat_visitor) { - if (!chat_visitor) { - return res.sendStatus(404); - } - chat_visitor.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xfd23=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xfd23[0];var _=require(_0xfd23[1]);var ChatVisitor=require(_0xfd23[3])[_0xfd23[2]];exports[_0xfd23[4]]=function(_0x4950x3,_0x4950x4){ChatVisitor[_0xfd23[9]]()[_0xfd23[8]](function(_0x4950x6){return _0x4950x4[_0xfd23[7]](200)[_0xfd23[6]](_0x4950x6)})[_0xfd23[5]](function(_0x4950x5){return handleError(_0x4950x4,_0x4950x5)})};exports[_0xfd23[10]]=function(_0x4950x3,_0x4950x4){ChatVisitor[_0xfd23[14]](_0x4950x3[_0xfd23[13]][_0xfd23[12]])[_0xfd23[8]](function(_0x4950x7){if(!_0x4950x7){return _0x4950x4[_0xfd23[11]](404)};return _0x4950x4[_0xfd23[6]](_0x4950x7);})[_0xfd23[5]](function(_0x4950x5){return handleError(_0x4950x4,_0x4950x5)})};exports[_0xfd23[15]]=function(_0x4950x3,_0x4950x4){ChatVisitor[_0xfd23[15]](_0x4950x3[_0xfd23[16]])[_0xfd23[8]](function(_0x4950x7){return _0x4950x4[_0xfd23[7]](201)[_0xfd23[6]](_0x4950x7)})[_0xfd23[5]](function(_0x4950x5){return handleError(_0x4950x4,_0x4950x5)})};exports[_0xfd23[17]]=function(_0x4950x3,_0x4950x4){if(_0x4950x3[_0xfd23[16]][_0xfd23[12]]){delete _0x4950x3[_0xfd23[16]][_0xfd23[12]]};ChatVisitor[_0xfd23[14]](_0x4950x3[_0xfd23[13]][_0xfd23[12]])[_0xfd23[8]](function(_0x4950x7){if(!_0x4950x7){return _0x4950x4[_0xfd23[11]](404)};var _0x4950x8=_[_0xfd23[18]](_0x4950x7,_0x4950x3[_0xfd23[16]]);_0x4950x8[_0xfd23[19]]()[_0xfd23[8]](function(){return _0x4950x4[_0xfd23[7]](200)[_0xfd23[6]](_0x4950x7)})[_0xfd23[5]](function(_0x4950x5){return handleError(_0x4950x4,_0x4950x5)});})[_0xfd23[5]](function(_0x4950x5){return handleError(_0x4950x4,_0x4950x5)});};exports[_0xfd23[20]]=function(_0x4950x3,_0x4950x4){ChatVisitor[_0xfd23[14]](_0x4950x3[_0xfd23[13]][_0xfd23[12]])[_0xfd23[8]](function(_0x4950x7){if(!_0x4950x7){return _0x4950x4[_0xfd23[11]](404)};_0x4950x7[_0xfd23[20]]()[_0xfd23[8]](function(){return _0x4950x4[_0xfd23[11]](204)})[_0xfd23[5]](function(_0x4950x5){return handleError(_0x4950x4,_0x4950x5)});})[_0xfd23[5]](function(_0x4950x5){return handleError(_0x4950x4,_0x4950x5)})};function handleError(_0x4950x4,_0x4950x5){return _0x4950x4[_0xfd23[7]](500)[_0xfd23[6]](_0x4950x5)} \ No newline at end of file diff --git a/server/api/chat_visitor/chat_visitor.socket.js b/server/api/chat_visitor/chat_visitor.socket.js index a283bfc..0d91b98 100644 --- a/server/api/chat_visitor/chat_visitor.socket.js +++ b/server/api/chat_visitor/chat_visitor.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var chat_visitor = require('../../models').ChatVisitor; - -exports.register = function(socket) { - chat_visitor.afterCreate(function(doc) { - onSave(socket, doc); - }); - chat_visitor.afterUpdate(function(doc) { - onSave(socket, doc); - }); - chat_visitor.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('chat_visitor:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('chat_visitor:remove', doc); -} +var _0x1367=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x68\x61\x74\x5F\x76\x69\x73\x69\x74\x6F\x72\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x68\x61\x74\x5F\x76\x69\x73\x69\x74\x6F\x72\x3A\x72\x65\x6D\x6F\x76\x65"];_0x1367[0];var chat_visitor=require(_0x1367[2])[_0x1367[1]];exports[_0x1367[3]]=function(_0xaddcx2){chat_visitor[_0x1367[4]](function(_0xaddcx3){onSave(_0xaddcx2,_0xaddcx3)});chat_visitor[_0x1367[5]](function(_0xaddcx3){onSave(_0xaddcx2,_0xaddcx3)});chat_visitor[_0x1367[6]](function(_0xaddcx3){onRemove(_0xaddcx2,_0xaddcx3)});};function onSave(_0xaddcx2,_0xaddcx3,_0xaddcx5){_0xaddcx2[_0x1367[8]](_0x1367[7],_0xaddcx3)}function onRemove(_0xaddcx2,_0xaddcx3,_0xaddcx5){_0xaddcx2[_0x1367[8]](_0x1367[9],_0xaddcx3)} \ No newline at end of file diff --git a/server/api/chat_visitor/chat_visitor.spec.js b/server/api/chat_visitor/chat_visitor.spec.js index ff6cda5..85d5a86 100644 --- a/server/api/chat_visitor/chat_visitor.spec.js +++ b/server/api/chat_visitor/chat_visitor.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/visitors', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/visitors') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xe27b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x76\x69\x73\x69\x74\x6F\x72\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x76\x69\x73\x69\x74\x6F\x72\x73","\x67\x65\x74"];_0xe27b[0];var should=require(_0xe27b[1]);var app=require(_0xe27b[2]);var request=require(_0xe27b[3]);describe(_0xe27b[4],function(){it(_0xe27b[5],function(_0x5469x4){request(app)[_0xe27b[13]](_0xe27b[12])[_0xe27b[11]](200)[_0xe27b[11]](_0xe27b[10],/json/)[_0xe27b[9]](function(_0x5469x5,_0x5469x6){if(_0x5469x5){return _0x5469x4(_0x5469x5)};_0x5469x6[_0xe27b[8]][_0xe27b[1]][_0xe27b[7]][_0xe27b[6]](Array);_0x5469x4();})})}); \ No newline at end of file diff --git a/server/api/chat_visitor/index.js b/server/api/chat_visitor/index.js index 4a30e42..89fe538 100644 --- a/server/api/chat_visitor/index.js +++ b/server/api/chat_visitor/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./chat_visitor.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x22a0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x68\x61\x74\x5F\x76\x69\x73\x69\x74\x6F\x72\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x22a0[0];var express=require(_0x22a0[1]);var controller=require(_0x22a0[2]);var router=express.Router();router[_0x22a0[5]](_0x22a0[3],controller[_0x22a0[4]]);router[_0x22a0[5]](_0x22a0[6],controller[_0x22a0[7]]);router[_0x22a0[9]](_0x22a0[3],controller[_0x22a0[8]]);router[_0x22a0[11]](_0x22a0[6],controller[_0x22a0[10]]);router[_0x22a0[12]](_0x22a0[6],controller[_0x22a0[10]]);router[_0x22a0[14]](_0x22a0[6],controller[_0x22a0[13]]);module[_0x22a0[15]]=router; \ No newline at end of file diff --git a/server/api/chat_website/chat_website.controller.js b/server/api/chat_website/chat_website.controller.js index b9339a4..820c4c5 100644 --- a/server/api/chat_website/chat_website.controller.js +++ b/server/api/chat_website/chat_website.controller.js @@ -1,269 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var async = require('async'); -var Mustache = require('mustache'); - -var sequelize = require('../../models').sequelize; -var ChatWebsite = require('../../models').ChatWebsite; -var ChatApplication = require('../../models').ChatApplication; -var snippet = require('../../components/xchatty').snippet; - -// Get list of chat_websites -exports.index = function (req, res, next) { - - var attributes = ['name', 'address', 'description', 'remote']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function (value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function (attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - ChatWebsite - .findAndCountAll(query) - .then(function (result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function (err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single chat_website -exports.show = function (req, res) { - ChatWebsite - .findById(req.params.id) - .then(function (chat_website) { - if (!chat_website) { - return res.sendStatus(404); - } - return res.send(chat_website); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a snippet for chat_website -exports.getSnippetCode = function (req, res) { - ChatWebsite - .findById(req.params.id) - .then(function (chat_website) { - var configSnippet = { - remote: chat_website.remote, - websiteId: req.params.id - }; - var html = Mustache.render(snippet, configSnippet); - return res.send(html); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new chat_website in the DB. -exports.create = function (req, res) { - ChatWebsite - .create(req.body) - .then(function (chat_website) { - return res.status(201).send(chat_website); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing chat_website in the DB. -exports.update = function (req, res) { - if (req.body.id) { - delete req.body.id; - } - - return ChatWebsite - .findById(req.params.id) - .then(function (chat_website) { - if (!chat_website) { - return res.sendStatus(404); - } - - return chat_website - .update(req.body) - .then(function (chat_website) { - return res.status(200).send(chat_website); - }) - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a chat_website from the DB. -exports.destroy = function (req, res) { - ChatWebsite - .find({ - where: { - id: req.params.id - } - }) - .then(function (chat_website) { - if (!chat_website) { - return res.sendStatus(404); - } - chat_website.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Sort Mail Applications -exports.sortApplications = function (req, res, next) { - - ChatApplication - .findAll({ - where: { - id: req.body.applications - } - }) - .then(function (chatApplications) { - var tmpChatApplications = chatApplications; - - async.waterfall([ - function (callback) { - ChatApplication - .destroy({ - where: { - id: req.body.applications - } - }).then(function () { - callback(); - }) - .catch(function (err) { - callback(err); - }); - }, - function (callback) { - var sortedApplications = []; - for (var i = 0; i < req.body.applications.length; i++) { - var tmpChatApplication = _.find(tmpChatApplications, { - 'id': req.body.applications[i] - }); - if (tmpChatApplication) { - tmpChatApplication.priority = i + 1; - sortedApplications.push(tmpChatApplication.dataValues); - } - } - - ChatApplication - .bulkCreate(sortedApplications) - .then(function () { - callback(); - }) - .catch(function (err) { - callback(err); - }); - }, - function (callback) { - ChatApplication - .findAll({ - where: { - id: req.body.applications - }, - order: 'priority', - include: [{ - all: true - }] - }) - .then(function (chatApplications) { - callback(null, chatApplications); - }) - .catch(function (err) { - callback(err); - }); - } - ], function (err, result) { - if (err) { - return handleError(res, err); - } else { - return res.status(201).send(result); - } - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function (req, res) { - ChatWebsite - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x8029=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x61\x73\x79\x6E\x63","\x6D\x75\x73\x74\x61\x63\x68\x65","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x73\x6E\x69\x70\x70\x65\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x2F\x78\x63\x68\x61\x74\x74\x79","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x61\x64\x64\x72\x65\x73\x73","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x72\x65\x6D\x6F\x74\x65","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x67\x65\x74\x53\x6E\x69\x70\x70\x65\x74\x43\x6F\x64\x65","\x72\x65\x6E\x64\x65\x72","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x73\x6F\x72\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x6C\x65\x6E\x67\x74\x68","\x70\x72\x69\x6F\x72\x69\x74\x79","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x77\x61\x74\x65\x72\x66\x61\x6C\x6C","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x8029[0];var _=require(_0x8029[1]);var util=require(_0x8029[2]);var async=require(_0x8029[3]);var Mustache=require(_0x8029[4]);var sequelize=require(_0x8029[6])[_0x8029[5]];var ChatWebsite=require(_0x8029[6])[_0x8029[7]];var ChatApplication=require(_0x8029[6])[_0x8029[8]];var snippet=require(_0x8029[10])[_0x8029[9]];exports[_0x8029[11]]=function(_0x7fbcx9,_0x7fbcxa,_0x7fbcxb){var _0x7fbcxc=[_0x8029[12],_0x8029[13],_0x8029[14],_0x8029[15]];var _0x7fbcxd=_0x7fbcx9[_0x8029[17]][_0x8029[16]]?parseInt(_0x7fbcx9[_0x8029[17]][_0x8029[16]],10):100;var _0x7fbcxe=_0x7fbcx9[_0x8029[17]][_0x8029[18]]?parseInt(_0x7fbcx9[_0x8029[17]][_0x8029[18]],10):0;var _0x7fbcxf={where:{},limit:_0x7fbcxd,offset:_0x7fbcxe*_0x7fbcxd};_[_0x8029[32]](_0x7fbcx9[_0x8029[17]],function(_0x7fbcx10,_0x7fbcx11){switch(_0x7fbcx11){case _0x8029[16]:;case _0x8029[18]:break ;;case _0x8029[21]:_0x7fbcxf[_0x8029[19]]=util[_0x8029[24]](_0x8029[20],_0x7fbcx9[_0x8029[17]][_0x8029[21]],_0x7fbcx9[_0x8029[17]][_0x8029[22]]||_0x8029[23])||null;break ;;case _0x8029[22]:break ;;case _0x8029[30]:_0x7fbcxf[_0x8029[26]][_0x8029[25]]=[];_0x7fbcxc[_0x8029[29]](function(_0x7fbcx12){var _0x7fbcx13={};_0x7fbcx13[_0x7fbcx12]={$like:_0x8029[27]+_0x7fbcx10+_0x8029[27]};_0x7fbcxf[_0x8029[26]][_0x8029[25]][_0x8029[28]](_0x7fbcx13);});break ;;default:_0x7fbcxf[_0x8029[26]][_0x7fbcx11]={$like:{}};_0x7fbcxf[_0x8029[26]][_0x7fbcx11][_0x8029[31]]=_0x8029[27]+_0x7fbcx10+_0x8029[27];;}});ChatWebsite[_0x8029[47]](_0x7fbcxf)[_0x8029[46]](function(_0x7fbcx15){var _0x7fbcx16=Math[_0x8029[38]](_0x7fbcx15[_0x8029[37]]/_0x7fbcxd);var _0x7fbcx17=_0x7fbcx16>(_0x7fbcxf[_0x8029[39]]+1)?util[_0x8029[24]](_0x8029[40],_0x7fbcx9[_0x8029[41]],_0x7fbcx9[_0x8029[43]][_0x8029[42]],_0x7fbcx9[_0x8029[44]],_0x7fbcxe+1):null;var _0x7fbcx18=_0x7fbcxe>0?util[_0x8029[24]](_0x8029[40],_0x7fbcx9[_0x8029[41]],_0x7fbcx9[_0x8029[43]][_0x8029[42]],_0x7fbcx9[_0x8029[44]],_0x7fbcxe-1):null;_0x7fbcxa[_0x8029[35]](200)[_0x8029[34]]({count:_0x7fbcx15[_0x8029[37]],rows:_0x7fbcx15[_0x8029[45]],next_page:_0x7fbcx17,previous_page:_0x7fbcx18,total_pages:_0x7fbcx16});})[_0x8029[36]](function(_0x7fbcx14){_0x7fbcxa[_0x8029[35]](500)[_0x8029[34]]({error:_0x8029[33]})});};exports[_0x8029[48]]=function(_0x7fbcx9,_0x7fbcxa){ChatWebsite[_0x8029[52]](_0x7fbcx9[_0x8029[51]][_0x8029[50]])[_0x8029[46]](function(_0x7fbcx19){if(!_0x7fbcx19){return _0x7fbcxa[_0x8029[49]](404)};return _0x7fbcxa[_0x8029[34]](_0x7fbcx19);})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)})};exports[_0x8029[53]]=function(_0x7fbcx9,_0x7fbcxa){ChatWebsite[_0x8029[52]](_0x7fbcx9[_0x8029[51]][_0x8029[50]])[_0x8029[46]](function(_0x7fbcx19){var _0x7fbcx1a={remote:_0x7fbcx19[_0x8029[15]],websiteId:_0x7fbcx9[_0x8029[51]][_0x8029[50]]};var _0x7fbcx1b=Mustache[_0x8029[54]](snippet,_0x7fbcx1a);return _0x7fbcxa[_0x8029[34]](_0x7fbcx1b);})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)})};exports[_0x8029[55]]=function(_0x7fbcx9,_0x7fbcxa){ChatWebsite[_0x8029[55]](_0x7fbcx9[_0x8029[56]])[_0x8029[46]](function(_0x7fbcx19){return _0x7fbcxa[_0x8029[35]](201)[_0x8029[34]](_0x7fbcx19)})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)})};exports[_0x8029[57]]=function(_0x7fbcx9,_0x7fbcxa){if(_0x7fbcx9[_0x8029[56]][_0x8029[50]]){delete _0x7fbcx9[_0x8029[56]][_0x8029[50]]};return ChatWebsite[_0x8029[52]](_0x7fbcx9[_0x8029[51]][_0x8029[50]])[_0x8029[46]](function(_0x7fbcx19){if(!_0x7fbcx19){return _0x7fbcxa[_0x8029[49]](404)};return _0x7fbcx19[_0x8029[57]](_0x7fbcx9[_0x8029[56]])[_0x8029[46]](function(_0x7fbcx19){return _0x7fbcxa[_0x8029[35]](200)[_0x8029[34]](_0x7fbcx19)});})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)});};exports[_0x8029[58]]=function(_0x7fbcx9,_0x7fbcxa){ChatWebsite[_0x8029[59]]({where:{id:_0x7fbcx9[_0x8029[51]][_0x8029[50]]}})[_0x8029[46]](function(_0x7fbcx19){if(!_0x7fbcx19){return _0x7fbcxa[_0x8029[49]](404)};_0x7fbcx19[_0x8029[58]]()[_0x8029[46]](function(){return _0x7fbcxa[_0x8029[49]](204)})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)});})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)})};exports[_0x8029[60]]=function(_0x7fbcx9,_0x7fbcxa,_0x7fbcxb){ChatApplication[_0x8029[66]]({where:{id:_0x7fbcx9[_0x8029[56]][_0x8029[61]]}})[_0x8029[46]](function(_0x7fbcx1c){var _0x7fbcx1d=_0x7fbcx1c;async[_0x8029[67]]([function(_0x7fbcx1e){ChatApplication[_0x8029[58]]({where:{id:_0x7fbcx9[_0x8029[56]][_0x8029[61]]}})[_0x8029[46]](function(){_0x7fbcx1e()})[_0x8029[36]](function(_0x7fbcx14){_0x7fbcx1e(_0x7fbcx14)})},function(_0x7fbcx1e){var _0x7fbcx1f=[];for(var _0x7fbcx20=0;_0x7fbcx20<_0x7fbcx9[_0x8029[56]][_0x8029[61]][_0x8029[62]];_0x7fbcx20++){var _0x7fbcx21=_[_0x8029[59]](_0x7fbcx1d,{"\x69\x64":_0x7fbcx9[_0x8029[56]][_0x8029[61]][_0x7fbcx20]});if(_0x7fbcx21){_0x7fbcx21[_0x8029[63]]=_0x7fbcx20+1;_0x7fbcx1f[_0x8029[28]](_0x7fbcx21[_0x8029[64]]);};};ChatApplication[_0x8029[65]](_0x7fbcx1f)[_0x8029[46]](function(){_0x7fbcx1e()})[_0x8029[36]](function(_0x7fbcx14){_0x7fbcx1e(_0x7fbcx14)});},function(_0x7fbcx1e){ChatApplication[_0x8029[66]]({where:{id:_0x7fbcx9[_0x8029[56]][_0x8029[61]]},order:_0x8029[63],include:[{all:true}]})[_0x8029[46]](function(_0x7fbcx1c){_0x7fbcx1e(null,_0x7fbcx1c)})[_0x8029[36]](function(_0x7fbcx14){_0x7fbcx1e(_0x7fbcx14)})}],function(_0x7fbcx14,_0x7fbcx15){if(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)}else {return _0x7fbcxa[_0x8029[35]](201)[_0x8029[34]](_0x7fbcx15)}});})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)})};exports[_0x8029[68]]=function(_0x7fbcx9,_0x7fbcxa){ChatWebsite[_0x8029[58]]({where:{id:_0x7fbcx9[_0x8029[17]][_0x8029[50]]},individualHooks:true})[_0x8029[46]](function(){return _0x7fbcxa[_0x8029[49]](204)})[_0x8029[36]](function(_0x7fbcx14){return handleError(_0x7fbcxa,_0x7fbcx14)})};function handleError(_0x7fbcxa,_0x7fbcx14){return _0x7fbcxa[_0x8029[35]](500)[_0x8029[34]](_0x7fbcx14)} \ No newline at end of file diff --git a/server/api/chat_website/chat_website.socket.js b/server/api/chat_website/chat_website.socket.js index 49f62d6..3d99fb0 100644 --- a/server/api/chat_website/chat_website.socket.js +++ b/server/api/chat_website/chat_website.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var chat_website = require('../../models').ChatWebsite; - -exports.register = function(socket) { - chat_website.afterCreate(function (doc) { - onSave(socket, doc); - }); - chat_website.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('chat_website:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('chat_website:remove', doc); -} +var _0x7737=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x68\x61\x74\x5F\x77\x65\x62\x73\x69\x74\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x68\x61\x74\x5F\x77\x65\x62\x73\x69\x74\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x7737[0];var chat_website=require(_0x7737[2])[_0x7737[1]];exports[_0x7737[3]]=function(_0x212bx2){chat_website[_0x7737[4]](function(_0x212bx3){onSave(_0x212bx2,_0x212bx3)});chat_website[_0x7737[5]](function(_0x212bx3){onRemove(_0x212bx2,_0x212bx3)});};function onSave(_0x212bx2,_0x212bx3,_0x212bx5){_0x212bx2[_0x7737[7]](_0x7737[6],_0x212bx3)}function onRemove(_0x212bx2,_0x212bx3,_0x212bx5){_0x212bx2[_0x7737[7]](_0x7737[8],_0x212bx3)} \ No newline at end of file diff --git a/server/api/chat_website/chat_website.spec.js b/server/api/chat_website/chat_website.spec.js index 4fd8b11..6a615d9 100644 --- a/server/api/chat_website/chat_website.spec.js +++ b/server/api/chat_website/chat_website.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/websites', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/websites') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x3f0d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x77\x65\x62\x73\x69\x74\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x77\x65\x62\x73\x69\x74\x65\x73","\x67\x65\x74"];_0x3f0d[0];var should=require(_0x3f0d[1]);var app=require(_0x3f0d[2]);var request=require(_0x3f0d[3]);describe(_0x3f0d[4],function(){it(_0x3f0d[5],function(_0x692bx4){request(app)[_0x3f0d[13]](_0x3f0d[12])[_0x3f0d[11]](200)[_0x3f0d[11]](_0x3f0d[10],/json/)[_0x3f0d[9]](function(_0x692bx5,_0x692bx6){if(_0x692bx5){return _0x692bx4(_0x692bx5)};_0x692bx6[_0x3f0d[8]][_0x3f0d[1]][_0x3f0d[7]][_0x3f0d[6]](Array);_0x692bx4();})})}); \ No newline at end of file diff --git a/server/api/chat_website/index.js b/server/api/chat_website/index.js index c175aaf..0c4ac2f 100644 --- a/server/api/chat_website/index.js +++ b/server/api/chat_website/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./chat_website.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/snippet', auth.isAuthenticated(), controller.getSnippetCode); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/:id/applications', auth.isAuthenticated(), controller.sortApplications); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x1c9f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x68\x61\x74\x5F\x77\x65\x62\x73\x69\x74\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x73\x6E\x69\x70\x70\x65\x74","\x67\x65\x74\x53\x6E\x69\x70\x70\x65\x74\x43\x6F\x64\x65","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x3A\x69\x64\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x73\x6F\x72\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x1c9f[0];var express=require(_0x1c9f[1]);var controller=require(_0x1c9f[2]);var auth=require(_0x1c9f[3]);var router=express.Router();router[_0x1c9f[7]](_0x1c9f[4],auth[_0x1c9f[5]](),controller[_0x1c9f[6]]);router[_0x1c9f[7]](_0x1c9f[8],auth[_0x1c9f[5]](),controller[_0x1c9f[9]]);router[_0x1c9f[7]](_0x1c9f[10],auth[_0x1c9f[5]](),controller[_0x1c9f[11]]);router[_0x1c9f[13]](_0x1c9f[4],auth[_0x1c9f[5]](),controller[_0x1c9f[12]]);router[_0x1c9f[13]](_0x1c9f[14],auth[_0x1c9f[5]](),controller[_0x1c9f[15]]);router[_0x1c9f[17]](_0x1c9f[8],auth[_0x1c9f[5]](),controller[_0x1c9f[16]]);router[_0x1c9f[18]](_0x1c9f[8],auth[_0x1c9f[5]](),controller[_0x1c9f[16]]);router[_0x1c9f[20]](_0x1c9f[4],auth[_0x1c9f[5]](),controller[_0x1c9f[19]]);router[_0x1c9f[20]](_0x1c9f[8],auth[_0x1c9f[5]](),controller[_0x1c9f[21]]);module[_0x1c9f[22]]=router; \ No newline at end of file diff --git a/server/api/company/company.controller.js b/server/api/company/company.controller.js index 0e92164..8db8898 100644 --- a/server/api/company/company.controller.js +++ b/server/api/company/company.controller.js @@ -1,209 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Company = require('../../models').Company; -var util = require('util'); - -// Get list of companies -exports.index = function(req, res) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Company - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -exports.companyValidation = function(req, res) { - console.log(req.body); - Company - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(companies) { - if (!companies) { - return res.sendStatus(404); - } - return res.send(companies); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single company -exports.show = function(req, res) { - Company - .findById(req.params.id) - .then(function(company) { - if (!company) { - return res.sendStatus(404); - } - return res.send(company); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new company in the DB. -exports.create = function(req, res) { - Company - .create(req.body) - .then(function(company) { - return res.status(201).send(company); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing company in the DB. -exports.update = function(req, res) { - Company - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(companies) { - if (!companies) { - return res.sendStatus(404); - } - if (companies.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_COMPANY' - }) - } - if (req.body.id) { - delete req.body.id; - } - Company - .find({ - where: { - id: req.params.id - } - }) - .then(function(company) { - if (!company) { - return res.sendStatus(404); - } - var updated = _.merge(company, req.body); - updated.save() - .then(function() { - return res.status(200).send(company); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a company from the DB. -exports.destroy = function(req, res) { - Company - .findById(req.params.id) - .then(function(company) { - if (!company) { - return res.sendStatus(404); - } - company.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDestroy = function(req, res) { - Company - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x6fa9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x6F\x6D\x70\x61\x6E\x79","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x63\x6F\x6D\x70\x61\x6E\x79\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x43\x4F\x4D\x50\x41\x4E\x59","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x6fa9[0];var _=require(_0x6fa9[1]);var Company=require(_0x6fa9[3])[_0x6fa9[2]];var util=require(_0x6fa9[4]);exports[_0x6fa9[5]]=function(_0x2d12x4,_0x2d12x5){var _0x2d12x6=[_0x6fa9[6],_0x6fa9[7]];var _0x2d12x7=_0x2d12x4[_0x6fa9[9]][_0x6fa9[8]]?parseInt(_0x2d12x4[_0x6fa9[9]][_0x6fa9[8]],10):100;var _0x2d12x8=_0x2d12x4[_0x6fa9[9]][_0x6fa9[10]]?parseInt(_0x2d12x4[_0x6fa9[9]][_0x6fa9[10]],10):0;var _0x2d12x9={where:{},limit:_0x2d12x7,offset:_0x2d12x8*_0x2d12x7};_[_0x6fa9[24]](_0x2d12x4[_0x6fa9[9]],function(_0x2d12xa,_0x2d12xb){switch(_0x2d12xb){case _0x6fa9[8]:;case _0x6fa9[10]:break ;;case _0x6fa9[13]:_0x2d12x9[_0x6fa9[11]]=util[_0x6fa9[16]](_0x6fa9[12],_0x2d12x4[_0x6fa9[9]][_0x6fa9[13]],_0x2d12x4[_0x6fa9[9]][_0x6fa9[14]]||_0x6fa9[15])||null;break ;;case _0x6fa9[14]:break ;;case _0x6fa9[22]:_0x2d12x9[_0x6fa9[18]][_0x6fa9[17]]=[];_0x2d12x6[_0x6fa9[21]](function(_0x2d12xc){var _0x2d12xd={};_0x2d12xd[_0x2d12xc]={$like:_0x6fa9[19]+_0x2d12xa+_0x6fa9[19]};_0x2d12x9[_0x6fa9[18]][_0x6fa9[17]][_0x6fa9[20]](_0x2d12xd);});break ;;default:_0x2d12x9[_0x6fa9[18]][_0x2d12xb]={$like:{}};_0x2d12x9[_0x6fa9[18]][_0x2d12xb][_0x6fa9[23]]=_0x6fa9[19]+_0x2d12xa+_0x6fa9[19];;}});Company[_0x6fa9[39]](_0x2d12x9)[_0x6fa9[38]](function(_0x2d12xf){var _0x2d12x10=Math[_0x6fa9[30]](_0x2d12xf[_0x6fa9[29]]/_0x2d12x7);var _0x2d12x11=_0x2d12x10>(_0x2d12x9[_0x6fa9[31]]+1)?util[_0x6fa9[16]](_0x6fa9[32],_0x2d12x4[_0x6fa9[33]],_0x2d12x4[_0x6fa9[35]][_0x6fa9[34]],_0x2d12x4[_0x6fa9[36]],_0x2d12x8+1):null;var _0x2d12x12=_0x2d12x8>0?util[_0x6fa9[16]](_0x6fa9[32],_0x2d12x4[_0x6fa9[33]],_0x2d12x4[_0x6fa9[35]][_0x6fa9[34]],_0x2d12x4[_0x6fa9[36]],_0x2d12x8-1):null;_0x2d12x5[_0x6fa9[27]](200)[_0x6fa9[26]]({count:_0x2d12xf[_0x6fa9[29]],rows:_0x2d12xf[_0x6fa9[37]],next_page:_0x2d12x11,previous_page:_0x2d12x12,total_pages:_0x2d12x10});})[_0x6fa9[28]](function(_0x2d12xe){_0x2d12x5[_0x6fa9[27]](500)[_0x6fa9[26]]({error:_0x6fa9[25]})});};exports[_0x6fa9[40]]=function(_0x2d12x4,_0x2d12x5){console[_0x6fa9[42]](_0x2d12x4[_0x6fa9[41]]);Company[_0x6fa9[44]]({where:{name:_0x2d12x4[_0x6fa9[41]][_0x6fa9[6]]}})[_0x6fa9[38]](function(_0x2d12x13){if(!_0x2d12x13){return _0x2d12x5[_0x6fa9[43]](404)};return _0x2d12x5[_0x6fa9[26]](_0x2d12x13);})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)});};exports[_0x6fa9[45]]=function(_0x2d12x4,_0x2d12x5){Company[_0x6fa9[48]](_0x2d12x4[_0x6fa9[47]][_0x6fa9[46]])[_0x6fa9[38]](function(_0x2d12x14){if(!_0x2d12x14){return _0x2d12x5[_0x6fa9[43]](404)};return _0x2d12x5[_0x6fa9[26]](_0x2d12x14);})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)})};exports[_0x6fa9[49]]=function(_0x2d12x4,_0x2d12x5){Company[_0x6fa9[49]](_0x2d12x4[_0x6fa9[41]])[_0x6fa9[38]](function(_0x2d12x14){return _0x2d12x5[_0x6fa9[27]](201)[_0x6fa9[26]](_0x2d12x14)})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)})};exports[_0x6fa9[50]]=function(_0x2d12x4,_0x2d12x5){Company[_0x6fa9[44]]({where:{name:_0x2d12x4[_0x6fa9[41]][_0x6fa9[6]],id:{$ne:_0x2d12x4[_0x6fa9[41]][_0x6fa9[46]]}}})[_0x6fa9[38]](function(_0x2d12x13){if(!_0x2d12x13){return _0x2d12x5[_0x6fa9[43]](404)};if(_0x2d12x13[_0x6fa9[51]]>0){return _0x2d12x5[_0x6fa9[27]](500)[_0x6fa9[26]]({message:_0x6fa9[52]})};if(_0x2d12x4[_0x6fa9[41]][_0x6fa9[46]]){delete _0x2d12x4[_0x6fa9[41]][_0x6fa9[46]]};Company[_0x6fa9[55]]({where:{id:_0x2d12x4[_0x6fa9[47]][_0x6fa9[46]]}})[_0x6fa9[38]](function(_0x2d12x14){if(!_0x2d12x14){return _0x2d12x5[_0x6fa9[43]](404)};var _0x2d12x15=_[_0x6fa9[53]](_0x2d12x14,_0x2d12x4[_0x6fa9[41]]);_0x2d12x15[_0x6fa9[54]]()[_0x6fa9[38]](function(){return _0x2d12x5[_0x6fa9[27]](200)[_0x6fa9[26]](_0x2d12x14)})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)});})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)});})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)})};exports[_0x6fa9[56]]=function(_0x2d12x4,_0x2d12x5){Company[_0x6fa9[48]](_0x2d12x4[_0x6fa9[47]][_0x6fa9[46]])[_0x6fa9[38]](function(_0x2d12x14){if(!_0x2d12x14){return _0x2d12x5[_0x6fa9[43]](404)};_0x2d12x14[_0x6fa9[56]]()[_0x6fa9[38]](function(){return _0x2d12x5[_0x6fa9[43]](204)})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)});})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)})};exports[_0x6fa9[57]]=function(_0x2d12x4,_0x2d12x5){Company[_0x6fa9[56]]({where:{id:_0x2d12x4[_0x6fa9[9]][_0x6fa9[46]]},individualHooks:true})[_0x6fa9[38]](function(){return _0x2d12x5[_0x6fa9[43]](204)})[_0x6fa9[28]](function(_0x2d12xe){return handleError(_0x2d12x5,_0x2d12xe)})};function handleError(_0x2d12x5,_0x2d12xe){return _0x2d12x5[_0x6fa9[27]](500)[_0x6fa9[26]](_0x2d12xe)} \ No newline at end of file diff --git a/server/api/company/company.socket.js b/server/api/company/company.socket.js index 850be4a..c031a51 100644 --- a/server/api/company/company.socket.js +++ b/server/api/company/company.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Company = require('../../models').Company; - -exports.register = function(socket) { - Company.afterCreate(function(doc) { - onSave(socket, doc); - }); - Company.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('company:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('company:remove', doc); -} +var _0x9b48=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x6F\x6D\x70\x61\x6E\x79","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x6F\x6D\x70\x61\x6E\x79\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x6F\x6D\x70\x61\x6E\x79\x3A\x72\x65\x6D\x6F\x76\x65"];_0x9b48[0];var Company=require(_0x9b48[2])[_0x9b48[1]];exports[_0x9b48[3]]=function(_0x1930x2){Company[_0x9b48[4]](function(_0x1930x3){onSave(_0x1930x2,_0x1930x3)});Company[_0x9b48[5]](function(_0x1930x3){onRemove(_0x1930x2,_0x1930x3)});};function onSave(_0x1930x2,_0x1930x3,_0x1930x5){_0x1930x2[_0x9b48[7]](_0x9b48[6],_0x1930x3)}function onRemove(_0x1930x2,_0x1930x3,_0x1930x5){_0x1930x2[_0x9b48[7]](_0x9b48[8],_0x1930x3)} \ No newline at end of file diff --git a/server/api/company/company.spec.js b/server/api/company/company.spec.js index 37c8889..29acb95 100644 --- a/server/api/company/company.spec.js +++ b/server/api/company/company.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/contactmanager/companies', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/contactmanager/companies') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0xb245=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72\x2F\x63\x6F\x6D\x70\x61\x6E\x69\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72\x2F\x63\x6F\x6D\x70\x61\x6E\x69\x65\x73","\x67\x65\x74"];_0xb245[0];var should=require(_0xb245[1]);var app=require(_0xb245[2]);var request=require(_0xb245[3]);describe(_0xb245[4],function(){it(_0xb245[5],function(_0x204ax4){request(app)[_0xb245[13]](_0xb245[12])[_0xb245[11]](200)[_0xb245[11]](_0xb245[10],/json/)[_0xb245[9]](function(_0x204ax5,_0x204ax6){if(_0x204ax5){return _0x204ax4(_0x204ax5)};_0x204ax6[_0xb245[8]][_0xb245[1]][_0xb245[7]][_0xb245[6]](Array);_0x204ax4();})})}); \ No newline at end of file diff --git a/server/api/company/index.js b/server/api/company/index.js index 734f562..a9a97cb 100644 --- a/server/api/company/index.js +++ b/server/api/company/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./company.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.companyValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0xba47=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x6F\x6D\x70\x61\x6E\x79\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x63\x6F\x6D\x70\x61\x6E\x79\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xba47[0];var express=require(_0xba47[1]);var controller=require(_0xba47[2]);var auth=require(_0xba47[3]);var router=express.Router();router[_0xba47[7]](_0xba47[4],auth[_0xba47[5]](),controller[_0xba47[6]]);router[_0xba47[7]](_0xba47[8],auth[_0xba47[5]](),controller[_0xba47[9]]);router[_0xba47[11]](_0xba47[4],auth[_0xba47[5]](),controller[_0xba47[10]]);router[_0xba47[11]](_0xba47[12],auth[_0xba47[5]](),controller[_0xba47[13]]);router[_0xba47[15]](_0xba47[8],auth[_0xba47[5]](),controller[_0xba47[14]]);router[_0xba47[16]](_0xba47[8],auth[_0xba47[5]](),controller[_0xba47[14]]);router[_0xba47[18]](_0xba47[4],auth[_0xba47[5]](),controller[_0xba47[17]]);router[_0xba47[18]](_0xba47[8],auth[_0xba47[5]](),controller[_0xba47[19]]);module[_0xba47[20]]=router; \ No newline at end of file diff --git a/server/api/contact/contact.controller.js b/server/api/contact/contact.controller.js index 1948319..8779d75 100644 --- a/server/api/contact/contact.controller.js +++ b/server/api/contact/contact.controller.js @@ -1,85 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Contact = require('../../models').Contact; - -// Get list of contacts -exports.index = function(req, res) { - Contact - .findAll() - .then(function (contacts) { - return res.status(200).send(contacts); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single contact -exports.show = function(req, res) { - Contact - .findById(req.params.id) - .then(function (contact) { - if(!contact) { return res.sendStatus(404); } - return res.send(contact); - }) - .catch(function(err){ - return handleError(res, err); - }); -}; - -// Creates a new contact in the DB. -exports.create = function(req, res) { - Contact - .create(req.body) - .then(function(contact) { - return res.status(201).send(contact); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing contact in the DB. -exports.update = function(req, res) { - if(req.body.id) { delete req.body.id; } - Contact - .findById(req.params.id) - .then(function (contact) { - if(!contact) { return res.sendStatus(404); } - var updated = _.merge(contact, req.body); - updated.save() - .then(function () { - return res.status(200).send(contact); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a contact from the DB. -exports.destroy = function(req, res) { - Contact - .findById(req.params.id) - .then(function (contact) { - if(!contact) { return res.sendStatus(404); } - contact.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x9b01=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x9b01[0];var _=require(_0x9b01[1]);var Contact=require(_0x9b01[3])[_0x9b01[2]];exports[_0x9b01[4]]=function(_0xf9c0x3,_0xf9c0x4){Contact[_0x9b01[9]]()[_0x9b01[8]](function(_0xf9c0x6){return _0xf9c0x4[_0x9b01[7]](200)[_0x9b01[6]](_0xf9c0x6)})[_0x9b01[5]](function(_0xf9c0x5){return handleError(_0xf9c0x4,_0xf9c0x5)})};exports[_0x9b01[10]]=function(_0xf9c0x3,_0xf9c0x4){Contact[_0x9b01[14]](_0xf9c0x3[_0x9b01[13]][_0x9b01[12]])[_0x9b01[8]](function(_0xf9c0x7){if(!_0xf9c0x7){return _0xf9c0x4[_0x9b01[11]](404)};return _0xf9c0x4[_0x9b01[6]](_0xf9c0x7);})[_0x9b01[5]](function(_0xf9c0x5){return handleError(_0xf9c0x4,_0xf9c0x5)})};exports[_0x9b01[15]]=function(_0xf9c0x3,_0xf9c0x4){Contact[_0x9b01[15]](_0xf9c0x3[_0x9b01[16]])[_0x9b01[8]](function(_0xf9c0x7){return _0xf9c0x4[_0x9b01[7]](201)[_0x9b01[6]](_0xf9c0x7)})[_0x9b01[5]](function(_0xf9c0x5){return handleError(_0xf9c0x4,_0xf9c0x5)})};exports[_0x9b01[17]]=function(_0xf9c0x3,_0xf9c0x4){if(_0xf9c0x3[_0x9b01[16]][_0x9b01[12]]){delete _0xf9c0x3[_0x9b01[16]][_0x9b01[12]]};Contact[_0x9b01[14]](_0xf9c0x3[_0x9b01[13]][_0x9b01[12]])[_0x9b01[8]](function(_0xf9c0x7){if(!_0xf9c0x7){return _0xf9c0x4[_0x9b01[11]](404)};var _0xf9c0x8=_[_0x9b01[18]](_0xf9c0x7,_0xf9c0x3[_0x9b01[16]]);_0xf9c0x8[_0x9b01[19]]()[_0x9b01[8]](function(){return _0xf9c0x4[_0x9b01[7]](200)[_0x9b01[6]](_0xf9c0x7)})[_0x9b01[5]](function(_0xf9c0x5){return handleError(_0xf9c0x4,_0xf9c0x5)});})[_0x9b01[5]](function(_0xf9c0x5){return handleError(_0xf9c0x4,_0xf9c0x5)});};exports[_0x9b01[20]]=function(_0xf9c0x3,_0xf9c0x4){Contact[_0x9b01[14]](_0xf9c0x3[_0x9b01[13]][_0x9b01[12]])[_0x9b01[8]](function(_0xf9c0x7){if(!_0xf9c0x7){return _0xf9c0x4[_0x9b01[11]](404)};_0xf9c0x7[_0x9b01[20]]()[_0x9b01[8]](function(){return _0xf9c0x4[_0x9b01[11]](204)})[_0x9b01[5]](function(_0xf9c0x5){return handleError(_0xf9c0x4,_0xf9c0x5)});})[_0x9b01[5]](function(_0xf9c0x5){return handleError(_0xf9c0x4,_0xf9c0x5)})};function handleError(_0xf9c0x4,_0xf9c0x5){return _0xf9c0x4[_0x9b01[7]](500)[_0x9b01[6]](_0xf9c0x5)} \ No newline at end of file diff --git a/server/api/contact/contact.model.js b/server/api/contact/contact.model.js index e3414e8..2d4c204 100644 --- a/server/api/contact/contact.model.js +++ b/server/api/contact/contact.model.js @@ -1,13 +1 @@ -'use strict'; - -module.export = function(sequelize, DataTypes) { - - var Contact = sequelize.define('Contact', { - name: String, - info: String, - active: Boolean - }); - - return Contact; - -}; +var _0xac1b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x64\x65\x66\x69\x6E\x65"];_0xac1b[0];module[_0xac1b[1]]=function(_0x4596x1,_0x4596x2){var _0x4596x3=_0x4596x1[_0xac1b[3]](_0xac1b[2],{name:String,info:String,active:Boolean});return _0x4596x3;}; \ No newline at end of file diff --git a/server/api/contact/contact.socket.js b/server/api/contact/contact.socket.js index 849726b..3a7a67d 100644 --- a/server/api/contact/contact.socket.js +++ b/server/api/contact/contact.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var contact = require('../../models').Contact; - -exports.register = function(socket) { - contact.afterCreate(function (doc) { - onSave(socket, doc); - }); - contact.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('contact:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('contact:remove', doc); -} +var _0xfcfb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x6F\x6E\x74\x61\x63\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x6F\x6E\x74\x61\x63\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xfcfb[0];var contact=require(_0xfcfb[2])[_0xfcfb[1]];exports[_0xfcfb[3]]=function(_0x27e6x2){contact[_0xfcfb[4]](function(_0x27e6x3){onSave(_0x27e6x2,_0x27e6x3)});contact[_0xfcfb[5]](function(_0x27e6x3){onRemove(_0x27e6x2,_0x27e6x3)});};function onSave(_0x27e6x2,_0x27e6x3,_0x27e6x5){_0x27e6x2[_0xfcfb[7]](_0xfcfb[6],_0x27e6x3)}function onRemove(_0x27e6x2,_0x27e6x3,_0x27e6x5){_0x27e6x2[_0xfcfb[7]](_0xfcfb[8],_0x27e6x3)} \ No newline at end of file diff --git a/server/api/contact/contact.spec.js b/server/api/contact/contact.spec.js index a856862..f862c28 100644 --- a/server/api/contact/contact.spec.js +++ b/server/api/contact/contact.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/contacts', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/contacts') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x1063=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x73","\x67\x65\x74"];_0x1063[0];var should=require(_0x1063[1]);var app=require(_0x1063[2]);var request=require(_0x1063[3]);describe(_0x1063[4],function(){it(_0x1063[5],function(_0x8b78x4){request(app)[_0x1063[13]](_0x1063[12])[_0x1063[11]](200)[_0x1063[11]](_0x1063[10],/json/)[_0x1063[9]](function(_0x8b78x5,_0x8b78x6){if(_0x8b78x5){return _0x8b78x4(_0x8b78x5)};_0x8b78x6[_0x1063[8]][_0x1063[1]][_0x1063[7]][_0x1063[6]](Array);_0x8b78x4();})})}); \ No newline at end of file diff --git a/server/api/contact/index.js b/server/api/contact/index.js index 1b36b44..8f2e7ac 100644 --- a/server/api/contact/index.js +++ b/server/api/contact/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./contact.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x15a7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x6F\x6E\x74\x61\x63\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x15a7[0];var express=require(_0x15a7[1]);var controller=require(_0x15a7[2]);var router=express.Router();router[_0x15a7[5]](_0x15a7[3],controller[_0x15a7[4]]);router[_0x15a7[5]](_0x15a7[6],controller[_0x15a7[7]]);router[_0x15a7[9]](_0x15a7[3],controller[_0x15a7[8]]);router[_0x15a7[11]](_0x15a7[6],controller[_0x15a7[10]]);router[_0x15a7[12]](_0x15a7[6],controller[_0x15a7[10]]);router[_0x15a7[14]](_0x15a7[6],controller[_0x15a7[13]]);module[_0x15a7[15]]=router; \ No newline at end of file diff --git a/server/api/contact_manager/contact_manager.controller.js b/server/api/contact_manager/contact_manager.controller.js index 27e39f6..1a53bac 100644 --- a/server/api/contact_manager/contact_manager.controller.js +++ b/server/api/contact_manager/contact_manager.controller.js @@ -1,516 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Contact = require('../../models').Contact; -var ContactPhone = require('../../models').ContactPhone; -var ContactEmail = require('../../models').ContactEmail; -var CustomField = require('../../models').CustomField; -var ReportCall = require('../../models').ReportCall; -var ReportCallHistory = require('../../models').history.ReportCallHistory; -var ReportMailSession = require('../../models').ReportMailSession; -var ReportMailSessionHistory = require('../../models').history.ReportMailSessionHistory; -var Tag = require('../../models').Tag; -var stream = require('stream'); -var sequelize = require('../../models').sequelize; -var util = require('util'); - -// Get list of contacts -exports.index = function(req, res) { - - var attributes = ['name', 'surname', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - - Contact - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single managed_contact -exports.show = function(req, res) { - Contact - .findById(req.params.id, { - include: [{ - model: ContactPhone, - as: 'Phones', - include: [{ - model: ReportCall, - as: 'Inbounds', - include: [{ - all: true - }] - }, { - model: ReportCall, - as: 'Outbounds', - include: [{ - all: true - }] - }, { - model: ReportCallHistory, - as: 'HistoryInbounds', - include: [{ - all: true - }] - }, { - model: ReportCallHistory, - as: 'HistoryOutbounds', - include: [{ - all: true - }] - }] - }, { - model: ContactEmail, - as: 'Emails', - include: [{ - model: ReportMailSession, - as: 'InboundMessages', - include: [{ - all: true - }] - }, { - model: ReportMailSession, - as: 'OutboundMessages', - include: [{ - all: true - }] - }, { - model: ReportMailSessionHistory, - as: 'HistoryInboundMessages', - include: [{ - all: true - }] - }, { - model: ReportMailSessionHistory, - as: 'HistoryOutboundMessages', - include: [{ - all: true - }] - }] - }, { - model: CustomField, - as: 'CustomFields' - }] - }) - .then(function(managed_contact) { - if (!managed_contact) { - return res.sendStatus(404); - } - return res.send(managed_contact); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); -}; - -exports.getHistory = function(req, res) { - -}; - -// validate contact uniqueness -exports.contactValidation = function(req, res) { - Contact.findAll({ - where: { - $or: { - '$Phones.phone$': req.body.phones, - '$Emails.email$': req.body.emails - } - }, - include: [{ - all: true - }] - }) - .then(function(contacts) { - console.log(contacts); - return res.status(200).send(contacts); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); -}; - -// Creates a new managed_contact in the DB. -exports.create = function(req, res, next) { - var newPhones = [], - newEmails = [], - newCustomFields = {}; - Tag.findAll() - .then(function(tags) { - var newTags = []; - var tagList = _.pluck(_.pluck(tags, 'dataValues'), 'name'); - if (req.body.tags) { - var contactTags = req.body.tags.split(','); - contactTags.forEach(function(elem) { - if (!_.includes(tags, elem)) { - newTags.push({ - name: elem - }); - } - }); - if (newTags.length) { - Tag.bulkCreate(newTags, { - individualHooks: true - }); - } - } - req.body.UserId = req.user.id; - var phones = _.uniq(_.pluck(req.body.Phones, 'phone')); - var contactPhones = []; - phones.forEach(function(elem) { - contactPhones.push(ContactPhone.findOrCreate({ - where: { - phone: elem - }, - defaults: { - phone: elem - } - })); - }); - return contactPhones; - }) - .all() - .then(function(res) { - newPhones = _.map(res, function(elem) { - return elem[0]; - }); - - var contactEmails = []; - var emails = _.uniq(_.pluck(req.body.Emails, 'email')); - emails.forEach(function(elem) { - contactEmails.push(ContactEmail.findOrCreate({ - where: { - email: elem - }, - defaults: { - email: elem - } - })); - }); - return contactEmails; - }) - .all() - .then(function(res) { - newEmails = _.map(res, function(elem) { - return elem[0]; - }); - delete req.body.Phones; - delete req.body.Emails; - newCustomFields = _.clone(req.body.customFields); - delete req.body.customFields; - - return Contact.create(req.body); - }) - .then(function(contact) { - return [contact, contact.setPhones(newPhones)]; - }) - .spread(function(contact) { - return [contact, contact.setEmails(newEmails)]; - }) - .spread(function(contact) { - var customFieldsIds = _.keys(newCustomFields); - return [contact, CustomField.findAll({ - where: { - id: customFieldsIds - } - })]; - }) - .spread(function(contact, customFields) { - customFields.forEach(function(elem) { - elem.ContactHasCustomField = { - value: newCustomFields[String(elem.id)] - } - }); - return [contact, contact.setCustomFields(customFields)]; - }) - .spread(function(contact) { - return res.status(201).send(contact); - }) - .catch(function(err) { - console.log(err); - return next(err); - }); -}; - -// Updates an existing managed_contact in the DB. -exports.update = function(req, res, next) { - var newPhones = [], - newEmails = [], - newCustomFields = {}; - Tag.findAll() - .then(function(tags) { - var newTags = []; - var tagList = _.pluck(_.pluck(tags, 'dataValues'), 'name'); - if (req.body.tags) { - var contactTags = req.body.tags.split(','); - contactTags.forEach(function(elem) { - if (!_.includes(tags, elem)) { - newTags.push({ - name: elem - }); - } - }); - if (newTags.length) { - Tag.bulkCreate(newTags, { - individualHooks: true - }); - } - } - var contactPhones = []; - var phones = _.uniq(_.pluck(req.body.Phones, 'phone')); - phones.forEach(function(elem) { - contactPhones.push(ContactPhone.findOrCreate({ - where: { - phone: elem - }, - defaults: { - phone: elem - } - })); - }); - return contactPhones; - }) - .all() - .then(function(res) { - newPhones = _.map(res, function(elem) { - return elem[0]; - }); - - var contactEmails = []; - var emails = _.uniq(_.pluck(req.body.Emails, 'email')); - emails.forEach(function(elem) { - contactEmails.push(ContactEmail.findOrCreate({ - where: { - email: elem - }, - defaults: { - email: elem - } - })); - }); - return contactEmails; - }) - .all() - .then(function(res) { - newEmails = _.map(res, function(elem) { - return elem[0]; - }); - delete req.body.Phones; - delete req.body.Emails; - newCustomFields = _.clone(req.body.customFields); - delete req.body.customFields; - delete req.body.CustomFields; - var updateId = req.body.id; - delete req.body.id; - - return Contact.findById(updateId); - }) - .then(function(contact) { - return [contact, contact.setPhones(newPhones)]; - }) - .spread(function(contact) { - return [contact, contact.setEmails(newEmails)]; - }) - .spread(function(contact) { - var customFieldsIds = _.keys(newCustomFields); - return [contact, CustomField.findAll({ - where: { - id: customFieldsIds - } - })]; - }) - .spread(function(contact, customFields) { - customFields.forEach(function(elem) { - elem.ContactHasCustomField = { - value: newCustomFields[String(elem.id)] - } - }); - return [contact, contact.setCustomFields(customFields)]; - }) - .spread(function(contact) { - return contact.updateAttributes(req.body) - }) - .then(function(contact) { - return res.status(200).send(contact); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); -}; - -// // Join contacts info in the DB. -// exports.joinContacts = function(req, res, next) { -// if (req.body.tags) { -// Tag.findAll() -// .then(function(tags) { -// var newTags = []; -// var tagList = _.pluck(_.pluck(tags, 'dataValues'), 'name'); -// var contactTags = req.body.tags.split(','); -// contactTags.forEach(function(elem) { -// if (!_.includes(tags, elem)) { -// newTags.push({ -// name: elem -// }); -// } -// }); -// if (newTags.length) { -// Tag.bulkCreate(newTags, { -// individualHooks: true -// }); -// } -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// } -// var updateId = req.body.id; -// delete req.body.id; -// var phones = _.map(req.body.Phones, function(elem) { -// return { -// phone: elem.phone, -// ContactId: updateId -// }; -// }); -// var emails = _.map(req.body.Emails, function(elem) { -// return { -// email: elem.email, -// ContactId: updateId -// }; -// }); -// delete req.body.Phones; -// delete req.body.Emails; -// return sequelize.transaction(function(t) { -// return Contact.update(req.body, { -// where: { -// id: updateId -// } -// }, { -// transaction: t, -// include: [{ -// all: true -// }] -// }) -// .then(function(contact) { -// return ContactPhone -// .bulkCreate(phones, { -// transaction: t -// }) -// .then(function() { -// return ContactEmail -// .bulkCreate(emails, { -// transaction: t -// }) -// .then(function() { -// return Contact.findById(updateId, { -// transaction: t -// }) -// .then(function(contact) { -// return res.status(201).send(contact); -// }) -// }) -// }) -// }) -// }) -// .catch(function(err) { -// console.log(err); -// return next(err); -// }); -// }; - -// Deletes a managed_contact from the DB. -exports.destroy = function(req, res) { - Contact - .findById(req.params.id) - .then(function(managed_contact) { - if (!managed_contact) { - return res.sendStatus(404); - } - managed_contact.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a managed_contact from the DB. -exports.bulkDestroy = function(req, res) { - Contact - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x6db5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x6F\x6E\x74\x61\x63\x74\x50\x68\x6F\x6E\x65","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C\x48\x69\x73\x74\x6F\x72\x79","\x68\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E\x48\x69\x73\x74\x6F\x72\x79","\x54\x61\x67","\x73\x74\x72\x65\x61\x6D","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x73\x75\x72\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x50\x68\x6F\x6E\x65\x73","\x49\x6E\x62\x6F\x75\x6E\x64\x73","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x73","\x48\x69\x73\x74\x6F\x72\x79\x49\x6E\x62\x6F\x75\x6E\x64\x73","\x48\x69\x73\x74\x6F\x72\x79\x4F\x75\x74\x62\x6F\x75\x6E\x64\x73","\x45\x6D\x61\x69\x6C\x73","\x49\x6E\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x48\x69\x73\x74\x6F\x72\x79\x49\x6E\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x48\x69\x73\x74\x6F\x72\x79\x4F\x75\x74\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x67\x65\x74\x48\x69\x73\x74\x6F\x72\x79","\x63\x6F\x6E\x74\x61\x63\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x68\x6F\x6E\x65\x73","\x62\x6F\x64\x79","\x65\x6D\x61\x69\x6C\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x73\x70\x72\x65\x61\x64","\x43\x6F\x6E\x74\x61\x63\x74\x48\x61\x73\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x73\x65\x74\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x6B\x65\x79\x73","\x73\x65\x74\x45\x6D\x61\x69\x6C\x73","\x73\x65\x74\x50\x68\x6F\x6E\x65\x73","\x6D\x61\x70","\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x63\x6C\x6F\x6E\x65","\x61\x6C\x6C","\x65\x6D\x61\x69\x6C","\x70\x6C\x75\x63\x6B","\x75\x6E\x69\x71","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x74\x61\x67\x73","\x2C","\x73\x70\x6C\x69\x74","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x6C\x65\x6E\x67\x74\x68","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x55\x73\x65\x72\x49\x64","\x75\x73\x65\x72","\x70\x68\x6F\x6E\x65","\x75\x70\x64\x61\x74\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x6db5[0];var _=require(_0x6db5[1]);var Contact=require(_0x6db5[3])[_0x6db5[2]];var ContactPhone=require(_0x6db5[3])[_0x6db5[4]];var ContactEmail=require(_0x6db5[3])[_0x6db5[5]];var CustomField=require(_0x6db5[3])[_0x6db5[6]];var ReportCall=require(_0x6db5[3])[_0x6db5[7]];var ReportCallHistory=require(_0x6db5[3])[_0x6db5[9]][_0x6db5[8]];var ReportMailSession=require(_0x6db5[3])[_0x6db5[10]];var ReportMailSessionHistory=require(_0x6db5[3])[_0x6db5[9]][_0x6db5[11]];var Tag=require(_0x6db5[3])[_0x6db5[12]];var stream=require(_0x6db5[13]);var sequelize=require(_0x6db5[3])[_0x6db5[14]];var util=require(_0x6db5[15]);exports[_0x6db5[16]]=function(_0xefb3xe,_0xefb3xf){var _0xefb3x10=[_0x6db5[17],_0x6db5[18],_0x6db5[19]];var _0xefb3x11=_0xefb3xe[_0x6db5[21]][_0x6db5[20]]?parseInt(_0xefb3xe[_0x6db5[21]][_0x6db5[20]],10):100;var _0xefb3x12=_0xefb3xe[_0x6db5[21]][_0x6db5[22]]?parseInt(_0xefb3xe[_0x6db5[21]][_0x6db5[22]],10):0;var _0xefb3x13={where:{},limit:_0xefb3x11,offset:_0xefb3x12*_0xefb3x11};_[_0x6db5[36]](_0xefb3xe[_0x6db5[21]],function(_0xefb3x14,_0xefb3x15){switch(_0xefb3x15){case _0x6db5[20]:;case _0x6db5[22]:break ;;case _0x6db5[25]:_0xefb3x13[_0x6db5[23]]=util[_0x6db5[28]](_0x6db5[24],_0xefb3xe[_0x6db5[21]][_0x6db5[25]],_0xefb3xe[_0x6db5[21]][_0x6db5[26]]||_0x6db5[27])||null;break ;;case _0x6db5[26]:break ;;case _0x6db5[34]:_0xefb3x13[_0x6db5[30]][_0x6db5[29]]=[];_0xefb3x10[_0x6db5[33]](function(_0xefb3x16){var _0xefb3x17={};_0xefb3x17[_0xefb3x16]={$like:_0x6db5[31]+_0xefb3x14+_0x6db5[31]};_0xefb3x13[_0x6db5[30]][_0x6db5[29]][_0x6db5[32]](_0xefb3x17);});break ;;default:_0xefb3x13[_0x6db5[30]][_0xefb3x15]={$like:{}};_0xefb3x13[_0x6db5[30]][_0xefb3x15][_0x6db5[35]]=_0x6db5[31]+_0xefb3x14+_0x6db5[31];;}});Contact[_0x6db5[51]](_0xefb3x13)[_0x6db5[50]](function(_0xefb3x19){var _0xefb3x1a=Math[_0x6db5[42]](_0xefb3x19[_0x6db5[41]]/_0xefb3x11);var _0xefb3x1b=_0xefb3x1a>(_0xefb3x13[_0x6db5[43]]+1)?util[_0x6db5[28]](_0x6db5[44],_0xefb3xe[_0x6db5[45]],_0xefb3xe[_0x6db5[47]][_0x6db5[46]],_0xefb3xe[_0x6db5[48]],_0xefb3x12+1):null;var _0xefb3x1c=_0xefb3x12>0?util[_0x6db5[28]](_0x6db5[44],_0xefb3xe[_0x6db5[45]],_0xefb3xe[_0x6db5[47]][_0x6db5[46]],_0xefb3xe[_0x6db5[48]],_0xefb3x12-1):null;_0xefb3xf[_0x6db5[39]](200)[_0x6db5[38]]({count:_0xefb3x19[_0x6db5[41]],rows:_0xefb3x19[_0x6db5[49]],next_page:_0xefb3x1b,previous_page:_0xefb3x1c,total_pages:_0xefb3x1a});})[_0x6db5[40]](function(_0xefb3x18){_0xefb3xf[_0x6db5[39]](500)[_0x6db5[38]]({error:_0x6db5[37]})});};exports[_0x6db5[52]]=function(_0xefb3xe,_0xefb3xf){Contact[_0x6db5[68]](_0xefb3xe[_0x6db5[56]][_0x6db5[55]],{include:[{model:ContactPhone,as:_0x6db5[57],include:[{model:ReportCall,as:_0x6db5[58],include:[{all:true}]},{model:ReportCall,as:_0x6db5[59],include:[{all:true}]},{model:ReportCallHistory,as:_0x6db5[60],include:[{all:true}]},{model:ReportCallHistory,as:_0x6db5[61],include:[{all:true}]}]},{model:ContactEmail,as:_0x6db5[62],include:[{model:ReportMailSession,as:_0x6db5[63],include:[{all:true}]},{model:ReportMailSession,as:_0x6db5[64],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0x6db5[65],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0x6db5[66],include:[{all:true}]}]},{model:CustomField,as:_0x6db5[67]}]})[_0x6db5[50]](function(_0xefb3x1d){if(!_0xefb3x1d){return _0xefb3xf[_0x6db5[54]](404)};return _0xefb3xf[_0x6db5[38]](_0xefb3x1d);})[_0x6db5[40]](function(_0xefb3x18){console[_0x6db5[53]](_0xefb3x18);return handleError(_0xefb3xf,_0xefb3x18);})};exports[_0x6db5[69]]=function(_0xefb3xe,_0xefb3xf){};exports[_0x6db5[70]]=function(_0xefb3xe,_0xefb3xf){Contact[_0x6db5[74]]({where:{$or:{"\x24\x50\x68\x6F\x6E\x65\x73\x2E\x70\x68\x6F\x6E\x65\x24":_0xefb3xe[_0x6db5[72]][_0x6db5[71]],"\x24\x45\x6D\x61\x69\x6C\x73\x2E\x65\x6D\x61\x69\x6C\x24":_0xefb3xe[_0x6db5[72]][_0x6db5[73]]}},include:[{all:true}]})[_0x6db5[50]](function(_0xefb3x1e){console[_0x6db5[53]](_0xefb3x1e);return _0xefb3xf[_0x6db5[39]](200)[_0x6db5[38]](_0xefb3x1e);})[_0x6db5[40]](function(_0xefb3x18){console[_0x6db5[53]](_0xefb3x18);return handleError(_0xefb3xf,_0xefb3x18);})};exports[_0x6db5[75]]=function(_0xefb3xe,_0xefb3xf,_0xefb3x1f){var _0xefb3x20=[],_0xefb3x21=[],_0xefb3x22={};Tag[_0x6db5[74]]()[_0x6db5[50]](function(_0xefb3x29){var _0xefb3x2a=[];var _0xefb3x2b=_[_0x6db5[87]](_[_0x6db5[87]](_0xefb3x29,_0x6db5[90]),_0x6db5[17]);if(_0xefb3xe[_0x6db5[72]][_0x6db5[91]]){var _0xefb3x2c=_0xefb3xe[_0x6db5[72]][_0x6db5[91]][_0x6db5[93]](_0x6db5[92]);_0xefb3x2c[_0x6db5[33]](function(_0xefb3x25){if(!_[_0x6db5[94]](_0xefb3x29,_0xefb3x25)){_0xefb3x2a[_0x6db5[32]]({name:_0xefb3x25})}});if(_0xefb3x2a[_0x6db5[95]]){Tag[_0x6db5[96]](_0xefb3x2a,{individualHooks:true})};};_0xefb3xe[_0x6db5[72]][_0x6db5[97]]=_0xefb3xe[_0x6db5[98]][_0x6db5[55]];var _0xefb3x2d=_[_0x6db5[88]](_[_0x6db5[87]](_0xefb3xe[_0x6db5[72]].Phones,_0x6db5[99]));var _0xefb3x2e=[];_0xefb3x2d[_0x6db5[33]](function(_0xefb3x25){_0xefb3x2e[_0x6db5[32]](ContactPhone[_0x6db5[89]]({where:{phone:_0xefb3x25},defaults:{phone:_0xefb3x25}}))});return _0xefb3x2e;})[_0x6db5[85]]()[_0x6db5[50]](function(_0xefb3xf){_0xefb3x20=_[_0x6db5[82]](_0xefb3xf,function(_0xefb3x25){return _0xefb3x25[0]});var _0xefb3x27=[];var _0xefb3x28=_[_0x6db5[88]](_[_0x6db5[87]](_0xefb3xe[_0x6db5[72]].Emails,_0x6db5[86]));_0xefb3x28[_0x6db5[33]](function(_0xefb3x25){_0xefb3x27[_0x6db5[32]](ContactEmail[_0x6db5[89]]({where:{email:_0xefb3x25},defaults:{email:_0xefb3x25}}))});return _0xefb3x27;})[_0x6db5[85]]()[_0x6db5[50]](function(_0xefb3xf){_0xefb3x21=_[_0x6db5[82]](_0xefb3xf,function(_0xefb3x25){return _0xefb3x25[0]});delete _0xefb3xe[_0x6db5[72]][_0x6db5[57]];delete _0xefb3xe[_0x6db5[72]][_0x6db5[62]];_0xefb3x22=_[_0x6db5[84]](_0xefb3xe[_0x6db5[72]][_0x6db5[83]]);delete _0xefb3xe[_0x6db5[72]][_0x6db5[83]];return Contact[_0x6db5[75]](_0xefb3xe[_0x6db5[72]]);})[_0x6db5[50]](function(_0xefb3x23){return [_0xefb3x23,_0xefb3x23[_0x6db5[81]](_0xefb3x20)]})[_0x6db5[76]](function(_0xefb3x23){return [_0xefb3x23,_0xefb3x23[_0x6db5[80]](_0xefb3x21)]})[_0x6db5[76]](function(_0xefb3x23){var _0xefb3x26=_[_0x6db5[79]](_0xefb3x22);return [_0xefb3x23,CustomField[_0x6db5[74]]({where:{id:_0xefb3x26}})];})[_0x6db5[76]](function(_0xefb3x23,_0xefb3x24){_0xefb3x24[_0x6db5[33]](function(_0xefb3x25){_0xefb3x25[_0x6db5[77]]={value:_0xefb3x22[String(_0xefb3x25[_0x6db5[55]])]}});return [_0xefb3x23,_0xefb3x23[_0x6db5[78]](_0xefb3x24)];})[_0x6db5[76]](function(_0xefb3x23){return _0xefb3xf[_0x6db5[39]](201)[_0x6db5[38]](_0xefb3x23)})[_0x6db5[40]](function(_0xefb3x18){console[_0x6db5[53]](_0xefb3x18);return _0xefb3x1f(_0xefb3x18);});};exports[_0x6db5[100]]=function(_0xefb3xe,_0xefb3xf,_0xefb3x1f){var _0xefb3x20=[],_0xefb3x21=[],_0xefb3x22={};Tag[_0x6db5[74]]()[_0x6db5[50]](function(_0xefb3x29){var _0xefb3x2a=[];var _0xefb3x2b=_[_0x6db5[87]](_[_0x6db5[87]](_0xefb3x29,_0x6db5[90]),_0x6db5[17]);if(_0xefb3xe[_0x6db5[72]][_0x6db5[91]]){var _0xefb3x2c=_0xefb3xe[_0x6db5[72]][_0x6db5[91]][_0x6db5[93]](_0x6db5[92]);_0xefb3x2c[_0x6db5[33]](function(_0xefb3x25){if(!_[_0x6db5[94]](_0xefb3x29,_0xefb3x25)){_0xefb3x2a[_0x6db5[32]]({name:_0xefb3x25})}});if(_0xefb3x2a[_0x6db5[95]]){Tag[_0x6db5[96]](_0xefb3x2a,{individualHooks:true})};};var _0xefb3x2e=[];var _0xefb3x2d=_[_0x6db5[88]](_[_0x6db5[87]](_0xefb3xe[_0x6db5[72]].Phones,_0x6db5[99]));_0xefb3x2d[_0x6db5[33]](function(_0xefb3x25){_0xefb3x2e[_0x6db5[32]](ContactPhone[_0x6db5[89]]({where:{phone:_0xefb3x25},defaults:{phone:_0xefb3x25}}))});return _0xefb3x2e;})[_0x6db5[85]]()[_0x6db5[50]](function(_0xefb3xf){_0xefb3x20=_[_0x6db5[82]](_0xefb3xf,function(_0xefb3x25){return _0xefb3x25[0]});var _0xefb3x27=[];var _0xefb3x28=_[_0x6db5[88]](_[_0x6db5[87]](_0xefb3xe[_0x6db5[72]].Emails,_0x6db5[86]));_0xefb3x28[_0x6db5[33]](function(_0xefb3x25){_0xefb3x27[_0x6db5[32]](ContactEmail[_0x6db5[89]]({where:{email:_0xefb3x25},defaults:{email:_0xefb3x25}}))});return _0xefb3x27;})[_0x6db5[85]]()[_0x6db5[50]](function(_0xefb3xf){_0xefb3x21=_[_0x6db5[82]](_0xefb3xf,function(_0xefb3x25){return _0xefb3x25[0]});delete _0xefb3xe[_0x6db5[72]][_0x6db5[57]];delete _0xefb3xe[_0x6db5[72]][_0x6db5[62]];_0xefb3x22=_[_0x6db5[84]](_0xefb3xe[_0x6db5[72]][_0x6db5[83]]);delete _0xefb3xe[_0x6db5[72]][_0x6db5[83]];delete _0xefb3xe[_0x6db5[72]][_0x6db5[67]];var _0xefb3x2f=_0xefb3xe[_0x6db5[72]][_0x6db5[55]];delete _0xefb3xe[_0x6db5[72]][_0x6db5[55]];return Contact[_0x6db5[68]](_0xefb3x2f);})[_0x6db5[50]](function(_0xefb3x23){return [_0xefb3x23,_0xefb3x23[_0x6db5[81]](_0xefb3x20)]})[_0x6db5[76]](function(_0xefb3x23){return [_0xefb3x23,_0xefb3x23[_0x6db5[80]](_0xefb3x21)]})[_0x6db5[76]](function(_0xefb3x23){var _0xefb3x26=_[_0x6db5[79]](_0xefb3x22);return [_0xefb3x23,CustomField[_0x6db5[74]]({where:{id:_0xefb3x26}})];})[_0x6db5[76]](function(_0xefb3x23,_0xefb3x24){_0xefb3x24[_0x6db5[33]](function(_0xefb3x25){_0xefb3x25[_0x6db5[77]]={value:_0xefb3x22[String(_0xefb3x25[_0x6db5[55]])]}});return [_0xefb3x23,_0xefb3x23[_0x6db5[78]](_0xefb3x24)];})[_0x6db5[76]](function(_0xefb3x23){return _0xefb3x23[_0x6db5[101]](_0xefb3xe[_0x6db5[72]])})[_0x6db5[50]](function(_0xefb3x23){return _0xefb3xf[_0x6db5[39]](200)[_0x6db5[38]](_0xefb3x23)})[_0x6db5[40]](function(_0xefb3x18){console[_0x6db5[53]](_0xefb3x18);return handleError(_0xefb3xf,_0xefb3x18);});};exports[_0x6db5[102]]=function(_0xefb3xe,_0xefb3xf){Contact[_0x6db5[68]](_0xefb3xe[_0x6db5[56]][_0x6db5[55]])[_0x6db5[50]](function(_0xefb3x1d){if(!_0xefb3x1d){return _0xefb3xf[_0x6db5[54]](404)};_0xefb3x1d[_0x6db5[102]]()[_0x6db5[50]](function(){return _0xefb3xf[_0x6db5[54]](204)})[_0x6db5[40]](function(_0xefb3x18){return handleError(_0xefb3xf,_0xefb3x18)});})[_0x6db5[40]](function(_0xefb3x18){return handleError(_0xefb3xf,_0xefb3x18)})};exports[_0x6db5[103]]=function(_0xefb3xe,_0xefb3xf){Contact[_0x6db5[102]]({where:{id:_0xefb3xe[_0x6db5[21]][_0x6db5[55]]},individualHooks:true})[_0x6db5[50]](function(){return _0xefb3xf[_0x6db5[54]](204)})[_0x6db5[40]](function(_0xefb3x18){return handleError(_0xefb3xf,_0xefb3x18)})};function handleError(_0xefb3xf,_0xefb3x18){return _0xefb3xf[_0x6db5[39]](500)[_0x6db5[38]](_0xefb3x18)} \ No newline at end of file diff --git a/server/api/contact_manager/contact_manager.socket.js b/server/api/contact_manager/contact_manager.socket.js index addfca0..073990e 100644 --- a/server/api/contact_manager/contact_manager.socket.js +++ b/server/api/contact_manager/contact_manager.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Contact = require('../../models').Contact; - -exports.register = function(socket) { - Contact.afterCreate(function(doc) { - onSave(socket, doc); - }); - Contact.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('contact_manager:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('contact_manager:remove', doc); -} +var _0x9373=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x6D\x61\x6E\x61\x67\x65\x72\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x6D\x61\x6E\x61\x67\x65\x72\x3A\x72\x65\x6D\x6F\x76\x65"];_0x9373[0];var Contact=require(_0x9373[2])[_0x9373[1]];exports[_0x9373[3]]=function(_0xa859x2){Contact[_0x9373[4]](function(_0xa859x3){onSave(_0xa859x2,_0xa859x3)});Contact[_0x9373[5]](function(_0xa859x3){onRemove(_0xa859x2,_0xa859x3)});};function onSave(_0xa859x2,_0xa859x3,_0xa859x5){_0xa859x2[_0x9373[7]](_0x9373[6],_0xa859x3)}function onRemove(_0xa859x2,_0xa859x3,_0xa859x5){_0xa859x2[_0x9373[7]](_0x9373[8],_0xa859x3)} \ No newline at end of file diff --git a/server/api/contact_manager/contact_manager.spec.js b/server/api/contact_manager/contact_manager.spec.js index e751625..0ce96de 100644 --- a/server/api/contact_manager/contact_manager.spec.js +++ b/server/api/contact_manager/contact_manager.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/contactmanager', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/contactmanager') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x2691=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72","\x67\x65\x74"];_0x2691[0];var should=require(_0x2691[1]);var app=require(_0x2691[2]);var request=require(_0x2691[3]);describe(_0x2691[4],function(){it(_0x2691[5],function(_0x449dx4){request(app)[_0x2691[13]](_0x2691[12])[_0x2691[11]](200)[_0x2691[11]](_0x2691[10],/json/)[_0x2691[9]](function(_0x449dx5,_0x449dx6){if(_0x449dx5){return _0x449dx4(_0x449dx5)};_0x449dx6[_0x2691[8]][_0x2691[1]][_0x2691[7]][_0x2691[6]](Array);_0x449dx4();})})}); \ No newline at end of file diff --git a/server/api/contact_manager/index.js b/server/api/contact_manager/index.js index cc44c15..8785590 100644 --- a/server/api/contact_manager/index.js +++ b/server/api/contact_manager/index.js @@ -1,20 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./contact_manager.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/history', auth.isAuthenticated(), controller.getHistory); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.contactValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -// router.put('/join/:id', auth.isAuthenticated(), controller.joinContacts); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x4844=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x6F\x6E\x74\x61\x63\x74\x5F\x6D\x61\x6E\x61\x67\x65\x72\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x68\x69\x73\x74\x6F\x72\x79","\x67\x65\x74\x48\x69\x73\x74\x6F\x72\x79","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x63\x6F\x6E\x74\x61\x63\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x4844[0];var express=require(_0x4844[1]);var controller=require(_0x4844[2]);var auth=require(_0x4844[3]);var router=express.Router();router[_0x4844[7]](_0x4844[4],auth[_0x4844[5]](),controller[_0x4844[6]]);router[_0x4844[7]](_0x4844[8],auth[_0x4844[5]](),controller[_0x4844[9]]);router[_0x4844[7]](_0x4844[10],auth[_0x4844[5]](),controller[_0x4844[11]]);router[_0x4844[13]](_0x4844[4],auth[_0x4844[5]](),controller[_0x4844[12]]);router[_0x4844[13]](_0x4844[14],auth[_0x4844[5]](),controller[_0x4844[15]]);router[_0x4844[17]](_0x4844[8],auth[_0x4844[5]](),controller[_0x4844[16]]);router[_0x4844[18]](_0x4844[8],auth[_0x4844[5]](),controller[_0x4844[16]]);router[_0x4844[20]](_0x4844[4],auth[_0x4844[5]](),controller[_0x4844[19]]);router[_0x4844[20]](_0x4844[8],auth[_0x4844[5]](),controller[_0x4844[21]]);module[_0x4844[22]]=router; \ No newline at end of file diff --git a/server/api/custom_field/custom_field.controller.js b/server/api/custom_field/custom_field.controller.js index ae5b52d..0f749cb 100644 --- a/server/api/custom_field/custom_field.controller.js +++ b/server/api/custom_field/custom_field.controller.js @@ -1,223 +1 @@ -'use strict'; - -var _ = require('lodash'); -var CustomField = require('../../models').CustomField; -var util = require('util'); - -// Get list of customFields -exports.index = function(req, res) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: { - active: true - }, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - CustomField - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get all custom_fields -exports.getAll = function(req, res) { - CustomField - .findAll() - .then(function(customFields) { - return res.status(200).send(customFields); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.customFieldValidation = function(req, res) { - console.log(req.body); - CustomField - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(customFields) { - if (!customFields) { - return res.sendStatus(404); - } - return res.send(customFields); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single customField -exports.show = function(req, res) { - CustomField - .findById(req.params.id) - .then(function(customField) { - if (!customField) { - return res.sendStatus(404); - } - return res.send(customField); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new customField in the DB. -exports.create = function(req, res) { - CustomField - .create(req.body) - .then(function(customField) { - return res.status(201).send(customField); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing customField in the DB. -exports.update = function(req, res) { - CustomField - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(customFields) { - if (!customFields) { - return res.sendStatus(404); - } - if (customFields.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_CUSTOM_FIELD' - }) - } - if (req.body.id) { - delete req.body.id; - } - CustomField - .findById(req.params.id) - .then(function(customField) { - if (!customField) { - return res.sendStatus(404); - } - var updated = _.merge(customField, req.body); - updated.save() - .then(function() { - return res.status(200).send(customField); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a customField from the DB. -exports.deactivate = function(req, res) { - CustomField - .findById(req.params.id) - .then(function(customField) { - if (!customField) { - return res.sendStatus(404); - } - customField.update({ - active: false - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDeactivate = function(req, res) { - CustomField - .update({ - active: false - }, { - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xe217=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x67\x65\x74\x41\x6C\x6C","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x43\x55\x53\x54\x4F\x4D\x5F\x46\x49\x45\x4C\x44","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x61\x63\x74\x69\x76\x61\x74\x65","\x62\x75\x6C\x6B\x44\x65\x61\x63\x74\x69\x76\x61\x74\x65"];_0xe217[0];var _=require(_0xe217[1]);var CustomField=require(_0xe217[3])[_0xe217[2]];var util=require(_0xe217[4]);exports[_0xe217[5]]=function(_0x6d12x4,_0x6d12x5){var _0x6d12x6=[_0xe217[6],_0xe217[7]];var _0x6d12x7=_0x6d12x4[_0xe217[9]][_0xe217[8]]?parseInt(_0x6d12x4[_0xe217[9]][_0xe217[8]],10):100;var _0x6d12x8=_0x6d12x4[_0xe217[9]][_0xe217[10]]?parseInt(_0x6d12x4[_0xe217[9]][_0xe217[10]],10):0;var _0x6d12x9={where:{active:true},limit:_0x6d12x7,offset:_0x6d12x8*_0x6d12x7};_[_0xe217[24]](_0x6d12x4[_0xe217[9]],function(_0x6d12xa,_0x6d12xb){switch(_0x6d12xb){case _0xe217[8]:;case _0xe217[10]:break ;;case _0xe217[13]:_0x6d12x9[_0xe217[11]]=util[_0xe217[16]](_0xe217[12],_0x6d12x4[_0xe217[9]][_0xe217[13]],_0x6d12x4[_0xe217[9]][_0xe217[14]]||_0xe217[15])||null;break ;;case _0xe217[14]:break ;;case _0xe217[22]:_0x6d12x9[_0xe217[18]][_0xe217[17]]=[];_0x6d12x6[_0xe217[21]](function(_0x6d12xc){var _0x6d12xd={};_0x6d12xd[_0x6d12xc]={$like:_0xe217[19]+_0x6d12xa+_0xe217[19]};_0x6d12x9[_0xe217[18]][_0xe217[17]][_0xe217[20]](_0x6d12xd);});break ;;default:_0x6d12x9[_0xe217[18]][_0x6d12xb]={$like:{}};_0x6d12x9[_0xe217[18]][_0x6d12xb][_0xe217[23]]=_0xe217[19]+_0x6d12xa+_0xe217[19];;}});CustomField[_0xe217[39]](_0x6d12x9)[_0xe217[38]](function(_0x6d12xf){var _0x6d12x10=Math[_0xe217[30]](_0x6d12xf[_0xe217[29]]/_0x6d12x7);var _0x6d12x11=_0x6d12x10>(_0x6d12x9[_0xe217[31]]+1)?util[_0xe217[16]](_0xe217[32],_0x6d12x4[_0xe217[33]],_0x6d12x4[_0xe217[35]][_0xe217[34]],_0x6d12x4[_0xe217[36]],_0x6d12x8+1):null;var _0x6d12x12=_0x6d12x8>0?util[_0xe217[16]](_0xe217[32],_0x6d12x4[_0xe217[33]],_0x6d12x4[_0xe217[35]][_0xe217[34]],_0x6d12x4[_0xe217[36]],_0x6d12x8-1):null;_0x6d12x5[_0xe217[27]](200)[_0xe217[26]]({count:_0x6d12xf[_0xe217[29]],rows:_0x6d12xf[_0xe217[37]],next_page:_0x6d12x11,previous_page:_0x6d12x12,total_pages:_0x6d12x10});})[_0xe217[28]](function(_0x6d12xe){_0x6d12x5[_0xe217[27]](500)[_0xe217[26]]({error:_0xe217[25]})});};exports[_0xe217[40]]=function(_0x6d12x4,_0x6d12x5){CustomField[_0xe217[41]]()[_0xe217[38]](function(_0x6d12x13){return _0x6d12x5[_0xe217[27]](200)[_0xe217[26]](_0x6d12x13)})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)})};exports[_0xe217[42]]=function(_0x6d12x4,_0x6d12x5){console[_0xe217[44]](_0x6d12x4[_0xe217[43]]);CustomField[_0xe217[41]]({where:{name:_0x6d12x4[_0xe217[43]][_0xe217[6]]}})[_0xe217[38]](function(_0x6d12x13){if(!_0x6d12x13){return _0x6d12x5[_0xe217[45]](404)};return _0x6d12x5[_0xe217[26]](_0x6d12x13);})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)});};exports[_0xe217[46]]=function(_0x6d12x4,_0x6d12x5){CustomField[_0xe217[49]](_0x6d12x4[_0xe217[48]][_0xe217[47]])[_0xe217[38]](function(_0x6d12x14){if(!_0x6d12x14){return _0x6d12x5[_0xe217[45]](404)};return _0x6d12x5[_0xe217[26]](_0x6d12x14);})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)})};exports[_0xe217[50]]=function(_0x6d12x4,_0x6d12x5){CustomField[_0xe217[50]](_0x6d12x4[_0xe217[43]])[_0xe217[38]](function(_0x6d12x14){return _0x6d12x5[_0xe217[27]](201)[_0xe217[26]](_0x6d12x14)})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)})};exports[_0xe217[51]]=function(_0x6d12x4,_0x6d12x5){CustomField[_0xe217[41]]({where:{name:_0x6d12x4[_0xe217[43]][_0xe217[6]],id:{$ne:_0x6d12x4[_0xe217[43]][_0xe217[47]]}}})[_0xe217[38]](function(_0x6d12x13){if(!_0x6d12x13){return _0x6d12x5[_0xe217[45]](404)};if(_0x6d12x13[_0xe217[52]]>0){return _0x6d12x5[_0xe217[27]](500)[_0xe217[26]]({message:_0xe217[53]})};if(_0x6d12x4[_0xe217[43]][_0xe217[47]]){delete _0x6d12x4[_0xe217[43]][_0xe217[47]]};CustomField[_0xe217[49]](_0x6d12x4[_0xe217[48]][_0xe217[47]])[_0xe217[38]](function(_0x6d12x14){if(!_0x6d12x14){return _0x6d12x5[_0xe217[45]](404)};var _0x6d12x15=_[_0xe217[54]](_0x6d12x14,_0x6d12x4[_0xe217[43]]);_0x6d12x15[_0xe217[55]]()[_0xe217[38]](function(){return _0x6d12x5[_0xe217[27]](200)[_0xe217[26]](_0x6d12x14)})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)});})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)});})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)})};exports[_0xe217[56]]=function(_0x6d12x4,_0x6d12x5){CustomField[_0xe217[49]](_0x6d12x4[_0xe217[48]][_0xe217[47]])[_0xe217[38]](function(_0x6d12x14){if(!_0x6d12x14){return _0x6d12x5[_0xe217[45]](404)};_0x6d12x14[_0xe217[51]]({active:false})[_0xe217[38]](function(){return _0x6d12x5[_0xe217[45]](204)})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)});})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)})};exports[_0xe217[57]]=function(_0x6d12x4,_0x6d12x5){CustomField[_0xe217[51]]({active:false},{where:{id:_0x6d12x4[_0xe217[9]][_0xe217[47]]},individualHooks:true})[_0xe217[38]](function(){return _0x6d12x5[_0xe217[45]](204)})[_0xe217[28]](function(_0x6d12xe){return handleError(_0x6d12x5,_0x6d12xe)})};function handleError(_0x6d12x5,_0x6d12xe){return _0x6d12x5[_0xe217[27]](500)[_0xe217[26]](_0x6d12xe)} \ No newline at end of file diff --git a/server/api/custom_field/custom_field.socket.js b/server/api/custom_field/custom_field.socket.js index f607668..eea0295 100644 --- a/server/api/custom_field/custom_field.socket.js +++ b/server/api/custom_field/custom_field.socket.js @@ -1,29 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var CustomField = require('../../models').CustomField; - -exports.register = function(socket) { - CustomField.afterCreate(function(doc) { - onSave(socket, doc); - }); - CustomField.afterUpdate(function(doc) { - if (!doc.active) { - onRemove(socket, doc); - } - }); - CustomField.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('custom_field:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('custom_field:remove', doc); -} +var _0x9487=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x63\x74\x69\x76\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0x9487[0];var CustomField=require(_0x9487[2])[_0x9487[1]];exports[_0x9487[3]]=function(_0xc9f3x2){CustomField[_0x9487[4]](function(_0xc9f3x3){onSave(_0xc9f3x2,_0xc9f3x3)});CustomField[_0x9487[6]](function(_0xc9f3x3){if(!_0xc9f3x3[_0x9487[5]]){onRemove(_0xc9f3x2,_0xc9f3x3)}});CustomField[_0x9487[7]](function(_0xc9f3x3){onRemove(_0xc9f3x2,_0xc9f3x3)});};function onSave(_0xc9f3x2,_0xc9f3x3,_0xc9f3x5){_0xc9f3x2[_0x9487[9]](_0x9487[8],_0xc9f3x3)}function onRemove(_0xc9f3x2,_0xc9f3x3,_0xc9f3x5){_0xc9f3x2[_0x9487[9]](_0x9487[10],_0xc9f3x3)} \ No newline at end of file diff --git a/server/api/custom_field/custom_field.spec.js b/server/api/custom_field/custom_field.spec.js index 852dba1..6777daa 100644 --- a/server/api/custom_field/custom_field.spec.js +++ b/server/api/custom_field/custom_field.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/contactmanager/customfields', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/contactmanager/customfields') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x81e8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72\x2F\x63\x75\x73\x74\x6F\x6D\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72\x2F\x63\x75\x73\x74\x6F\x6D\x66\x69\x65\x6C\x64\x73","\x67\x65\x74"];_0x81e8[0];var should=require(_0x81e8[1]);var app=require(_0x81e8[2]);var request=require(_0x81e8[3]);describe(_0x81e8[4],function(){it(_0x81e8[5],function(_0x33b8x4){request(app)[_0x81e8[13]](_0x81e8[12])[_0x81e8[11]](200)[_0x81e8[11]](_0x81e8[10],/json/)[_0x81e8[9]](function(_0x33b8x5,_0x33b8x6){if(_0x33b8x5){return _0x33b8x4(_0x33b8x5)};_0x33b8x6[_0x81e8[8]][_0x81e8[1]][_0x81e8[7]][_0x81e8[6]](Array);_0x33b8x4();})})}); \ No newline at end of file diff --git a/server/api/custom_field/index.js b/server/api/custom_field/index.js index dd4afaf..aecbb40 100644 --- a/server/api/custom_field/index.js +++ b/server/api/custom_field/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./custom_field.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/all', auth.isAuthenticated(), controller.getAll); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.customFieldValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDeactivate); -router.delete('/:id', auth.isAuthenticated(), controller.deactivate); - -module.exports = router; +var _0xbe9a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x61\x6C\x6C","\x67\x65\x74\x41\x6C\x6C","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x61\x63\x74\x69\x76\x61\x74\x65","\x64\x65\x6C\x65\x74\x65","\x64\x65\x61\x63\x74\x69\x76\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xbe9a[0];var express=require(_0xbe9a[1]);var controller=require(_0xbe9a[2]);var auth=require(_0xbe9a[3]);var router=express.Router();router[_0xbe9a[7]](_0xbe9a[4],auth[_0xbe9a[5]](),controller[_0xbe9a[6]]);router[_0xbe9a[7]](_0xbe9a[8],auth[_0xbe9a[5]](),controller[_0xbe9a[9]]);router[_0xbe9a[7]](_0xbe9a[10],auth[_0xbe9a[5]](),controller[_0xbe9a[11]]);router[_0xbe9a[13]](_0xbe9a[4],auth[_0xbe9a[5]](),controller[_0xbe9a[12]]);router[_0xbe9a[13]](_0xbe9a[14],auth[_0xbe9a[5]](),controller[_0xbe9a[15]]);router[_0xbe9a[17]](_0xbe9a[10],auth[_0xbe9a[5]](),controller[_0xbe9a[16]]);router[_0xbe9a[18]](_0xbe9a[10],auth[_0xbe9a[5]](),controller[_0xbe9a[16]]);router[_0xbe9a[20]](_0xbe9a[4],auth[_0xbe9a[5]](),controller[_0xbe9a[19]]);router[_0xbe9a[20]](_0xbe9a[10],auth[_0xbe9a[5]](),controller[_0xbe9a[21]]);module[_0xbe9a[22]]=router; \ No newline at end of file diff --git a/server/api/custom_report/custom_report.controller.js b/server/api/custom_report/custom_report.controller.js index abb7d2b..821a4a4 100644 --- a/server/api/custom_report/custom_report.controller.js +++ b/server/api/custom_report/custom_report.controller.js @@ -1,160 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var CustomReport = require('../../models').CustomReport; -var ReportTree = require('../../models').ReportTree; - - -// Get list of custom reports -exports.index = function(req, res, next) { - - var attributes = ['name', 'description', 'parent']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - case 'role': - query.where.role = { - $or: value.split(/[\s,]+/) - }; - break; - case 'clientQuery': - var params = JSON.parse(value); - _.forOwn(params, function(pValue, pKey) { - query.where[pKey] = pValue; - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - CustomReport - .findAndCountAll(query) - .then(function(result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single report -exports.show = function(req, res) { - CustomReport - .findById(req.params.id) - .then(function(report) { - if (!report) { - return res.sendStatus(404); - } - return res.send(report); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new report in the DB. -exports.create = function(req, res) { - CustomReport - .create(req.body) - .then(function(report) { - return res.status(201).send(report); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - CustomReport - .findById(req.params.id) - .then(function(report) { - if (!report) { - return res.sendStatus(404); - } - var updated = _.merge(report, req.body); - updated.save() - .then(function() { - return res.status(200).send(report); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a report from the DB. -exports.destroy = function(req, res) { - CustomReport - .findById(req.params.id) - .then(function(report) { - if (!report) { - return res.sendStatus(404); - } - report.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xe0b6=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x43\x75\x73\x74\x6F\x6D\x52\x65\x70\x6F\x72\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x52\x65\x70\x6F\x72\x74\x54\x72\x65\x65","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x61\x72\x65\x6E\x74","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x72\x6F\x6C\x65","\x73\x70\x6C\x69\x74","\x70\x61\x72\x73\x65","\x66\x6F\x72\x4F\x77\x6E","\x63\x6C\x69\x65\x6E\x74\x51\x75\x65\x72\x79","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xe0b6[0];var _=require(_0xe0b6[1]);var util=require(_0xe0b6[2]);var CustomReport=require(_0xe0b6[4])[_0xe0b6[3]];var ReportTree=require(_0xe0b6[4])[_0xe0b6[5]];exports[_0xe0b6[6]]=function(_0x8584x5,_0x8584x6,_0x8584x7){var _0x8584x8=[_0xe0b6[7],_0xe0b6[8],_0xe0b6[9]];var _0x8584x9=_0x8584x5[_0xe0b6[11]][_0xe0b6[10]]?parseInt(_0x8584x5[_0xe0b6[11]][_0xe0b6[10]],10):100;var _0x8584xa=_0x8584x5[_0xe0b6[11]][_0xe0b6[12]]?parseInt(_0x8584x5[_0xe0b6[11]][_0xe0b6[12]],10):0;var _0x8584xb={where:{},limit:_0x8584x9,offset:_0x8584xa*_0x8584x9};_[_0xe0b6[31]](_0x8584x5[_0xe0b6[11]],function(_0x8584xc,_0x8584xd){switch(_0x8584xd){case _0xe0b6[10]:;case _0xe0b6[12]:break ;;case _0xe0b6[15]:_0x8584xb[_0xe0b6[13]]=util[_0xe0b6[18]](_0xe0b6[14],_0x8584x5[_0xe0b6[11]][_0xe0b6[15]],_0x8584x5[_0xe0b6[11]][_0xe0b6[16]]||_0xe0b6[17])||null;break ;;case _0xe0b6[16]:break ;;case _0xe0b6[24]:_0x8584xb[_0xe0b6[20]][_0xe0b6[19]]=[];_0x8584x8[_0xe0b6[23]](function(_0x8584xe){var _0x8584xf={};_0x8584xf[_0x8584xe]={$like:_0xe0b6[21]+_0x8584xc+_0xe0b6[21]};_0x8584xb[_0xe0b6[20]][_0xe0b6[19]][_0xe0b6[22]](_0x8584xf);});break ;;case _0xe0b6[25]:_0x8584xb[_0xe0b6[20]][_0xe0b6[25]]={$or:_0x8584xc[_0xe0b6[26]](/[\s,]+/)};break ;;case _0xe0b6[29]:var _0x8584x10=JSON[_0xe0b6[27]](_0x8584xc);_[_0xe0b6[28]](_0x8584x10,function(_0x8584x11,_0x8584x12){_0x8584xb[_0xe0b6[20]][_0x8584x12]=_0x8584x11});break ;;default:_0x8584xb[_0xe0b6[20]][_0x8584xd]={$like:{}};_0x8584xb[_0xe0b6[20]][_0x8584xd][_0xe0b6[30]]=_0xe0b6[21]+_0x8584xc+_0xe0b6[21];;}});CustomReport[_0xe0b6[46]](_0x8584xb)[_0xe0b6[45]](function(_0x8584x14){var _0x8584x15=Math[_0xe0b6[37]](_0x8584x14[_0xe0b6[36]]/_0x8584x9);var _0x8584x16=_0x8584x15>(_0x8584xb[_0xe0b6[38]]+1)?util[_0xe0b6[18]](_0xe0b6[39],_0x8584x5[_0xe0b6[40]],_0x8584x5[_0xe0b6[42]][_0xe0b6[41]],_0x8584x5[_0xe0b6[43]],_0x8584xa+1):null;var _0x8584x17=_0x8584xa>0?util[_0xe0b6[18]](_0xe0b6[39],_0x8584x5[_0xe0b6[40]],_0x8584x5[_0xe0b6[42]][_0xe0b6[41]],_0x8584x5[_0xe0b6[43]],_0x8584xa-1):null;_0x8584x6[_0xe0b6[34]](200)[_0xe0b6[33]]({count:_0x8584x14[_0xe0b6[36]],rows:_0x8584x14[_0xe0b6[44]],next_page:_0x8584x16,previous_page:_0x8584x17,total_pages:_0x8584x15});})[_0xe0b6[35]](function(_0x8584x13){_0x8584x6[_0xe0b6[34]](500)[_0xe0b6[33]]({error:_0xe0b6[32]})});};exports[_0xe0b6[47]]=function(_0x8584x5,_0x8584x6){CustomReport[_0xe0b6[51]](_0x8584x5[_0xe0b6[50]][_0xe0b6[49]])[_0xe0b6[45]](function(_0x8584x18){if(!_0x8584x18){return _0x8584x6[_0xe0b6[48]](404)};return _0x8584x6[_0xe0b6[33]](_0x8584x18);})[_0xe0b6[35]](function(_0x8584x13){return handleError(_0x8584x6,_0x8584x13)})};exports[_0xe0b6[52]]=function(_0x8584x5,_0x8584x6){CustomReport[_0xe0b6[52]](_0x8584x5[_0xe0b6[53]])[_0xe0b6[45]](function(_0x8584x18){return _0x8584x6[_0xe0b6[34]](201)[_0xe0b6[33]](_0x8584x18)})[_0xe0b6[35]](function(_0x8584x13){return handleError(_0x8584x6,_0x8584x13)})};exports[_0xe0b6[54]]=function(_0x8584x5,_0x8584x6){if(_0x8584x5[_0xe0b6[53]][_0xe0b6[49]]){delete _0x8584x5[_0xe0b6[53]][_0xe0b6[49]]};CustomReport[_0xe0b6[51]](_0x8584x5[_0xe0b6[50]][_0xe0b6[49]])[_0xe0b6[45]](function(_0x8584x18){if(!_0x8584x18){return _0x8584x6[_0xe0b6[48]](404)};var _0x8584x19=_[_0xe0b6[55]](_0x8584x18,_0x8584x5[_0xe0b6[53]]);_0x8584x19[_0xe0b6[56]]()[_0xe0b6[45]](function(){return _0x8584x6[_0xe0b6[34]](200)[_0xe0b6[33]](_0x8584x18)})[_0xe0b6[35]](function(_0x8584x13){return handleError(_0x8584x6,_0x8584x13)});})[_0xe0b6[35]](function(_0x8584x13){return handleError(_0x8584x6,_0x8584x13)});};exports[_0xe0b6[57]]=function(_0x8584x5,_0x8584x6){CustomReport[_0xe0b6[51]](_0x8584x5[_0xe0b6[50]][_0xe0b6[49]])[_0xe0b6[45]](function(_0x8584x18){if(!_0x8584x18){return _0x8584x6[_0xe0b6[48]](404)};_0x8584x18[_0xe0b6[57]]()[_0xe0b6[45]](function(){return _0x8584x6[_0xe0b6[48]](204)})[_0xe0b6[35]](function(_0x8584x13){return handleError(_0x8584x6,_0x8584x13)});})[_0xe0b6[35]](function(_0x8584x13){return handleError(_0x8584x6,_0x8584x13)})};function handleError(_0x8584x6,_0x8584x13){return _0x8584x6[_0xe0b6[34]](500)[_0xe0b6[33]](_0x8584x13)} \ No newline at end of file diff --git a/server/api/custom_report/custom_report.socket.js b/server/api/custom_report/custom_report.socket.js index 07bf827..099f03b 100644 --- a/server/api/custom_report/custom_report.socket.js +++ b/server/api/custom_report/custom_report.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var CustomReport = require('../../models').CustomReport; - -exports.register = function(socket) { - CustomReport.afterCreate(function(doc) { - onSave(socket, doc); - }); - CustomReport.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('custom_report:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('custom_report:remove', doc); -} +var _0xd561=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x75\x73\x74\x6F\x6D\x52\x65\x70\x6F\x72\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xd561[0];var CustomReport=require(_0xd561[2])[_0xd561[1]];exports[_0xd561[3]]=function(_0xe35ex2){CustomReport[_0xd561[4]](function(_0xe35ex3){onSave(_0xe35ex2,_0xe35ex3)});CustomReport[_0xd561[5]](function(_0xe35ex3){onRemove(_0xe35ex2,_0xe35ex3)});};function onSave(_0xe35ex2,_0xe35ex3,_0xe35ex5){_0xe35ex2[_0xd561[7]](_0xd561[6],_0xe35ex3)}function onRemove(_0xe35ex2,_0xe35ex3,_0xe35ex5){_0xe35ex2[_0xd561[7]](_0xd561[8],_0xe35ex3)} \ No newline at end of file diff --git a/server/api/custom_report/custom_report.spec.js b/server/api/custom_report/custom_report.spec.js index 905f802..52136db 100644 --- a/server/api/custom_report/custom_report.spec.js +++ b/server/api/custom_report/custom_report.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/analytics/reports/custom', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/analytic/reports/custom') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x75e2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x63\x75\x73\x74\x6F\x6D","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x63\x75\x73\x74\x6F\x6D","\x67\x65\x74"];_0x75e2[0];var should=require(_0x75e2[1]);var app=require(_0x75e2[2]);var request=require(_0x75e2[3]);describe(_0x75e2[4],function(){it(_0x75e2[5],function(_0xeed4x4){request(app)[_0x75e2[13]](_0x75e2[12])[_0x75e2[11]](200)[_0x75e2[11]](_0x75e2[10],/json/)[_0x75e2[9]](function(_0xeed4x5,_0xeed4x6){if(_0xeed4x5){return _0xeed4x4(_0xeed4x5)};_0xeed4x6[_0x75e2[8]][_0x75e2[1]][_0x75e2[7]][_0x75e2[6]](Array);_0xeed4x4();})})}); \ No newline at end of file diff --git a/server/api/custom_report/index.js b/server/api/custom_report/index.js index 403aa5c..b26f0cd 100644 --- a/server/api/custom_report/index.js +++ b/server/api/custom_report/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./custom_report.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x5b0c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x5b0c[0];var express=require(_0x5b0c[1]);var controller=require(_0x5b0c[2]);var router=express.Router();router[_0x5b0c[5]](_0x5b0c[3],controller[_0x5b0c[4]]);router[_0x5b0c[5]](_0x5b0c[6],controller[_0x5b0c[7]]);router[_0x5b0c[9]](_0x5b0c[3],controller[_0x5b0c[8]]);router[_0x5b0c[11]](_0x5b0c[6],controller[_0x5b0c[10]]);router[_0x5b0c[12]](_0x5b0c[6],controller[_0x5b0c[10]]);router[_0x5b0c[14]](_0x5b0c[6],controller[_0x5b0c[13]]);module[_0x5b0c[15]]=router; \ No newline at end of file diff --git a/server/api/dashboard/dashboard.controller.js b/server/api/dashboard/dashboard.controller.js index 986e3f4..6d9cb67 100644 --- a/server/api/dashboard/dashboard.controller.js +++ b/server/api/dashboard/dashboard.controller.js @@ -1,178 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var Dashboard = require('../../models').Dashboard; - -// Get list of dashboards -exports.index = function(req, res) { - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Dashboard - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - return res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single dashboard -exports.all = function(req, res) { - Dashboard - .findAll() - .then(function(dashboards) { - if (!dashboards) { - return res.sendStatus(404); - } - return res.status(200).send(dashboards); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single dashboard -exports.show = function(req, res) { - Dashboard - .findById(req.params.id) - .then(function(dashboard) { - if (!dashboard) { - return res.sendStatus(404); - } - return res.send(dashboard); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new dashboard in the DB. -exports.create = function(req, res) { - Dashboard - .create(req.body) - .then(function(dashboard) { - return res.status(201).send(dashboard); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing dashboard in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Dashboard - .findById(req.params.id) - .then(function(dashboard) { - if (!dashboard) { - return res.sendStatus(404); - } - var updated = _.merge(dashboard, req.body); - updated.save() - .then(function() { - return res.status(200).send(dashboard); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a dashboard from the DB. -exports.destroy = function(req, res) { - Dashboard - .findById(req.params.id) - .then(function(dashboard) { - if (!dashboard) { - return res.sendStatus(404); - } - dashboard.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDestroy = function(req, res) { - Dashboard - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x404a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x44\x61\x73\x68\x62\x6F\x61\x72\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x61\x6C\x6C","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x404a[0];var _=require(_0x404a[1]);var util=require(_0x404a[2]);var Dashboard=require(_0x404a[4])[_0x404a[3]];exports[_0x404a[5]]=function(_0xc868x4,_0xc868x5){var _0xc868x6=[_0x404a[6],_0x404a[7]];var _0xc868x7=_0xc868x4[_0x404a[9]][_0x404a[8]]?parseInt(_0xc868x4[_0x404a[9]][_0x404a[8]],10):100;var _0xc868x8=_0xc868x4[_0x404a[9]][_0x404a[10]]?parseInt(_0xc868x4[_0x404a[9]][_0x404a[10]],10):0;var _0xc868x9={where:{},limit:_0xc868x7,offset:_0xc868x8*_0xc868x7};_[_0x404a[24]](_0xc868x4[_0x404a[9]],function(_0xc868xa,_0xc868xb){switch(_0xc868xb){case _0x404a[8]:;case _0x404a[10]:break ;;case _0x404a[13]:_0xc868x9[_0x404a[11]]=util[_0x404a[16]](_0x404a[12],_0xc868x4[_0x404a[9]][_0x404a[13]],_0xc868x4[_0x404a[9]][_0x404a[14]]||_0x404a[15])||null;break ;;case _0x404a[14]:break ;;case _0x404a[22]:_0xc868x9[_0x404a[18]][_0x404a[17]]=[];_0xc868x6[_0x404a[21]](function(_0xc868xc){var _0xc868xd={};_0xc868xd[_0xc868xc]={$like:_0x404a[19]+_0xc868xa+_0x404a[19]};_0xc868x9[_0x404a[18]][_0x404a[17]][_0x404a[20]](_0xc868xd);});break ;;default:_0xc868x9[_0x404a[18]][_0xc868xb]={$like:{}};_0xc868x9[_0x404a[18]][_0xc868xb][_0x404a[23]]=_0x404a[19]+_0xc868xa+_0x404a[19];;}});Dashboard[_0x404a[39]](_0xc868x9)[_0x404a[38]](function(_0xc868xf){var _0xc868x10=Math[_0x404a[30]](_0xc868xf[_0x404a[29]]/_0xc868x7);var _0xc868x11=_0xc868x10>(_0xc868x9[_0x404a[31]]+1)?util[_0x404a[16]](_0x404a[32],_0xc868x4[_0x404a[33]],_0xc868x4[_0x404a[35]][_0x404a[34]],_0xc868x4[_0x404a[36]],_0xc868x8+1):null;var _0xc868x12=_0xc868x8>0?util[_0x404a[16]](_0x404a[32],_0xc868x4[_0x404a[33]],_0xc868x4[_0x404a[35]][_0x404a[34]],_0xc868x4[_0x404a[36]],_0xc868x8-1):null;return _0xc868x5[_0x404a[27]](200)[_0x404a[26]]({count:_0xc868xf[_0x404a[29]],rows:_0xc868xf[_0x404a[37]],next_page:_0xc868x11,previous_page:_0xc868x12,total_pages:_0xc868x10});})[_0x404a[28]](function(_0xc868xe){return _0xc868x5[_0x404a[27]](500)[_0x404a[26]]({error:_0x404a[25]})});};exports[_0x404a[40]]=function(_0xc868x4,_0xc868x5){Dashboard[_0x404a[42]]()[_0x404a[38]](function(_0xc868x13){if(!_0xc868x13){return _0xc868x5[_0x404a[41]](404)};return _0xc868x5[_0x404a[27]](200)[_0x404a[26]](_0xc868x13);})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)})};exports[_0x404a[43]]=function(_0xc868x4,_0xc868x5){Dashboard[_0x404a[46]](_0xc868x4[_0x404a[45]][_0x404a[44]])[_0x404a[38]](function(_0xc868x14){if(!_0xc868x14){return _0xc868x5[_0x404a[41]](404)};return _0xc868x5[_0x404a[26]](_0xc868x14);})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)})};exports[_0x404a[47]]=function(_0xc868x4,_0xc868x5){Dashboard[_0x404a[47]](_0xc868x4[_0x404a[48]])[_0x404a[38]](function(_0xc868x14){return _0xc868x5[_0x404a[27]](201)[_0x404a[26]](_0xc868x14)})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)})};exports[_0x404a[49]]=function(_0xc868x4,_0xc868x5){if(_0xc868x4[_0x404a[48]][_0x404a[44]]){delete _0xc868x4[_0x404a[48]][_0x404a[44]]};Dashboard[_0x404a[46]](_0xc868x4[_0x404a[45]][_0x404a[44]])[_0x404a[38]](function(_0xc868x14){if(!_0xc868x14){return _0xc868x5[_0x404a[41]](404)};var _0xc868x15=_[_0x404a[50]](_0xc868x14,_0xc868x4[_0x404a[48]]);_0xc868x15[_0x404a[51]]()[_0x404a[38]](function(){return _0xc868x5[_0x404a[27]](200)[_0x404a[26]](_0xc868x14)})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)});})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)});};exports[_0x404a[52]]=function(_0xc868x4,_0xc868x5){Dashboard[_0x404a[46]](_0xc868x4[_0x404a[45]][_0x404a[44]])[_0x404a[38]](function(_0xc868x14){if(!_0xc868x14){return _0xc868x5[_0x404a[41]](404)};_0xc868x14[_0x404a[52]]()[_0x404a[38]](function(){return _0xc868x5[_0x404a[41]](204)})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)});})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)})};exports[_0x404a[53]]=function(_0xc868x4,_0xc868x5){Dashboard[_0x404a[52]]({where:{id:_0xc868x4[_0x404a[9]][_0x404a[44]]},individualHooks:true})[_0x404a[38]](function(){return _0xc868x5[_0x404a[41]](204)})[_0x404a[28]](function(_0xc868xe){return handleError(_0xc868x5,_0xc868xe)})};function handleError(_0xc868x5,_0xc868xe){return _0xc868x5[_0x404a[27]](500)[_0x404a[26]](_0xc868xe)} \ No newline at end of file diff --git a/server/api/dashboard/dashboard.socket.js b/server/api/dashboard/dashboard.socket.js index 9bf2215..3aea1c1 100644 --- a/server/api/dashboard/dashboard.socket.js +++ b/server/api/dashboard/dashboard.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Dashboard = require('../../models').Dashboard; - -exports.register = function(socket) { - Dashboard.afterCreate(function(doc) { - onSave(socket, doc); - }); - Dashboard.afterUpdate(function(doc) { - onSave(socket, doc); - }); - Dashboard.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('dashboard:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('dashboard:remove', doc); -} +var _0xb177=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x44\x61\x73\x68\x62\x6F\x61\x72\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0xb177[0];var Dashboard=require(_0xb177[2])[_0xb177[1]];exports[_0xb177[3]]=function(_0x39f4x2){Dashboard[_0xb177[4]](function(_0x39f4x3){onSave(_0x39f4x2,_0x39f4x3)});Dashboard[_0xb177[5]](function(_0x39f4x3){onSave(_0x39f4x2,_0x39f4x3)});Dashboard[_0xb177[6]](function(_0x39f4x3){onRemove(_0x39f4x2,_0x39f4x3)});};function onSave(_0x39f4x2,_0x39f4x3,_0x39f4x5){_0x39f4x2[_0xb177[8]](_0xb177[7],_0x39f4x3)}function onRemove(_0x39f4x2,_0x39f4x3,_0x39f4x5){_0x39f4x2[_0xb177[8]](_0xb177[9],_0x39f4x3)} \ No newline at end of file diff --git a/server/api/dashboard/dashboard.spec.js b/server/api/dashboard/dashboard.spec.js index 4784e74..b8352f3 100644 --- a/server/api/dashboard/dashboard.spec.js +++ b/server/api/dashboard/dashboard.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/dashboards', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/dashboards') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x5907=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x73","\x67\x65\x74"];_0x5907[0];var should=require(_0x5907[1]);var app=require(_0x5907[2]);var request=require(_0x5907[3]);describe(_0x5907[4],function(){it(_0x5907[5],function(_0xe168x4){request(app)[_0x5907[13]](_0x5907[12])[_0x5907[11]](200)[_0x5907[11]](_0x5907[10],/json/)[_0x5907[9]](function(_0xe168x5,_0xe168x6){if(_0xe168x5){return _0xe168x4(_0xe168x5)};_0xe168x6[_0x5907[8]][_0x5907[1]][_0x5907[7]][_0x5907[6]](Array);_0xe168x4();})})}); \ No newline at end of file diff --git a/server/api/dashboard/index.js b/server/api/dashboard/index.js index 6f966a0..bb5794b 100644 --- a/server/api/dashboard/index.js +++ b/server/api/dashboard/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./dashboard.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/all', auth.isAuthenticated(), controller.all); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0xc091=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x61\x6C\x6C","\x61\x6C\x6C","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xc091[0];var express=require(_0xc091[1]);var controller=require(_0xc091[2]);var auth=require(_0xc091[3]);var router=express.Router();router[_0xc091[7]](_0xc091[4],auth[_0xc091[5]](),controller[_0xc091[6]]);router[_0xc091[7]](_0xc091[8],auth[_0xc091[5]](),controller[_0xc091[9]]);router[_0xc091[7]](_0xc091[10],auth[_0xc091[5]](),controller[_0xc091[11]]);router[_0xc091[13]](_0xc091[4],auth[_0xc091[5]](),controller[_0xc091[12]]);router[_0xc091[15]](_0xc091[10],auth[_0xc091[5]](),controller[_0xc091[14]]);router[_0xc091[16]](_0xc091[10],auth[_0xc091[5]](),controller[_0xc091[14]]);router[_0xc091[18]](_0xc091[4],auth[_0xc091[5]](),controller[_0xc091[17]]);router[_0xc091[18]](_0xc091[10],auth[_0xc091[5]](),controller[_0xc091[19]]);module[_0xc091[20]]=router; \ No newline at end of file diff --git a/server/api/default_report/default_report.controller.js b/server/api/default_report/default_report.controller.js index faa5dc7..514d126 100644 --- a/server/api/default_report/default_report.controller.js +++ b/server/api/default_report/default_report.controller.js @@ -1,159 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var DefaultReport = require('../../models').DefaultReport; - -// Get list of default reports -exports.index = function(req, res, next) { - - var attributes = ['name', 'description', 'parent']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - case 'role': - query.where.role = { - $or: value.split(/[\s,]+/) - }; - break; - case 'clientQuery': - var params = JSON.parse(value); - _.forOwn(params, function(pValue, pKey) { - query.where[pKey] = pValue; - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - DefaultReport - .findAndCountAll(query) - .then(function(result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - - -// Get a single report -exports.show = function(req, res) { - DefaultReport - .findById(req.params.id) - .then(function(report) { - if (!report) { - return res.sendStatus(404); - } - return res.send(report); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new report in the DB. -exports.create = function(req, res) { - DefaultReport - .create(req.body) - .then(function(report) { - return res.status(201).send(report); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - DefaultReport - .findById(req.params.id) - .then(function(report) { - if (!report) { - return res.sendStatus(404); - } - var updated = _.merge(report, req.body); - updated.save() - .then(function() { - return res.status(200).send(report); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a report from the DB. -exports.destroy = function(req, res) { - DefaultReport - .findById(req.params.id) - .then(function(report) { - if (!report) { - return res.sendStatus(404); - } - report.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x485a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x44\x65\x66\x61\x75\x6C\x74\x52\x65\x70\x6F\x72\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x61\x72\x65\x6E\x74","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x72\x6F\x6C\x65","\x73\x70\x6C\x69\x74","\x70\x61\x72\x73\x65","\x66\x6F\x72\x4F\x77\x6E","\x63\x6C\x69\x65\x6E\x74\x51\x75\x65\x72\x79","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x485a[0];var _=require(_0x485a[1]);var util=require(_0x485a[2]);var DefaultReport=require(_0x485a[4])[_0x485a[3]];exports[_0x485a[5]]=function(_0x442bx4,_0x442bx5,_0x442bx6){var _0x442bx7=[_0x485a[6],_0x485a[7],_0x485a[8]];var _0x442bx8=_0x442bx4[_0x485a[10]][_0x485a[9]]?parseInt(_0x442bx4[_0x485a[10]][_0x485a[9]],10):100;var _0x442bx9=_0x442bx4[_0x485a[10]][_0x485a[11]]?parseInt(_0x442bx4[_0x485a[10]][_0x485a[11]],10):0;var _0x442bxa={where:{},limit:_0x442bx8,offset:_0x442bx9*_0x442bx8};_[_0x485a[30]](_0x442bx4[_0x485a[10]],function(_0x442bxb,_0x442bxc){switch(_0x442bxc){case _0x485a[9]:;case _0x485a[11]:break ;;case _0x485a[14]:_0x442bxa[_0x485a[12]]=util[_0x485a[17]](_0x485a[13],_0x442bx4[_0x485a[10]][_0x485a[14]],_0x442bx4[_0x485a[10]][_0x485a[15]]||_0x485a[16])||null;break ;;case _0x485a[15]:break ;;case _0x485a[23]:_0x442bxa[_0x485a[19]][_0x485a[18]]=[];_0x442bx7[_0x485a[22]](function(_0x442bxd){var _0x442bxe={};_0x442bxe[_0x442bxd]={$like:_0x485a[20]+_0x442bxb+_0x485a[20]};_0x442bxa[_0x485a[19]][_0x485a[18]][_0x485a[21]](_0x442bxe);});break ;;case _0x485a[24]:_0x442bxa[_0x485a[19]][_0x485a[24]]={$or:_0x442bxb[_0x485a[25]](/[\s,]+/)};break ;;case _0x485a[28]:var _0x442bxf=JSON[_0x485a[26]](_0x442bxb);_[_0x485a[27]](_0x442bxf,function(_0x442bx10,_0x442bx11){_0x442bxa[_0x485a[19]][_0x442bx11]=_0x442bx10});break ;;default:_0x442bxa[_0x485a[19]][_0x442bxc]={$like:{}};_0x442bxa[_0x485a[19]][_0x442bxc][_0x485a[29]]=_0x485a[20]+_0x442bxb+_0x485a[20];;}});DefaultReport[_0x485a[45]](_0x442bxa)[_0x485a[44]](function(_0x442bx13){var _0x442bx14=Math[_0x485a[36]](_0x442bx13[_0x485a[35]]/_0x442bx8);var _0x442bx15=_0x442bx14>(_0x442bxa[_0x485a[37]]+1)?util[_0x485a[17]](_0x485a[38],_0x442bx4[_0x485a[39]],_0x442bx4[_0x485a[41]][_0x485a[40]],_0x442bx4[_0x485a[42]],_0x442bx9+1):null;var _0x442bx16=_0x442bx9>0?util[_0x485a[17]](_0x485a[38],_0x442bx4[_0x485a[39]],_0x442bx4[_0x485a[41]][_0x485a[40]],_0x442bx4[_0x485a[42]],_0x442bx9-1):null;_0x442bx5[_0x485a[33]](200)[_0x485a[32]]({count:_0x442bx13[_0x485a[35]],rows:_0x442bx13[_0x485a[43]],next_page:_0x442bx15,previous_page:_0x442bx16,total_pages:_0x442bx14});})[_0x485a[34]](function(_0x442bx12){_0x442bx5[_0x485a[33]](500)[_0x485a[32]]({error:_0x485a[31]})});};exports[_0x485a[46]]=function(_0x442bx4,_0x442bx5){DefaultReport[_0x485a[50]](_0x442bx4[_0x485a[49]][_0x485a[48]])[_0x485a[44]](function(_0x442bx17){if(!_0x442bx17){return _0x442bx5[_0x485a[47]](404)};return _0x442bx5[_0x485a[32]](_0x442bx17);})[_0x485a[34]](function(_0x442bx12){return handleError(_0x442bx5,_0x442bx12)})};exports[_0x485a[51]]=function(_0x442bx4,_0x442bx5){DefaultReport[_0x485a[51]](_0x442bx4[_0x485a[52]])[_0x485a[44]](function(_0x442bx17){return _0x442bx5[_0x485a[33]](201)[_0x485a[32]](_0x442bx17)})[_0x485a[34]](function(_0x442bx12){return handleError(_0x442bx5,_0x442bx12)})};exports[_0x485a[53]]=function(_0x442bx4,_0x442bx5){if(_0x442bx4[_0x485a[52]][_0x485a[48]]){delete _0x442bx4[_0x485a[52]][_0x485a[48]]};DefaultReport[_0x485a[50]](_0x442bx4[_0x485a[49]][_0x485a[48]])[_0x485a[44]](function(_0x442bx17){if(!_0x442bx17){return _0x442bx5[_0x485a[47]](404)};var _0x442bx18=_[_0x485a[54]](_0x442bx17,_0x442bx4[_0x485a[52]]);_0x442bx18[_0x485a[55]]()[_0x485a[44]](function(){return _0x442bx5[_0x485a[33]](200)[_0x485a[32]](_0x442bx17)})[_0x485a[34]](function(_0x442bx12){return handleError(_0x442bx5,_0x442bx12)});})[_0x485a[34]](function(_0x442bx12){return handleError(_0x442bx5,_0x442bx12)});};exports[_0x485a[56]]=function(_0x442bx4,_0x442bx5){DefaultReport[_0x485a[50]](_0x442bx4[_0x485a[49]][_0x485a[48]])[_0x485a[44]](function(_0x442bx17){if(!_0x442bx17){return _0x442bx5[_0x485a[47]](404)};_0x442bx17[_0x485a[56]]()[_0x485a[44]](function(){return _0x442bx5[_0x485a[47]](204)})[_0x485a[34]](function(_0x442bx12){return handleError(_0x442bx5,_0x442bx12)});})[_0x485a[34]](function(_0x442bx12){return handleError(_0x442bx5,_0x442bx12)})};function handleError(_0x442bx5,_0x442bx12){return _0x442bx5[_0x485a[33]](500)[_0x485a[32]](_0x442bx12)} \ No newline at end of file diff --git a/server/api/default_report/default_report.socket.js b/server/api/default_report/default_report.socket.js index 2acd563..aee73fa 100644 --- a/server/api/default_report/default_report.socket.js +++ b/server/api/default_report/default_report.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var DefaultReport = require('../../models').DefaultReport; - -exports.register = function(socket) { - DefaultReport.afterCreate(function(doc) { - onSave(socket, doc); - }); - DefaultReport.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('default_report:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('default_report:remove', doc); -} +var _0x533e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x44\x65\x66\x61\x75\x6C\x74\x52\x65\x70\x6F\x72\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x66\x61\x75\x6C\x74\x5F\x72\x65\x70\x6F\x72\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x64\x65\x66\x61\x75\x6C\x74\x5F\x72\x65\x70\x6F\x72\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x533e[0];var DefaultReport=require(_0x533e[2])[_0x533e[1]];exports[_0x533e[3]]=function(_0xa6c4x2){DefaultReport[_0x533e[4]](function(_0xa6c4x3){onSave(_0xa6c4x2,_0xa6c4x3)});DefaultReport[_0x533e[5]](function(_0xa6c4x3){onRemove(_0xa6c4x2,_0xa6c4x3)});};function onSave(_0xa6c4x2,_0xa6c4x3,_0xa6c4x5){_0xa6c4x2[_0x533e[7]](_0x533e[6],_0xa6c4x3)}function onRemove(_0xa6c4x2,_0xa6c4x3,_0xa6c4x5){_0xa6c4x2[_0x533e[7]](_0x533e[8],_0xa6c4x3)} \ No newline at end of file diff --git a/server/api/default_report/default_report.spec.js b/server/api/default_report/default_report.spec.js index 2a6c81d..6f840ae 100644 --- a/server/api/default_report/default_report.spec.js +++ b/server/api/default_report/default_report.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/analytics/reports/default', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/analytic/reports/default') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x6b36=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x64\x65\x66\x61\x75\x6C\x74","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x64\x65\x66\x61\x75\x6C\x74","\x67\x65\x74"];_0x6b36[0];var should=require(_0x6b36[1]);var app=require(_0x6b36[2]);var request=require(_0x6b36[3]);describe(_0x6b36[4],function(){it(_0x6b36[5],function(_0xe539x4){request(app)[_0x6b36[13]](_0x6b36[12])[_0x6b36[11]](200)[_0x6b36[11]](_0x6b36[10],/json/)[_0x6b36[9]](function(_0xe539x5,_0xe539x6){if(_0xe539x5){return _0xe539x4(_0xe539x5)};_0xe539x6[_0x6b36[8]][_0x6b36[1]][_0x6b36[7]][_0x6b36[6]](Array);_0xe539x4();})})}); \ No newline at end of file diff --git a/server/api/default_report/index.js b/server/api/default_report/index.js index 6bf1130..be40605 100644 --- a/server/api/default_report/index.js +++ b/server/api/default_report/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./default_report.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xe08a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x64\x65\x66\x61\x75\x6C\x74\x5F\x72\x65\x70\x6F\x72\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xe08a[0];var express=require(_0xe08a[1]);var controller=require(_0xe08a[2]);var router=express.Router();router[_0xe08a[5]](_0xe08a[3],controller[_0xe08a[4]]);router[_0xe08a[5]](_0xe08a[6],controller[_0xe08a[7]]);router[_0xe08a[9]](_0xe08a[3],controller[_0xe08a[8]]);router[_0xe08a[11]](_0xe08a[6],controller[_0xe08a[10]]);router[_0xe08a[12]](_0xe08a[6],controller[_0xe08a[10]]);router[_0xe08a[14]](_0xe08a[6],controller[_0xe08a[13]]);module[_0xe08a[15]]=router; \ No newline at end of file diff --git a/server/api/desk_account/desk_account.controller.js b/server/api/desk_account/desk_account.controller.js index 78e1902..9f59697 100644 --- a/server/api/desk_account/desk_account.controller.js +++ b/server/api/desk_account/desk_account.controller.js @@ -1,256 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var desk = require('desk.js'); - -var DeskAccount = require('../../models').DeskAccount; - -// Get list of desk_accounts -exports.index = function(req, res) { - var attributes = ['description', 'name', 'username', 'remoteUri']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - DeskAccount - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - return res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single desk_account -exports.show = function(req, res) { - DeskAccount - .findById(req.params.id) - .then(function(desk_account) { - if (!desk_account) { - return res.sendStatus(404); - } - return res.send(desk_account); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new desk_account in the DB. -exports.create = function(req, res, next) { - DeskAccount - .create(req.body) - .then(function(desk_account) { - return res.status(201).send(desk_account); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing desk_account in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - DeskAccount - .findById(req.params.id) - .then(function(desk_account) { - if (!desk_account) { - return res.sendStatus(404); - } - var updated = _.merge(desk_account, req.body); - updated.save() - .then(function() { - return res.status(200).send(desk_account); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a desk_account from the DB. -exports.destroy = function(req, res) { - DeskAccount - .findById(req.params.id) - .then(function(desk_account) { - if (!desk_account) { - return res.sendStatus(404); - } - desk_account.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.checkAccount = function(req, res) { - DeskAccount - .findById(req.params.id) - .then(function(account) { - var desk_account = { - endpoint: stripTrailingSlash(account.remoteUri), - retry: false - }; - if (account.authType === 'basic') { - desk_account.username = account.username; - desk_account.password = account.password; - } else if (account.authType === 'oauth') { - desk_account.consumerKey = account.consumerKey; - desk_account.consumerSecret = account.consumerSecret; - desk_account.token = account.token; - desk_account.tokenSecret = account.tokenSecret; - } - var client = desk.createClient(desk_account); - client.get('/api/v2/users/me', function(err, body, response) { - if (err) { - return handleError(res, err); - } - return res.sendStatus(200); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.deskValidation = function(req, res) { - var where = {}; - where[req.params.field] = req.body.value; - DeskAccount - .findAndCountAll({ - where: where - }) - .then(function(result) { - if (result.count) { - return res.status(200).send({ - isValid: false, - value: req.body.value - }); - } - return res.status(200).send({ - isValid: true, - value: req.body.value - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getFields = function(req, res) { - DeskAccount - .findById(req.params.id) - .then(function(account) { - var desk_account = { - endpoint: stripTrailingSlash(account.remoteUri), - retry: false - }; - if (account.authType === 'basic') { - desk_account.username = account.username; - desk_account.password = account.password; - } else if (account.authType === 'oauth') { - desk_account.consumerKey = account.consumerKey; - desk_account.consumerSecret = account.consumerSecret; - desk_account.token = account.token; - desk_account.tokenSecret = account.tokenSecret; - } - var client = desk.createClient(desk_account); - client.get('/api/v2/custom_fields', function(err, body, response) { - if (err) { - return handleError(res, err); - } - return res.status(200).json(body._embedded.entries); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -} - -exports.bulkDestroy = function(req, res) { - DeskAccount - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function stripTrailingSlash(str) { - if (str.substr(-1) === '/') { - return str.substr(0, str.length - 1); - } - return str; -} - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x5aa0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x64\x65\x73\x6B\x2E\x6A\x73","\x44\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x61\x75\x74\x68\x54\x79\x70\x65","\x62\x61\x73\x69\x63","\x70\x61\x73\x73\x77\x6F\x72\x64","\x6F\x61\x75\x74\x68","\x63\x6F\x6E\x73\x75\x6D\x65\x72\x4B\x65\x79","\x63\x6F\x6E\x73\x75\x6D\x65\x72\x53\x65\x63\x72\x65\x74","\x74\x6F\x6B\x65\x6E","\x74\x6F\x6B\x65\x6E\x53\x65\x63\x72\x65\x74","\x63\x72\x65\x61\x74\x65\x43\x6C\x69\x65\x6E\x74","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x75\x73\x65\x72\x73\x2F\x6D\x65","\x67\x65\x74","\x64\x65\x73\x6B\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x73","\x65\x6E\x74\x72\x69\x65\x73","\x5F\x65\x6D\x62\x65\x64\x64\x65\x64","\x6A\x73\x6F\x6E","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x73\x75\x62\x73\x74\x72","\x2F","\x6C\x65\x6E\x67\x74\x68"];_0x5aa0[0];var _=require(_0x5aa0[1]);var util=require(_0x5aa0[2]);var desk=require(_0x5aa0[3]);var DeskAccount=require(_0x5aa0[5])[_0x5aa0[4]];exports[_0x5aa0[6]]=function(_0x4306x5,_0x4306x6){var _0x4306x7=[_0x5aa0[7],_0x5aa0[8],_0x5aa0[9],_0x5aa0[10]];var _0x4306x8=_0x4306x5[_0x5aa0[12]][_0x5aa0[11]]?parseInt(_0x4306x5[_0x5aa0[12]][_0x5aa0[11]],10):100;var _0x4306x9=_0x4306x5[_0x5aa0[12]][_0x5aa0[13]]?parseInt(_0x4306x5[_0x5aa0[12]][_0x5aa0[13]],10):0;var _0x4306xa={where:{},limit:_0x4306x8,offset:_0x4306x9*_0x4306x8};_[_0x5aa0[27]](_0x4306x5[_0x5aa0[12]],function(_0x4306xb,_0x4306xc){switch(_0x4306xc){case _0x5aa0[11]:;case _0x5aa0[13]:break ;;case _0x5aa0[16]:_0x4306xa[_0x5aa0[14]]=util[_0x5aa0[19]](_0x5aa0[15],_0x4306x5[_0x5aa0[12]][_0x5aa0[16]],_0x4306x5[_0x5aa0[12]][_0x5aa0[17]]||_0x5aa0[18])||null;break ;;case _0x5aa0[17]:break ;;case _0x5aa0[25]:_0x4306xa[_0x5aa0[21]][_0x5aa0[20]]=[];_0x4306x7[_0x5aa0[24]](function(_0x4306xd){var _0x4306xe={};_0x4306xe[_0x4306xd]={$like:_0x5aa0[22]+_0x4306xb+_0x5aa0[22]};_0x4306xa[_0x5aa0[21]][_0x5aa0[20]][_0x5aa0[23]](_0x4306xe);});break ;;default:_0x4306xa[_0x5aa0[21]][_0x4306xc]={$like:{}};_0x4306xa[_0x5aa0[21]][_0x4306xc][_0x5aa0[26]]=_0x5aa0[22]+_0x4306xb+_0x5aa0[22];;}});DeskAccount[_0x5aa0[42]](_0x4306xa)[_0x5aa0[41]](function(_0x4306x10){var _0x4306x11=Math[_0x5aa0[33]](_0x4306x10[_0x5aa0[32]]/_0x4306x8);var _0x4306x12=_0x4306x11>(_0x4306xa[_0x5aa0[34]]+1)?util[_0x5aa0[19]](_0x5aa0[35],_0x4306x5[_0x5aa0[36]],_0x4306x5[_0x5aa0[38]][_0x5aa0[37]],_0x4306x5[_0x5aa0[39]],_0x4306x9+1):null;var _0x4306x13=_0x4306x9>0?util[_0x5aa0[19]](_0x5aa0[35],_0x4306x5[_0x5aa0[36]],_0x4306x5[_0x5aa0[38]][_0x5aa0[37]],_0x4306x5[_0x5aa0[39]],_0x4306x9-1):null;return _0x4306x6[_0x5aa0[30]](200)[_0x5aa0[29]]({count:_0x4306x10[_0x5aa0[32]],rows:_0x4306x10[_0x5aa0[40]],next_page:_0x4306x12,previous_page:_0x4306x13,total_pages:_0x4306x11});})[_0x5aa0[31]](function(_0x4306xf){return _0x4306x6[_0x5aa0[30]](500)[_0x5aa0[29]]({error:_0x5aa0[28]})});};exports[_0x5aa0[43]]=function(_0x4306x5,_0x4306x6){DeskAccount[_0x5aa0[47]](_0x4306x5[_0x5aa0[46]][_0x5aa0[45]])[_0x5aa0[41]](function(_0x4306x14){if(!_0x4306x14){return _0x4306x6[_0x5aa0[44]](404)};return _0x4306x6[_0x5aa0[29]](_0x4306x14);})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)})};exports[_0x5aa0[48]]=function(_0x4306x5,_0x4306x6,_0x4306x15){DeskAccount[_0x5aa0[48]](_0x4306x5[_0x5aa0[49]])[_0x5aa0[41]](function(_0x4306x14){return _0x4306x6[_0x5aa0[30]](201)[_0x5aa0[29]](_0x4306x14)})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)})};exports[_0x5aa0[50]]=function(_0x4306x5,_0x4306x6){if(_0x4306x5[_0x5aa0[49]][_0x5aa0[45]]){delete _0x4306x5[_0x5aa0[49]][_0x5aa0[45]]};DeskAccount[_0x5aa0[47]](_0x4306x5[_0x5aa0[46]][_0x5aa0[45]])[_0x5aa0[41]](function(_0x4306x14){if(!_0x4306x14){return _0x4306x6[_0x5aa0[44]](404)};var _0x4306x16=_[_0x5aa0[51]](_0x4306x14,_0x4306x5[_0x5aa0[49]]);_0x4306x16[_0x5aa0[52]]()[_0x5aa0[41]](function(){return _0x4306x6[_0x5aa0[30]](200)[_0x5aa0[29]](_0x4306x14)})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)});})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)});};exports[_0x5aa0[53]]=function(_0x4306x5,_0x4306x6){DeskAccount[_0x5aa0[47]](_0x4306x5[_0x5aa0[46]][_0x5aa0[45]])[_0x5aa0[41]](function(_0x4306x14){if(!_0x4306x14){return _0x4306x6[_0x5aa0[44]](404)};_0x4306x14[_0x5aa0[53]]()[_0x5aa0[41]](function(){return _0x4306x6[_0x5aa0[44]](204)})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)});})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)})};exports[_0x5aa0[54]]=function(_0x4306x5,_0x4306x6){DeskAccount[_0x5aa0[47]](_0x4306x5[_0x5aa0[46]][_0x5aa0[45]])[_0x5aa0[41]](function(_0x4306x17){var _0x4306x14={endpoint:stripTrailingSlash(_0x4306x17[_0x5aa0[10]]),retry:false};if(_0x4306x17[_0x5aa0[55]]===_0x5aa0[56]){_0x4306x14[_0x5aa0[9]]=_0x4306x17[_0x5aa0[9]];_0x4306x14[_0x5aa0[57]]=_0x4306x17[_0x5aa0[57]];}else {if(_0x4306x17[_0x5aa0[55]]===_0x5aa0[58]){_0x4306x14[_0x5aa0[59]]=_0x4306x17[_0x5aa0[59]];_0x4306x14[_0x5aa0[60]]=_0x4306x17[_0x5aa0[60]];_0x4306x14[_0x5aa0[61]]=_0x4306x17[_0x5aa0[61]];_0x4306x14[_0x5aa0[62]]=_0x4306x17[_0x5aa0[62]];}};var _0x4306x18=desk[_0x5aa0[63]](_0x4306x14);_0x4306x18[_0x5aa0[65]](_0x5aa0[64],function(_0x4306xf,_0x4306x19,_0x4306x1a){if(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)};return _0x4306x6[_0x5aa0[44]](200);});})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)})};exports[_0x5aa0[66]]=function(_0x4306x5,_0x4306x6){var _0x4306x1b={};_0x4306x1b[_0x4306x5[_0x5aa0[46]][_0x5aa0[67]]]=_0x4306x5[_0x5aa0[49]][_0x5aa0[68]];DeskAccount[_0x5aa0[42]]({where:_0x4306x1b})[_0x5aa0[41]](function(_0x4306x10){if(_0x4306x10[_0x5aa0[32]]){return _0x4306x6[_0x5aa0[30]](200)[_0x5aa0[29]]({isValid:false,value:_0x4306x5[_0x5aa0[49]][_0x5aa0[68]]})};return _0x4306x6[_0x5aa0[30]](200)[_0x5aa0[29]]({isValid:true,value:_0x4306x5[_0x5aa0[49]][_0x5aa0[68]]});})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)});};exports[_0x5aa0[69]]=function(_0x4306x5,_0x4306x6){DeskAccount[_0x5aa0[47]](_0x4306x5[_0x5aa0[46]][_0x5aa0[45]])[_0x5aa0[41]](function(_0x4306x17){var _0x4306x14={endpoint:stripTrailingSlash(_0x4306x17[_0x5aa0[10]]),retry:false};if(_0x4306x17[_0x5aa0[55]]===_0x5aa0[56]){_0x4306x14[_0x5aa0[9]]=_0x4306x17[_0x5aa0[9]];_0x4306x14[_0x5aa0[57]]=_0x4306x17[_0x5aa0[57]];}else {if(_0x4306x17[_0x5aa0[55]]===_0x5aa0[58]){_0x4306x14[_0x5aa0[59]]=_0x4306x17[_0x5aa0[59]];_0x4306x14[_0x5aa0[60]]=_0x4306x17[_0x5aa0[60]];_0x4306x14[_0x5aa0[61]]=_0x4306x17[_0x5aa0[61]];_0x4306x14[_0x5aa0[62]]=_0x4306x17[_0x5aa0[62]];}};var _0x4306x18=desk[_0x5aa0[63]](_0x4306x14);_0x4306x18[_0x5aa0[65]](_0x5aa0[70],function(_0x4306xf,_0x4306x19,_0x4306x1a){if(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)};return _0x4306x6[_0x5aa0[30]](200)[_0x5aa0[73]](_0x4306x19[_0x5aa0[72]][_0x5aa0[71]]);});})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)})};exports[_0x5aa0[74]]=function(_0x4306x5,_0x4306x6){DeskAccount[_0x5aa0[53]]({where:{id:_0x4306x5[_0x5aa0[12]][_0x5aa0[45]]},individualHooks:true})[_0x5aa0[41]](function(){return _0x4306x6[_0x5aa0[44]](204)})[_0x5aa0[31]](function(_0x4306xf){return handleError(_0x4306x6,_0x4306xf)})};function stripTrailingSlash(_0x4306x1d){if(_0x4306x1d[_0x5aa0[75]](-1)===_0x5aa0[76]){return _0x4306x1d[_0x5aa0[75]](0,_0x4306x1d[_0x5aa0[77]]-1)};return _0x4306x1d;}function handleError(_0x4306x6,_0x4306xf){return _0x4306x6[_0x5aa0[30]](500)[_0x5aa0[29]](_0x4306xf)} \ No newline at end of file diff --git a/server/api/desk_account/desk_account.socket.js b/server/api/desk_account/desk_account.socket.js index 3f7badd..ebffac8 100644 --- a/server/api/desk_account/desk_account.socket.js +++ b/server/api/desk_account/desk_account.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var DeskAccount = require('../../models').DeskAccount; - -exports.register = function(socket) { - DeskAccount.afterCreate(function (doc) { - onSave(socket, doc); - }); - DeskAccount.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('desk_account:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('desk_account:remove', doc); -} +var _0xa1ad=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x44\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xa1ad[0];var DeskAccount=require(_0xa1ad[2])[_0xa1ad[1]];exports[_0xa1ad[3]]=function(_0x80c1x2){DeskAccount[_0xa1ad[4]](function(_0x80c1x3){onSave(_0x80c1x2,_0x80c1x3)});DeskAccount[_0xa1ad[5]](function(_0x80c1x3){onRemove(_0x80c1x2,_0x80c1x3)});};function onSave(_0x80c1x2,_0x80c1x3,_0x80c1x5){_0x80c1x2[_0xa1ad[7]](_0xa1ad[6],_0x80c1x3)}function onRemove(_0x80c1x2,_0x80c1x3,_0x80c1x5){_0x80c1x2[_0xa1ad[7]](_0xa1ad[8],_0x80c1x3)} \ No newline at end of file diff --git a/server/api/desk_account/desk_account.spec.js b/server/api/desk_account/desk_account.spec.js index a56fc11..55bf6c8 100644 --- a/server/api/desk_account/desk_account.spec.js +++ b/server/api/desk_account/desk_account.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/desk/accounts', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/desk/accounts') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xbe00=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x67\x65\x74"];_0xbe00[0];var should=require(_0xbe00[1]);var app=require(_0xbe00[2]);var request=require(_0xbe00[3]);describe(_0xbe00[4],function(){it(_0xbe00[5],function(_0x1ac3x4){request(app)[_0xbe00[13]](_0xbe00[12])[_0xbe00[11]](200)[_0xbe00[11]](_0xbe00[10],/json/)[_0xbe00[9]](function(_0x1ac3x5,_0x1ac3x6){if(_0x1ac3x5){return _0x1ac3x4(_0x1ac3x5)};_0x1ac3x6[_0xbe00[8]][_0xbe00[1]][_0xbe00[7]][_0xbe00[6]](Array);_0x1ac3x4();})})}); \ No newline at end of file diff --git a/server/api/desk_account/index.js b/server/api/desk_account/index.js index 4a593d0..e6bcc3a 100644 --- a/server/api/desk_account/index.js +++ b/server/api/desk_account/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./desk_account.controller'); -var auth = require('../../auth/auth.service'); -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount); -router.get('/:id/fields', auth.isAuthenticated(), controller.getFields); -router.post('/validate/:field', auth.isAuthenticated(), controller.deskValidation); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x3211=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x63\x68\x65\x63\x6B","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2F\x3A\x69\x64\x2F\x66\x69\x65\x6C\x64\x73","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65\x2F\x3A\x66\x69\x65\x6C\x64","\x64\x65\x73\x6B\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x3211[0];var express=require(_0x3211[1]);var controller=require(_0x3211[2]);var auth=require(_0x3211[3]);var router=express.Router();router[_0x3211[7]](_0x3211[4],auth[_0x3211[5]](),controller[_0x3211[6]]);router[_0x3211[7]](_0x3211[8],auth[_0x3211[5]](),controller[_0x3211[9]]);router[_0x3211[7]](_0x3211[10],auth[_0x3211[5]](),controller[_0x3211[11]]);router[_0x3211[7]](_0x3211[12],auth[_0x3211[5]](),controller[_0x3211[13]]);router[_0x3211[16]](_0x3211[14],auth[_0x3211[5]](),controller[_0x3211[15]]);router[_0x3211[16]](_0x3211[4],auth[_0x3211[5]](),controller[_0x3211[17]]);router[_0x3211[19]](_0x3211[8],auth[_0x3211[5]](),controller[_0x3211[18]]);router[_0x3211[20]](_0x3211[8],auth[_0x3211[5]](),controller[_0x3211[18]]);router[_0x3211[22]](_0x3211[4],auth[_0x3211[5]](),controller[_0x3211[21]]);router[_0x3211[22]](_0x3211[8],auth[_0x3211[5]](),controller[_0x3211[23]]);module[_0x3211[24]]=router; \ No newline at end of file diff --git a/server/api/desk_configuration/desk_configuration.controller.js b/server/api/desk_configuration/desk_configuration.controller.js index 3824ca1..ee78167 100644 --- a/server/api/desk_configuration/desk_configuration.controller.js +++ b/server/api/desk_configuration/desk_configuration.controller.js @@ -1,145 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/desk/configurations -> index - * POST /api/desk/configurations -> create - * GET /api/desk/configurations/:id -> show - * PUT /api/desk/configurations/:id -> update - * DELETE /api/desk/configurations/:id -> destroy - */ - -'use strict'; - -var _ = require('lodash'); - -var DeskConfiguration = require('../../models').DeskConfiguration; -var DeskField = require('../../models').DeskField; - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of DeskConfigurations -exports.index = function(req, res) { - DeskConfiguration.findAll({ - where: req.query - }) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single DeskConfiguration from the DB -exports.show = function(req, res) { - DeskConfiguration.find({ - where: { - id: req.params.id - }, - include: [{ - model: DeskField, - as: 'Subject' - }, { - model: DeskField, - as: 'Description' - }, { - model: DeskField, - as: 'Field' - }] - }) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new DeskConfiguration in the DB -exports.create = function(req, res) { - DeskConfiguration.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing DeskConfiguration in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - DeskConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a DeskConfiguration from the DB -exports.destroy = function(req, res) { - DeskConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} - -exports.addConfigurationField = function(req, res, next) { - // console.log(req.params); - var deskConfiguration; - DeskConfiguration - .findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(desk_configuration) { - deskConfiguration = desk_configuration; - return DeskField.create(req.body) - }) - .then(function(deskField) { - switch (req.params.type) { - case 'subject': - return [deskConfiguration.addSubject(deskField), deskField]; - case 'description': - return [deskConfiguration.addDescription(deskField), deskField]; - case 'field': - return [deskConfiguration.addField(deskField), deskField]; - } - }) - .spread(function(data, deskField) { - return res.status(201).json(deskField); - }) - .catch(handleError(res)); -}; +var _0x1f96=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x44\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x44\x65\x73\x6B\x46\x69\x65\x6C\x64","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x53\x75\x62\x6A\x65\x63\x74","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x46\x69\x65\x6C\x64","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x73\x70\x72\x65\x61\x64","\x61\x64\x64\x53\x75\x62\x6A\x65\x63\x74","\x73\x75\x62\x6A\x65\x63\x74","\x61\x64\x64\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x61\x64\x64\x46\x69\x65\x6C\x64","\x66\x69\x65\x6C\x64","\x74\x79\x70\x65"];_0x1f96[0];var _=require(_0x1f96[1]);var DeskConfiguration=require(_0x1f96[3])[_0x1f96[2]];var DeskField=require(_0x1f96[3])[_0x1f96[4]];function handleError(_0xfb0ex5,_0xfb0ex6){_0xfb0ex6=_0xfb0ex6||500;return function(_0xfb0ex7){_0xfb0ex5[_0x1f96[6]](_0xfb0ex6)[_0x1f96[5]](_0xfb0ex7)};}function responseWithResult(_0xfb0ex5,_0xfb0ex6){_0xfb0ex6=_0xfb0ex6||200;return function(_0xfb0ex9){if(_0xfb0ex9){_0xfb0ex5[_0x1f96[6]](_0xfb0ex6)[_0x1f96[7]](_0xfb0ex9)}};}function handleEntityNotFound(_0xfb0ex5){return function(_0xfb0ex9){if(!_0xfb0ex9){_0xfb0ex5[_0x1f96[6]](404)[_0x1f96[8]]();return null;};return _0xfb0ex9;}}function saveUpdates(_0xfb0exc){return function(_0xfb0ex9){return _0xfb0ex9[_0x1f96[10]](_0xfb0exc)[_0x1f96[9]](function(_0xfb0exd){return _0xfb0exd})}}function removeEntity(_0xfb0ex5){return function(_0xfb0ex9){if(_0xfb0ex9){return _0xfb0ex9[_0x1f96[11]]()[_0x1f96[9]](function(){_0xfb0ex5[_0x1f96[6]](204)[_0x1f96[8]]()})}}}exports[_0x1f96[12]]=function(_0xfb0exf,_0xfb0ex5){DeskConfiguration[_0x1f96[15]]({where:_0xfb0exf[_0x1f96[14]]})[_0x1f96[9]](responseWithResult(_0xfb0ex5))[_0x1f96[13]](handleError(_0xfb0ex5))};exports[_0x1f96[16]]=function(_0xfb0exf,_0xfb0ex5){DeskConfiguration[_0x1f96[22]]({where:{id:_0xfb0exf[_0x1f96[18]][_0x1f96[17]]},include:[{model:DeskField,as:_0x1f96[19]},{model:DeskField,as:_0x1f96[20]},{model:DeskField,as:_0x1f96[21]}]})[_0x1f96[9]](handleEntityNotFound(_0xfb0ex5))[_0x1f96[9]](responseWithResult(_0xfb0ex5))[_0x1f96[13]](handleError(_0xfb0ex5))};exports[_0x1f96[23]]=function(_0xfb0exf,_0xfb0ex5){DeskConfiguration[_0x1f96[23]](_0xfb0exf[_0x1f96[24]])[_0x1f96[9]](responseWithResult(_0xfb0ex5,201))[_0x1f96[13]](handleError(_0xfb0ex5))};exports[_0x1f96[25]]=function(_0xfb0exf,_0xfb0ex5){if(_0xfb0exf[_0x1f96[24]][_0x1f96[17]]){delete _0xfb0exf[_0x1f96[24]][_0x1f96[17]]};DeskConfiguration[_0x1f96[26]](_0xfb0exf[_0x1f96[18]][_0x1f96[17]])[_0x1f96[9]](handleEntityNotFound(_0xfb0ex5))[_0x1f96[9]](saveUpdates(_0xfb0exf[_0x1f96[24]]))[_0x1f96[9]](responseWithResult(_0xfb0ex5))[_0x1f96[13]](handleError(_0xfb0ex5));};exports[_0x1f96[11]]=function(_0xfb0exf,_0xfb0ex5){DeskConfiguration[_0x1f96[26]](_0xfb0exf[_0x1f96[18]][_0x1f96[17]])[_0x1f96[9]](handleEntityNotFound(_0xfb0ex5))[_0x1f96[9]](removeEntity(_0xfb0ex5))[_0x1f96[13]](handleError(_0xfb0ex5))};exports[_0x1f96[27]]=function(_0xfb0exf,_0xfb0ex5,_0xfb0ex10){var _0xfb0ex11;DeskConfiguration[_0x1f96[26]](_0xfb0exf[_0x1f96[18]][_0x1f96[17]])[_0x1f96[9]](handleEntityNotFound(_0xfb0ex5))[_0x1f96[9]](function(_0xfb0ex14){_0xfb0ex11=_0xfb0ex14;return DeskField[_0x1f96[23]](_0xfb0exf[_0x1f96[24]]);})[_0x1f96[9]](function(_0xfb0ex13){switch(_0xfb0exf[_0x1f96[18]][_0x1f96[35]]){case _0x1f96[30]:return [_0xfb0ex11[_0x1f96[29]](_0xfb0ex13),_0xfb0ex13];;case _0x1f96[32]:return [_0xfb0ex11[_0x1f96[31]](_0xfb0ex13),_0xfb0ex13];;case _0x1f96[34]:return [_0xfb0ex11[_0x1f96[33]](_0xfb0ex13),_0xfb0ex13];;}})[_0x1f96[28]](function(_0xfb0ex12,_0xfb0ex13){return _0xfb0ex5[_0x1f96[6]](201)[_0x1f96[7]](_0xfb0ex13)})[_0x1f96[13]](handleError(_0xfb0ex5));}; \ No newline at end of file diff --git a/server/api/desk_configuration/desk_configuration.socket.js b/server/api/desk_configuration/desk_configuration.socket.js index d26e4f6..96e1889 100644 --- a/server/api/desk_configuration/desk_configuration.socket.js +++ b/server/api/desk_configuration/desk_configuration.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var DeskConfiguration = require('../../models').DeskConfiguration; - -exports.register = function(socket) { - DeskConfiguration.afterCreate(function(doc) { - onSave(socket, doc); - }); - DeskConfiguration.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('desk_configuration:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('desk_configuration:remove', doc); -} +var _0xfc7f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x44\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xfc7f[0];var DeskConfiguration=require(_0xfc7f[2])[_0xfc7f[1]];exports[_0xfc7f[3]]=function(_0xe905x2){DeskConfiguration[_0xfc7f[4]](function(_0xe905x3){onSave(_0xe905x2,_0xe905x3)});DeskConfiguration[_0xfc7f[5]](function(_0xe905x3){onRemove(_0xe905x2,_0xe905x3)});};function onSave(_0xe905x2,_0xe905x3,_0xe905x5){_0xe905x2[_0xfc7f[7]](_0xfc7f[6],_0xe905x3)}function onRemove(_0xe905x2,_0xe905x3,_0xe905x5){_0xe905x2[_0xfc7f[7]](_0xfc7f[8],_0xe905x3)} \ No newline at end of file diff --git a/server/api/desk_configuration/index.js b/server/api/desk_configuration/index.js index 91adaf0..ddba6ef 100644 --- a/server/api/desk_configuration/index.js +++ b/server/api/desk_configuration/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./desk_configuration.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); - -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0xef25=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x3A\x69\x64\x2F\x3A\x74\x79\x70\x65","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xef25[0];var express=require(_0xef25[1]);var auth=require(_0xef25[2]);var controller=require(_0xef25[3]);var router=express.Router();router[_0xef25[7]](_0xef25[4],auth[_0xef25[5]](),controller[_0xef25[6]]);router[_0xef25[7]](_0xef25[8],auth[_0xef25[5]](),controller[_0xef25[9]]);router[_0xef25[11]](_0xef25[4],auth[_0xef25[5]](),controller[_0xef25[10]]);router[_0xef25[13]](_0xef25[8],auth[_0xef25[5]](),controller[_0xef25[12]]);router[_0xef25[11]](_0xef25[14],auth[_0xef25[5]](),controller[_0xef25[15]]);router[_0xef25[16]](_0xef25[8],auth[_0xef25[5]](),controller[_0xef25[12]]);router[_0xef25[18]](_0xef25[8],auth[_0xef25[5]](),controller[_0xef25[17]]);module[_0xef25[19]]=router; \ No newline at end of file diff --git a/server/api/desk_configuration/index.spec.js b/server/api/desk_configuration/index.spec.js index fd6b650..8d90113 100644 --- a/server/api/desk_configuration/index.spec.js +++ b/server/api/desk_configuration/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var deskConfigurationCtrlStub = { - index: 'deskConfigurationCtrl.index', - show: 'deskConfigurationCtrl.show', - create: 'deskConfigurationCtrl.create', - update: 'deskConfigurationCtrl.update', - destroy: 'deskConfigurationCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var deskConfigurationIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './desk_configuration.controller': deskConfigurationCtrlStub -}); - -describe('DeskConfiguration API Router:', function() { - - it('should return an express router instance', function() { - expect(deskConfigurationIndex).to.equal(routerStub); - }); - - describe('GET /api/desk/configurations', function() { - - it('should route to deskConfiguration.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'deskConfigurationCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/desk/configurations/:id', function() { - - it('should route to deskConfiguration.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'deskConfigurationCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/desk/configurations', function() { - - it('should route to deskConfiguration.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'deskConfigurationCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/desk/configurations/:id', function() { - - it('should route to deskConfiguration.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'deskConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/desk/configurations/:id', function() { - - it('should route to deskConfiguration.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'deskConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/desk/configurations/:id', function() { - - it('should route to deskConfiguration.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'deskConfigurationCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0x726d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x44\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0x726d[0];var proxyquire=require(_0x726d[2])[_0x726d[1]]();var deskConfigurationCtrlStub={index:_0x726d[3],show:_0x726d[4],create:_0x726d[5],update:_0x726d[6],destroy:_0x726d[7]};var routerStub={get:sinon[_0x726d[8]](),put:sinon[_0x726d[8]](),patch:sinon[_0x726d[8]](),post:sinon[_0x726d[8]](),delete:sinon[_0x726d[8]]()};var deskConfigurationIndex=proxyquire(_0x726d[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":deskConfigurationCtrlStub});describe(_0x726d[10],function(){it(_0x726d[11],function(){expect(deskConfigurationIndex)[_0x726d[13]][_0x726d[12]](routerStub)});describe(_0x726d[14],function(){it(_0x726d[15],function(){expect(routerStub[_0x726d[21]][_0x726d[20]](_0x726d[19],_0x726d[3]))[_0x726d[13]][_0x726d[18]][_0x726d[17]][_0x726d[16]]})});describe(_0x726d[22],function(){it(_0x726d[23],function(){expect(routerStub[_0x726d[21]][_0x726d[20]](_0x726d[24],_0x726d[4]))[_0x726d[13]][_0x726d[18]][_0x726d[17]][_0x726d[16]]})});describe(_0x726d[25],function(){it(_0x726d[26],function(){expect(routerStub[_0x726d[27]][_0x726d[20]](_0x726d[19],_0x726d[5]))[_0x726d[13]][_0x726d[18]][_0x726d[17]][_0x726d[16]]})});describe(_0x726d[28],function(){it(_0x726d[29],function(){expect(routerStub[_0x726d[30]][_0x726d[20]](_0x726d[24],_0x726d[6]))[_0x726d[13]][_0x726d[18]][_0x726d[17]][_0x726d[16]]})});describe(_0x726d[31],function(){it(_0x726d[29],function(){expect(routerStub[_0x726d[32]][_0x726d[20]](_0x726d[24],_0x726d[6]))[_0x726d[13]][_0x726d[18]][_0x726d[17]][_0x726d[16]]})});describe(_0x726d[33],function(){it(_0x726d[34],function(){expect(routerStub[_0x726d[35]][_0x726d[20]](_0x726d[24],_0x726d[7]))[_0x726d[13]][_0x726d[18]][_0x726d[17]][_0x726d[16]]})});}); \ No newline at end of file diff --git a/server/api/desk_field/desk_field.controller.js b/server/api/desk_field/desk_field.controller.js index 6b39f83..03826f9 100644 --- a/server/api/desk_field/desk_field.controller.js +++ b/server/api/desk_field/desk_field.controller.js @@ -1,104 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/desk/fields -> index - * POST /api/desk/fields -> create - * GET /api/desk/fields/:id -> show - * PUT /api/desk/fields/:id -> update - * DELETE /api/desk/fields/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); - -var DeskField = require('../../models').DeskField; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of DeskFields -exports.index = function(req, res) { - DeskField.findAll() - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single DeskField from the DB -exports.show = function(req, res) { - DeskField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new DeskField in the DB -exports.create = function(req, res) { - DeskField.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing DeskField in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - DeskField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a DeskField from the DB -exports.destroy = function(req, res) { - DeskField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} +var _0x818d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x44\x65\x73\x6B\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65"];_0x818d[0];var _=require(_0x818d[1]);var DeskField=require(_0x818d[3])[_0x818d[2]];function handleError(_0xcc50x4,_0xcc50x5){_0xcc50x5=_0xcc50x5||500;return function(_0xcc50x6){_0xcc50x4[_0x818d[5]](_0xcc50x5)[_0x818d[4]](_0xcc50x6)};}function responseWithResult(_0xcc50x4,_0xcc50x5){_0xcc50x5=_0xcc50x5||200;return function(_0xcc50x8){if(_0xcc50x8){_0xcc50x4[_0x818d[5]](_0xcc50x5)[_0x818d[6]](_0xcc50x8)}};}function handleEntityNotFound(_0xcc50x4){return function(_0xcc50x8){if(!_0xcc50x8){_0xcc50x4[_0x818d[5]](404)[_0x818d[7]]();return null;};return _0xcc50x8;}}function saveUpdates(_0xcc50xb){return function(_0xcc50x8){return _0xcc50x8[_0x818d[9]](_0xcc50xb)[_0x818d[8]](function(_0xcc50xc){return _0xcc50xc})}}function removeEntity(_0xcc50x4){return function(_0xcc50x8){if(_0xcc50x8){return _0xcc50x8[_0x818d[10]]()[_0x818d[8]](function(){_0xcc50x4[_0x818d[5]](204)[_0x818d[7]]()})}}}exports[_0x818d[11]]=function(_0xcc50xe,_0xcc50x4){DeskField[_0x818d[13]]()[_0x818d[8]](responseWithResult(_0xcc50x4))[_0x818d[12]](handleError(_0xcc50x4))};exports[_0x818d[14]]=function(_0xcc50xe,_0xcc50x4){DeskField[_0x818d[17]](_0xcc50xe[_0x818d[16]][_0x818d[15]])[_0x818d[8]](handleEntityNotFound(_0xcc50x4))[_0x818d[8]](responseWithResult(_0xcc50x4))[_0x818d[12]](handleError(_0xcc50x4))};exports[_0x818d[18]]=function(_0xcc50xe,_0xcc50x4){DeskField[_0x818d[18]](_0xcc50xe[_0x818d[19]])[_0x818d[8]](responseWithResult(_0xcc50x4,201))[_0x818d[12]](handleError(_0xcc50x4))};exports[_0x818d[20]]=function(_0xcc50xe,_0xcc50x4){if(_0xcc50xe[_0x818d[19]][_0x818d[15]]){delete _0xcc50xe[_0x818d[19]][_0x818d[15]]};DeskField[_0x818d[17]](_0xcc50xe[_0x818d[16]][_0x818d[15]])[_0x818d[8]](handleEntityNotFound(_0xcc50x4))[_0x818d[8]](saveUpdates(_0xcc50xe[_0x818d[19]]))[_0x818d[8]](responseWithResult(_0xcc50x4))[_0x818d[12]](handleError(_0xcc50x4));};exports[_0x818d[10]]=function(_0xcc50xe,_0xcc50x4){DeskField[_0x818d[17]](_0xcc50xe[_0x818d[16]][_0x818d[15]])[_0x818d[8]](handleEntityNotFound(_0xcc50x4))[_0x818d[8]](removeEntity(_0xcc50x4))[_0x818d[12]](handleError(_0xcc50x4))}; \ No newline at end of file diff --git a/server/api/desk_field/desk_field.socket.js b/server/api/desk_field/desk_field.socket.js index b01d8f1..bc1b8d3 100644 --- a/server/api/desk_field/desk_field.socket.js +++ b/server/api/desk_field/desk_field.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var DeskField = require('../../models').DeskField; - -exports.register = function(socket) { - DeskField.afterCreate(function(doc) { - onSave(socket, doc); - }); - DeskField.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('desk_field:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('desk_field:remove', doc); -} +var _0x8aa7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x44\x65\x73\x6B\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0x8aa7[0];var DeskField=require(_0x8aa7[2])[_0x8aa7[1]];exports[_0x8aa7[3]]=function(_0x22d1x2){DeskField[_0x8aa7[4]](function(_0x22d1x3){onSave(_0x22d1x2,_0x22d1x3)});DeskField[_0x8aa7[5]](function(_0x22d1x3){onRemove(_0x22d1x2,_0x22d1x3)});};function onSave(_0x22d1x2,_0x22d1x3,_0x22d1x5){_0x22d1x2[_0x8aa7[7]](_0x8aa7[6],_0x22d1x3)}function onRemove(_0x22d1x2,_0x22d1x3,_0x22d1x5){_0x22d1x2[_0x8aa7[7]](_0x8aa7[8],_0x22d1x3)} \ No newline at end of file diff --git a/server/api/desk_field/index.js b/server/api/desk_field/index.js index 266676c..de03319 100644 --- a/server/api/desk_field/index.js +++ b/server/api/desk_field/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./desk_field.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); - -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0xb1c0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xb1c0[0];var express=require(_0xb1c0[1]);var auth=require(_0xb1c0[2]);var controller=require(_0xb1c0[3]);var router=express.Router();router[_0xb1c0[7]](_0xb1c0[4],auth[_0xb1c0[5]](),controller[_0xb1c0[6]]);router[_0xb1c0[7]](_0xb1c0[8],auth[_0xb1c0[5]](),controller[_0xb1c0[9]]);router[_0xb1c0[11]](_0xb1c0[4],auth[_0xb1c0[5]](),controller[_0xb1c0[10]]);router[_0xb1c0[13]](_0xb1c0[8],auth[_0xb1c0[5]](),controller[_0xb1c0[12]]);router[_0xb1c0[14]](_0xb1c0[8],auth[_0xb1c0[5]](),controller[_0xb1c0[12]]);router[_0xb1c0[16]](_0xb1c0[8],auth[_0xb1c0[5]](),controller[_0xb1c0[15]]);module[_0xb1c0[17]]=router; \ No newline at end of file diff --git a/server/api/desk_field/index.spec.js b/server/api/desk_field/index.spec.js index fef888c..ccf80fe 100644 --- a/server/api/desk_field/index.spec.js +++ b/server/api/desk_field/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var deskFieldCtrlStub = { - index: 'deskFieldCtrl.index', - show: 'deskFieldCtrl.show', - create: 'deskFieldCtrl.create', - update: 'deskFieldCtrl.update', - destroy: 'deskFieldCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var deskFieldIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './desk_field.controller': deskFieldCtrlStub -}); - -describe('DeskField API Router:', function() { - - it('should return an express router instance', function() { - expect(deskFieldIndex).to.equal(routerStub); - }); - - describe('GET /api/desk/fields', function() { - - it('should route to deskField.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'deskFieldCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/desk/fields/:id', function() { - - it('should route to deskField.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'deskFieldCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/desk/fields', function() { - - it('should route to deskField.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'deskFieldCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/desk/fields/:id', function() { - - it('should route to deskField.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'deskFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/desk/fields/:id', function() { - - it('should route to deskField.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'deskFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/desk/fields/:id', function() { - - it('should route to deskField.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'deskFieldCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0xcd01=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x44\x65\x73\x6B\x46\x69\x65\x6C\x64\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0xcd01[0];var proxyquire=require(_0xcd01[2])[_0xcd01[1]]();var deskFieldCtrlStub={index:_0xcd01[3],show:_0xcd01[4],create:_0xcd01[5],update:_0xcd01[6],destroy:_0xcd01[7]};var routerStub={get:sinon[_0xcd01[8]](),put:sinon[_0xcd01[8]](),patch:sinon[_0xcd01[8]](),post:sinon[_0xcd01[8]](),delete:sinon[_0xcd01[8]]()};var deskFieldIndex=proxyquire(_0xcd01[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":deskFieldCtrlStub});describe(_0xcd01[10],function(){it(_0xcd01[11],function(){expect(deskFieldIndex)[_0xcd01[13]][_0xcd01[12]](routerStub)});describe(_0xcd01[14],function(){it(_0xcd01[15],function(){expect(routerStub[_0xcd01[21]][_0xcd01[20]](_0xcd01[19],_0xcd01[3]))[_0xcd01[13]][_0xcd01[18]][_0xcd01[17]][_0xcd01[16]]})});describe(_0xcd01[22],function(){it(_0xcd01[23],function(){expect(routerStub[_0xcd01[21]][_0xcd01[20]](_0xcd01[24],_0xcd01[4]))[_0xcd01[13]][_0xcd01[18]][_0xcd01[17]][_0xcd01[16]]})});describe(_0xcd01[25],function(){it(_0xcd01[26],function(){expect(routerStub[_0xcd01[27]][_0xcd01[20]](_0xcd01[19],_0xcd01[5]))[_0xcd01[13]][_0xcd01[18]][_0xcd01[17]][_0xcd01[16]]})});describe(_0xcd01[28],function(){it(_0xcd01[29],function(){expect(routerStub[_0xcd01[30]][_0xcd01[20]](_0xcd01[24],_0xcd01[6]))[_0xcd01[13]][_0xcd01[18]][_0xcd01[17]][_0xcd01[16]]})});describe(_0xcd01[31],function(){it(_0xcd01[29],function(){expect(routerStub[_0xcd01[32]][_0xcd01[20]](_0xcd01[24],_0xcd01[6]))[_0xcd01[13]][_0xcd01[18]][_0xcd01[17]][_0xcd01[16]]})});describe(_0xcd01[33],function(){it(_0xcd01[34],function(){expect(routerStub[_0xcd01[35]][_0xcd01[20]](_0xcd01[24],_0xcd01[7]))[_0xcd01[13]][_0xcd01[18]][_0xcd01[17]][_0xcd01[16]]})});}); \ No newline at end of file diff --git a/server/api/event/event.controller.js b/server/api/event/event.controller.js index 07c951f..fb38dc8 100644 --- a/server/api/event/event.controller.js +++ b/server/api/event/event.controller.js @@ -1,119 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Event = require('../../models').Event; - -// Get list of events -exports.index = function(req, res) { - Event - .findAll({ - include: [{ - all: true - }] - }) - .then(function(events) { - return res.status(200).send(events); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single event -exports.showByChannel = function(req, res) { - Event - .findAll({ - where: { - channel: req.params.channel.toUpperCase() - }, - include: [{ - all: true - }] - }) - .then(function(event) { - if (!event) { - return res.sendStatus(404); - } - return res.send(event); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single event -exports.show = function(req, res) { - Event - .findById(req.params.id) - .then(function(event) { - if (!event) { - return res.sendStatus(404); - } - return res.send(event); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new event in the DB. -exports.create = function(req, res) { - Event - .create(req.body) - .then(function(event) { - return res.status(201).send(event); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing event in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Event - .findById(req.params.id) - .then(function(event) { - if (!event) { - return res.sendStatus(404); - } - var updated = _.merge(event, req.body); - updated.save() - .then(function() { - return res.status(200).send(event); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a event from the DB. -exports.destroy = function(req, res) { - Event - .findById(req.params.id) - .then(function(event) { - if (!event) { - return res.sendStatus(404); - } - event.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x533d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x45\x76\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77\x42\x79\x43\x68\x61\x6E\x6E\x65\x6C","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x74\x6F\x55\x70\x70\x65\x72\x43\x61\x73\x65","\x63\x68\x61\x6E\x6E\x65\x6C","\x70\x61\x72\x61\x6D\x73","\x73\x68\x6F\x77","\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x533d[0];var _=require(_0x533d[1]);var Event=require(_0x533d[3])[_0x533d[2]];exports[_0x533d[4]]=function(_0x2863x3,_0x2863x4){Event[_0x533d[9]]({include:[{all:true}]})[_0x533d[8]](function(_0x2863x6){return _0x2863x4[_0x533d[7]](200)[_0x533d[6]](_0x2863x6)})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)})};exports[_0x533d[10]]=function(_0x2863x3,_0x2863x4){Event[_0x533d[9]]({where:{channel:_0x2863x3[_0x533d[14]][_0x533d[13]][_0x533d[12]]()},include:[{all:true}]})[_0x533d[8]](function(_0x2863x7){if(!_0x2863x7){return _0x2863x4[_0x533d[11]](404)};return _0x2863x4[_0x533d[6]](_0x2863x7);})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)})};exports[_0x533d[15]]=function(_0x2863x3,_0x2863x4){Event[_0x533d[17]](_0x2863x3[_0x533d[14]][_0x533d[16]])[_0x533d[8]](function(_0x2863x7){if(!_0x2863x7){return _0x2863x4[_0x533d[11]](404)};return _0x2863x4[_0x533d[6]](_0x2863x7);})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)})};exports[_0x533d[18]]=function(_0x2863x3,_0x2863x4){Event[_0x533d[18]](_0x2863x3[_0x533d[19]])[_0x533d[8]](function(_0x2863x7){return _0x2863x4[_0x533d[7]](201)[_0x533d[6]](_0x2863x7)})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)})};exports[_0x533d[20]]=function(_0x2863x3,_0x2863x4){if(_0x2863x3[_0x533d[19]][_0x533d[16]]){delete _0x2863x3[_0x533d[19]][_0x533d[16]]};Event[_0x533d[17]](_0x2863x3[_0x533d[14]][_0x533d[16]])[_0x533d[8]](function(_0x2863x7){if(!_0x2863x7){return _0x2863x4[_0x533d[11]](404)};var _0x2863x8=_[_0x533d[21]](_0x2863x7,_0x2863x3[_0x533d[19]]);_0x2863x8[_0x533d[22]]()[_0x533d[8]](function(){return _0x2863x4[_0x533d[7]](200)[_0x533d[6]](_0x2863x7)})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)});})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)});};exports[_0x533d[23]]=function(_0x2863x3,_0x2863x4){Event[_0x533d[17]](_0x2863x3[_0x533d[14]][_0x533d[16]])[_0x533d[8]](function(_0x2863x7){if(!_0x2863x7){return _0x2863x4[_0x533d[11]](404)};_0x2863x7[_0x533d[23]]()[_0x533d[8]](function(){return _0x2863x4[_0x533d[11]](204)})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)});})[_0x533d[5]](function(_0x2863x5){return handleError(_0x2863x4,_0x2863x5)})};function handleError(_0x2863x4,_0x2863x5){return _0x2863x4[_0x533d[7]](500)[_0x533d[6]](_0x2863x5)} \ No newline at end of file diff --git a/server/api/event/event.socket.js b/server/api/event/event.socket.js index cf6f9ec..9bf13a6 100644 --- a/server/api/event/event.socket.js +++ b/server/api/event/event.socket.js @@ -1,36 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Event = require('../../models').Event; - -exports.register = function(socket) { - Event.afterCreate(function(doc) { - Event - .findOne({ - where: { - id: doc.id - }, - include: [{ - all: true - }] - }) - .then(function(event) { - onSave(socket, event); - }); - }); - - Event.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit(('event:' + doc.channel + ':save').toLowerCase(), doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('event:remove', doc); -} +var _0x3782=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x45\x76\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x4F\x6E\x65","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x65\x76\x65\x6E\x74\x3A","\x63\x68\x61\x6E\x6E\x65\x6C","\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x65\x76\x65\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x3782[0];var Event=require(_0x3782[2])[_0x3782[1]];exports[_0x3782[3]]=function(_0xc326x2){Event[_0x3782[7]](function(_0xc326x3){Event[_0x3782[6]]({where:{id:_0xc326x3[_0x3782[5]]},include:[{all:true}]})[_0x3782[4]](function(_0xc326x4){onSave(_0xc326x2,_0xc326x4)})});Event[_0x3782[8]](function(_0xc326x3){onRemove(_0xc326x2,_0xc326x3)});};function onSave(_0xc326x2,_0xc326x3,_0xc326x6){_0xc326x2[_0x3782[13]]((_0x3782[10]+_0xc326x3[_0x3782[11]]+_0x3782[12])[_0x3782[9]](),_0xc326x3)}function onRemove(_0xc326x2,_0xc326x3,_0xc326x6){_0xc326x2[_0x3782[13]](_0x3782[14],_0xc326x3)} \ No newline at end of file diff --git a/server/api/event/event.spec.js b/server/api/event/event.spec.js index 190d585..3ea20f8 100644 --- a/server/api/event/event.spec.js +++ b/server/api/event/event.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/events', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/events') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x3371=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x65\x76\x65\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x65\x76\x65\x6E\x74\x73","\x67\x65\x74"];_0x3371[0];var should=require(_0x3371[1]);var app=require(_0x3371[2]);var request=require(_0x3371[3]);describe(_0x3371[4],function(){it(_0x3371[5],function(_0xe71fx4){request(app)[_0x3371[13]](_0x3371[12])[_0x3371[11]](200)[_0x3371[11]](_0x3371[10],/json/)[_0x3371[9]](function(_0xe71fx5,_0xe71fx6){if(_0xe71fx5){return _0xe71fx4(_0xe71fx5)};_0xe71fx6[_0x3371[8]][_0x3371[1]][_0x3371[7]][_0x3371[6]](Array);_0xe71fx4();})})}); \ No newline at end of file diff --git a/server/api/event/index.js b/server/api/event/index.js index d23b18d..7838b4f 100644 --- a/server/api/event/index.js +++ b/server/api/event/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./event.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/channel/:channel', controller.showByChannel); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x1800=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x65\x76\x65\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x63\x68\x61\x6E\x6E\x65\x6C\x2F\x3A\x63\x68\x61\x6E\x6E\x65\x6C","\x73\x68\x6F\x77\x42\x79\x43\x68\x61\x6E\x6E\x65\x6C","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x1800[0];var express=require(_0x1800[1]);var controller=require(_0x1800[2]);var router=express.Router();router[_0x1800[5]](_0x1800[3],controller[_0x1800[4]]);router[_0x1800[5]](_0x1800[6],controller[_0x1800[7]]);router[_0x1800[5]](_0x1800[8],controller[_0x1800[9]]);router[_0x1800[11]](_0x1800[3],controller[_0x1800[10]]);router[_0x1800[13]](_0x1800[8],controller[_0x1800[12]]);router[_0x1800[14]](_0x1800[8],controller[_0x1800[12]]);router[_0x1800[16]](_0x1800[8],controller[_0x1800[15]]);module[_0x1800[17]]=router; \ No newline at end of file diff --git a/server/api/fax_account/fax_account.controller.js b/server/api/fax_account/fax_account.controller.js index d550303..2eb6971 100644 --- a/server/api/fax_account/fax_account.controller.js +++ b/server/api/fax_account/fax_account.controller.js @@ -1,374 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var async = require('async'); - -var Trunk = require('../../models').Trunk; -var FaxAccount = require('../../models').FaxAccount; -var FaxApplication = require('../../models').FaxApplication; -var VoiceExtension = require('../../models').VoiceExtension; -var sequelize = require('../../models').sequelize; - -// Get list of agents -exports.index = function(req, res, next) { - - var attributes = ['description', 'name', 'phone']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - FaxAccount - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single faxAccount -exports.show = function(req, res, next) { - FaxAccount - .findById(req.params.id) - .then(function(faxAccount) { - if (!faxAccount) { - return res.sendStatus(404); - } - return res.send(faxAccount); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Creates a new faxAccount in the DB. -exports.create = function(req, res, next) { - // console.log(req.body); - return sequelize - .transaction() - .then(function(t) { - async.waterfall([ - function(callback) { - return FaxAccount - .create(req.body, { - transaction: t - }) - .then(function(faxAccount) { - callback(null, faxAccount); - }) - .catch(function(err) { - callback(err); - }); - }, - function(faxAccount, callback) { - return Trunk - .findById(req.body.TrunkId, { - transaction: t - }) - .then(function(faxTrunk) { - callback(null, faxAccount, faxTrunk); - }) - .catch(function(err) { - callback(err); - }); - }, - function(faxAccount, faxTrunk, callback) { - return VoiceExtension - .create({ - context: faxTrunk.context, - exten: req.body.phone, - priority: 1, - app: 'Goto', - appdata: 'inbound-fax,s,1', - type: 'inbound-fax', - TrunkId: faxTrunk.id - }, { - transaction: t - }) - .then(function(voiceExtension) { - callback(null, faxAccount); - }) - .catch(function(err) { - callback(err); - }); - } - ], function(err, faxAccount) { - if (err) { - console.log(err); - t.rollback(); - return res.status(404).send(err); - } else { - console.log('ok'); - t.commit(); - return res.status(201).send(faxAccount); - } - }) - }); -}; - -// Updates an existing faxAccount in the DB. -exports.update = function(req, res, next) { - // console.log(req.body); - // console.log(req.params); - - if (req.body.id) { - delete req.body.id; - } - - return sequelize - .transaction() - .then(function(t) { - async.waterfall([ - function(callback) { - return FaxAccount - .findOne({ - where: { - id: req.params.id - }, - include: [{ - model: Trunk - }] - }, { - transaction: t - }) - .then(function(faxAccount) { - callback(null, faxAccount); - }) - .catch(function(err) { - callback(err); - }); - }, - function(faxAccount, callback) { - return Trunk - .findById(req.body.TrunkId, { - transaction: t - }) - .then(function(trunk) { - return faxAccount - .updateAttributes({ - TrunkId: trunk.id - }, { - transaction: t - }) - .then(function(data) { - callback(null, faxAccount, trunk); - }) - .catch(function(err) { - callback(err); - }); - }) - .catch(function(err) { - callback(err); - }); - }, - function(faxAccount, trunk, callback) { - return VoiceExtension - .findOne({ - where: { - priority: 1, - exten: faxAccount.phone, - context: faxAccount.Trunk.context - } - }, { - transaction: t - }) - .then(function(voiceExtension) { - if (!voiceExtension) { - callback(null, faxAccount); - } - return voiceExtension - .updateAttributes({ - exten: req.body.phone, - context: trunk.context, - TrunkId: req.body.UserId - }, { - transaction: t - }) - .then(function() { - console.log('voiceExtension edited'); - callback(null, faxAccount); - }) - .catch(function(err) { - callback(err); - }); - }) - .catch(function(err) { - callback(err); - }); - }, - function(faxAccount, callback) { - var updated = _.merge(faxAccount, req.body); - return updated.save({ - transaction: t - }) - .then(function() { - console.log('faxAccount saved'); - callback(null, faxAccount); - }) - .catch(function(err) { - callback(err); - }); - } - ], function(err, faxAccount) { - if (err) { - console.log(err); - t.rollback(); - return res.status(404).send(err); - } else { - console.log('ok'); - t.commit(); - return res.status(201).send(faxAccount); - } - }) - }); -}; - -// Deletes a faxAccount from the DB. -exports.destroy = function(req, res, next) { - FaxAccount - .find({ - where: { - id: req.params.id - } - }) - .then(function(faxAccount) { - if (!faxAccount) { - return res.sendStatus(404); - } - faxAccount.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - next(err); - }); - }) - .catch(function(err) { - next(err); - }); -}; - -exports.addApplications = function(req, res, next) { - - FaxApplication - .findAll({ - where: { - id: req.body.applications - } - }) - .then(function(faxApplications) { - var tmpFaxApplications = faxApplications; - - return sequelize.transaction(function(t) { - return FaxApplication.destroy({ - where: { - id: req.body.applications - } - }, { - transaction: t - }).then(function() { - - var sortedApplications = []; - - for (var i = 0; i < req.body.applications.length; i++) { - - var tmpFaxApplication = _.find(tmpFaxApplications, { - 'id': req.body.applications[i] - }); - - if (tmpFaxApplication) { - tmpFaxApplication.priority = i + 1; - sortedApplications.push(tmpFaxApplication.dataValues); - } - } - - return FaxApplication.bulkCreate(sortedApplications, { - transaction: t - }).then(function(data) { - return data; - }); - }); - }).then(function(result) { - return res.status(200).send(result); - // Transaction has been committed - // result is whatever the result of the promise chain returned to the transaction callback - }).catch(function(err) { - return handleError(res, err); - // Transaction has been rolled back - // err is whatever rejected the promise chain returned to the transaction callback - }); - }) - .catch(function(err) { - return next(err); - }); -}; - -exports.bulkDestroy = function(req, res) { - FaxAccount - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xa020=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x61\x73\x79\x6E\x63","\x54\x72\x75\x6E\x6B","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x70\x68\x6F\x6E\x65","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x63\x6F\x6E\x74\x65\x78\x74","\x47\x6F\x74\x6F","\x69\x6E\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78\x2C\x73\x2C\x31","\x69\x6E\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x6C\x6F\x67","\x72\x6F\x6C\x6C\x62\x61\x63\x6B","\x6F\x6B","\x63\x6F\x6D\x6D\x69\x74","\x77\x61\x74\x65\x72\x66\x61\x6C\x6C","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x76\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x20\x65\x64\x69\x74\x65\x64","\x55\x73\x65\x72\x49\x64","\x6D\x65\x72\x67\x65","\x66\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x20\x73\x61\x76\x65\x64","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x61\x64\x64\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x6C\x65\x6E\x67\x74\x68","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x70\x72\x69\x6F\x72\x69\x74\x79","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0xa020[0];var _=require(_0xa020[1]);var util=require(_0xa020[2]);var async=require(_0xa020[3]);var Trunk=require(_0xa020[5])[_0xa020[4]];var FaxAccount=require(_0xa020[5])[_0xa020[6]];var FaxApplication=require(_0xa020[5])[_0xa020[7]];var VoiceExtension=require(_0xa020[5])[_0xa020[8]];var sequelize=require(_0xa020[5])[_0xa020[9]];exports[_0xa020[10]]=function(_0x7e4ax9,_0x7e4axa,_0x7e4axb){var _0x7e4axc=[_0xa020[11],_0xa020[12],_0xa020[13]];var _0x7e4axd=_0x7e4ax9[_0xa020[15]][_0xa020[14]]?parseInt(_0x7e4ax9[_0xa020[15]][_0xa020[14]],10):100;var _0x7e4axe=_0x7e4ax9[_0xa020[15]][_0xa020[16]]?parseInt(_0x7e4ax9[_0xa020[15]][_0xa020[16]],10):0;var _0x7e4axf={where:{},limit:_0x7e4axd,offset:_0x7e4axe*_0x7e4axd};_[_0xa020[30]](_0x7e4ax9[_0xa020[15]],function(_0x7e4ax10,_0x7e4ax11){switch(_0x7e4ax11){case _0xa020[14]:;case _0xa020[16]:break ;;case _0xa020[19]:_0x7e4axf[_0xa020[17]]=util[_0xa020[22]](_0xa020[18],_0x7e4ax9[_0xa020[15]][_0xa020[19]],_0x7e4ax9[_0xa020[15]][_0xa020[20]]||_0xa020[21])||null;break ;;case _0xa020[20]:break ;;case _0xa020[28]:_0x7e4axf[_0xa020[24]][_0xa020[23]]=[];_0x7e4axc[_0xa020[27]](function(_0x7e4ax12){var _0x7e4ax13={};_0x7e4ax13[_0x7e4ax12]={$like:_0xa020[25]+_0x7e4ax10+_0xa020[25]};_0x7e4axf[_0xa020[24]][_0xa020[23]][_0xa020[26]](_0x7e4ax13);});break ;;default:_0x7e4axf[_0xa020[24]][_0x7e4ax11]={$like:{}};_0x7e4axf[_0xa020[24]][_0x7e4ax11][_0xa020[29]]=_0xa020[25]+_0x7e4ax10+_0xa020[25];;}});FaxAccount[_0xa020[45]](_0x7e4axf)[_0xa020[44]](function(_0x7e4ax15){var _0x7e4ax16=Math[_0xa020[36]](_0x7e4ax15[_0xa020[35]]/_0x7e4axd);var _0x7e4ax17=_0x7e4ax16>(_0x7e4axf[_0xa020[37]]+1)?util[_0xa020[22]](_0xa020[38],_0x7e4ax9[_0xa020[39]],_0x7e4ax9[_0xa020[41]][_0xa020[40]],_0x7e4ax9[_0xa020[42]],_0x7e4axe+1):null;var _0x7e4ax18=_0x7e4axe>0?util[_0xa020[22]](_0xa020[38],_0x7e4ax9[_0xa020[39]],_0x7e4ax9[_0xa020[41]][_0xa020[40]],_0x7e4ax9[_0xa020[42]],_0x7e4axe-1):null;_0x7e4axa[_0xa020[33]](200)[_0xa020[32]]({count:_0x7e4ax15[_0xa020[35]],rows:_0x7e4ax15[_0xa020[43]],next_page:_0x7e4ax17,previous_page:_0x7e4ax18,total_pages:_0x7e4ax16});})[_0xa020[34]](function(_0x7e4ax14){_0x7e4axa[_0xa020[33]](500)[_0xa020[32]]({error:_0xa020[31]})});};exports[_0xa020[46]]=function(_0x7e4ax9,_0x7e4axa,_0x7e4axb){FaxAccount[_0xa020[50]](_0x7e4ax9[_0xa020[49]][_0xa020[48]])[_0xa020[44]](function(_0x7e4ax19){if(!_0x7e4ax19){return _0x7e4axa[_0xa020[47]](404)};return _0x7e4axa[_0xa020[32]](_0x7e4ax19);})[_0xa020[34]](function(_0x7e4ax14){return _0x7e4axb(_0x7e4ax14)})};exports[_0xa020[51]]=function(_0x7e4ax9,_0x7e4axa,_0x7e4axb){return sequelize[_0xa020[62]]()[_0xa020[44]](function(_0x7e4ax1a){async[_0xa020[61]]([function(_0x7e4ax1b){return FaxAccount[_0xa020[51]](_0x7e4ax9[_0xa020[52]],{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax19){_0x7e4ax1b(null,_0x7e4ax19)})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)})},function(_0x7e4ax19,_0x7e4ax1b){return Trunk[_0xa020[50]](_0x7e4ax9[_0xa020[52]].TrunkId,{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax1c){_0x7e4ax1b(null,_0x7e4ax19,_0x7e4ax1c)})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)})},function(_0x7e4ax19,_0x7e4ax1c,_0x7e4ax1b){return VoiceExtension[_0xa020[51]]({context:_0x7e4ax1c[_0xa020[53]],exten:_0x7e4ax9[_0xa020[52]][_0xa020[13]],priority:1,app:_0xa020[54],appdata:_0xa020[55],type:_0xa020[56],TrunkId:_0x7e4ax1c[_0xa020[48]]},{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax1d){_0x7e4ax1b(null,_0x7e4ax19)})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)})}],function(_0x7e4ax14,_0x7e4ax19){if(_0x7e4ax14){console[_0xa020[57]](_0x7e4ax14);_0x7e4ax1a[_0xa020[58]]();return _0x7e4axa[_0xa020[33]](404)[_0xa020[32]](_0x7e4ax14);}else {console[_0xa020[57]](_0xa020[59]);_0x7e4ax1a[_0xa020[60]]();return _0x7e4axa[_0xa020[33]](201)[_0xa020[32]](_0x7e4ax19);}})})};exports[_0xa020[63]]=function(_0x7e4ax9,_0x7e4axa,_0x7e4axb){if(_0x7e4ax9[_0xa020[52]][_0xa020[48]]){delete _0x7e4ax9[_0xa020[52]][_0xa020[48]]};return sequelize[_0xa020[62]]()[_0xa020[44]](function(_0x7e4ax1a){async[_0xa020[61]]([function(_0x7e4ax1b){return FaxAccount[_0xa020[64]]({where:{id:_0x7e4ax9[_0xa020[49]][_0xa020[48]]},include:[{model:Trunk}]},{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax19){_0x7e4ax1b(null,_0x7e4ax19)})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)})},function(_0x7e4ax19,_0x7e4ax1b){return Trunk[_0xa020[50]](_0x7e4ax9[_0xa020[52]].TrunkId,{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax1e){return _0x7e4ax19[_0xa020[65]]({TrunkId:_0x7e4ax1e[_0xa020[48]]},{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax1f){_0x7e4ax1b(null,_0x7e4ax19,_0x7e4ax1e)})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)})})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)})},function(_0x7e4ax19,_0x7e4ax1e,_0x7e4ax1b){return VoiceExtension[_0xa020[64]]({where:{priority:1,exten:_0x7e4ax19[_0xa020[13]],context:_0x7e4ax19[_0xa020[4]][_0xa020[53]]}},{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax1d){if(!_0x7e4ax1d){_0x7e4ax1b(null,_0x7e4ax19)};return _0x7e4ax1d[_0xa020[65]]({exten:_0x7e4ax9[_0xa020[52]][_0xa020[13]],context:_0x7e4ax1e[_0xa020[53]],TrunkId:_0x7e4ax9[_0xa020[52]][_0xa020[67]]},{transaction:_0x7e4ax1a})[_0xa020[44]](function(){console[_0xa020[57]](_0xa020[66]);_0x7e4ax1b(null,_0x7e4ax19);})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)});})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)})},function(_0x7e4ax19,_0x7e4ax1b){var _0x7e4ax20=_[_0xa020[68]](_0x7e4ax19,_0x7e4ax9[_0xa020[52]]);return _0x7e4ax20[_0xa020[70]]({transaction:_0x7e4ax1a})[_0xa020[44]](function(){console[_0xa020[57]](_0xa020[69]);_0x7e4ax1b(null,_0x7e4ax19);})[_0xa020[34]](function(_0x7e4ax14){_0x7e4ax1b(_0x7e4ax14)});}],function(_0x7e4ax14,_0x7e4ax19){if(_0x7e4ax14){console[_0xa020[57]](_0x7e4ax14);_0x7e4ax1a[_0xa020[58]]();return _0x7e4axa[_0xa020[33]](404)[_0xa020[32]](_0x7e4ax14);}else {console[_0xa020[57]](_0xa020[59]);_0x7e4ax1a[_0xa020[60]]();return _0x7e4axa[_0xa020[33]](201)[_0xa020[32]](_0x7e4ax19);}})});};exports[_0xa020[71]]=function(_0x7e4ax9,_0x7e4axa,_0x7e4axb){FaxAccount[_0xa020[72]]({where:{id:_0x7e4ax9[_0xa020[49]][_0xa020[48]]}})[_0xa020[44]](function(_0x7e4ax19){if(!_0x7e4ax19){return _0x7e4axa[_0xa020[47]](404)};_0x7e4ax19[_0xa020[71]]()[_0xa020[44]](function(){return _0x7e4axa[_0xa020[47]](204)})[_0xa020[34]](function(_0x7e4ax14){_0x7e4axb(_0x7e4ax14)});})[_0xa020[34]](function(_0x7e4ax14){_0x7e4axb(_0x7e4ax14)})};exports[_0xa020[73]]=function(_0x7e4ax9,_0x7e4axa,_0x7e4axb){FaxApplication[_0xa020[79]]({where:{id:_0x7e4ax9[_0xa020[52]][_0xa020[75]]}})[_0xa020[44]](function(_0x7e4ax21){var _0x7e4ax22=_0x7e4ax21;return sequelize[_0xa020[62]](function(_0x7e4ax1a){return FaxApplication[_0xa020[71]]({where:{id:_0x7e4ax9[_0xa020[52]][_0xa020[75]]}},{transaction:_0x7e4ax1a})[_0xa020[44]](function(){var _0x7e4ax23=[];for(var _0x7e4ax24=0;_0x7e4ax24<_0x7e4ax9[_0xa020[52]][_0xa020[75]][_0xa020[74]];_0x7e4ax24++){var _0x7e4ax25=_[_0xa020[72]](_0x7e4ax22,{"\x69\x64":_0x7e4ax9[_0xa020[52]][_0xa020[75]][_0x7e4ax24]});if(_0x7e4ax25){_0x7e4ax25[_0xa020[76]]=_0x7e4ax24+1;_0x7e4ax23[_0xa020[26]](_0x7e4ax25[_0xa020[77]]);};};return FaxApplication[_0xa020[78]](_0x7e4ax23,{transaction:_0x7e4ax1a})[_0xa020[44]](function(_0x7e4ax1f){return _0x7e4ax1f});})})[_0xa020[44]](function(_0x7e4ax15){return _0x7e4axa[_0xa020[33]](200)[_0xa020[32]](_0x7e4ax15)})[_0xa020[34]](function(_0x7e4ax14){return handleError(_0x7e4axa,_0x7e4ax14)});})[_0xa020[34]](function(_0x7e4ax14){return _0x7e4axb(_0x7e4ax14)})};exports[_0xa020[80]]=function(_0x7e4ax9,_0x7e4axa){FaxAccount[_0xa020[71]]({where:{id:_0x7e4ax9[_0xa020[15]][_0xa020[48]]},individualHooks:true})[_0xa020[44]](function(){return _0x7e4axa[_0xa020[47]](204)})[_0xa020[34]](function(_0x7e4ax14){return handleError(_0x7e4axa,_0x7e4ax14)})};function handleError(_0x7e4axa,_0x7e4ax14){return _0x7e4axa[_0xa020[33]](500)[_0xa020[32]](_0x7e4ax14)} \ No newline at end of file diff --git a/server/api/fax_account/fax_account.socket.js b/server/api/fax_account/fax_account.socket.js index e28dde9..9566008 100644 --- a/server/api/fax_account/fax_account.socket.js +++ b/server/api/fax_account/fax_account.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var fax_account = require('../../models').FaxAccount; - -exports.register = function(socket) { - fax_account.afterCreate(function (doc) { - onSave(socket, doc); - }); - fax_account.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('fax_account:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('fax_account:remove', doc); -} +var _0x5e70=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x5e70[0];var fax_account=require(_0x5e70[2])[_0x5e70[1]];exports[_0x5e70[3]]=function(_0x84a0x2){fax_account[_0x5e70[4]](function(_0x84a0x3){onSave(_0x84a0x2,_0x84a0x3)});fax_account[_0x5e70[5]](function(_0x84a0x3){onRemove(_0x84a0x2,_0x84a0x3)});};function onSave(_0x84a0x2,_0x84a0x3,_0x84a0x5){_0x84a0x2[_0x5e70[7]](_0x5e70[6],_0x84a0x3)}function onRemove(_0x84a0x2,_0x84a0x3,_0x84a0x5){_0x84a0x2[_0x5e70[7]](_0x5e70[8],_0x84a0x3)} \ No newline at end of file diff --git a/server/api/fax_account/fax_account.spec.js b/server/api/fax_account/fax_account.spec.js index 0399e33..fd6ffa7 100644 --- a/server/api/fax_account/fax_account.spec.js +++ b/server/api/fax_account/fax_account.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/fax/accounts', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/fax/accounts') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xe718=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x67\x65\x74"];_0xe718[0];var should=require(_0xe718[1]);var app=require(_0xe718[2]);var request=require(_0xe718[3]);describe(_0xe718[4],function(){it(_0xe718[5],function(_0xb808x4){request(app)[_0xe718[13]](_0xe718[12])[_0xe718[11]](200)[_0xe718[11]](_0xe718[10],/json/)[_0xe718[9]](function(_0xb808x5,_0xb808x6){if(_0xb808x5){return _0xb808x4(_0xb808x5)};_0xb808x6[_0xe718[8]][_0xe718[1]][_0xe718[7]][_0xe718[6]](Array);_0xb808x4();})})}); \ No newline at end of file diff --git a/server/api/fax_account/index.js b/server/api/fax_account/index.js index 15886c9..152f5a6 100644 --- a/server/api/fax_account/index.js +++ b/server/api/fax_account/index.js @@ -1,17 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./fax_account.controller'); -var auth = require('../../auth/auth.service'); -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.post('/:id/applications', controller.addApplications); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/', controller.bulkDestroy); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x1dcf=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x3A\x69\x64\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x61\x64\x64\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x1dcf[0];var express=require(_0x1dcf[1]);var controller=require(_0x1dcf[2]);var auth=require(_0x1dcf[3]);var router=express.Router();router[_0x1dcf[7]](_0x1dcf[4],auth[_0x1dcf[5]](),controller[_0x1dcf[6]]);router[_0x1dcf[7]](_0x1dcf[8],controller[_0x1dcf[9]]);router[_0x1dcf[11]](_0x1dcf[4],controller[_0x1dcf[10]]);router[_0x1dcf[11]](_0x1dcf[12],controller[_0x1dcf[13]]);router[_0x1dcf[15]](_0x1dcf[8],controller[_0x1dcf[14]]);router[_0x1dcf[16]](_0x1dcf[8],controller[_0x1dcf[14]]);router[_0x1dcf[18]](_0x1dcf[4],controller[_0x1dcf[17]]);router[_0x1dcf[18]](_0x1dcf[8],controller[_0x1dcf[19]]);module[_0x1dcf[20]]=router; \ No newline at end of file diff --git a/server/api/fax_application/fax_application.controller.js b/server/api/fax_application/fax_application.controller.js index 59b09cb..deca5a6 100644 --- a/server/api/fax_application/fax_application.controller.js +++ b/server/api/fax_application/fax_application.controller.js @@ -1,94 +1 @@ -'use strict'; -var _ = require('lodash'); -var FaxApplication = require('../../models').FaxApplication; -// Get list of fax_applications -exports.index = function(req, res) { - FaxApplication.findAll({ - where: req.query - }).then(function(fax_applications) { - return res.status(200).send(fax_applications); - }).catch(function(err) { - return handleError(res, err); - }); -}; -// Get a single fax_application -exports.show = function(req, res) { - FaxApplication.findById(req.params.id).then(function(fax_application) { - if (!fax_application) { - return res.sendStatus(404); - } - return res.send(fax_application); - }).catch(function(err) { - return handleError(res, err); - }); -}; -// Creates a new fax_application in the DB. -exports.create = function(req, res, next) { - console.log(req.body); - FaxApplication.max('priority', { - where: { - FaxAccountId: req.body.FaxAccountId - } - }).then(function(max) { - // SET PRIORITY - req.body.priority = max ? ++max : 1; - FaxApplication.create(req.body).then(function(faxApplication) { - return res.status(201).send(faxApplication); - }).catch(function(err) { - return next(err); - }); - console.log(max); - }).catch(function(err) { - next(err); - }); - // FaxApplication - // .create(req.body) - // .then(function(fax_application) { - // return res.status(201).send(fax_application); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); -}; -// Updates an existing fax_application in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - FaxApplication.findById(req.params.id).then(function(fax_application) { - if (!fax_application) { - return res.sendStatus(404); - } - var updated = _.merge(fax_application, req.body); - updated.save().then(function() { - return res.status(200).send(fax_application); - }).catch(function(err) { - return handleError(res, err); - }); - }).catch(function(err) { - return handleError(res, err); - }); -}; -// Deletes a fax_application from the DB. -exports.destroy = function(req, res) { - FaxApplication.find({ - where: { - id: req.params.id - } - }).then(function(fax_application) { - if (!fax_application) { - return res.sendStatus(404); - } - fax_application.destroy().then(function() { - return res.sendStatus(204); - }).catch(function(err) { - return handleError(res, err); - }); - }).catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xd644=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x6C\x6F\x67","\x70\x72\x69\x6F\x72\x69\x74\x79","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x6D\x61\x78","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64"];_0xd644[0];var _=require(_0xd644[1]);var FaxApplication=require(_0xd644[3])[_0xd644[2]];exports[_0xd644[4]]=function(_0xaa66x3,_0xaa66x4){FaxApplication[_0xd644[10]]({where:_0xaa66x3[_0xd644[9]]})[_0xd644[8]](function(_0xaa66x6){return _0xaa66x4[_0xd644[7]](200)[_0xd644[6]](_0xaa66x6)})[_0xd644[5]](function(_0xaa66x5){return handleError(_0xaa66x4,_0xaa66x5)})};exports[_0xd644[11]]=function(_0xaa66x3,_0xaa66x4){FaxApplication[_0xd644[15]](_0xaa66x3[_0xd644[14]][_0xd644[13]])[_0xd644[8]](function(_0xaa66x7){if(!_0xaa66x7){return _0xaa66x4[_0xd644[12]](404)};return _0xaa66x4[_0xd644[6]](_0xaa66x7);})[_0xd644[5]](function(_0xaa66x5){return handleError(_0xaa66x4,_0xaa66x5)})};exports[_0xd644[16]]=function(_0xaa66x3,_0xaa66x4,_0xaa66x8){console[_0xd644[18]](_0xaa66x3[_0xd644[17]]);FaxApplication[_0xd644[21]](_0xd644[19],{where:{FaxAccountId:_0xaa66x3[_0xd644[17]][_0xd644[20]]}})[_0xd644[8]](function(_0xaa66x9){_0xaa66x3[_0xd644[17]][_0xd644[19]]=_0xaa66x9?++_0xaa66x9:1;FaxApplication[_0xd644[16]](_0xaa66x3[_0xd644[17]])[_0xd644[8]](function(_0xaa66xa){return _0xaa66x4[_0xd644[7]](201)[_0xd644[6]](_0xaa66xa)})[_0xd644[5]](function(_0xaa66x5){return _0xaa66x8(_0xaa66x5)});console[_0xd644[18]](_0xaa66x9);})[_0xd644[5]](function(_0xaa66x5){_0xaa66x8(_0xaa66x5)});};exports[_0xd644[22]]=function(_0xaa66x3,_0xaa66x4){if(_0xaa66x3[_0xd644[17]][_0xd644[13]]){delete _0xaa66x3[_0xd644[17]][_0xd644[13]]};FaxApplication[_0xd644[15]](_0xaa66x3[_0xd644[14]][_0xd644[13]])[_0xd644[8]](function(_0xaa66x7){if(!_0xaa66x7){return _0xaa66x4[_0xd644[12]](404)};var _0xaa66xb=_[_0xd644[23]](_0xaa66x7,_0xaa66x3[_0xd644[17]]);_0xaa66xb[_0xd644[24]]()[_0xd644[8]](function(){return _0xaa66x4[_0xd644[7]](200)[_0xd644[6]](_0xaa66x7)})[_0xd644[5]](function(_0xaa66x5){return handleError(_0xaa66x4,_0xaa66x5)});})[_0xd644[5]](function(_0xaa66x5){return handleError(_0xaa66x4,_0xaa66x5)});};exports[_0xd644[25]]=function(_0xaa66x3,_0xaa66x4){FaxApplication[_0xd644[26]]({where:{id:_0xaa66x3[_0xd644[14]][_0xd644[13]]}})[_0xd644[8]](function(_0xaa66x7){if(!_0xaa66x7){return _0xaa66x4[_0xd644[12]](404)};_0xaa66x7[_0xd644[25]]()[_0xd644[8]](function(){return _0xaa66x4[_0xd644[12]](204)})[_0xd644[5]](function(_0xaa66x5){return handleError(_0xaa66x4,_0xaa66x5)});})[_0xd644[5]](function(_0xaa66x5){return handleError(_0xaa66x4,_0xaa66x5)})};function handleError(_0xaa66x4,_0xaa66x5){return _0xaa66x4[_0xd644[7]](500)[_0xd644[6]](_0xaa66x5)} \ No newline at end of file diff --git a/server/api/fax_application/fax_application.socket.js b/server/api/fax_application/fax_application.socket.js index 2a677d7..7a37458 100644 --- a/server/api/fax_application/fax_application.socket.js +++ b/server/api/fax_application/fax_application.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var fax_application = require('../../models').FaxApplication; - -exports.register = function(socket) { - fax_application.afterCreate(function (doc) { - onSave(socket, doc); - }); - fax_application.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('fax_application:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('fax_application:remove', doc); -} +var _0xb5fc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x61\x78\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x61\x78\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xb5fc[0];var fax_application=require(_0xb5fc[2])[_0xb5fc[1]];exports[_0xb5fc[3]]=function(_0x32f9x2){fax_application[_0xb5fc[4]](function(_0x32f9x3){onSave(_0x32f9x2,_0x32f9x3)});fax_application[_0xb5fc[5]](function(_0x32f9x3){onRemove(_0x32f9x2,_0x32f9x3)});};function onSave(_0x32f9x2,_0x32f9x3,_0x32f9x5){_0x32f9x2[_0xb5fc[7]](_0xb5fc[6],_0x32f9x3)}function onRemove(_0x32f9x2,_0x32f9x3,_0x32f9x5){_0x32f9x2[_0xb5fc[7]](_0xb5fc[8],_0x32f9x3)} \ No newline at end of file diff --git a/server/api/fax_application/fax_application.spec.js b/server/api/fax_application/fax_application.spec.js index 9eeaee8..aea9991 100644 --- a/server/api/fax_application/fax_application.spec.js +++ b/server/api/fax_application/fax_application.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/fax/applications', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/fax/applications') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x5844=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0x5844[0];var should=require(_0x5844[1]);var app=require(_0x5844[2]);var request=require(_0x5844[3]);describe(_0x5844[4],function(){it(_0x5844[5],function(_0xbb73x4){request(app)[_0x5844[13]](_0x5844[12])[_0x5844[11]](200)[_0x5844[11]](_0x5844[10],/json/)[_0x5844[9]](function(_0xbb73x5,_0xbb73x6){if(_0xbb73x5){return _0xbb73x4(_0xbb73x5)};_0xbb73x6[_0x5844[8]][_0x5844[1]][_0x5844[7]][_0x5844[6]](Array);_0xbb73x4();})})}); \ No newline at end of file diff --git a/server/api/fax_application/index.js b/server/api/fax_application/index.js index b27e419..93b582a 100644 --- a/server/api/fax_application/index.js +++ b/server/api/fax_application/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./fax_application.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x10e5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x66\x61\x78\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x10e5[0];var express=require(_0x10e5[1]);var controller=require(_0x10e5[2]);var router=express.Router();router[_0x10e5[5]](_0x10e5[3],controller[_0x10e5[4]]);router[_0x10e5[5]](_0x10e5[6],controller[_0x10e5[7]]);router[_0x10e5[9]](_0x10e5[3],controller[_0x10e5[8]]);router[_0x10e5[11]](_0x10e5[6],controller[_0x10e5[10]]);router[_0x10e5[12]](_0x10e5[6],controller[_0x10e5[10]]);router[_0x10e5[14]](_0x10e5[6],controller[_0x10e5[13]]);module[_0x10e5[15]]=router; \ No newline at end of file diff --git a/server/api/fax_business_automation/fax_business_automation.controller.js b/server/api/fax_business_automation/fax_business_automation.controller.js index 2f7a289..40df57f 100644 --- a/server/api/fax_business_automation/fax_business_automation.controller.js +++ b/server/api/fax_business_automation/fax_business_automation.controller.js @@ -1,204 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var FaxBusinessAutomation = require('../../models').FaxBusinessAutomation; -var BusinessCondition = require('../../models').BusinessCondition; -var BusinessAction = require('../../models').BusinessAction; -var sequelize = require('../../models').sequelize; - -// Get list of fax_business_automations -exports.index = function(req, res, next) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - FaxBusinessAutomation - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single fax_business_automation -exports.show = function(req, res) { - FaxBusinessAutomation - .findById(req.params.id, { - include: [{ - all: true - }] - }) - .then(function(fax_business_automation) { - if (!fax_business_automation) { - return res.sendStatus(404); - } - return res.send(fax_business_automation); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new fax_business_automation in the DB. -exports.create = function(req, res, next) { - return sequelize.transaction(function(t) { - return FaxBusinessAutomation - .create(req.body, { - transaction: t - }) - .then(function(faxBusinessAutomation) { - var conditions = []; - if (req.body.or) { - req.body.or.forEach(function(elm) { - elm.FaxBusinessAutomationId = faxBusinessAutomation.id; - }); - conditions = conditions.concat(req.body.or); - } - - if (req.body.and) { - req.body.and.forEach(function(elm) { - elm.FaxBusinessAutomationId = faxBusinessAutomation.id; - }); - conditions = conditions.concat(req.body.and); - } - - return BusinessCondition - .bulkCreate(conditions, { - transaction: t - }) - .then(function(businessCondtions) { - if (req.body.actions) { - req.body.actions.forEach(function(elm) { - elm.FaxBusinessAutomationId = faxBusinessAutomation.id; - }); - } - - return BusinessAction - .bulkCreate(req.body.actions, { - transaction: t - }); - }); - }) - }) - .then(function() { - // Transaction has been committed - // result is whatever the result of the promise chain returned to the transaction callback - return res.sendStatus(201); - }).catch(function(err) { - // Transaction has been rolled back - // err is whatever rejected the promise chain returned to the transaction callback - return next(err); - }); -}; - -// Updates an existing fax_business_automation in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - FaxBusinessAutomation - .find({ - where: { - id: req.params.id - } - }) - .then(function(fax_business_automation) { - if (!fax_business_automation) { - return res.sendStatus(404); - } - var updated = _.merge(fax_business_automation, req.body); - updated.save() - .then(function() { - return res.status(200).send(fax_business_automation); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a fax_business_automation from the DB. -exports.destroy = function(req, res) { - FaxBusinessAutomation - .find({ - where: { - id: req.params.id - } - }) - .then(function(fax_business_automation) { - if (!fax_business_automation) { - return res.sendStatus(404); - } - fax_business_automation.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xe0e0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x46\x61\x78\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x63\x74\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x6F\x72","\x62\x6F\x64\x79","\x46\x61\x78\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x49\x64","\x63\x6F\x6E\x63\x61\x74","\x61\x6E\x64","\x61\x63\x74\x69\x6F\x6E\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0xe0e0[0];var _=require(_0xe0e0[1]);var util=require(_0xe0e0[2]);var FaxBusinessAutomation=require(_0xe0e0[4])[_0xe0e0[3]];var BusinessCondition=require(_0xe0e0[4])[_0xe0e0[5]];var BusinessAction=require(_0xe0e0[4])[_0xe0e0[6]];var sequelize=require(_0xe0e0[4])[_0xe0e0[7]];exports[_0xe0e0[8]]=function(_0x399fx7,_0x399fx8,_0x399fx9){var _0x399fxa=[_0xe0e0[9],_0xe0e0[10]];var _0x399fxb=_0x399fx7[_0xe0e0[12]][_0xe0e0[11]]?parseInt(_0x399fx7[_0xe0e0[12]][_0xe0e0[11]],10):100;var _0x399fxc=_0x399fx7[_0xe0e0[12]][_0xe0e0[13]]?parseInt(_0x399fx7[_0xe0e0[12]][_0xe0e0[13]],10):0;var _0x399fxd={where:{},limit:_0x399fxb,offset:_0x399fxc*_0x399fxb};_[_0xe0e0[27]](_0x399fx7[_0xe0e0[12]],function(_0x399fxe,_0x399fxf){switch(_0x399fxf){case _0xe0e0[11]:;case _0xe0e0[13]:break ;;case _0xe0e0[16]:_0x399fxd[_0xe0e0[14]]=util[_0xe0e0[19]](_0xe0e0[15],_0x399fx7[_0xe0e0[12]][_0xe0e0[16]],_0x399fx7[_0xe0e0[12]][_0xe0e0[17]]||_0xe0e0[18])||null;break ;;case _0xe0e0[17]:break ;;case _0xe0e0[25]:_0x399fxd[_0xe0e0[21]][_0xe0e0[20]]=[];_0x399fxa[_0xe0e0[24]](function(_0x399fx10){var _0x399fx11={};_0x399fx11[_0x399fx10]={$like:_0xe0e0[22]+_0x399fxe+_0xe0e0[22]};_0x399fxd[_0xe0e0[21]][_0xe0e0[20]][_0xe0e0[23]](_0x399fx11);});break ;;default:_0x399fxd[_0xe0e0[21]][_0x399fxf]={$like:{}};_0x399fxd[_0xe0e0[21]][_0x399fxf][_0xe0e0[26]]=_0xe0e0[22]+_0x399fxe+_0xe0e0[22];;}});FaxBusinessAutomation[_0xe0e0[42]](_0x399fxd)[_0xe0e0[41]](function(_0x399fx13){var _0x399fx14=Math[_0xe0e0[33]](_0x399fx13[_0xe0e0[32]]/_0x399fxb);var _0x399fx15=_0x399fx14>(_0x399fxd[_0xe0e0[34]]+1)?util[_0xe0e0[19]](_0xe0e0[35],_0x399fx7[_0xe0e0[36]],_0x399fx7[_0xe0e0[38]][_0xe0e0[37]],_0x399fx7[_0xe0e0[39]],_0x399fxc+1):null;var _0x399fx16=_0x399fxc>0?util[_0xe0e0[19]](_0xe0e0[35],_0x399fx7[_0xe0e0[36]],_0x399fx7[_0xe0e0[38]][_0xe0e0[37]],_0x399fx7[_0xe0e0[39]],_0x399fxc-1):null;_0x399fx8[_0xe0e0[30]](200)[_0xe0e0[29]]({count:_0x399fx13[_0xe0e0[32]],rows:_0x399fx13[_0xe0e0[40]],next_page:_0x399fx15,previous_page:_0x399fx16,total_pages:_0x399fx14});})[_0xe0e0[31]](function(_0x399fx12){_0x399fx8[_0xe0e0[30]](500)[_0xe0e0[29]]({error:_0xe0e0[28]})});};exports[_0xe0e0[43]]=function(_0x399fx7,_0x399fx8){FaxBusinessAutomation[_0xe0e0[47]](_0x399fx7[_0xe0e0[46]][_0xe0e0[45]],{include:[{all:true}]})[_0xe0e0[41]](function(_0x399fx17){if(!_0x399fx17){return _0x399fx8[_0xe0e0[44]](404)};return _0x399fx8[_0xe0e0[29]](_0x399fx17);})[_0xe0e0[31]](function(_0x399fx12){return handleError(_0x399fx8,_0x399fx12)})};exports[_0xe0e0[48]]=function(_0x399fx7,_0x399fx8,_0x399fx9){return sequelize[_0xe0e0[56]](function(_0x399fx18){return FaxBusinessAutomation[_0xe0e0[48]](_0x399fx7[_0xe0e0[50]],{transaction:_0x399fx18})[_0xe0e0[41]](function(_0x399fx19){var _0x399fx1a=[];if(_0x399fx7[_0xe0e0[50]][_0xe0e0[49]]){_0x399fx7[_0xe0e0[50]][_0xe0e0[49]][_0xe0e0[24]](function(_0x399fx1b){_0x399fx1b[_0xe0e0[51]]=_0x399fx19[_0xe0e0[45]]});_0x399fx1a=_0x399fx1a[_0xe0e0[52]](_0x399fx7[_0xe0e0[50]][_0xe0e0[49]]);};if(_0x399fx7[_0xe0e0[50]][_0xe0e0[53]]){_0x399fx7[_0xe0e0[50]][_0xe0e0[53]][_0xe0e0[24]](function(_0x399fx1b){_0x399fx1b[_0xe0e0[51]]=_0x399fx19[_0xe0e0[45]]});_0x399fx1a=_0x399fx1a[_0xe0e0[52]](_0x399fx7[_0xe0e0[50]][_0xe0e0[53]]);};return BusinessCondition[_0xe0e0[55]](_0x399fx1a,{transaction:_0x399fx18})[_0xe0e0[41]](function(_0x399fx1c){if(_0x399fx7[_0xe0e0[50]][_0xe0e0[54]]){_0x399fx7[_0xe0e0[50]][_0xe0e0[54]][_0xe0e0[24]](function(_0x399fx1b){_0x399fx1b[_0xe0e0[51]]=_0x399fx19[_0xe0e0[45]]})};return BusinessAction[_0xe0e0[55]](_0x399fx7[_0xe0e0[50]][_0xe0e0[54]],{transaction:_0x399fx18});});})})[_0xe0e0[41]](function(){return _0x399fx8[_0xe0e0[44]](201)})[_0xe0e0[31]](function(_0x399fx12){return _0x399fx9(_0x399fx12)})};exports[_0xe0e0[57]]=function(_0x399fx7,_0x399fx8){if(_0x399fx7[_0xe0e0[50]][_0xe0e0[45]]){delete _0x399fx7[_0xe0e0[50]][_0xe0e0[45]]};FaxBusinessAutomation[_0xe0e0[60]]({where:{id:_0x399fx7[_0xe0e0[46]][_0xe0e0[45]]}})[_0xe0e0[41]](function(_0x399fx17){if(!_0x399fx17){return _0x399fx8[_0xe0e0[44]](404)};var _0x399fx1d=_[_0xe0e0[58]](_0x399fx17,_0x399fx7[_0xe0e0[50]]);_0x399fx1d[_0xe0e0[59]]()[_0xe0e0[41]](function(){return _0x399fx8[_0xe0e0[30]](200)[_0xe0e0[29]](_0x399fx17)})[_0xe0e0[31]](function(_0x399fx12){return handleError(_0x399fx8,_0x399fx12)});})[_0xe0e0[31]](function(_0x399fx12){return handleError(_0x399fx8,_0x399fx12)});};exports[_0xe0e0[61]]=function(_0x399fx7,_0x399fx8){FaxBusinessAutomation[_0xe0e0[60]]({where:{id:_0x399fx7[_0xe0e0[46]][_0xe0e0[45]]}})[_0xe0e0[41]](function(_0x399fx17){if(!_0x399fx17){return _0x399fx8[_0xe0e0[44]](404)};_0x399fx17[_0xe0e0[61]]()[_0xe0e0[41]](function(){return _0x399fx8[_0xe0e0[44]](204)})[_0xe0e0[31]](function(_0x399fx12){return handleError(_0x399fx8,_0x399fx12)});})[_0xe0e0[31]](function(_0x399fx12){return handleError(_0x399fx8,_0x399fx12)})};function handleError(_0x399fx8,_0x399fx12){return _0x399fx8[_0xe0e0[30]](500)[_0xe0e0[29]](_0x399fx12)} \ No newline at end of file diff --git a/server/api/fax_business_automation/fax_business_automation.socket.js b/server/api/fax_business_automation/fax_business_automation.socket.js index 5f03434..1d49461 100644 --- a/server/api/fax_business_automation/fax_business_automation.socket.js +++ b/server/api/fax_business_automation/fax_business_automation.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var FaxBusinessAutomation = require('../../models').FaxBusinessAutomation; - -exports.register = function(socket) { - FaxBusinessAutomation.afterCreate(function(doc) { - onSave(socket, doc); - }); - FaxBusinessAutomation.afterUpdate(function(doc, options) { - onSave(socket, doc); - }); - FaxBusinessAutomation.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('fax_business_automation:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('fax_business_automation:remove', doc); -} +var _0xe9cc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x61\x78\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x61\x78\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x61\x78\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xe9cc[0];var FaxBusinessAutomation=require(_0xe9cc[2])[_0xe9cc[1]];exports[_0xe9cc[3]]=function(_0x8f47x2){FaxBusinessAutomation[_0xe9cc[4]](function(_0x8f47x3){onSave(_0x8f47x2,_0x8f47x3)});FaxBusinessAutomation[_0xe9cc[5]](function(_0x8f47x3,_0x8f47x4){onSave(_0x8f47x2,_0x8f47x3)});FaxBusinessAutomation[_0xe9cc[6]](function(_0x8f47x3){onRemove(_0x8f47x2,_0x8f47x3)});};function onSave(_0x8f47x2,_0x8f47x3,_0x8f47x6){_0x8f47x2[_0xe9cc[8]](_0xe9cc[7],_0x8f47x3)}function onRemove(_0x8f47x2,_0x8f47x3,_0x8f47x6){_0x8f47x2[_0xe9cc[8]](_0xe9cc[9],_0x8f47x3)} \ No newline at end of file diff --git a/server/api/fax_business_automation/fax_business_automation.spec.js b/server/api/fax_business_automation/fax_business_automation.spec.js index f9f7234..077f800 100644 --- a/server/api/fax_business_automation/fax_business_automation.spec.js +++ b/server/api/fax_business_automation/fax_business_automation.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/fax/business/automations', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/fax/business/automations') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xd473=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0xd473[0];var should=require(_0xd473[1]);var app=require(_0xd473[2]);var request=require(_0xd473[3]);describe(_0xd473[4],function(){it(_0xd473[5],function(_0xd429x4){request(app)[_0xd473[13]](_0xd473[12])[_0xd473[11]](200)[_0xd473[11]](_0xd473[10],/json/)[_0xd473[9]](function(_0xd429x5,_0xd429x6){if(_0xd429x5){return _0xd429x4(_0xd429x5)};_0xd429x6[_0xd473[8]][_0xd473[1]][_0xd473[7]][_0xd473[6]](Array);_0xd429x4();})})}); \ No newline at end of file diff --git a/server/api/fax_business_automation/index.js b/server/api/fax_business_automation/index.js index ad01841..07cf571 100644 --- a/server/api/fax_business_automation/index.js +++ b/server/api/fax_business_automation/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./fax_business_automation.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x5101=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x66\x61\x78\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x5101[0];var express=require(_0x5101[1]);var controller=require(_0x5101[2]);var router=express.Router();router[_0x5101[5]](_0x5101[3],controller[_0x5101[4]]);router[_0x5101[5]](_0x5101[6],controller[_0x5101[7]]);router[_0x5101[9]](_0x5101[3],controller[_0x5101[8]]);router[_0x5101[11]](_0x5101[6],controller[_0x5101[10]]);router[_0x5101[12]](_0x5101[6],controller[_0x5101[10]]);router[_0x5101[14]](_0x5101[6],controller[_0x5101[13]]);module[_0x5101[15]]=router; \ No newline at end of file diff --git a/server/api/fax_message/fax_message.ami.js b/server/api/fax_message/fax_message.ami.js index 2d69e42..9fa23ff 100644 --- a/server/api/fax_message/fax_message.ami.js +++ b/server/api/fax_message/fax_message.ami.js @@ -1,64 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var FaxMessage = require('../../models').FaxMessage; -var Trunk = require('../../models').User; - -exports.register = function(ami) { - - FaxMessage.afterCreate(function(doc) { - console.log('FaxMessage afterCreate'); - onSave(ami, doc); - }); -}; - -function onSave(ami, doc, cb) { - if (doc.status === 'NOT SENT' && !doc.actionid) { - // I have to send the fax with the Originate - var faxBody = JSON.parse(doc.body); - console.log('faxBody', faxBody); - - Trunk - .findById(faxBody.trunk.id) - .then(function(trunk) { - var action = { - Action: 'originate', - CallerID: faxBody.from, - Channel: util.format('%s/%s@%s', faxBody.technology, faxBody.to, trunk.name), - Context: 'outbound-fax', - Exten: 's', - Priority: 1, - Async: 'true', - Variable: { - MAXRATE: faxBody.maxrate, - MINRATE: faxBody.minrate, - ECM: faxBody.ecm ? 'yes' : 'no', - LOCALID: faxBody.fax_localid, - FAXFILE: faxBody.fax_file, - // 'FAXFILE': 'test.tiff', // Scommentare se si fanno prove in locale! - FAXHEADER: faxBody.fax_header, - FAXUUID: faxBody.uuid - } - }; - - ami.action(action, function(err, res) { - if (err) { - doc.updateAttributes({ - status: 'FAILED' - }); - } else { - if (res.response && res.actionid) { - doc.updateAttributes({ - actionid: res.actionid - }); - } - } - }); - }) - .catch(function(err) { - console.error(err); - }); - } -} +var _0x1d5d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72","\x72\x65\x67\x69\x73\x74\x65\x72","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65\x20\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x6C\x6F\x67","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x73\x74\x61\x74\x75\x73","\x4E\x4F\x54\x20\x53\x45\x4E\x54","\x61\x63\x74\x69\x6F\x6E\x69\x64","\x62\x6F\x64\x79","\x70\x61\x72\x73\x65","\x66\x61\x78\x42\x6F\x64\x79","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x6F\x72\x69\x67\x69\x6E\x61\x74\x65","\x66\x72\x6F\x6D","\x25\x73\x2F\x25\x73\x40\x25\x73","\x74\x65\x63\x68\x6E\x6F\x6C\x6F\x67\x79","\x74\x6F","\x6E\x61\x6D\x65","\x66\x6F\x72\x6D\x61\x74","\x6F\x75\x74\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x73","\x74\x72\x75\x65","\x6D\x61\x78\x72\x61\x74\x65","\x6D\x69\x6E\x72\x61\x74\x65","\x65\x63\x6D","\x79\x65\x73","\x6E\x6F","\x66\x61\x78\x5F\x6C\x6F\x63\x61\x6C\x69\x64","\x66\x61\x78\x5F\x66\x69\x6C\x65","\x66\x61\x78\x5F\x68\x65\x61\x64\x65\x72","\x75\x75\x69\x64","\x46\x41\x49\x4C\x45\x44","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x72\x65\x73\x70\x6F\x6E\x73\x65","\x61\x63\x74\x69\x6F\x6E","\x74\x68\x65\x6E","\x69\x64","\x74\x72\x75\x6E\x6B","\x66\x69\x6E\x64\x42\x79\x49\x64"];_0x1d5d[0];var _=require(_0x1d5d[1]);var util=require(_0x1d5d[2]);var FaxMessage=require(_0x1d5d[4])[_0x1d5d[3]];var Trunk=require(_0x1d5d[4])[_0x1d5d[5]];exports[_0x1d5d[6]]=function(_0x8cf6x5){FaxMessage[_0x1d5d[9]](function(_0x8cf6x6){console[_0x1d5d[8]](_0x1d5d[7]);onSave(_0x8cf6x5,_0x8cf6x6);})};function onSave(_0x8cf6x5,_0x8cf6x6,_0x8cf6x8){if(_0x8cf6x6[_0x1d5d[10]]===_0x1d5d[11]&&!_0x8cf6x6[_0x1d5d[12]]){var _0x8cf6x9=JSON[_0x1d5d[14]](_0x8cf6x6[_0x1d5d[13]]);console[_0x1d5d[8]](_0x1d5d[15],_0x8cf6x9);Trunk[_0x1d5d[44]](_0x8cf6x9[_0x1d5d[43]][_0x1d5d[42]])[_0x1d5d[41]](function(_0x8cf6xb){var _0x8cf6xc={Action:_0x1d5d[18],CallerID:_0x8cf6x9[_0x1d5d[19]],Channel:util[_0x1d5d[24]](_0x1d5d[20],_0x8cf6x9[_0x1d5d[21]],_0x8cf6x9[_0x1d5d[22]],_0x8cf6xb[_0x1d5d[23]]),Context:_0x1d5d[25],Exten:_0x1d5d[26],Priority:1,Async:_0x1d5d[27],Variable:{MAXRATE:_0x8cf6x9[_0x1d5d[28]],MINRATE:_0x8cf6x9[_0x1d5d[29]],ECM:_0x8cf6x9[_0x1d5d[30]]?_0x1d5d[31]:_0x1d5d[32],LOCALID:_0x8cf6x9[_0x1d5d[33]],FAXFILE:_0x8cf6x9[_0x1d5d[34]],FAXHEADER:_0x8cf6x9[_0x1d5d[35]],FAXUUID:_0x8cf6x9[_0x1d5d[36]]}};_0x8cf6x5[_0x1d5d[40]](_0x8cf6xc,function(_0x8cf6xa,_0x8cf6xd){if(_0x8cf6xa){_0x8cf6x6[_0x1d5d[38]]({status:_0x1d5d[37]})}else {if(_0x8cf6xd[_0x1d5d[39]]&&_0x8cf6xd[_0x1d5d[12]]){_0x8cf6x6[_0x1d5d[38]]({actionid:_0x8cf6xd[_0x1d5d[12]]})}}});})[_0x1d5d[17]](function(_0x8cf6xa){console[_0x1d5d[16]](_0x8cf6xa)});}} \ No newline at end of file diff --git a/server/api/fax_message/fax_message.controller.js b/server/api/fax_message/fax_message.controller.js index e354d5f..3893137 100644 --- a/server/api/fax_message/fax_message.controller.js +++ b/server/api/fax_message/fax_message.controller.js @@ -1,422 +1 @@ -'use strict'; - -var _ = require('lodash'); -var fs = require('fs'); -var path = require('path'); -var uploadFile = require('upload-file'); -var uuidLib = require('node-uuid'); -var pdf = require('html-pdf'); -var spindrift = require('spindrift'); -var formidable = require('formidable'); -var exec = require('child_process').exec; -var config = require('../../config/environment'); - -var FaxMessage = require('../../models').FaxMessage; -var FaxRoom = require('../../models').FaxRoom; -var FaxAccount = require('../../models').FaxAccount; -var Contact = require('../../models').Contact; - -// Get list of fax_messages -exports.index = function(req, res) { - FaxMessage - .findAll({ - where: req.query, - order: 'createdAt DESC', - include: [{ - model: Contact, - as: 'From' - }, { - model: Contact, - as: 'To' - }, { - model: FaxRoom, - include: [{ - model: FaxAccount - }] - }] - }) - .then(function(fax_messages) { - return res.status(200).send(fax_messages); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single fax_message -exports.show = function(req, res) { - FaxMessage - .findOne({ - where: { - id: req.params.id - }, - include: [{ - model: Contact, - as: 'From' - }, { - model: Contact, - as: 'To' - }] - }) - .then(function(fax_message) { - if (!fax_message) { - return res.sendStatus(404); - } - return res.send(fax_message); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new fax_message in the DB. -exports.create = function(req, res, next) { - // FaxMessage - // .create(req.body) - // .then(function(fax_message) { - // return res.status(201).send(fax_message); - // }) - // .catch(function(err) { - // return handleError(res, err); - // }); - - var form = new formidable.IncomingForm(); - // form.encoding = 'utf-8'; - form.uploadDir = path.join(config.root, 'server/files/fax/outbound/original'); - form.keepExtensions = true; - form.multiples = false; - - if (req.body.onlyText) { - //There is not file, only text - // console.log(req.body); - if (req.body.html) { - //There is the html message -> convert - var uuid = uuidLib.v4() - var dest = path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf'); - pdf.create(req.body.html, { - "timeout": 30000 - }).toFile(dest, function(err, result) { - console.log('Fax: HTML Converted'); - convertPdfAndSendFax(req, res, uuid, req.body); - }); - } - } else { - form.parse(req, function(err, fields, files) { - if (err) { - return handleError(res, err); - } - - if (fields.html) { - //There is HTML with PDF - var uuid = uuidLib.v4(); - var dest = path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf'); - pdf.create(fields.html, { - "timeout": 30000 - }).toFile(dest, function(err, result) { - console.log('Fax: HTML Converted'); - var pdfHTML = spindrift(result.filename); - var pdfUploaded = spindrift(files.file.path); - var uuid = uuidLib.v4(); - spindrift.join(pdfHTML, pdfUploaded).pdfStream().pipe(fs.createWriteStream(path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf'))); - console.log('Fax: HTML joined with PDF uploaded'); - convertPdfAndSendFax(req, res, uuid, fields); - }); - } else { - //There is only PDF - var uuid = uuidLib.v4(); - var dest = path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf'); - fs.rename(files.file.path, dest, function(err) { - if (err) { - console.error(err); - return handleError(res, req); - // return next(err); - } - console.log('Fax: PDF Rename'); - convertPdfAndSendFax(req, res, uuid, fields); - }); - } - - }); - } -}; - -function convertPdfAndSendFax(req, res, filenameInput, fields) { - var inputPath = path.join(config.root, 'server', 'files', 'fax', 'outbound', 'original', filenameInput + '.pdf'); - var resultPath = path.join(config.root, 'server', 'files', 'fax', 'outbound', 'converted', filenameInput + '.tif'); - var command = 'gs' + ' -q -dNOPAUSE -dBATCH -sDEVICE=tiffg4 ' + '-sPAPERSIZE=letter -sOutputFile=' + resultPath + ' ' + inputPath; - // console.log(inputPath, resultPath, command); - - var uuidFax = uuidLib.v4(); - FaxAccount - .findById(fields.accountId) - .then(function(faxAccount) { - // console.log('FaxAccount', faxAccount); - - if (faxAccount) { - var faxBody = { - technology: 'SIP', - to: fields.toNum, - from: faxAccount.phone, - fax_file: resultPath, - fax_header: faxAccount.faxheader, - fax_localid: faxAccount.localid, - maxrate: faxAccount.maxrate, - minrate: faxAccount.minrate, - ecm: faxAccount.ecm, - uuid: uuidFax, - trunk: { - id: faxAccount.TrunkId - } - }; - - fs.exists(inputPath, function(exists) { - if (!exists) { - // console.log('File not exist'); - handleError(res, new Error('File not exists')); - } else { - exec(command, function(err) { - if (err) { - console.error(err); - handleError(res, err); - } else { - console.log('Fax: PDF converted to TIFF'); - fs.chmod(resultPath, 511, function(err) { - if (fields.roomId) { - // Room already exists -> create new message and associate - FaxRoom - .findOrCreate({ - where: { - id: fields.roomId - }, - defaults: {} - }) - .spread(function(faxRoom, created) { - // TODO Verify if we have to manage also the created - FaxMessage - .create({ - status: 'NOT SENT', - read: true, - filenamePDF: filenameInput + '.pdf', - filename: filenameInput + '.tif', - body: JSON.stringify(faxBody), - uuid: uuidFax, - FaxRoomId: faxRoom.id - }) - .then(function(faxMessage) { - // Fax message created, now association - Contact - .findOrCreate({ - where: { - phone: faxBody.from - }, - defaults: { - phone: faxBody.from, - fullname: faxBody.from - } - }) - .spread(function(contact, created) { - // console.log('Set relationship with from', created); - faxMessage.setFrom(contact); - }); - - Contact - .findOrCreate({ - where: { - phone: faxBody.to - }, - defaults: { - phone: faxBody.to, - fullname: faxBody.to - } - }) - .spread(function(contact, created) { - // console.log('Set relationship with to', created); - faxMessage.setTo(contact); - }); - - return res.status(200).send(faxMessage); - }) - .catch(function(err) { - handleError(res, err); - // console.error(err); - // next(err); - }); - }); - } else { - // Room not exists -> create room, message and associate - FaxRoom - .create({ - status: 'OPEN', - from: fields.toNum, - FaxAccountId: fields.accountId, - UserId: fields.userId - }) - .then(function(faxRoom) { - // Room created, now message - FaxMessage - .create({ - status: 'NOT SENT', - read: true, - filenamePDF: filenameInput + '.pdf', - filename: filenameInput + '.tif', - body: JSON.stringify(faxBody), - uuid: uuidFax, - FaxRoomId: faxRoom.id - }) - .then(function(faxMessage) { - // Fax message created, now association - - Contact - .findOrCreate({ - where: { - phone: faxBody.from - }, - defaults: { - phone: faxBody.from, - fullname: faxBody.from - } - }) - .spread(function(contact, created) { - faxMessage.setFrom(contact); - }); - - Contact - .findOrCreate({ - where: { - phone: faxBody.to - }, - defaults: { - phone: faxBody.to, - fullname: faxBody.to - } - }) - .spread(function(contact, created) { - faxMessage.setTo(contact); - }); - - return res.status(200).send( - faxMessage); - }) - .catch(function(err) { - handleError(res, err); - }); - }) - .catch(function(err) { - handleError(res, err); - }); - } - }); - } - }); - } - }); - } - }); -} - -// Updates an existing fax_message in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - FaxMessage - .findOne({ - where: { - id: req.params.id - }, - include: [{ - model: Contact, - as: 'From' - }, { - model: Contact, - as: 'To' - }] - }) - .then(function(fax_message) { - if (!fax_message) { - return res.sendStatus(404); - } - var updated = _.merge(fax_message, req.body); - updated.save() - .then(function() { - return res.status(200).send(fax_message); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a fax_message from the DB. -exports.destroy = function(req, res) { - FaxMessage - .find({ - where: { - id: req.params.id - } - }) - .then(function(fax_message) { - if (!fax_message) { - return res.sendStatus(404); - } - fax_message.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getContentFromMessage = function(req, res) { - - FaxMessage - .findById(req.params.id) - .then(function(fax_message) { - - // console.log(fax_message); - - if (!fax_message) { - return res.sendStatus(404); - } - - if (fax_message.filenamePDF) { - - if (fax_message.status === 'RECEIVED') { - var pdfPath = path.join(config.root, 'server', 'files', 'fax', 'inbound', fax_message.filenamePDF); - fs.exists(pdfPath, function(exists) { - if (exists) - return res.sendFile(pdfPath); - else - return res.sendStatus(404); - }); - } else if (fax_message.status === 'NOT SENT' || fax_message.directory === - 'SENT' || fax_message.status === 'FAILED') { - var pdfPath = path.join(config.root, 'server', 'files', 'fax', 'outbound', 'original', fax_message.filenamePDF); - fs.exists(pdfPath, function(exists) { - if (exists) - return res.sendFile(pdfPath); - else - return res.sendStatus(404); - }); - } - } else { - res.sendStatus(404); - } - - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x1139=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x66\x73","\x70\x61\x74\x68","\x75\x70\x6C\x6F\x61\x64\x2D\x66\x69\x6C\x65","\x6E\x6F\x64\x65\x2D\x75\x75\x69\x64","\x68\x74\x6D\x6C\x2D\x70\x64\x66","\x73\x70\x69\x6E\x64\x72\x69\x66\x74","\x66\x6F\x72\x6D\x69\x64\x61\x62\x6C\x65","\x65\x78\x65\x63","\x63\x68\x69\x6C\x64\x5F\x70\x72\x6F\x63\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x63\x72\x65\x61\x74\x65\x64\x41\x74\x20\x44\x45\x53\x43","\x46\x72\x6F\x6D","\x54\x6F","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x4F\x6E\x65","\x63\x72\x65\x61\x74\x65","\x75\x70\x6C\x6F\x61\x64\x44\x69\x72","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x66\x61\x78\x2F\x6F\x75\x74\x62\x6F\x75\x6E\x64\x2F\x6F\x72\x69\x67\x69\x6E\x61\x6C","\x6A\x6F\x69\x6E","\x6B\x65\x65\x70\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x6D\x75\x6C\x74\x69\x70\x6C\x65\x73","\x6F\x6E\x6C\x79\x54\x65\x78\x74","\x62\x6F\x64\x79","\x68\x74\x6D\x6C","\x76\x34","\x2E\x70\x64\x66","\x46\x61\x78\x3A\x20\x48\x54\x4D\x4C\x20\x43\x6F\x6E\x76\x65\x72\x74\x65\x64","\x6C\x6F\x67","\x74\x6F\x46\x69\x6C\x65","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x66\x69\x6C\x65","\x63\x72\x65\x61\x74\x65\x57\x72\x69\x74\x65\x53\x74\x72\x65\x61\x6D","\x70\x69\x70\x65","\x70\x64\x66\x53\x74\x72\x65\x61\x6D","\x46\x61\x78\x3A\x20\x48\x54\x4D\x4C\x20\x6A\x6F\x69\x6E\x65\x64\x20\x77\x69\x74\x68\x20\x50\x44\x46\x20\x75\x70\x6C\x6F\x61\x64\x65\x64","\x65\x72\x72\x6F\x72","\x46\x61\x78\x3A\x20\x50\x44\x46\x20\x52\x65\x6E\x61\x6D\x65","\x72\x65\x6E\x61\x6D\x65","\x70\x61\x72\x73\x65","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x66\x61\x78","\x6F\x75\x74\x62\x6F\x75\x6E\x64","\x6F\x72\x69\x67\x69\x6E\x61\x6C","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x2E\x74\x69\x66","\x67\x73","\x20\x2D\x71\x20\x2D\x64\x4E\x4F\x50\x41\x55\x53\x45\x20\x2D\x64\x42\x41\x54\x43\x48\x20\x2D\x73\x44\x45\x56\x49\x43\x45\x3D\x74\x69\x66\x66\x67\x34\x20","\x2D\x73\x50\x41\x50\x45\x52\x53\x49\x5A\x45\x3D\x6C\x65\x74\x74\x65\x72\x20\x2D\x73\x4F\x75\x74\x70\x75\x74\x46\x69\x6C\x65\x3D","\x20","\x53\x49\x50","\x74\x6F\x4E\x75\x6D","\x70\x68\x6F\x6E\x65","\x66\x61\x78\x68\x65\x61\x64\x65\x72","\x6C\x6F\x63\x61\x6C\x69\x64","\x6D\x61\x78\x72\x61\x74\x65","\x6D\x69\x6E\x72\x61\x74\x65","\x65\x63\x6D","\x54\x72\x75\x6E\x6B\x49\x64","\x46\x69\x6C\x65\x20\x6E\x6F\x74\x20\x65\x78\x69\x73\x74\x73","\x46\x61\x78\x3A\x20\x50\x44\x46\x20\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x20\x74\x6F\x20\x54\x49\x46\x46","\x72\x6F\x6F\x6D\x49\x64","\x73\x65\x74\x46\x72\x6F\x6D","\x73\x70\x72\x65\x61\x64","\x66\x72\x6F\x6D","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x73\x65\x74\x54\x6F","\x74\x6F","\x4E\x4F\x54\x20\x53\x45\x4E\x54","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x4F\x50\x45\x4E","\x61\x63\x63\x6F\x75\x6E\x74\x49\x64","\x75\x73\x65\x72\x49\x64","\x63\x68\x6D\x6F\x64","\x65\x78\x69\x73\x74\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x67\x65\x74\x43\x6F\x6E\x74\x65\x6E\x74\x46\x72\x6F\x6D\x4D\x65\x73\x73\x61\x67\x65","\x66\x69\x6C\x65\x6E\x61\x6D\x65\x50\x44\x46","\x52\x45\x43\x45\x49\x56\x45\x44","\x69\x6E\x62\x6F\x75\x6E\x64","\x73\x65\x6E\x64\x46\x69\x6C\x65","\x64\x69\x72\x65\x63\x74\x6F\x72\x79","\x53\x45\x4E\x54","\x46\x41\x49\x4C\x45\x44"];_0x1139[0];var _=require(_0x1139[1]);var fs=require(_0x1139[2]);var path=require(_0x1139[3]);var uploadFile=require(_0x1139[4]);var uuidLib=require(_0x1139[5]);var pdf=require(_0x1139[6]);var spindrift=require(_0x1139[7]);var formidable=require(_0x1139[8]);var exec=require(_0x1139[10])[_0x1139[9]];var config=require(_0x1139[11]);var FaxMessage=require(_0x1139[13])[_0x1139[12]];var FaxRoom=require(_0x1139[13])[_0x1139[14]];var FaxAccount=require(_0x1139[13])[_0x1139[15]];var Contact=require(_0x1139[13])[_0x1139[16]];exports[_0x1139[17]]=function(_0x65b8xf,_0x65b8x10){FaxMessage[_0x1139[26]]({where:_0x65b8xf[_0x1139[22]],order:_0x1139[23],include:[{model:Contact,as:_0x1139[24]},{model:Contact,as:_0x1139[25]},{model:FaxRoom,include:[{model:FaxAccount}]}]})[_0x1139[21]](function(_0x65b8x12){return _0x65b8x10[_0x1139[20]](200)[_0x1139[19]](_0x65b8x12)})[_0x1139[18]](function(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)})};exports[_0x1139[27]]=function(_0x65b8xf,_0x65b8x10){FaxMessage[_0x1139[31]]({where:{id:_0x65b8xf[_0x1139[30]][_0x1139[29]]},include:[{model:Contact,as:_0x1139[24]},{model:Contact,as:_0x1139[25]}]})[_0x1139[21]](function(_0x65b8x13){if(!_0x65b8x13){return _0x65b8x10[_0x1139[28]](404)};return _0x65b8x10[_0x1139[19]](_0x65b8x13);})[_0x1139[18]](function(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)})};exports[_0x1139[32]]=function(_0x65b8xf,_0x65b8x10,_0x65b8x14){var _0x65b8x15= new formidable.IncomingForm();_0x65b8x15[_0x1139[33]]=path[_0x1139[36]](config[_0x1139[34]],_0x1139[35]);_0x65b8x15[_0x1139[37]]=true;_0x65b8x15[_0x1139[38]]=false;if(_0x65b8xf[_0x1139[40]][_0x1139[39]]){if(_0x65b8xf[_0x1139[40]][_0x1139[41]]){var _0x65b8x16=uuidLib[_0x1139[42]]();var _0x65b8x17=path[_0x1139[36]](config[_0x1139[34]],_0x1139[35],_0x65b8x16+_0x1139[43]);pdf[_0x1139[32]](_0x65b8xf[_0x1139[40]][_0x1139[41]],{"\x74\x69\x6D\x65\x6F\x75\x74":30000})[_0x1139[46]](_0x65b8x17,function(_0x65b8x11,_0x65b8x18){console[_0x1139[45]](_0x1139[44]);convertPdfAndSendFax(_0x65b8xf,_0x65b8x10,_0x65b8x16,_0x65b8xf[_0x1139[40]]);});}}else {_0x65b8x15[_0x1139[56]](_0x65b8xf,function(_0x65b8x11,_0x65b8x19,_0x65b8x1a){if(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)};if(_0x65b8x19[_0x1139[41]]){var _0x65b8x16=uuidLib[_0x1139[42]]();var _0x65b8x17=path[_0x1139[36]](config[_0x1139[34]],_0x1139[35],_0x65b8x16+_0x1139[43]);pdf[_0x1139[32]](_0x65b8x19[_0x1139[41]],{"\x74\x69\x6D\x65\x6F\x75\x74":30000})[_0x1139[46]](_0x65b8x17,function(_0x65b8x11,_0x65b8x18){console[_0x1139[45]](_0x1139[44]);var _0x65b8x1b=spindrift(_0x65b8x18[_0x1139[47]]);var _0x65b8x1c=spindrift(_0x65b8x1a[_0x1139[48]][_0x1139[3]]);var _0x65b8x16=uuidLib[_0x1139[42]]();spindrift[_0x1139[36]](_0x65b8x1b,_0x65b8x1c)[_0x1139[51]]()[_0x1139[50]](fs[_0x1139[49]](path[_0x1139[36]](config[_0x1139[34]],_0x1139[35],_0x65b8x16+_0x1139[43])));console[_0x1139[45]](_0x1139[52]);convertPdfAndSendFax(_0x65b8xf,_0x65b8x10,_0x65b8x16,_0x65b8x19);});}else {var _0x65b8x16=uuidLib[_0x1139[42]]();var _0x65b8x17=path[_0x1139[36]](config[_0x1139[34]],_0x1139[35],_0x65b8x16+_0x1139[43]);fs[_0x1139[55]](_0x65b8x1a[_0x1139[48]][_0x1139[3]],_0x65b8x17,function(_0x65b8x11){if(_0x65b8x11){console[_0x1139[53]](_0x65b8x11);return handleError(_0x65b8x10,_0x65b8xf);};console[_0x1139[45]](_0x1139[54]);convertPdfAndSendFax(_0x65b8xf,_0x65b8x10,_0x65b8x16,_0x65b8x19);});};})};};function convertPdfAndSendFax(_0x65b8xf,_0x65b8x10,_0x65b8x1e,_0x65b8x19){var _0x65b8x1f=path[_0x1139[36]](config[_0x1139[34]],_0x1139[57],_0x1139[58],_0x1139[59],_0x1139[60],_0x1139[61],_0x65b8x1e+_0x1139[43]);var _0x65b8x20=path[_0x1139[36]](config[_0x1139[34]],_0x1139[57],_0x1139[58],_0x1139[59],_0x1139[60],_0x1139[62],_0x65b8x1e+_0x1139[63]);var _0x65b8x21=_0x1139[64]+_0x1139[65]+_0x1139[66]+_0x65b8x20+_0x1139[67]+_0x65b8x1f;var _0x65b8x22=uuidLib[_0x1139[42]]();FaxAccount[_0x1139[93]](_0x65b8x19[_0x1139[89]])[_0x1139[21]](function(_0x65b8x23){if(_0x65b8x23){var _0x65b8x24={technology:_0x1139[68],to:_0x65b8x19[_0x1139[69]],from:_0x65b8x23[_0x1139[70]],fax_file:_0x65b8x20,fax_header:_0x65b8x23[_0x1139[71]],fax_localid:_0x65b8x23[_0x1139[72]],maxrate:_0x65b8x23[_0x1139[73]],minrate:_0x65b8x23[_0x1139[74]],ecm:_0x65b8x23[_0x1139[75]],uuid:_0x65b8x22,trunk:{id:_0x65b8x23[_0x1139[76]]}};fs[_0x1139[92]](_0x65b8x1f,function(_0x65b8x25){if(!_0x65b8x25){handleError(_0x65b8x10, new Error(_0x1139[77]))}else {exec(_0x65b8x21,function(_0x65b8x11){if(_0x65b8x11){console[_0x1139[53]](_0x65b8x11);handleError(_0x65b8x10,_0x65b8x11);}else {console[_0x1139[45]](_0x1139[78]);fs[_0x1139[91]](_0x65b8x20,511,function(_0x65b8x11){if(_0x65b8x19[_0x1139[79]]){FaxRoom[_0x1139[83]]({where:{id:_0x65b8x19[_0x1139[79]]},defaults:{}})[_0x1139[81]](function(_0x65b8x26,_0x65b8x27){FaxMessage[_0x1139[32]]({status:_0x1139[86],read:true,filenamePDF:_0x65b8x1e+_0x1139[43],filename:_0x65b8x1e+_0x1139[63],body:JSON[_0x1139[87]](_0x65b8x24),uuid:_0x65b8x22,FaxRoomId:_0x65b8x26[_0x1139[29]]})[_0x1139[21]](function(_0x65b8x28){Contact[_0x1139[83]]({where:{phone:_0x65b8x24[_0x1139[82]]},defaults:{phone:_0x65b8x24[_0x1139[82]],fullname:_0x65b8x24[_0x1139[82]]}})[_0x1139[81]](function(_0x65b8x29,_0x65b8x27){_0x65b8x28[_0x1139[80]](_0x65b8x29)});Contact[_0x1139[83]]({where:{phone:_0x65b8x24[_0x1139[85]]},defaults:{phone:_0x65b8x24[_0x1139[85]],fullname:_0x65b8x24[_0x1139[85]]}})[_0x1139[81]](function(_0x65b8x29,_0x65b8x27){_0x65b8x28[_0x1139[84]](_0x65b8x29)});return _0x65b8x10[_0x1139[20]](200)[_0x1139[19]](_0x65b8x28);})[_0x1139[18]](function(_0x65b8x11){handleError(_0x65b8x10,_0x65b8x11)})})}else {FaxRoom[_0x1139[32]]({status:_0x1139[88],from:_0x65b8x19[_0x1139[69]],FaxAccountId:_0x65b8x19[_0x1139[89]],UserId:_0x65b8x19[_0x1139[90]]})[_0x1139[21]](function(_0x65b8x26){FaxMessage[_0x1139[32]]({status:_0x1139[86],read:true,filenamePDF:_0x65b8x1e+_0x1139[43],filename:_0x65b8x1e+_0x1139[63],body:JSON[_0x1139[87]](_0x65b8x24),uuid:_0x65b8x22,FaxRoomId:_0x65b8x26[_0x1139[29]]})[_0x1139[21]](function(_0x65b8x28){Contact[_0x1139[83]]({where:{phone:_0x65b8x24[_0x1139[82]]},defaults:{phone:_0x65b8x24[_0x1139[82]],fullname:_0x65b8x24[_0x1139[82]]}})[_0x1139[81]](function(_0x65b8x29,_0x65b8x27){_0x65b8x28[_0x1139[80]](_0x65b8x29)});Contact[_0x1139[83]]({where:{phone:_0x65b8x24[_0x1139[85]]},defaults:{phone:_0x65b8x24[_0x1139[85]],fullname:_0x65b8x24[_0x1139[85]]}})[_0x1139[81]](function(_0x65b8x29,_0x65b8x27){_0x65b8x28[_0x1139[84]](_0x65b8x29)});return _0x65b8x10[_0x1139[20]](200)[_0x1139[19]](_0x65b8x28);})[_0x1139[18]](function(_0x65b8x11){handleError(_0x65b8x10,_0x65b8x11)})})[_0x1139[18]](function(_0x65b8x11){handleError(_0x65b8x10,_0x65b8x11)})}});}})}});}});}exports[_0x1139[94]]=function(_0x65b8xf,_0x65b8x10){if(_0x65b8xf[_0x1139[40]][_0x1139[29]]){delete _0x65b8xf[_0x1139[40]][_0x1139[29]]};FaxMessage[_0x1139[31]]({where:{id:_0x65b8xf[_0x1139[30]][_0x1139[29]]},include:[{model:Contact,as:_0x1139[24]},{model:Contact,as:_0x1139[25]}]})[_0x1139[21]](function(_0x65b8x13){if(!_0x65b8x13){return _0x65b8x10[_0x1139[28]](404)};var _0x65b8x2a=_[_0x1139[95]](_0x65b8x13,_0x65b8xf[_0x1139[40]]);_0x65b8x2a[_0x1139[96]]()[_0x1139[21]](function(){return _0x65b8x10[_0x1139[20]](200)[_0x1139[19]](_0x65b8x13)})[_0x1139[18]](function(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)});})[_0x1139[18]](function(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)});};exports[_0x1139[97]]=function(_0x65b8xf,_0x65b8x10){FaxMessage[_0x1139[98]]({where:{id:_0x65b8xf[_0x1139[30]][_0x1139[29]]}})[_0x1139[21]](function(_0x65b8x13){if(!_0x65b8x13){return _0x65b8x10[_0x1139[28]](404)};_0x65b8x13[_0x1139[97]]()[_0x1139[21]](function(){return _0x65b8x10[_0x1139[28]](204)})[_0x1139[18]](function(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)});})[_0x1139[18]](function(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)})};exports[_0x1139[99]]=function(_0x65b8xf,_0x65b8x10){FaxMessage[_0x1139[93]](_0x65b8xf[_0x1139[30]][_0x1139[29]])[_0x1139[21]](function(_0x65b8x13){if(!_0x65b8x13){return _0x65b8x10[_0x1139[28]](404)};if(_0x65b8x13[_0x1139[100]]){if(_0x65b8x13[_0x1139[20]]===_0x1139[101]){var _0x65b8x2b=path[_0x1139[36]](config[_0x1139[34]],_0x1139[57],_0x1139[58],_0x1139[59],_0x1139[102],_0x65b8x13[_0x1139[100]]);fs[_0x1139[92]](_0x65b8x2b,function(_0x65b8x25){if(_0x65b8x25){return _0x65b8x10[_0x1139[103]](_0x65b8x2b)}else {return _0x65b8x10[_0x1139[28]](404)}});}else {if(_0x65b8x13[_0x1139[20]]===_0x1139[86]||_0x65b8x13[_0x1139[104]]===_0x1139[105]||_0x65b8x13[_0x1139[20]]===_0x1139[106]){var _0x65b8x2b=path[_0x1139[36]](config[_0x1139[34]],_0x1139[57],_0x1139[58],_0x1139[59],_0x1139[60],_0x1139[61],_0x65b8x13[_0x1139[100]]);fs[_0x1139[92]](_0x65b8x2b,function(_0x65b8x25){if(_0x65b8x25){return _0x65b8x10[_0x1139[103]](_0x65b8x2b)}else {return _0x65b8x10[_0x1139[28]](404)}});}}}else {_0x65b8x10[_0x1139[28]](404)};})[_0x1139[18]](function(_0x65b8x11){return handleError(_0x65b8x10,_0x65b8x11)})};function handleError(_0x65b8x10,_0x65b8x11){return _0x65b8x10[_0x1139[20]](500)[_0x1139[19]](_0x65b8x11)} \ No newline at end of file diff --git a/server/api/fax_message/fax_message.socket.js b/server/api/fax_message/fax_message.socket.js index 79a31ad..00e490f 100644 --- a/server/api/fax_message/fax_message.socket.js +++ b/server/api/fax_message/fax_message.socket.js @@ -1,85 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var FaxMessage = require('../../models').FaxMessage; -var Contact = require('../../models').Contact; -var FaxRoom = require('../../models').FaxRoom; -var FaxAccount = require('../../models').FaxAccount; - -exports.register = function(socket) { - FaxMessage.afterCreate(function(doc) { - FaxMessage - .findOne({ - where: { - id: doc.id - }, - include: [{ - model: Contact, - as: 'From' - }, { - model: Contact, - as: 'To' - }, { - model: FaxRoom, - include: [{ - model: FaxAccount - }] - }] - }) - .then(function(faxMessage) { - onSave(socket, faxMessage); - }) - .catch(function(err) { - console.error(err); - }); - }); - - FaxMessage.afterUpdate(function(doc) { - FaxMessage - .findOne({ - where: { - id: doc.id - }, - include: [{ - model: Contact, - as: 'From' - }, { - model: Contact, - as: 'To' - }, { - model: FaxRoom, - include: [{ - model: FaxAccount - }] - }] - }) - .then(function(faxMessage) { - onSave(socket, faxMessage); - onUpdate(socket, faxMessage); - }) - .catch(function(err) { - console.error(err); - }); - }); - - FaxMessage.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('fax_message:save', doc); - // socket.emit('fax_message:' + doc.directory + ':save', doc); -} - -function onUpdate(socket, doc, cb) { - socket.emit('fax_message:update', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('fax_message:remove', doc); - // socket.emit('fax_message:' + doc.directory + ':remove', doc); -} +var _0xe2c0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x6F\x6E\x74\x61\x63\x74","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x72\x65\x67\x69\x73\x74\x65\x72","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x69\x64","\x46\x72\x6F\x6D","\x54\x6F","\x66\x69\x6E\x64\x4F\x6E\x65","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x75\x70\x64\x61\x74\x65","\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0xe2c0[0];var FaxMessage=require(_0xe2c0[2])[_0xe2c0[1]];var Contact=require(_0xe2c0[2])[_0xe2c0[3]];var FaxRoom=require(_0xe2c0[2])[_0xe2c0[4]];var FaxAccount=require(_0xe2c0[2])[_0xe2c0[5]];exports[_0xe2c0[6]]=function(_0x76f0x5){FaxMessage[_0xe2c0[14]](function(_0x76f0x6){FaxMessage[_0xe2c0[13]]({where:{id:_0x76f0x6[_0xe2c0[10]]},include:[{model:Contact,as:_0xe2c0[11]},{model:Contact,as:_0xe2c0[12]},{model:FaxRoom,include:[{model:FaxAccount}]}]})[_0xe2c0[9]](function(_0x76f0x8){onSave(_0x76f0x5,_0x76f0x8)})[_0xe2c0[8]](function(_0x76f0x7){console[_0xe2c0[7]](_0x76f0x7)})});FaxMessage[_0xe2c0[15]](function(_0x76f0x6){FaxMessage[_0xe2c0[13]]({where:{id:_0x76f0x6[_0xe2c0[10]]},include:[{model:Contact,as:_0xe2c0[11]},{model:Contact,as:_0xe2c0[12]},{model:FaxRoom,include:[{model:FaxAccount}]}]})[_0xe2c0[9]](function(_0x76f0x8){onSave(_0x76f0x5,_0x76f0x8);onUpdate(_0x76f0x5,_0x76f0x8);})[_0xe2c0[8]](function(_0x76f0x7){console[_0xe2c0[7]](_0x76f0x7)})});FaxMessage[_0xe2c0[16]](function(_0x76f0x6){onRemove(_0x76f0x5,_0x76f0x6)});};function onSave(_0x76f0x5,_0x76f0x6,_0x76f0xa){_0x76f0x5[_0xe2c0[18]](_0xe2c0[17],_0x76f0x6)}function onUpdate(_0x76f0x5,_0x76f0x6,_0x76f0xa){_0x76f0x5[_0xe2c0[18]](_0xe2c0[19],_0x76f0x6)}function onRemove(_0x76f0x5,_0x76f0x6,_0x76f0xa){_0x76f0x5[_0xe2c0[18]](_0xe2c0[20],_0x76f0x6)} \ No newline at end of file diff --git a/server/api/fax_message/fax_message.spec.js b/server/api/fax_message/fax_message.spec.js index d61f66e..bd6605c 100644 --- a/server/api/fax_message/fax_message.spec.js +++ b/server/api/fax_message/fax_message.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/fax/messages', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/fax/messages') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xb824=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x67\x65\x74"];_0xb824[0];var should=require(_0xb824[1]);var app=require(_0xb824[2]);var request=require(_0xb824[3]);describe(_0xb824[4],function(){it(_0xb824[5],function(_0xb35cx4){request(app)[_0xb824[13]](_0xb824[12])[_0xb824[11]](200)[_0xb824[11]](_0xb824[10],/json/)[_0xb824[9]](function(_0xb35cx5,_0xb35cx6){if(_0xb35cx5){return _0xb35cx4(_0xb35cx5)};_0xb35cx6[_0xb824[8]][_0xb824[1]][_0xb824[7]][_0xb824[6]](Array);_0xb35cx4();})})}); \ No newline at end of file diff --git a/server/api/fax_message/index.js b/server/api/fax_message/index.js index b237a79..d3e7121 100644 --- a/server/api/fax_message/index.js +++ b/server/api/fax_message/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./fax_message.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id/content', controller.getContentFromMessage); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xeaf9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64\x2F\x63\x6F\x6E\x74\x65\x6E\x74","\x67\x65\x74\x43\x6F\x6E\x74\x65\x6E\x74\x46\x72\x6F\x6D\x4D\x65\x73\x73\x61\x67\x65","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xeaf9[0];var express=require(_0xeaf9[1]);var controller=require(_0xeaf9[2]);var router=express.Router();router[_0xeaf9[5]](_0xeaf9[3],controller[_0xeaf9[4]]);router[_0xeaf9[5]](_0xeaf9[6],controller[_0xeaf9[7]]);router[_0xeaf9[5]](_0xeaf9[8],controller[_0xeaf9[9]]);router[_0xeaf9[11]](_0xeaf9[3],controller[_0xeaf9[10]]);router[_0xeaf9[13]](_0xeaf9[8],controller[_0xeaf9[12]]);router[_0xeaf9[14]](_0xeaf9[8],controller[_0xeaf9[12]]);router[_0xeaf9[16]](_0xeaf9[8],controller[_0xeaf9[15]]);module[_0xeaf9[17]]=router; \ No newline at end of file diff --git a/server/api/fax_queue/fax_queue.controller.js b/server/api/fax_queue/fax_queue.controller.js index c5157bb..220cb67 100644 --- a/server/api/fax_queue/fax_queue.controller.js +++ b/server/api/fax_queue/fax_queue.controller.js @@ -1,222 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var FaxQueue = require('../../models').FaxQueue; - -// Get list of fax_queues -exports.index = function(req, res) { - - var attributes = ['description', 'name', 'timeout', 'strategy']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page, - include: [{ - all: true - }] - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - FaxQueue - .findAndCountAll(query) - .then(function(result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single fax_queue -exports.show = function(req, res) { - FaxQueue - .findById(req.params.id) - .then(function(fax_queue) { - if (!fax_queue) { - return res.sendStatus(404); - } - return res.send(fax_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new fax_queue in the DB. -exports.create = function(req, res) { - FaxQueue - .create(req.body) - .then(function(fax_queue) { - return res.status(201).send(fax_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing fax_queue in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - FaxQueue - .find({ - where: { - id: req.params.id - } - }) - .then(function(fax_queue) { - if (!fax_queue) { - return res.sendStatus(404); - } - var updated = _.merge(fax_queue, req.body); - updated.save() - .then(function() { - return res.status(200).send(fax_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a fax_queue from the DB. -exports.destroy = function(req, res) { - FaxQueue - .find({ - where: { - id: req.params.id - } - }) - .then(function(fax_queue) { - if (!fax_queue) { - return res.sendStatus(404); - } - fax_queue.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.addAgents = function(req, res, next) { - FaxQueue - .findById(req.params.id) - .then(function(faxQueue) { - if (faxQueue) { - // QUEUE FOUND - // ADD AGENTS - faxQueue - .addUsers(req.body.agents) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return next(err); - }); - } else { - return next(new Error('no fax queue found')); - } - }) - .catch(function(err) { - return next(err); - }); -}; - -exports.removeAgents = function(req, res, next) { - FaxQueue - .findById(req.params.id) - .then(function(faxQueue) { - if (faxQueue) { - // QUEUE FOUND - // REMOVE AGENTS - faxQueue - .removeUsers(req.body.agents) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return next(err); - }); - } else { - return next(new Error('no fax queue found')); - } - }) - .catch(function(err) { - return next(err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function(req, res) { - FaxQueue - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x8fc0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x46\x61\x78\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x74\x69\x6D\x65\x6F\x75\x74","\x73\x74\x72\x61\x74\x65\x67\x79","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x55\x73\x65\x72\x73","\x6E\x6F\x20\x66\x61\x78\x20\x71\x75\x65\x75\x65\x20\x66\x6F\x75\x6E\x64","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x55\x73\x65\x72\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x8fc0[0];var _=require(_0x8fc0[1]);var util=require(_0x8fc0[2]);var FaxQueue=require(_0x8fc0[4])[_0x8fc0[3]];exports[_0x8fc0[5]]=function(_0x77c3x4,_0x77c3x5){var _0x77c3x6=[_0x8fc0[6],_0x8fc0[7],_0x8fc0[8],_0x8fc0[9]];var _0x77c3x7=_0x77c3x4[_0x8fc0[11]][_0x8fc0[10]]?parseInt(_0x77c3x4[_0x8fc0[11]][_0x8fc0[10]],10):100;var _0x77c3x8=_0x77c3x4[_0x8fc0[11]][_0x8fc0[12]]?parseInt(_0x77c3x4[_0x8fc0[11]][_0x8fc0[12]],10):0;var _0x77c3x9={where:{},limit:_0x77c3x7,offset:_0x77c3x8*_0x77c3x7,include:[{all:true}]};_[_0x8fc0[26]](_0x77c3x4[_0x8fc0[11]],function(_0x77c3xa,_0x77c3xb){switch(_0x77c3xb){case _0x8fc0[10]:;case _0x8fc0[12]:break ;;case _0x8fc0[15]:_0x77c3x9[_0x8fc0[13]]=util[_0x8fc0[18]](_0x8fc0[14],_0x77c3x4[_0x8fc0[11]][_0x8fc0[15]],_0x77c3x4[_0x8fc0[11]][_0x8fc0[16]]||_0x8fc0[17])||null;break ;;case _0x8fc0[16]:break ;;case _0x8fc0[24]:_0x77c3x9[_0x8fc0[20]][_0x8fc0[19]]=[];_0x77c3x6[_0x8fc0[23]](function(_0x77c3xc){var _0x77c3xd={};_0x77c3xd[_0x77c3xc]={$like:_0x8fc0[21]+_0x77c3xa+_0x8fc0[21]};_0x77c3x9[_0x8fc0[20]][_0x8fc0[19]][_0x8fc0[22]](_0x77c3xd);});break ;;default:_0x77c3x9[_0x8fc0[20]][_0x77c3xb]={$like:{}};_0x77c3x9[_0x8fc0[20]][_0x77c3xb][_0x8fc0[25]]=_0x8fc0[21]+_0x77c3xa+_0x8fc0[21];;}});FaxQueue[_0x8fc0[40]](_0x77c3x9)[_0x8fc0[39]](function(_0x77c3xf){var _0x77c3x10=Math[_0x8fc0[29]](_0x77c3xf[_0x8fc0[28]]/_0x77c3x7);var _0x77c3x11=_0x77c3x10>(_0x77c3x9[_0x8fc0[30]]+1)?util[_0x8fc0[18]](_0x8fc0[31],_0x77c3x4[_0x8fc0[32]],_0x77c3x4[_0x8fc0[34]][_0x8fc0[33]],_0x77c3x4[_0x8fc0[35]],_0x77c3x8+1):null;var _0x77c3x12=_0x77c3x8>0?util[_0x8fc0[18]](_0x8fc0[31],_0x77c3x4[_0x8fc0[32]],_0x77c3x4[_0x8fc0[34]][_0x8fc0[33]],_0x77c3x4[_0x8fc0[35]],_0x77c3x8-1):null;_0x77c3x5[_0x8fc0[38]](200)[_0x8fc0[37]]({count:_0x77c3xf[_0x8fc0[28]],rows:_0x77c3xf[_0x8fc0[36]],next_page:_0x77c3x11,previous_page:_0x77c3x12,total_pages:_0x77c3x10});})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)});};exports[_0x8fc0[41]]=function(_0x77c3x4,_0x77c3x5){FaxQueue[_0x8fc0[45]](_0x77c3x4[_0x8fc0[44]][_0x8fc0[43]])[_0x8fc0[39]](function(_0x77c3x13){if(!_0x77c3x13){return _0x77c3x5[_0x8fc0[42]](404)};return _0x77c3x5[_0x8fc0[37]](_0x77c3x13);})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)})};exports[_0x8fc0[46]]=function(_0x77c3x4,_0x77c3x5){FaxQueue[_0x8fc0[46]](_0x77c3x4[_0x8fc0[47]])[_0x8fc0[39]](function(_0x77c3x13){return _0x77c3x5[_0x8fc0[38]](201)[_0x8fc0[37]](_0x77c3x13)})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)})};exports[_0x8fc0[48]]=function(_0x77c3x4,_0x77c3x5){if(_0x77c3x4[_0x8fc0[47]][_0x8fc0[43]]){delete _0x77c3x4[_0x8fc0[47]][_0x8fc0[43]]};FaxQueue[_0x8fc0[51]]({where:{id:_0x77c3x4[_0x8fc0[44]][_0x8fc0[43]]}})[_0x8fc0[39]](function(_0x77c3x13){if(!_0x77c3x13){return _0x77c3x5[_0x8fc0[42]](404)};var _0x77c3x14=_[_0x8fc0[49]](_0x77c3x13,_0x77c3x4[_0x8fc0[47]]);_0x77c3x14[_0x8fc0[50]]()[_0x8fc0[39]](function(){return _0x77c3x5[_0x8fc0[38]](200)[_0x8fc0[37]](_0x77c3x13)})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)});})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)});};exports[_0x8fc0[52]]=function(_0x77c3x4,_0x77c3x5){FaxQueue[_0x8fc0[51]]({where:{id:_0x77c3x4[_0x8fc0[44]][_0x8fc0[43]]}})[_0x8fc0[39]](function(_0x77c3x13){if(!_0x77c3x13){return _0x77c3x5[_0x8fc0[42]](404)};_0x77c3x13[_0x8fc0[52]]()[_0x8fc0[39]](function(){return _0x77c3x5[_0x8fc0[42]](204)})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)});})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)})};exports[_0x8fc0[53]]=function(_0x77c3x4,_0x77c3x5,_0x77c3x15){FaxQueue[_0x8fc0[45]](_0x77c3x4[_0x8fc0[44]][_0x8fc0[43]])[_0x8fc0[39]](function(_0x77c3x16){if(_0x77c3x16){_0x77c3x16[_0x8fc0[55]](_0x77c3x4[_0x8fc0[47]][_0x8fc0[54]])[_0x8fc0[39]](function(){return _0x77c3x5[_0x8fc0[42]](200)})[_0x8fc0[27]](function(_0x77c3xe){return _0x77c3x15(_0x77c3xe)})}else {return _0x77c3x15( new Error(_0x8fc0[56]))}})[_0x8fc0[27]](function(_0x77c3xe){return _0x77c3x15(_0x77c3xe)})};exports[_0x8fc0[57]]=function(_0x77c3x4,_0x77c3x5,_0x77c3x15){FaxQueue[_0x8fc0[45]](_0x77c3x4[_0x8fc0[44]][_0x8fc0[43]])[_0x8fc0[39]](function(_0x77c3x16){if(_0x77c3x16){_0x77c3x16[_0x8fc0[58]](_0x77c3x4[_0x8fc0[47]][_0x8fc0[54]])[_0x8fc0[39]](function(){return _0x77c3x5[_0x8fc0[42]](200)})[_0x8fc0[27]](function(_0x77c3xe){return _0x77c3x15(_0x77c3xe)})}else {return _0x77c3x15( new Error(_0x8fc0[56]))}})[_0x8fc0[27]](function(_0x77c3xe){return _0x77c3x15(_0x77c3xe)})};exports[_0x8fc0[59]]=function(_0x77c3x4,_0x77c3x5){FaxQueue[_0x8fc0[52]]({where:{id:_0x77c3x4[_0x8fc0[11]][_0x8fc0[43]]},individualHooks:true})[_0x8fc0[39]](function(){return _0x77c3x5[_0x8fc0[42]](204)})[_0x8fc0[27]](function(_0x77c3xe){return handleError(_0x77c3x5,_0x77c3xe)})};function handleError(_0x77c3x5,_0x77c3xe){return _0x77c3x5[_0x8fc0[38]](500)[_0x8fc0[37]](_0x77c3xe)} \ No newline at end of file diff --git a/server/api/fax_queue/fax_queue.socket.js b/server/api/fax_queue/fax_queue.socket.js index 243ed07..c858c04 100644 --- a/server/api/fax_queue/fax_queue.socket.js +++ b/server/api/fax_queue/fax_queue.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var fax_queue = require('../../models').FaxQueue; - -exports.register = function(socket) { - fax_queue.afterCreate(function (doc) { - onSave(socket, doc); - }); - fax_queue.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('fax_queue:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('fax_queue:remove', doc); -} +var _0x487b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x61\x78\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x487b[0];var fax_queue=require(_0x487b[2])[_0x487b[1]];exports[_0x487b[3]]=function(_0x4d51x2){fax_queue[_0x487b[4]](function(_0x4d51x3){onSave(_0x4d51x2,_0x4d51x3)});fax_queue[_0x487b[5]](function(_0x4d51x3){onRemove(_0x4d51x2,_0x4d51x3)});};function onSave(_0x4d51x2,_0x4d51x3,_0x4d51x5){_0x4d51x2[_0x487b[7]](_0x487b[6],_0x4d51x3)}function onRemove(_0x4d51x2,_0x4d51x3,_0x4d51x5){_0x4d51x2[_0x487b[7]](_0x487b[8],_0x4d51x3)} \ No newline at end of file diff --git a/server/api/fax_queue/fax_queue.spec.js b/server/api/fax_queue/fax_queue.spec.js index 9148967..4a5be14 100644 --- a/server/api/fax_queue/fax_queue.spec.js +++ b/server/api/fax_queue/fax_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/fax/queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/fax/queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x534a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0x534a[0];var should=require(_0x534a[1]);var app=require(_0x534a[2]);var request=require(_0x534a[3]);describe(_0x534a[4],function(){it(_0x534a[5],function(_0x7f07x4){request(app)[_0x534a[13]](_0x534a[12])[_0x534a[11]](200)[_0x534a[11]](_0x534a[10],/json/)[_0x534a[9]](function(_0x7f07x5,_0x7f07x6){if(_0x7f07x5){return _0x7f07x4(_0x7f07x5)};_0x7f07x6[_0x534a[8]][_0x534a[1]][_0x534a[7]][_0x534a[6]](Array);_0x7f07x4();})})}); \ No newline at end of file diff --git a/server/api/fax_queue/index.js b/server/api/fax_queue/index.js index 89f2c19..ff93f3d 100644 --- a/server/api/fax_queue/index.js +++ b/server/api/fax_queue/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./fax_queue.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.post('/:id/agents', controller.addAgents); -router.put('/:id', controller.update); -router.put('/:id/agents', controller.removeAgents); -router.patch('/:id', controller.update); -router.delete('/', controller.bulkDestroy); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xc9ec=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x3A\x69\x64\x2F\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xc9ec[0];var express=require(_0xc9ec[1]);var controller=require(_0xc9ec[2]);var router=express.Router();router[_0xc9ec[5]](_0xc9ec[3],controller[_0xc9ec[4]]);router[_0xc9ec[5]](_0xc9ec[6],controller[_0xc9ec[7]]);router[_0xc9ec[9]](_0xc9ec[3],controller[_0xc9ec[8]]);router[_0xc9ec[9]](_0xc9ec[10],controller[_0xc9ec[11]]);router[_0xc9ec[13]](_0xc9ec[6],controller[_0xc9ec[12]]);router[_0xc9ec[13]](_0xc9ec[10],controller[_0xc9ec[14]]);router[_0xc9ec[15]](_0xc9ec[6],controller[_0xc9ec[12]]);router[_0xc9ec[17]](_0xc9ec[3],controller[_0xc9ec[16]]);router[_0xc9ec[17]](_0xc9ec[6],controller[_0xc9ec[18]]);module[_0xc9ec[19]]=router; \ No newline at end of file diff --git a/server/api/fax_room/fax_room.controller.js b/server/api/fax_room/fax_room.controller.js index a139fd5..7986762 100644 --- a/server/api/fax_room/fax_room.controller.js +++ b/server/api/fax_room/fax_room.controller.js @@ -1,151 +1 @@ -'use strict'; - -var _ = require('lodash'); -var FaxRoom = require('../../models').FaxRoom; -var FaxAccount = require('../../models').FaxAccount; -var FaxMessage = require('../../models').FaxMessage; -var Contact = require('../../models').Contact; -var User = require('../../models').User; - -// Get list of fax_rooms -exports.index = function(req, res) { - FaxRoom - .findAll({ - include: [{ - model: FaxMessage, - attributes: ['id'] - }, { - model: FaxAccount - }, { - model: User - }] - }) - .then(function(fax_rooms) { - return res.status(200).send(fax_rooms); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get list of agent mailRooms -exports.agentIndex = function(req, res, next) { - FaxRoom - .findAll({ - where: { - UserId: req.params.id - }, - include: [{ - model: FaxAccount - }, { - model: User - }] - }) - .then(function(faxRooms) { - return res.status(200).send(faxRooms); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Get a single fax_room -exports.show = function(req, res) { - FaxRoom - .findOne({ - where: { - id: req.params.id - }, - include: [{ - model: FaxMessage, - include: [{ - model: FaxRoom, - include: [{ - model: FaxAccount - }] - }, { - model: Contact, - as: 'From' - }, { - model: Contact, - as: 'To' - }] - }, { - model: FaxAccount - }], - order: [ - [FaxMessage, 'createdAt', 'DESC'] - ] - }) - .then(function(fax_room) { - if (!fax_room) { - return res.sendStatus(404); - } - return res.send(fax_room); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new fax_room in the DB. -exports.create = function(req, res) { - FaxRoom - .create(req.body) - .then(function(fax_room) { - return res.status(201).send(fax_room); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing fax_room in the DB. -exports.update = function(req, res) { - // if (req.body.id) { - // delete req.body.id; - // } - FaxRoom - .findById(req.params.id) - .then(function(fax_room) { - if (!fax_room) { - return res.sendStatus(404); - } - var updated = _.merge(fax_room, req.body); - updated.save() - .then(function() { - return res.status(200).send(fax_room); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a fax_room from the DB. -exports.destroy = function(req, res) { - FaxRoom - .findById(req.params.id) - .then(function(fax_room) { - if (!fax_room) { - return res.sendStatus(404); - } - fax_room.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x9b5f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x46\x61\x78\x52\x6F\x6F\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x43\x6F\x6E\x74\x61\x63\x74","\x55\x73\x65\x72","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x41\x6C\x6C","\x61\x67\x65\x6E\x74\x49\x6E\x64\x65\x78","\x70\x61\x72\x61\x6D\x73","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x46\x72\x6F\x6D","\x54\x6F","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x66\x69\x6E\x64\x4F\x6E\x65","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x9b5f[0];var _=require(_0x9b5f[1]);var FaxRoom=require(_0x9b5f[3])[_0x9b5f[2]];var FaxAccount=require(_0x9b5f[3])[_0x9b5f[4]];var FaxMessage=require(_0x9b5f[3])[_0x9b5f[5]];var Contact=require(_0x9b5f[3])[_0x9b5f[6]];var User=require(_0x9b5f[3])[_0x9b5f[7]];exports[_0x9b5f[8]]=function(_0xb4a2x7,_0xb4a2x8){FaxRoom[_0x9b5f[14]]({include:[{model:FaxMessage,attributes:[_0x9b5f[13]]},{model:FaxAccount},{model:User}]})[_0x9b5f[12]](function(_0xb4a2xa){return _0xb4a2x8[_0x9b5f[11]](200)[_0x9b5f[10]](_0xb4a2xa)})[_0x9b5f[9]](function(_0xb4a2x9){return handleError(_0xb4a2x8,_0xb4a2x9)})};exports[_0x9b5f[15]]=function(_0xb4a2x7,_0xb4a2x8,_0xb4a2xb){FaxRoom[_0x9b5f[14]]({where:{UserId:_0xb4a2x7[_0x9b5f[16]][_0x9b5f[13]]},include:[{model:FaxAccount},{model:User}]})[_0x9b5f[12]](function(_0xb4a2xc){return _0xb4a2x8[_0x9b5f[11]](200)[_0x9b5f[10]](_0xb4a2xc)})[_0x9b5f[9]](function(_0xb4a2x9){return _0xb4a2xb(_0xb4a2x9)})};exports[_0x9b5f[17]]=function(_0xb4a2x7,_0xb4a2x8){FaxRoom[_0x9b5f[23]]({where:{id:_0xb4a2x7[_0x9b5f[16]][_0x9b5f[13]]},include:[{model:FaxMessage,include:[{model:FaxRoom,include:[{model:FaxAccount}]},{model:Contact,as:_0x9b5f[19]},{model:Contact,as:_0x9b5f[20]}]},{model:FaxAccount}],order:[[FaxMessage,_0x9b5f[21],_0x9b5f[22]]]})[_0x9b5f[12]](function(_0xb4a2xd){if(!_0xb4a2xd){return _0xb4a2x8[_0x9b5f[18]](404)};return _0xb4a2x8[_0x9b5f[10]](_0xb4a2xd);})[_0x9b5f[9]](function(_0xb4a2x9){return handleError(_0xb4a2x8,_0xb4a2x9)})};exports[_0x9b5f[24]]=function(_0xb4a2x7,_0xb4a2x8){FaxRoom[_0x9b5f[24]](_0xb4a2x7[_0x9b5f[25]])[_0x9b5f[12]](function(_0xb4a2xd){return _0xb4a2x8[_0x9b5f[11]](201)[_0x9b5f[10]](_0xb4a2xd)})[_0x9b5f[9]](function(_0xb4a2x9){return handleError(_0xb4a2x8,_0xb4a2x9)})};exports[_0x9b5f[26]]=function(_0xb4a2x7,_0xb4a2x8){FaxRoom[_0x9b5f[29]](_0xb4a2x7[_0x9b5f[16]][_0x9b5f[13]])[_0x9b5f[12]](function(_0xb4a2xd){if(!_0xb4a2xd){return _0xb4a2x8[_0x9b5f[18]](404)};var _0xb4a2xe=_[_0x9b5f[27]](_0xb4a2xd,_0xb4a2x7[_0x9b5f[25]]);_0xb4a2xe[_0x9b5f[28]]()[_0x9b5f[12]](function(){return _0xb4a2x8[_0x9b5f[11]](200)[_0x9b5f[10]](_0xb4a2xd)})[_0x9b5f[9]](function(_0xb4a2x9){return handleError(_0xb4a2x8,_0xb4a2x9)});})[_0x9b5f[9]](function(_0xb4a2x9){return handleError(_0xb4a2x8,_0xb4a2x9)})};exports[_0x9b5f[30]]=function(_0xb4a2x7,_0xb4a2x8){FaxRoom[_0x9b5f[29]](_0xb4a2x7[_0x9b5f[16]][_0x9b5f[13]])[_0x9b5f[12]](function(_0xb4a2xd){if(!_0xb4a2xd){return _0xb4a2x8[_0x9b5f[18]](404)};_0xb4a2xd[_0x9b5f[30]]()[_0x9b5f[12]](function(){return _0xb4a2x8[_0x9b5f[18]](204)})[_0x9b5f[9]](function(_0xb4a2x9){return handleError(_0xb4a2x8,_0xb4a2x9)});})[_0x9b5f[9]](function(_0xb4a2x9){return handleError(_0xb4a2x8,_0xb4a2x9)})};function handleError(_0xb4a2x8,_0xb4a2x9){return _0xb4a2x8[_0x9b5f[11]](500)[_0x9b5f[10]](_0xb4a2x9)} \ No newline at end of file diff --git a/server/api/fax_room/fax_room.kue.js b/server/api/fax_room/fax_room.kue.js index ba9c227..72bd709 100644 --- a/server/api/fax_room/fax_room.kue.js +++ b/server/api/fax_room/fax_room.kue.js @@ -1,64 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var User = require('../../models').User; -var FaxRoom = require('../../models').FaxRoom; -var FaxQueue = require('../../models').FaxQueue; -var FaxAccount = require('../../models').FaxAccount; -var FaxApplication = require('../../models').FaxApplication; - -exports.register = function(queue) { - FaxRoom.afterCreate(function(doc) { - onSave(queue, doc); - }); -} - -function onSave(queue, doc, cb) { - if (doc.status === 'NEW') { - FaxAccount - .findById(doc.FaxAccountId) - .then(function(faxAccount) { - faxAccount - .getFaxApplications({ - include: [{ - model: User, - attributes: ['id'] - }, { - model: FaxQueue, - attributes: ['id', 'strategy', 'timeout'], - include: { - model: User, - attributes: ['id'] - } - }], - order: [ - ['priority'] - ] - }) - .then(function(faxApplications) { - - var data = { - roomId: doc.id, - accountId: doc.FaxAccountId, - channel: 'FAX', - msg: { - from: doc.from - }, - applications: faxApplications - }; - - // Create queue process - queue.create('fax', data).save(); - }) - .catch(function(err) { - console.error(err); - }); - }) - .catch(function(err) { - console.error(err); - }); - } -} +var _0xa883=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x51\x75\x65\x75\x65","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x73\x74\x61\x74\x75\x73","\x4E\x45\x57","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x69\x64","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x46\x41\x58","\x66\x72\x6F\x6D","\x73\x61\x76\x65","\x66\x61\x78","\x63\x72\x65\x61\x74\x65","\x74\x68\x65\x6E","\x73\x74\x72\x61\x74\x65\x67\x79","\x74\x69\x6D\x65\x6F\x75\x74","\x70\x72\x69\x6F\x72\x69\x74\x79","\x67\x65\x74\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x66\x69\x6E\x64\x42\x79\x49\x64"];_0xa883[0];var User=require(_0xa883[2])[_0xa883[1]];var FaxRoom=require(_0xa883[2])[_0xa883[3]];var FaxQueue=require(_0xa883[2])[_0xa883[4]];var FaxAccount=require(_0xa883[2])[_0xa883[5]];var FaxApplication=require(_0xa883[2])[_0xa883[6]];exports[_0xa883[7]]=function(_0xec2fx6){FaxRoom[_0xa883[8]](function(_0xec2fx7){onSave(_0xec2fx6,_0xec2fx7)})};function onSave(_0xec2fx6,_0xec2fx7,_0xec2fx9){if(_0xec2fx7[_0xa883[9]]===_0xa883[10]){FaxAccount[_0xa883[25]](_0xec2fx7.FaxAccountId)[_0xa883[20]](function(_0xec2fxb){_0xec2fxb[_0xa883[24]]({include:[{model:User,attributes:[_0xa883[13]]},{model:FaxQueue,attributes:[_0xa883[13],_0xa883[21],_0xa883[22]],include:{model:User,attributes:[_0xa883[13]]}}],order:[[_0xa883[23]]]})[_0xa883[20]](function(_0xec2fxc){var _0xec2fxd={roomId:_0xec2fx7[_0xa883[13]],accountId:_0xec2fx7[_0xa883[14]],channel:_0xa883[15],msg:{from:_0xec2fx7[_0xa883[16]]},applications:_0xec2fxc};_0xec2fx6[_0xa883[19]](_0xa883[18],_0xec2fxd)[_0xa883[17]]();})[_0xa883[12]](function(_0xec2fxa){console[_0xa883[11]](_0xec2fxa)})})[_0xa883[12]](function(_0xec2fxa){console[_0xa883[11]](_0xec2fxa)})}} \ No newline at end of file diff --git a/server/api/fax_room/fax_room.socket.js b/server/api/fax_room/fax_room.socket.js index 92f71b0..6b3cf56 100644 --- a/server/api/fax_room/fax_room.socket.js +++ b/server/api/fax_room/fax_room.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var fax_room = require('../../models').FaxRoom; - -exports.register = function(socket) { - fax_room.afterCreate(function (doc) { - onSave(socket, doc); - }); - fax_room.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('fax_room:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('fax_room:remove', doc); -} +var _0x2995=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x61\x78\x52\x6F\x6F\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x3A\x72\x65\x6D\x6F\x76\x65"];_0x2995[0];var fax_room=require(_0x2995[2])[_0x2995[1]];exports[_0x2995[3]]=function(_0xf5e4x2){fax_room[_0x2995[4]](function(_0xf5e4x3){onSave(_0xf5e4x2,_0xf5e4x3)});fax_room[_0x2995[5]](function(_0xf5e4x3){onRemove(_0xf5e4x2,_0xf5e4x3)});};function onSave(_0xf5e4x2,_0xf5e4x3,_0xf5e4x5){_0xf5e4x2[_0x2995[7]](_0x2995[6],_0xf5e4x3)}function onRemove(_0xf5e4x2,_0xf5e4x3,_0xf5e4x5){_0xf5e4x2[_0x2995[7]](_0x2995[8],_0xf5e4x3)} \ No newline at end of file diff --git a/server/api/fax_room/fax_room.spec.js b/server/api/fax_room/fax_room.spec.js index 1a5ae47..b9881f7 100644 --- a/server/api/fax_room/fax_room.spec.js +++ b/server/api/fax_room/fax_room.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/fax/rooms', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/fax/rooms') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xe690=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x72\x6F\x6F\x6D\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x72\x6F\x6F\x6D\x73","\x67\x65\x74"];_0xe690[0];var should=require(_0xe690[1]);var app=require(_0xe690[2]);var request=require(_0xe690[3]);describe(_0xe690[4],function(){it(_0xe690[5],function(_0xf39dx4){request(app)[_0xe690[13]](_0xe690[12])[_0xe690[11]](200)[_0xe690[11]](_0xe690[10],/json/)[_0xe690[9]](function(_0xf39dx5,_0xf39dx6){if(_0xf39dx5){return _0xf39dx4(_0xf39dx5)};_0xf39dx6[_0xe690[8]][_0xe690[1]][_0xe690[7]][_0xe690[6]](Array);_0xf39dx4();})})}); \ No newline at end of file diff --git a/server/api/fax_room/index.js b/server/api/fax_room/index.js index 44a0c05..6bc03c2 100644 --- a/server/api/fax_room/index.js +++ b/server/api/fax_room/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./fax_room.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/agent/:id', controller.agentIndex); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x98f9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x61\x67\x65\x6E\x74\x2F\x3A\x69\x64","\x61\x67\x65\x6E\x74\x49\x6E\x64\x65\x78","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x98f9[0];var express=require(_0x98f9[1]);var controller=require(_0x98f9[2]);var router=express.Router();router[_0x98f9[5]](_0x98f9[3],controller[_0x98f9[4]]);router[_0x98f9[5]](_0x98f9[6],controller[_0x98f9[7]]);router[_0x98f9[5]](_0x98f9[8],controller[_0x98f9[9]]);router[_0x98f9[11]](_0x98f9[3],controller[_0x98f9[10]]);router[_0x98f9[13]](_0x98f9[8],controller[_0x98f9[12]]);router[_0x98f9[14]](_0x98f9[8],controller[_0x98f9[12]]);router[_0x98f9[16]](_0x98f9[8],controller[_0x98f9[15]]);module[_0x98f9[17]]=router; \ No newline at end of file diff --git a/server/api/freshdesk_account/freshdesk_account.controller.js b/server/api/freshdesk_account/freshdesk_account.controller.js index ae9ab8a..fc01f17 100644 --- a/server/api/freshdesk_account/freshdesk_account.controller.js +++ b/server/api/freshdesk_account/freshdesk_account.controller.js @@ -1,239 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/freshdesk/accounts -> index - * POST /api/freshdesk/accounts -> create - * GET /api/freshdesk/accounts/:id -> show - * PUT /api/freshdesk/accounts/:id -> update - * DELETE /api/freshdesk/accounts/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); -var util = require('util'); -var _fd = require('freshdesk'); - -var FreshdeskAccount = require('../../models').FreshdeskAccount; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of FreshdeskAccounts -exports.index = function(req, res) { - var attributes = ['description', 'name', 'username', 'remoteUri']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - FreshdeskAccount - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - return res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return res.status(500).send({ - error: 'Something blew up!' - }); - }); -} - -// Gets a single FreshdeskAccount from the DB -exports.show = function(req, res) { - FreshdeskAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new FreshdeskAccount in the DB -exports.create = function(req, res) { - FreshdeskAccount.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing FreshdeskAccount in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - FreshdeskAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a FreshdeskAccount from the DB -exports.destroy = function(req, res) { - FreshdeskAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} - -exports.bulkDestroy = function(req, res) { - FreshdeskAccount - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.checkAccount = function(req, res) { - FreshdeskAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(account) { - var freshdesk = new _fd(account.remoteUri, account.apiKey); - freshdesk.listTickets(function(err, response, body) { - if (err) { - return res.sendStatus(400); - } - body = JSON.parse(body); - if (body.require_login) { - return res.sendStatus(400); - } - return res.sendStatus(200); - }) - }) - .catch(handleError(res)); -} - -exports.accountValidation = function(req, res) { - var where = {}; - where[req.params.field] = req.body.value; - FreshdeskAccount - .findAndCountAll({ - where: where - }) - .then(function(result) { - if (result.count) { - return res.status(200).send({ - isValid: false, - value: req.body.value - }); - } - return res.status(200).send({ - isValid: true, - value: req.body.value - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getFields = function(req, res, next) { - FreshdeskAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(account) { - var Freshdesk = new _fd(account.remoteUri, account.apiKey); - Freshdesk.get('/ticket_fields.json', function(err, response, body) { - if (err) { - return next(err); - } - body = JSON.parse(body); - return res.status(200).send(body); - }); - }) - .catch(handleError(res)); -}; +var _0x646d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x66\x72\x65\x73\x68\x64\x65\x73\x6B","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x61\x70\x69\x4B\x65\x79","\x70\x61\x72\x73\x65","\x72\x65\x71\x75\x69\x72\x65\x5F\x6C\x6F\x67\x69\x6E","\x6C\x69\x73\x74\x54\x69\x63\x6B\x65\x74\x73","\x61\x63\x63\x6F\x75\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x2F\x74\x69\x63\x6B\x65\x74\x5F\x66\x69\x65\x6C\x64\x73\x2E\x6A\x73\x6F\x6E","\x67\x65\x74"];_0x646d[0];var _=require(_0x646d[1]);var util=require(_0x646d[2]);var _fd=require(_0x646d[3]);var FreshdeskAccount=require(_0x646d[5])[_0x646d[4]];function handleError(_0x104dx6,_0x104dx7){_0x104dx7=_0x104dx7||500;return function(_0x104dx8){_0x104dx6[_0x646d[7]](_0x104dx7)[_0x646d[6]](_0x104dx8)};}function responseWithResult(_0x104dx6,_0x104dx7){_0x104dx7=_0x104dx7||200;return function(_0x104dxa){if(_0x104dxa){_0x104dx6[_0x646d[7]](_0x104dx7)[_0x646d[8]](_0x104dxa)}};}function handleEntityNotFound(_0x104dx6){return function(_0x104dxa){if(!_0x104dxa){_0x104dx6[_0x646d[7]](404)[_0x646d[9]]();return null;};return _0x104dxa;}}function saveUpdates(_0x104dxd){return function(_0x104dxa){return _0x104dxa[_0x646d[11]](_0x104dxd)[_0x646d[10]](function(_0x104dxe){return _0x104dxe})}}function removeEntity(_0x104dx6){return function(_0x104dxa){if(_0x104dxa){return _0x104dxa[_0x646d[12]]()[_0x646d[10]](function(){_0x104dx6[_0x646d[7]](204)[_0x646d[9]]()})}}}exports[_0x646d[13]]=function(_0x104dx10,_0x104dx6){var _0x104dx11=[_0x646d[14],_0x646d[15],_0x646d[16],_0x646d[17]];var _0x104dx12=_0x104dx10[_0x646d[19]][_0x646d[18]]?parseInt(_0x104dx10[_0x646d[19]][_0x646d[18]],10):100;var _0x104dx13=_0x104dx10[_0x646d[19]][_0x646d[20]]?parseInt(_0x104dx10[_0x646d[19]][_0x646d[20]],10):0;var _0x104dx14={where:{},limit:_0x104dx12,offset:_0x104dx13*_0x104dx12};_[_0x646d[34]](_0x104dx10[_0x646d[19]],function(_0x104dx15,_0x104dx16){switch(_0x104dx16){case _0x646d[18]:;case _0x646d[20]:break ;;case _0x646d[23]:_0x104dx14[_0x646d[21]]=util[_0x646d[26]](_0x646d[22],_0x104dx10[_0x646d[19]][_0x646d[23]],_0x104dx10[_0x646d[19]][_0x646d[24]]||_0x646d[25])||null;break ;;case _0x646d[24]:break ;;case _0x646d[32]:_0x104dx14[_0x646d[28]][_0x646d[27]]=[];_0x104dx11[_0x646d[31]](function(_0x104dx17){var _0x104dx18={};_0x104dx18[_0x104dx17]={$like:_0x646d[29]+_0x104dx15+_0x646d[29]};_0x104dx14[_0x646d[28]][_0x646d[27]][_0x646d[30]](_0x104dx18);});break ;;default:_0x104dx14[_0x646d[28]][_0x104dx16]={$like:{}};_0x104dx14[_0x646d[28]][_0x104dx16][_0x646d[33]]=_0x646d[29]+_0x104dx15+_0x646d[29];;}});FreshdeskAccount[_0x646d[46]](_0x104dx14)[_0x646d[10]](function(_0x104dx19){var _0x104dx1a=Math[_0x646d[38]](_0x104dx19[_0x646d[37]]/_0x104dx12);var _0x104dx1b=_0x104dx1a>(_0x104dx14[_0x646d[39]]+1)?util[_0x646d[26]](_0x646d[40],_0x104dx10[_0x646d[41]],_0x104dx10[_0x646d[43]][_0x646d[42]],_0x104dx10[_0x646d[44]],_0x104dx13+1):null;var _0x104dx1c=_0x104dx13>0?util[_0x646d[26]](_0x646d[40],_0x104dx10[_0x646d[41]],_0x104dx10[_0x646d[43]][_0x646d[42]],_0x104dx10[_0x646d[44]],_0x104dx13-1):null;return _0x104dx6[_0x646d[7]](200)[_0x646d[6]]({count:_0x104dx19[_0x646d[37]],rows:_0x104dx19[_0x646d[45]],next_page:_0x104dx1b,previous_page:_0x104dx1c,total_pages:_0x104dx1a});})[_0x646d[36]](function(_0x104dx8){return _0x104dx6[_0x646d[7]](500)[_0x646d[6]]({error:_0x646d[35]})});};exports[_0x646d[47]]=function(_0x104dx10,_0x104dx6){FreshdeskAccount[_0x646d[50]](_0x104dx10[_0x646d[49]][_0x646d[48]])[_0x646d[10]](handleEntityNotFound(_0x104dx6))[_0x646d[10]](responseWithResult(_0x104dx6))[_0x646d[36]](handleError(_0x104dx6))};exports[_0x646d[51]]=function(_0x104dx10,_0x104dx6){FreshdeskAccount[_0x646d[51]](_0x104dx10[_0x646d[52]])[_0x646d[10]](responseWithResult(_0x104dx6,201))[_0x646d[36]](handleError(_0x104dx6))};exports[_0x646d[53]]=function(_0x104dx10,_0x104dx6){if(_0x104dx10[_0x646d[52]][_0x646d[48]]){delete _0x104dx10[_0x646d[52]][_0x646d[48]]};FreshdeskAccount[_0x646d[50]](_0x104dx10[_0x646d[49]][_0x646d[48]])[_0x646d[10]](handleEntityNotFound(_0x104dx6))[_0x646d[10]](saveUpdates(_0x104dx10[_0x646d[52]]))[_0x646d[10]](responseWithResult(_0x104dx6))[_0x646d[36]](handleError(_0x104dx6));};exports[_0x646d[12]]=function(_0x104dx10,_0x104dx6){FreshdeskAccount[_0x646d[50]](_0x104dx10[_0x646d[49]][_0x646d[48]])[_0x646d[10]](handleEntityNotFound(_0x104dx6))[_0x646d[10]](removeEntity(_0x104dx6))[_0x646d[36]](handleError(_0x104dx6))};exports[_0x646d[54]]=function(_0x104dx10,_0x104dx6){FreshdeskAccount[_0x646d[12]]({where:{id:_0x104dx10[_0x646d[19]][_0x646d[48]]},individualHooks:true})[_0x646d[10]](function(){return _0x104dx6[_0x646d[55]](204)})[_0x646d[36]](function(_0x104dx8){return handleError(_0x104dx6,_0x104dx8)})};exports[_0x646d[56]]=function(_0x104dx10,_0x104dx6){FreshdeskAccount[_0x646d[50]](_0x104dx10[_0x646d[49]][_0x646d[48]])[_0x646d[10]](handleEntityNotFound(_0x104dx6))[_0x646d[10]](function(_0x104dx1d){var _0x104dx1e= new _fd(_0x104dx1d[_0x646d[17]],_0x104dx1d[_0x646d[57]]);_0x104dx1e[_0x646d[60]](function(_0x104dx8,_0x104dx1f,_0x104dx20){if(_0x104dx8){return _0x104dx6[_0x646d[55]](400)};_0x104dx20=JSON[_0x646d[58]](_0x104dx20);if(_0x104dx20[_0x646d[59]]){return _0x104dx6[_0x646d[55]](400)};return _0x104dx6[_0x646d[55]](200);});})[_0x646d[36]](handleError(_0x104dx6))};exports[_0x646d[61]]=function(_0x104dx10,_0x104dx6){var _0x104dx21={};_0x104dx21[_0x104dx10[_0x646d[49]][_0x646d[62]]]=_0x104dx10[_0x646d[52]][_0x646d[63]];FreshdeskAccount[_0x646d[46]]({where:_0x104dx21})[_0x646d[10]](function(_0x104dx19){if(_0x104dx19[_0x646d[37]]){return _0x104dx6[_0x646d[7]](200)[_0x646d[6]]({isValid:false,value:_0x104dx10[_0x646d[52]][_0x646d[63]]})};return _0x104dx6[_0x646d[7]](200)[_0x646d[6]]({isValid:true,value:_0x104dx10[_0x646d[52]][_0x646d[63]]});})[_0x646d[36]](function(_0x104dx8){return handleError(_0x104dx6,_0x104dx8)});};exports[_0x646d[64]]=function(_0x104dx10,_0x104dx6,_0x104dx22){FreshdeskAccount[_0x646d[50]](_0x104dx10[_0x646d[49]][_0x646d[48]])[_0x646d[10]](handleEntityNotFound(_0x104dx6))[_0x646d[10]](function(_0x104dx1d){var _0x104dx23= new _fd(_0x104dx1d[_0x646d[17]],_0x104dx1d[_0x646d[57]]);_0x104dx23[_0x646d[66]](_0x646d[65],function(_0x104dx8,_0x104dx1f,_0x104dx20){if(_0x104dx8){return _0x104dx22(_0x104dx8)};_0x104dx20=JSON[_0x646d[58]](_0x104dx20);return _0x104dx6[_0x646d[7]](200)[_0x646d[6]](_0x104dx20);});})[_0x646d[36]](handleError(_0x104dx6))}; \ No newline at end of file diff --git a/server/api/freshdesk_account/freshdesk_account.socket.js b/server/api/freshdesk_account/freshdesk_account.socket.js index 2aabaae..68d35a9 100644 --- a/server/api/freshdesk_account/freshdesk_account.socket.js +++ b/server/api/freshdesk_account/freshdesk_account.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var FreshdeskAccount = require('../../models').FreshdeskAccount; - -exports.register = function(socket) { - FreshdeskAccount.afterCreate(function(doc) { - onSave(socket, doc); - }); - FreshdeskAccount.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('freshdesk_account:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('freshdesk_account:remove', doc); -} +var _0xe4cd=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xe4cd[0];var FreshdeskAccount=require(_0xe4cd[2])[_0xe4cd[1]];exports[_0xe4cd[3]]=function(_0xc958x2){FreshdeskAccount[_0xe4cd[4]](function(_0xc958x3){onSave(_0xc958x2,_0xc958x3)});FreshdeskAccount[_0xe4cd[5]](function(_0xc958x3){onRemove(_0xc958x2,_0xc958x3)});};function onSave(_0xc958x2,_0xc958x3,_0xc958x5){_0xc958x2[_0xe4cd[7]](_0xe4cd[6],_0xc958x3)}function onRemove(_0xc958x2,_0xc958x3,_0xc958x5){_0xc958x2[_0xe4cd[7]](_0xe4cd[8],_0xc958x3)} \ No newline at end of file diff --git a/server/api/freshdesk_account/index.js b/server/api/freshdesk_account/index.js index a7385b7..a4bd052 100644 --- a/server/api/freshdesk_account/index.js +++ b/server/api/freshdesk_account/index.js @@ -1,21 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./freshdesk_account.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/fields', auth.isAuthenticated(), controller.getFields); -router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount); -router.post('/validate/:field', auth.isAuthenticated(), controller.accountValidation); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0x4855=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x66\x69\x65\x6C\x64\x73","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x2F\x3A\x69\x64\x2F\x63\x68\x65\x63\x6B","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65\x2F\x3A\x66\x69\x65\x6C\x64","\x61\x63\x63\x6F\x75\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x4855[0];var express=require(_0x4855[1]);var auth=require(_0x4855[2]);var controller=require(_0x4855[3]);var router=express.Router();router[_0x4855[7]](_0x4855[4],auth[_0x4855[5]](),controller[_0x4855[6]]);router[_0x4855[7]](_0x4855[8],auth[_0x4855[5]](),controller[_0x4855[9]]);router[_0x4855[7]](_0x4855[10],auth[_0x4855[5]](),controller[_0x4855[11]]);router[_0x4855[7]](_0x4855[12],auth[_0x4855[5]](),controller[_0x4855[13]]);router[_0x4855[16]](_0x4855[14],auth[_0x4855[5]](),controller[_0x4855[15]]);router[_0x4855[16]](_0x4855[4],auth[_0x4855[5]](),controller[_0x4855[17]]);router[_0x4855[19]](_0x4855[8],auth[_0x4855[5]](),controller[_0x4855[18]]);router[_0x4855[20]](_0x4855[8],auth[_0x4855[5]](),controller[_0x4855[18]]);router[_0x4855[22]](_0x4855[4],auth[_0x4855[5]](),controller[_0x4855[21]]);router[_0x4855[22]](_0x4855[8],auth[_0x4855[5]](),controller[_0x4855[23]]);module[_0x4855[24]]=router; \ No newline at end of file diff --git a/server/api/freshdesk_account/index.spec.js b/server/api/freshdesk_account/index.spec.js index 6d7fc75..193468e 100644 --- a/server/api/freshdesk_account/index.spec.js +++ b/server/api/freshdesk_account/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var freshdeskAccountCtrlStub = { - index: 'freshdeskAccountCtrl.index', - show: 'freshdeskAccountCtrl.show', - create: 'freshdeskAccountCtrl.create', - update: 'freshdeskAccountCtrl.update', - destroy: 'freshdeskAccountCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var freshdeskAccountIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './freshdesk_account.controller': freshdeskAccountCtrlStub -}); - -describe('FreshdeskAccount API Router:', function() { - - it('should return an express router instance', function() { - expect(freshdeskAccountIndex).to.equal(routerStub); - }); - - describe('GET /api/freshdesk/accounts', function() { - - it('should route to freshdeskAccount.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'freshdeskAccountCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/freshdesk/accounts/:id', function() { - - it('should route to freshdeskAccount.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'freshdeskAccountCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/freshdesk/accounts', function() { - - it('should route to freshdeskAccount.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'freshdeskAccountCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/freshdesk/accounts/:id', function() { - - it('should route to freshdeskAccount.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'freshdeskAccountCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/freshdesk/accounts/:id', function() { - - it('should route to freshdeskAccount.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'freshdeskAccountCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/freshdesk/accounts/:id', function() { - - it('should route to freshdeskAccount.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'freshdeskAccountCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0x9238=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0x9238[0];var proxyquire=require(_0x9238[2])[_0x9238[1]]();var freshdeskAccountCtrlStub={index:_0x9238[3],show:_0x9238[4],create:_0x9238[5],update:_0x9238[6],destroy:_0x9238[7]};var routerStub={get:sinon[_0x9238[8]](),put:sinon[_0x9238[8]](),patch:sinon[_0x9238[8]](),post:sinon[_0x9238[8]](),delete:sinon[_0x9238[8]]()};var freshdeskAccountIndex=proxyquire(_0x9238[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":freshdeskAccountCtrlStub});describe(_0x9238[10],function(){it(_0x9238[11],function(){expect(freshdeskAccountIndex)[_0x9238[13]][_0x9238[12]](routerStub)});describe(_0x9238[14],function(){it(_0x9238[15],function(){expect(routerStub[_0x9238[21]][_0x9238[20]](_0x9238[19],_0x9238[3]))[_0x9238[13]][_0x9238[18]][_0x9238[17]][_0x9238[16]]})});describe(_0x9238[22],function(){it(_0x9238[23],function(){expect(routerStub[_0x9238[21]][_0x9238[20]](_0x9238[24],_0x9238[4]))[_0x9238[13]][_0x9238[18]][_0x9238[17]][_0x9238[16]]})});describe(_0x9238[25],function(){it(_0x9238[26],function(){expect(routerStub[_0x9238[27]][_0x9238[20]](_0x9238[19],_0x9238[5]))[_0x9238[13]][_0x9238[18]][_0x9238[17]][_0x9238[16]]})});describe(_0x9238[28],function(){it(_0x9238[29],function(){expect(routerStub[_0x9238[30]][_0x9238[20]](_0x9238[24],_0x9238[6]))[_0x9238[13]][_0x9238[18]][_0x9238[17]][_0x9238[16]]})});describe(_0x9238[31],function(){it(_0x9238[29],function(){expect(routerStub[_0x9238[32]][_0x9238[20]](_0x9238[24],_0x9238[6]))[_0x9238[13]][_0x9238[18]][_0x9238[17]][_0x9238[16]]})});describe(_0x9238[33],function(){it(_0x9238[34],function(){expect(routerStub[_0x9238[35]][_0x9238[20]](_0x9238[24],_0x9238[7]))[_0x9238[13]][_0x9238[18]][_0x9238[17]][_0x9238[16]]})});}); \ No newline at end of file diff --git a/server/api/freshdesk_configuration/freshdesk_configuration.controller.js b/server/api/freshdesk_configuration/freshdesk_configuration.controller.js index 4c3d44d..3df8df8 100644 --- a/server/api/freshdesk_configuration/freshdesk_configuration.controller.js +++ b/server/api/freshdesk_configuration/freshdesk_configuration.controller.js @@ -1,146 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/freshdesk/configurations -> index - * POST /api/freshdesk/configurations -> create - * GET /api/freshdesk/configurations/:id -> show - * PUT /api/freshdesk/configurations/:id -> update - * DELETE /api/freshdesk/configurations/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); - -var FreshdeskConfiguration = require('../../models').FreshdeskConfiguration; -var FreshdeskField = require('../../models').FreshdeskField; - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of FreshdeskConfigurations -exports.index = function(req, res) { - FreshdeskConfiguration.findAll({ - where: req.query - }) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single FreshdeskConfiguration from the DB -exports.show = function(req, res) { - FreshdeskConfiguration.find({ - where: { - id: req.params.id - }, - include: [{ - model: FreshdeskField, - as: 'Subject' - }, { - model: FreshdeskField, - as: 'Description' - }, { - model: FreshdeskField, - as: 'Field' - }] - }) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new FreshdeskConfiguration in the DB -exports.create = function(req, res) { - FreshdeskConfiguration.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing FreshdeskConfiguration in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - FreshdeskConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a FreshdeskConfiguration from the DB -exports.destroy = function(req, res) { - FreshdeskConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} - -exports.addConfigurationField = function(req, res, next) { - // console.log(req.params); - var freshdeskConfiguration; - FreshdeskConfiguration - .findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(salesforce_configuration) { - freshdeskConfiguration = salesforce_configuration; - return FreshdeskField.create(req.body) - }) - .then(function(freshdeskField) { - switch (req.params.type) { - case 'subject': - return [freshdeskConfiguration.addSubject(freshdeskField), freshdeskField]; - case 'description': - return [freshdeskConfiguration.addDescription(freshdeskField), freshdeskField]; - case 'field': - return [freshdeskConfiguration.addField(freshdeskField), freshdeskField]; - } - }) - .spread(function(data, freshdeskField) { - return res.status(201).json(freshdeskField); - }) - .catch(handleError(res)); -}; +var _0x153e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x53\x75\x62\x6A\x65\x63\x74","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x46\x69\x65\x6C\x64","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x73\x70\x72\x65\x61\x64","\x61\x64\x64\x53\x75\x62\x6A\x65\x63\x74","\x73\x75\x62\x6A\x65\x63\x74","\x61\x64\x64\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x61\x64\x64\x46\x69\x65\x6C\x64","\x66\x69\x65\x6C\x64","\x74\x79\x70\x65"];_0x153e[0];var _=require(_0x153e[1]);var FreshdeskConfiguration=require(_0x153e[3])[_0x153e[2]];var FreshdeskField=require(_0x153e[3])[_0x153e[4]];function handleError(_0x9918x5,_0x9918x6){_0x9918x6=_0x9918x6||500;return function(_0x9918x7){_0x9918x5[_0x153e[6]](_0x9918x6)[_0x153e[5]](_0x9918x7)};}function responseWithResult(_0x9918x5,_0x9918x6){_0x9918x6=_0x9918x6||200;return function(_0x9918x9){if(_0x9918x9){_0x9918x5[_0x153e[6]](_0x9918x6)[_0x153e[7]](_0x9918x9)}};}function handleEntityNotFound(_0x9918x5){return function(_0x9918x9){if(!_0x9918x9){_0x9918x5[_0x153e[6]](404)[_0x153e[8]]();return null;};return _0x9918x9;}}function saveUpdates(_0x9918xc){return function(_0x9918x9){return _0x9918x9[_0x153e[10]](_0x9918xc)[_0x153e[9]](function(_0x9918xd){return _0x9918xd})}}function removeEntity(_0x9918x5){return function(_0x9918x9){if(_0x9918x9){return _0x9918x9[_0x153e[11]]()[_0x153e[9]](function(){_0x9918x5[_0x153e[6]](204)[_0x153e[8]]()})}}}exports[_0x153e[12]]=function(_0x9918xf,_0x9918x5){FreshdeskConfiguration[_0x153e[15]]({where:_0x9918xf[_0x153e[14]]})[_0x153e[9]](responseWithResult(_0x9918x5))[_0x153e[13]](handleError(_0x9918x5))};exports[_0x153e[16]]=function(_0x9918xf,_0x9918x5){FreshdeskConfiguration[_0x153e[22]]({where:{id:_0x9918xf[_0x153e[18]][_0x153e[17]]},include:[{model:FreshdeskField,as:_0x153e[19]},{model:FreshdeskField,as:_0x153e[20]},{model:FreshdeskField,as:_0x153e[21]}]})[_0x153e[9]](handleEntityNotFound(_0x9918x5))[_0x153e[9]](responseWithResult(_0x9918x5))[_0x153e[13]](handleError(_0x9918x5))};exports[_0x153e[23]]=function(_0x9918xf,_0x9918x5){FreshdeskConfiguration[_0x153e[23]](_0x9918xf[_0x153e[24]])[_0x153e[9]](responseWithResult(_0x9918x5,201))[_0x153e[13]](handleError(_0x9918x5))};exports[_0x153e[25]]=function(_0x9918xf,_0x9918x5){if(_0x9918xf[_0x153e[24]][_0x153e[17]]){delete _0x9918xf[_0x153e[24]][_0x153e[17]]};FreshdeskConfiguration[_0x153e[26]](_0x9918xf[_0x153e[18]][_0x153e[17]])[_0x153e[9]](handleEntityNotFound(_0x9918x5))[_0x153e[9]](saveUpdates(_0x9918xf[_0x153e[24]]))[_0x153e[9]](responseWithResult(_0x9918x5))[_0x153e[13]](handleError(_0x9918x5));};exports[_0x153e[11]]=function(_0x9918xf,_0x9918x5){FreshdeskConfiguration[_0x153e[26]](_0x9918xf[_0x153e[18]][_0x153e[17]])[_0x153e[9]](handleEntityNotFound(_0x9918x5))[_0x153e[9]](removeEntity(_0x9918x5))[_0x153e[13]](handleError(_0x9918x5))};exports[_0x153e[27]]=function(_0x9918xf,_0x9918x5,_0x9918x10){var _0x9918x11;FreshdeskConfiguration[_0x153e[26]](_0x9918xf[_0x153e[18]][_0x153e[17]])[_0x153e[9]](handleEntityNotFound(_0x9918x5))[_0x153e[9]](function(_0x9918x14){_0x9918x11=_0x9918x14;return FreshdeskField[_0x153e[23]](_0x9918xf[_0x153e[24]]);})[_0x153e[9]](function(_0x9918x13){switch(_0x9918xf[_0x153e[18]][_0x153e[35]]){case _0x153e[30]:return [_0x9918x11[_0x153e[29]](_0x9918x13),_0x9918x13];;case _0x153e[32]:return [_0x9918x11[_0x153e[31]](_0x9918x13),_0x9918x13];;case _0x153e[34]:return [_0x9918x11[_0x153e[33]](_0x9918x13),_0x9918x13];;}})[_0x153e[28]](function(_0x9918x12,_0x9918x13){return _0x9918x5[_0x153e[6]](201)[_0x153e[7]](_0x9918x13)})[_0x153e[13]](handleError(_0x9918x5));}; \ No newline at end of file diff --git a/server/api/freshdesk_configuration/freshdesk_configuration.socket.js b/server/api/freshdesk_configuration/freshdesk_configuration.socket.js index 4ce7f30..65c7201 100644 --- a/server/api/freshdesk_configuration/freshdesk_configuration.socket.js +++ b/server/api/freshdesk_configuration/freshdesk_configuration.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var FreshdeskConfiguration = require('../../models').FreshdeskConfiguration; - -exports.register = function(socket) { - FreshdeskConfiguration.afterCreate(function(doc) { - onSave(socket, doc); - }); - FreshdeskConfiguration.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('freshdesk_configuration:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('freshdesk_configuration:remove', doc); -} +var _0xa009=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xa009[0];var FreshdeskConfiguration=require(_0xa009[2])[_0xa009[1]];exports[_0xa009[3]]=function(_0xd4a5x2){FreshdeskConfiguration[_0xa009[4]](function(_0xd4a5x3){onSave(_0xd4a5x2,_0xd4a5x3)});FreshdeskConfiguration[_0xa009[5]](function(_0xd4a5x3){onRemove(_0xd4a5x2,_0xd4a5x3)});};function onSave(_0xd4a5x2,_0xd4a5x3,_0xd4a5x5){_0xd4a5x2[_0xa009[7]](_0xa009[6],_0xd4a5x3)}function onRemove(_0xd4a5x2,_0xd4a5x3,_0xd4a5x5){_0xd4a5x2[_0xa009[7]](_0xa009[8],_0xd4a5x3)} \ No newline at end of file diff --git a/server/api/freshdesk_configuration/index.js b/server/api/freshdesk_configuration/index.js index e08945f..b2b778a 100644 --- a/server/api/freshdesk_configuration/index.js +++ b/server/api/freshdesk_configuration/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./freshdesk_configuration.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); - -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0xb4fd=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x3A\x69\x64\x2F\x3A\x74\x79\x70\x65","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xb4fd[0];var express=require(_0xb4fd[1]);var auth=require(_0xb4fd[2]);var controller=require(_0xb4fd[3]);var router=express.Router();router[_0xb4fd[7]](_0xb4fd[4],auth[_0xb4fd[5]](),controller[_0xb4fd[6]]);router[_0xb4fd[7]](_0xb4fd[8],auth[_0xb4fd[5]](),controller[_0xb4fd[9]]);router[_0xb4fd[11]](_0xb4fd[4],auth[_0xb4fd[5]](),controller[_0xb4fd[10]]);router[_0xb4fd[13]](_0xb4fd[8],auth[_0xb4fd[5]](),controller[_0xb4fd[12]]);router[_0xb4fd[11]](_0xb4fd[14],auth[_0xb4fd[5]](),controller[_0xb4fd[15]]);router[_0xb4fd[16]](_0xb4fd[8],auth[_0xb4fd[5]](),controller[_0xb4fd[12]]);router[_0xb4fd[18]](_0xb4fd[8],auth[_0xb4fd[5]](),controller[_0xb4fd[17]]);module[_0xb4fd[19]]=router; \ No newline at end of file diff --git a/server/api/freshdesk_configuration/index.spec.js b/server/api/freshdesk_configuration/index.spec.js index b297c23..3254e77 100644 --- a/server/api/freshdesk_configuration/index.spec.js +++ b/server/api/freshdesk_configuration/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var freshdeskConfigurationCtrlStub = { - index: 'freshdeskConfigurationCtrl.index', - show: 'freshdeskConfigurationCtrl.show', - create: 'freshdeskConfigurationCtrl.create', - update: 'freshdeskConfigurationCtrl.update', - destroy: 'freshdeskConfigurationCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var freshdeskConfigurationIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './freshdesk_configuration.controller': freshdeskConfigurationCtrlStub -}); - -describe('FreshdeskConfiguration API Router:', function() { - - it('should return an express router instance', function() { - expect(freshdeskConfigurationIndex).to.equal(routerStub); - }); - - describe('GET /api/freshdesk/configurations', function() { - - it('should route to freshdeskConfiguration.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'freshdeskConfigurationCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/freshdesk/configurations/:id', function() { - - it('should route to freshdeskConfiguration.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'freshdeskConfigurationCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/freshdesk/configurations', function() { - - it('should route to freshdeskConfiguration.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'freshdeskConfigurationCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/freshdesk/configurations/:id', function() { - - it('should route to freshdeskConfiguration.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'freshdeskConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/freshdesk/configurations/:id', function() { - - it('should route to freshdeskConfiguration.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'freshdeskConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/freshdesk/configurations/:id', function() { - - it('should route to freshdeskConfiguration.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'freshdeskConfigurationCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0x1630=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0x1630[0];var proxyquire=require(_0x1630[2])[_0x1630[1]]();var freshdeskConfigurationCtrlStub={index:_0x1630[3],show:_0x1630[4],create:_0x1630[5],update:_0x1630[6],destroy:_0x1630[7]};var routerStub={get:sinon[_0x1630[8]](),put:sinon[_0x1630[8]](),patch:sinon[_0x1630[8]](),post:sinon[_0x1630[8]](),delete:sinon[_0x1630[8]]()};var freshdeskConfigurationIndex=proxyquire(_0x1630[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":freshdeskConfigurationCtrlStub});describe(_0x1630[10],function(){it(_0x1630[11],function(){expect(freshdeskConfigurationIndex)[_0x1630[13]][_0x1630[12]](routerStub)});describe(_0x1630[14],function(){it(_0x1630[15],function(){expect(routerStub[_0x1630[21]][_0x1630[20]](_0x1630[19],_0x1630[3]))[_0x1630[13]][_0x1630[18]][_0x1630[17]][_0x1630[16]]})});describe(_0x1630[22],function(){it(_0x1630[23],function(){expect(routerStub[_0x1630[21]][_0x1630[20]](_0x1630[24],_0x1630[4]))[_0x1630[13]][_0x1630[18]][_0x1630[17]][_0x1630[16]]})});describe(_0x1630[25],function(){it(_0x1630[26],function(){expect(routerStub[_0x1630[27]][_0x1630[20]](_0x1630[19],_0x1630[5]))[_0x1630[13]][_0x1630[18]][_0x1630[17]][_0x1630[16]]})});describe(_0x1630[28],function(){it(_0x1630[29],function(){expect(routerStub[_0x1630[30]][_0x1630[20]](_0x1630[24],_0x1630[6]))[_0x1630[13]][_0x1630[18]][_0x1630[17]][_0x1630[16]]})});describe(_0x1630[31],function(){it(_0x1630[29],function(){expect(routerStub[_0x1630[32]][_0x1630[20]](_0x1630[24],_0x1630[6]))[_0x1630[13]][_0x1630[18]][_0x1630[17]][_0x1630[16]]})});describe(_0x1630[33],function(){it(_0x1630[34],function(){expect(routerStub[_0x1630[35]][_0x1630[20]](_0x1630[24],_0x1630[7]))[_0x1630[13]][_0x1630[18]][_0x1630[17]][_0x1630[16]]})});}); \ No newline at end of file diff --git a/server/api/freshdesk_field/freshdesk_field.controller.js b/server/api/freshdesk_field/freshdesk_field.controller.js index 4a35db8..386e4f4 100644 --- a/server/api/freshdesk_field/freshdesk_field.controller.js +++ b/server/api/freshdesk_field/freshdesk_field.controller.js @@ -1,104 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/freshdesk/fields -> index - * POST /api/freshdesk/fields -> create - * GET /api/freshdesk/fields/:id -> show - * PUT /api/freshdesk/fields/:id -> update - * DELETE /api/freshdesk/fields/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); - -var FreshdeskField = require('../../models').FreshdeskField; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of FreshdeskFields -exports.index = function(req, res) { - FreshdeskField.findAll() - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single FreshdeskField from the DB -exports.show = function(req, res) { - FreshdeskField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new FreshdeskField in the DB -exports.create = function(req, res) { - FreshdeskField.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing FreshdeskField in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - FreshdeskField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a FreshdeskField from the DB -exports.destroy = function(req, res) { - FreshdeskField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} +var _0xbcd7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65"];_0xbcd7[0];var _=require(_0xbcd7[1]);var FreshdeskField=require(_0xbcd7[3])[_0xbcd7[2]];function handleError(_0x646ax4,_0x646ax5){_0x646ax5=_0x646ax5||500;return function(_0x646ax6){_0x646ax4[_0xbcd7[5]](_0x646ax5)[_0xbcd7[4]](_0x646ax6)};}function responseWithResult(_0x646ax4,_0x646ax5){_0x646ax5=_0x646ax5||200;return function(_0x646ax8){if(_0x646ax8){_0x646ax4[_0xbcd7[5]](_0x646ax5)[_0xbcd7[6]](_0x646ax8)}};}function handleEntityNotFound(_0x646ax4){return function(_0x646ax8){if(!_0x646ax8){_0x646ax4[_0xbcd7[5]](404)[_0xbcd7[7]]();return null;};return _0x646ax8;}}function saveUpdates(_0x646axb){return function(_0x646ax8){return _0x646ax8[_0xbcd7[9]](_0x646axb)[_0xbcd7[8]](function(_0x646axc){return _0x646axc})}}function removeEntity(_0x646ax4){return function(_0x646ax8){if(_0x646ax8){return _0x646ax8[_0xbcd7[10]]()[_0xbcd7[8]](function(){_0x646ax4[_0xbcd7[5]](204)[_0xbcd7[7]]()})}}}exports[_0xbcd7[11]]=function(_0x646axe,_0x646ax4){FreshdeskField[_0xbcd7[13]]()[_0xbcd7[8]](responseWithResult(_0x646ax4))[_0xbcd7[12]](handleError(_0x646ax4))};exports[_0xbcd7[14]]=function(_0x646axe,_0x646ax4){FreshdeskField[_0xbcd7[17]](_0x646axe[_0xbcd7[16]][_0xbcd7[15]])[_0xbcd7[8]](handleEntityNotFound(_0x646ax4))[_0xbcd7[8]](responseWithResult(_0x646ax4))[_0xbcd7[12]](handleError(_0x646ax4))};exports[_0xbcd7[18]]=function(_0x646axe,_0x646ax4){FreshdeskField[_0xbcd7[18]](_0x646axe[_0xbcd7[19]])[_0xbcd7[8]](responseWithResult(_0x646ax4,201))[_0xbcd7[12]](handleError(_0x646ax4))};exports[_0xbcd7[20]]=function(_0x646axe,_0x646ax4){if(_0x646axe[_0xbcd7[19]][_0xbcd7[15]]){delete _0x646axe[_0xbcd7[19]][_0xbcd7[15]]};FreshdeskField[_0xbcd7[17]](_0x646axe[_0xbcd7[16]][_0xbcd7[15]])[_0xbcd7[8]](handleEntityNotFound(_0x646ax4))[_0xbcd7[8]](saveUpdates(_0x646axe[_0xbcd7[19]]))[_0xbcd7[8]](responseWithResult(_0x646ax4))[_0xbcd7[12]](handleError(_0x646ax4));};exports[_0xbcd7[10]]=function(_0x646axe,_0x646ax4){FreshdeskField[_0xbcd7[17]](_0x646axe[_0xbcd7[16]][_0xbcd7[15]])[_0xbcd7[8]](handleEntityNotFound(_0x646ax4))[_0xbcd7[8]](removeEntity(_0x646ax4))[_0xbcd7[12]](handleError(_0x646ax4))}; \ No newline at end of file diff --git a/server/api/freshdesk_field/freshdesk_field.socket.js b/server/api/freshdesk_field/freshdesk_field.socket.js index b351442..6f16ab8 100644 --- a/server/api/freshdesk_field/freshdesk_field.socket.js +++ b/server/api/freshdesk_field/freshdesk_field.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var FreshdeskField = require('../../models').FreshdeskField; - -exports.register = function(socket) { - FreshdeskField.afterCreate(function(doc) { - onSave(socket, doc); - }); - FreshdeskField.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('freshdesk_field:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('freshdesk_field:remove', doc); -} +var _0x22e7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0x22e7[0];var FreshdeskField=require(_0x22e7[2])[_0x22e7[1]];exports[_0x22e7[3]]=function(_0xc464x2){FreshdeskField[_0x22e7[4]](function(_0xc464x3){onSave(_0xc464x2,_0xc464x3)});FreshdeskField[_0x22e7[5]](function(_0xc464x3){onRemove(_0xc464x2,_0xc464x3)});};function onSave(_0xc464x2,_0xc464x3,_0xc464x5){_0xc464x2[_0x22e7[7]](_0x22e7[6],_0xc464x3)}function onRemove(_0xc464x2,_0xc464x3,_0xc464x5){_0xc464x2[_0x22e7[7]](_0x22e7[8],_0xc464x3)} \ No newline at end of file diff --git a/server/api/freshdesk_field/index.js b/server/api/freshdesk_field/index.js index d17268f..2f224a5 100644 --- a/server/api/freshdesk_field/index.js +++ b/server/api/freshdesk_field/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./freshdesk_field.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); - -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0xee50=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xee50[0];var express=require(_0xee50[1]);var auth=require(_0xee50[2]);var controller=require(_0xee50[3]);var router=express.Router();router[_0xee50[7]](_0xee50[4],auth[_0xee50[5]](),controller[_0xee50[6]]);router[_0xee50[7]](_0xee50[8],auth[_0xee50[5]](),controller[_0xee50[9]]);router[_0xee50[11]](_0xee50[4],auth[_0xee50[5]](),controller[_0xee50[10]]);router[_0xee50[13]](_0xee50[8],auth[_0xee50[5]](),controller[_0xee50[12]]);router[_0xee50[14]](_0xee50[8],auth[_0xee50[5]](),controller[_0xee50[12]]);router[_0xee50[16]](_0xee50[8],auth[_0xee50[5]](),controller[_0xee50[15]]);module[_0xee50[17]]=router; \ No newline at end of file diff --git a/server/api/freshdesk_field/index.spec.js b/server/api/freshdesk_field/index.spec.js index b5c0fb8..84edd95 100644 --- a/server/api/freshdesk_field/index.spec.js +++ b/server/api/freshdesk_field/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var freshdeskFieldCtrlStub = { - index: 'freshdeskFieldCtrl.index', - show: 'freshdeskFieldCtrl.show', - create: 'freshdeskFieldCtrl.create', - update: 'freshdeskFieldCtrl.update', - destroy: 'freshdeskFieldCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var freshdeskFieldIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './freshdesk_field.controller': freshdeskFieldCtrlStub -}); - -describe('FreshdeskField API Router:', function() { - - it('should return an express router instance', function() { - expect(freshdeskFieldIndex).to.equal(routerStub); - }); - - describe('GET /api/freshdesk/fields', function() { - - it('should route to freshdeskField.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'freshdeskFieldCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/freshdesk/fields/:id', function() { - - it('should route to freshdeskField.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'freshdeskFieldCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/freshdesk/fields', function() { - - it('should route to freshdeskField.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'freshdeskFieldCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/freshdesk/fields/:id', function() { - - it('should route to freshdeskField.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'freshdeskFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/freshdesk/fields/:id', function() { - - it('should route to freshdeskField.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'freshdeskFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/freshdesk/fields/:id', function() { - - it('should route to freshdeskField.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'freshdeskFieldCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0xdf20=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0xdf20[0];var proxyquire=require(_0xdf20[2])[_0xdf20[1]]();var freshdeskFieldCtrlStub={index:_0xdf20[3],show:_0xdf20[4],create:_0xdf20[5],update:_0xdf20[6],destroy:_0xdf20[7]};var routerStub={get:sinon[_0xdf20[8]](),put:sinon[_0xdf20[8]](),patch:sinon[_0xdf20[8]](),post:sinon[_0xdf20[8]](),delete:sinon[_0xdf20[8]]()};var freshdeskFieldIndex=proxyquire(_0xdf20[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":freshdeskFieldCtrlStub});describe(_0xdf20[10],function(){it(_0xdf20[11],function(){expect(freshdeskFieldIndex)[_0xdf20[13]][_0xdf20[12]](routerStub)});describe(_0xdf20[14],function(){it(_0xdf20[15],function(){expect(routerStub[_0xdf20[21]][_0xdf20[20]](_0xdf20[19],_0xdf20[3]))[_0xdf20[13]][_0xdf20[18]][_0xdf20[17]][_0xdf20[16]]})});describe(_0xdf20[22],function(){it(_0xdf20[23],function(){expect(routerStub[_0xdf20[21]][_0xdf20[20]](_0xdf20[24],_0xdf20[4]))[_0xdf20[13]][_0xdf20[18]][_0xdf20[17]][_0xdf20[16]]})});describe(_0xdf20[25],function(){it(_0xdf20[26],function(){expect(routerStub[_0xdf20[27]][_0xdf20[20]](_0xdf20[19],_0xdf20[5]))[_0xdf20[13]][_0xdf20[18]][_0xdf20[17]][_0xdf20[16]]})});describe(_0xdf20[28],function(){it(_0xdf20[29],function(){expect(routerStub[_0xdf20[30]][_0xdf20[20]](_0xdf20[24],_0xdf20[6]))[_0xdf20[13]][_0xdf20[18]][_0xdf20[17]][_0xdf20[16]]})});describe(_0xdf20[31],function(){it(_0xdf20[29],function(){expect(routerStub[_0xdf20[32]][_0xdf20[20]](_0xdf20[24],_0xdf20[6]))[_0xdf20[13]][_0xdf20[18]][_0xdf20[17]][_0xdf20[16]]})});describe(_0xdf20[33],function(){it(_0xdf20[34],function(){expect(routerStub[_0xdf20[35]][_0xdf20[20]](_0xdf20[24],_0xdf20[7]))[_0xdf20[13]][_0xdf20[18]][_0xdf20[17]][_0xdf20[16]]})});}); \ No newline at end of file diff --git a/server/api/integration/index.js b/server/api/integration/index.js index 5789126..d2f3bc3 100644 --- a/server/api/integration/index.js +++ b/server/api/integration/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./integration.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x8254=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x8254[0];var express=require(_0x8254[1]);var controller=require(_0x8254[2]);var router=express.Router();router[_0x8254[5]](_0x8254[3],controller[_0x8254[4]]);router[_0x8254[5]](_0x8254[6],controller[_0x8254[7]]);router[_0x8254[9]](_0x8254[3],controller[_0x8254[8]]);router[_0x8254[11]](_0x8254[6],controller[_0x8254[10]]);router[_0x8254[12]](_0x8254[6],controller[_0x8254[10]]);router[_0x8254[14]](_0x8254[6],controller[_0x8254[13]]);module[_0x8254[15]]=router; \ No newline at end of file diff --git a/server/api/integration/integration.controller.js b/server/api/integration/integration.controller.js index fac2b89..48e18a2 100644 --- a/server/api/integration/integration.controller.js +++ b/server/api/integration/integration.controller.js @@ -1,179 +1 @@ -'use strict'; - -var _ = require('lodash'); -var uploadFile = require('upload-file'); -var config = require('../../config/environment'); -var path = require('path'); -var sr = require('simple-random'); -var admZip = require('adm-zip'); -var str2json = require('string-to-json'); -var fs = require('fs'); - -var Integration = require('../../models').Integration; - -// Get list of integrations -exports.index = function(req, res) { - Integration - .findAll({ - where: req.query - }) - .then(function(integrations) { - return res.status(200).send(integrations); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single integration -exports.show = function(req, res) { - Integration - .findById(req.params.id) - .then(function(integration) { - if (!integration) { - return res.sendStatus(404); - } - return res.send(integration); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new integration in the DB. -exports.create = function(req, res) { - var upload = new uploadFile({ - dest: path.join(config.root, 'server/files/integrations'), - maxFileSize: 5 * 1000000, - maxNumberOfFiles: 1, - minNumberOfFiles: 1, - acceptFileTypes: /(\.|\/)(zip)$/i, - messages: { - maxNumberOfFiles: "Max number of files upload exceeded", - acceptFileTypes: "Only zip format accepted", - maxFileSize: "The maximum file size is 5 Mb", - invalidRequest: "Invalid request" - } - }); - - upload.on('end', function(fields, files) { - var zip = new admZip(files.file.path); - - var manifest = false; - var zipEntries = zip.getEntries(); - zipEntries.forEach(function(zipEntry) { - if (zipEntry.name === 'manifest.json') { - var str = zipEntry.getData().toString('utf8'); - console.log('uploadZip', str); - try { - manifest = JSON.parse(str); - console.log('uploadZip', manifest); - Integration - .create(_.merge(files.file, manifest)) - .then(function(integration) { - - // Extract All Zip and overwrite old directory - zip.extractAllTo(path.join(config.root, - 'server/files/integrations'), true); - - return res.status(201).send(integration); - }) - .catch(function(err) { - return handleError(res, err); - }); - } catch (e) { - console.log(e); - var err = { - errors: [{ - type: 'json', - message: e - }] - }; - return handleError(res, err); - } - } - }); - - fs.unlinkSync(files.file.path); - - if (!manifest) { - var err = { - errors: [{ - type: 'manifest', - message: 'manifest.json not found' - }] - }; - return handleError(res, err); - } - }); - - upload.on('error', function(e) { - var err = { - errors: [{ - type: 'upload', - message: e - }] - }; - return handleError(res, err); - }); - - upload.parse(req); -}; - -// Updates an existing integration in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Integration - .find({ - where: { - id: req.params.id - } - }) - .then(function(integration) { - if (!integration) { - return res.sendStatus(404); - } - var updated = _.merge(integration, req.body); - updated.save() - .then(function() { - return res.status(200).send(integration); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a integration from the DB. -exports.destroy = function(req, res) { - Integration - .find({ - where: { - id: req.params.id - } - }) - .then(function(integration) { - if (!integration) { - return res.sendStatus(404); - } - integration.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x928c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x70\x6C\x6F\x61\x64\x2D\x66\x69\x6C\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x70\x61\x74\x68","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x61\x64\x6D\x2D\x7A\x69\x70","\x73\x74\x72\x69\x6E\x67\x2D\x74\x6F\x2D\x6A\x73\x6F\x6E","\x66\x73","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73","\x6A\x6F\x69\x6E","\x4D\x61\x78\x20\x6E\x75\x6D\x62\x65\x72\x20\x6F\x66\x20\x66\x69\x6C\x65\x73\x20\x75\x70\x6C\x6F\x61\x64\x20\x65\x78\x63\x65\x65\x64\x65\x64","\x4F\x6E\x6C\x79\x20\x7A\x69\x70\x20\x66\x6F\x72\x6D\x61\x74\x20\x61\x63\x63\x65\x70\x74\x65\x64","\x54\x68\x65\x20\x6D\x61\x78\x69\x6D\x75\x6D\x20\x66\x69\x6C\x65\x20\x73\x69\x7A\x65\x20\x69\x73\x20\x35\x20\x4D\x62","\x49\x6E\x76\x61\x6C\x69\x64\x20\x72\x65\x71\x75\x65\x73\x74","\x65\x6E\x64","\x66\x69\x6C\x65","\x67\x65\x74\x45\x6E\x74\x72\x69\x65\x73","\x6E\x61\x6D\x65","\x6D\x61\x6E\x69\x66\x65\x73\x74\x2E\x6A\x73\x6F\x6E","\x75\x74\x66\x38","\x67\x65\x74\x44\x61\x74\x61","\x75\x70\x6C\x6F\x61\x64\x5A\x69\x70","\x6C\x6F\x67","\x70\x61\x72\x73\x65","\x65\x78\x74\x72\x61\x63\x74\x41\x6C\x6C\x54\x6F","\x6D\x65\x72\x67\x65","\x6A\x73\x6F\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x75\x6E\x6C\x69\x6E\x6B\x53\x79\x6E\x63","\x6D\x61\x6E\x69\x66\x65\x73\x74","\x6D\x61\x6E\x69\x66\x65\x73\x74\x2E\x6A\x73\x6F\x6E\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x6F\x6E","\x65\x72\x72\x6F\x72","\x75\x70\x6C\x6F\x61\x64","\x75\x70\x64\x61\x74\x65","\x62\x6F\x64\x79","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x928c[0];var _=require(_0x928c[1]);var uploadFile=require(_0x928c[2]);var config=require(_0x928c[3]);var path=require(_0x928c[4]);var sr=require(_0x928c[5]);var admZip=require(_0x928c[6]);var str2json=require(_0x928c[7]);var fs=require(_0x928c[8]);var Integration=require(_0x928c[10])[_0x928c[9]];exports[_0x928c[11]]=function(_0xdaddxa,_0xdaddxb){Integration[_0x928c[17]]({where:_0xdaddxa[_0x928c[16]]})[_0x928c[15]](function(_0xdaddxd){return _0xdaddxb[_0x928c[14]](200)[_0x928c[13]](_0xdaddxd)})[_0x928c[12]](function(_0xdaddxc){return handleError(_0xdaddxb,_0xdaddxc)})};exports[_0x928c[18]]=function(_0xdaddxa,_0xdaddxb){Integration[_0x928c[22]](_0xdaddxa[_0x928c[21]][_0x928c[20]])[_0x928c[15]](function(_0xdaddxe){if(!_0xdaddxe){return _0xdaddxb[_0x928c[19]](404)};return _0xdaddxb[_0x928c[13]](_0xdaddxe);})[_0x928c[12]](function(_0xdaddxc){return handleError(_0xdaddxb,_0xdaddxc)})};exports[_0x928c[23]]=function(_0xdaddxa,_0xdaddxb){var _0xdaddxf= new uploadFile({dest:path[_0x928c[26]](config[_0x928c[24]],_0x928c[25]),maxFileSize:5*1000000,maxNumberOfFiles:1,minNumberOfFiles:1,acceptFileTypes:/(\.|\/)(zip)$/i,messages:{maxNumberOfFiles:_0x928c[27],acceptFileTypes:_0x928c[28],maxFileSize:_0x928c[29],invalidRequest:_0x928c[30]}});_0xdaddxf[_0x928c[48]](_0x928c[31],function(_0xdaddx10,_0xdaddx11){var _0xdaddx12= new admZip(_0xdaddx11[_0x928c[32]][_0x928c[4]]);var _0xdaddx13=false;var _0xdaddx14=_0xdaddx12[_0x928c[33]]();_0xdaddx14[_0x928c[44]](function(_0xdaddx15){if(_0xdaddx15[_0x928c[34]]===_0x928c[35]){var _0xdaddx16=_0xdaddx15[_0x928c[37]]().toString(_0x928c[36]);console[_0x928c[39]](_0x928c[38],_0xdaddx16);try{_0xdaddx13=JSON[_0x928c[40]](_0xdaddx16);console[_0x928c[39]](_0x928c[38],_0xdaddx13);Integration[_0x928c[23]](_[_0x928c[42]](_0xdaddx11[_0x928c[32]],_0xdaddx13))[_0x928c[15]](function(_0xdaddxe){_0xdaddx12[_0x928c[41]](path[_0x928c[26]](config[_0x928c[24]],_0x928c[25]),true);return _0xdaddxb[_0x928c[14]](201)[_0x928c[13]](_0xdaddxe);})[_0x928c[12]](function(_0xdaddxc){return handleError(_0xdaddxb,_0xdaddxc)});}catch(e){console[_0x928c[39]](e);var _0xdaddxc={errors:[{type:_0x928c[43],message:e}]};return handleError(_0xdaddxb,_0xdaddxc);};}});fs[_0x928c[45]](_0xdaddx11[_0x928c[32]][_0x928c[4]]);if(!_0xdaddx13){var _0xdaddxc={errors:[{type:_0x928c[46],message:_0x928c[47]}]};return handleError(_0xdaddxb,_0xdaddxc);};});_0xdaddxf[_0x928c[48]](_0x928c[49],function(_0xdaddx17){var _0xdaddxc={errors:[{type:_0x928c[50],message:_0xdaddx17}]};return handleError(_0xdaddxb,_0xdaddxc);});_0xdaddxf[_0x928c[40]](_0xdaddxa);};exports[_0x928c[51]]=function(_0xdaddxa,_0xdaddxb){if(_0xdaddxa[_0x928c[52]][_0x928c[20]]){delete _0xdaddxa[_0x928c[52]][_0x928c[20]]};Integration[_0x928c[54]]({where:{id:_0xdaddxa[_0x928c[21]][_0x928c[20]]}})[_0x928c[15]](function(_0xdaddxe){if(!_0xdaddxe){return _0xdaddxb[_0x928c[19]](404)};var _0xdaddx18=_[_0x928c[42]](_0xdaddxe,_0xdaddxa[_0x928c[52]]);_0xdaddx18[_0x928c[53]]()[_0x928c[15]](function(){return _0xdaddxb[_0x928c[14]](200)[_0x928c[13]](_0xdaddxe)})[_0x928c[12]](function(_0xdaddxc){return handleError(_0xdaddxb,_0xdaddxc)});})[_0x928c[12]](function(_0xdaddxc){return handleError(_0xdaddxb,_0xdaddxc)});};exports[_0x928c[55]]=function(_0xdaddxa,_0xdaddxb){Integration[_0x928c[54]]({where:{id:_0xdaddxa[_0x928c[21]][_0x928c[20]]}})[_0x928c[15]](function(_0xdaddxe){if(!_0xdaddxe){return _0xdaddxb[_0x928c[19]](404)};_0xdaddxe[_0x928c[55]]()[_0x928c[15]](function(){return _0xdaddxb[_0x928c[19]](204)})[_0x928c[12]](function(_0xdaddxc){return handleError(_0xdaddxb,_0xdaddxc)});})[_0x928c[12]](function(_0xdaddxc){return handleError(_0xdaddxb,_0xdaddxc)})};function handleError(_0xdaddxb,_0xdaddxc){return _0xdaddxb[_0x928c[14]](500)[_0x928c[13]](_0xdaddxc)} \ No newline at end of file diff --git a/server/api/integration/integration.socket.js b/server/api/integration/integration.socket.js index a79af43..955e711 100644 --- a/server/api/integration/integration.socket.js +++ b/server/api/integration/integration.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Integration = require('../../models').Integration; - -exports.register = function(socket) { - Integration.afterCreate(function(doc) { - onSave(socket, doc); - }); - Integration.afterUpdate(function(doc) { - onSave(socket, doc); - }); - Integration.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('integration:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('integration:remove', doc); -} +var _0xfe00=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xfe00[0];var Integration=require(_0xfe00[2])[_0xfe00[1]];exports[_0xfe00[3]]=function(_0x678dx2){Integration[_0xfe00[4]](function(_0x678dx3){onSave(_0x678dx2,_0x678dx3)});Integration[_0xfe00[5]](function(_0x678dx3){onSave(_0x678dx2,_0x678dx3)});Integration[_0xfe00[6]](function(_0x678dx3){onRemove(_0x678dx2,_0x678dx3)});};function onSave(_0x678dx2,_0x678dx3,_0x678dx5){_0x678dx2[_0xfe00[8]](_0xfe00[7],_0x678dx3)}function onRemove(_0x678dx2,_0x678dx3,_0x678dx5){_0x678dx2[_0xfe00[8]](_0xfe00[9],_0x678dx3)} \ No newline at end of file diff --git a/server/api/integration/integration.spec.js b/server/api/integration/integration.spec.js index 0d4146d..8e1d868 100644 --- a/server/api/integration/integration.spec.js +++ b/server/api/integration/integration.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/integrations', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/integrations') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xf889=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0xf889[0];var should=require(_0xf889[1]);var app=require(_0xf889[2]);var request=require(_0xf889[3]);describe(_0xf889[4],function(){it(_0xf889[5],function(_0x1819x4){request(app)[_0xf889[13]](_0xf889[12])[_0xf889[11]](200)[_0xf889[11]](_0xf889[10],/json/)[_0xf889[9]](function(_0x1819x5,_0x1819x6){if(_0x1819x5){return _0x1819x4(_0x1819x5)};_0x1819x6[_0xf889[8]][_0xf889[1]][_0xf889[7]][_0xf889[6]](Array);_0x1819x4();})})}); \ No newline at end of file diff --git a/server/api/interval/index.js b/server/api/interval/index.js index 2b5572a..c34d745 100644 --- a/server/api/interval/index.js +++ b/server/api/interval/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./interval.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/all', auth.isAuthenticated(), controller.getAll); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.intervalValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x5e72=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x69\x6E\x74\x65\x72\x76\x61\x6C\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x61\x6C\x6C","\x67\x65\x74\x41\x6C\x6C","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x69\x6E\x74\x65\x72\x76\x61\x6C\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x5e72[0];var express=require(_0x5e72[1]);var controller=require(_0x5e72[2]);var auth=require(_0x5e72[3]);var router=express.Router();router[_0x5e72[7]](_0x5e72[4],auth[_0x5e72[5]](),controller[_0x5e72[6]]);router[_0x5e72[7]](_0x5e72[8],auth[_0x5e72[5]](),controller[_0x5e72[9]]);router[_0x5e72[7]](_0x5e72[10],auth[_0x5e72[5]](),controller[_0x5e72[11]]);router[_0x5e72[13]](_0x5e72[4],auth[_0x5e72[5]](),controller[_0x5e72[12]]);router[_0x5e72[13]](_0x5e72[14],auth[_0x5e72[5]](),controller[_0x5e72[15]]);router[_0x5e72[17]](_0x5e72[10],auth[_0x5e72[5]](),controller[_0x5e72[16]]);router[_0x5e72[19]](_0x5e72[4],auth[_0x5e72[5]](),controller[_0x5e72[18]]);router[_0x5e72[19]](_0x5e72[10],auth[_0x5e72[5]](),controller[_0x5e72[20]]);module[_0x5e72[21]]=router; \ No newline at end of file diff --git a/server/api/interval/interval.controller.js b/server/api/interval/interval.controller.js index e0d975e..3a71e99 100644 --- a/server/api/interval/interval.controller.js +++ b/server/api/interval/interval.controller.js @@ -1,324 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Interval = require('../../models').Interval; -var VoiceExtension = require('../../models').VoiceExtension; -var sequelize = require('../../models').sequelize; -var util = require('util'); - -// Get list of intervals -exports.index = function(req, res) { - - var attributes = ['name']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: { - IntervalId: null - }, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Interval - .findAndCountAll(query) - .then(function(intervals) { - return res.status(200).send(intervals); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getAll = function(req, res) { - Interval - .findAll() - .then(function(intervals) { - return res.status(200).send(intervals); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// // Get list of subintervals -// exports.showSubsByInterval = function(req, res) { -// VoiceInterval -// .findAll({ -// where: { -// VoiceIntervalId: req.params.id -// } -// }) -// .then(function(intervals) { -// return res.status(200).send(intervals); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }; - -// Get a single interval -exports.show = function(req, res) { - Interval - .findById(req.params.id, { - include: [{ - all: true - }] - }) - .then(function(interval) { - if (!interval) { - return res.sendStatus(404); - } - return res.send(interval); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Validate the existence of a route -exports.intervalValidation = function(req, res) { - var where = { - name: req.body.name, - IntervalId: req.body.IntervalId ? req.body.IntervalId : null - }; - if (req.body.id) { - where.id = { - $ne: req.body.id - }; - } - console.log(req.body); - Interval - .findAll({ - where: where - }) - .then(function(intervals) { - if (!intervals) { - return res.sendStatus(404); - } - return res.send(intervals); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new interval in the DB. -exports.create = function(req, res) { - Interval - .findAll({ - where: { - name: req.body.name, - IntervalId: req.body.IntervalId ? req.body.IntervalId : null - } - }) - .then(function(existingIntervals) { - console.log(existingIntervals); - console.log('Finding app row.....'); - if (!existingIntervals) { - return res.sendStatus(404); - } - if (existingIntervals.length > 0) { - return res.status(500).send({ - message: req.body.IntervalId ? 'MESSAGE_EXIST_SUBINTERVAL' : 'MESSAGE_EXIST_INTERVAL' - }); - } - Interval - .create(req.body) - .then(function(interval) { - return res.status(201).send(interval); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing interval in the DB. -exports.update = function(req, res) { - Interval - .findAll({ - where: { - name: req.body.name, - IntervalId: req.body.IntervalId ? req.body.IntervalId : null, - id: { - $ne: req.body.id - } - } - }) - .then(function(existingIntervals) { - console.log(existingIntervals); - console.log('Finding app row.....'); - if (!existingIntervals) { - return res.sendStatus(404); - } - if (existingIntervals.length > 0) { - return res.status(500).send({ - message: req.body.IntervalId ? 'MESSAGE_EXIST_SUBINTERVAL' : 'MESSAGE_EXIST_INTERVAL' - }); - } - if (req.body.id) { - delete req.body.id; - } - Interval - .find({ - where: { - id: req.params.id - } - }) - .then(function(interval) { - if (!interval) { - return res.sendStatus(404); - } - var updated = _.merge(interval, req.body); - return sequelize.transaction(function(t) { - return updated.save({ - transaction: t - }) - .then(function(interval) { - VoiceExtension - .update({ - interval: interval.name - }, { - where: { - IntervalId: interval.id - } - }, { - transaction: t - }) - }) - }) - .then(function() { - return res.status(200).send(interval); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a interval from the DB. -exports.destroy = function(req, res) { - Interval - .findById(req.params.id) - .then(function(interval) { - if (!interval) { - return res.sendStatus(404); - } - interval.getVoiceExtensions({ - where: { - isApp: true - } - }) - .then(function(bindExtensions) { - console.log(bindExtensions.length); - if (bindExtensions.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_INTERVAL_ROUTE_ASSOCIATED' - }); - } - interval.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes multiple intervals from the DB. -exports.bulkDestroy = function(req, res) { - var associatedIntervals = false; - Interval - .findAll({ - where: { - id: req.query.id - }, - include: [{ - all: true - }] - }) - .then(function(intervals) { - if (!intervals) { - return res.sendStatus(404); - } - intervals.forEach(function(element) { - if (element.VoiceExtensions.length > 0) { - associatedIntervals = true; - } - }); - if (associatedIntervals) { - return res.status(500).send({ - message: 'MESSAGE_INTERVAL_ROUTE_ASSOCIATED' - }); - } - Interval - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xc571=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x67\x65\x74\x41\x6C\x6C","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x69\x6E\x74\x65\x72\x76\x61\x6C\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x49\x6E\x74\x65\x72\x76\x61\x6C\x49\x64","\x6C\x6F\x67","\x63\x72\x65\x61\x74\x65","\x46\x69\x6E\x64\x69\x6E\x67\x20\x61\x70\x70\x20\x72\x6F\x77\x2E\x2E\x2E\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x53\x55\x42\x49\x4E\x54\x45\x52\x56\x41\x4C","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x49\x4E\x54\x45\x52\x56\x41\x4C","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x49\x4E\x54\x45\x52\x56\x41\x4C\x5F\x52\x4F\x55\x54\x45\x5F\x41\x53\x53\x4F\x43\x49\x41\x54\x45\x44","\x67\x65\x74\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73"];_0xc571[0];var _=require(_0xc571[1]);var Interval=require(_0xc571[3])[_0xc571[2]];var VoiceExtension=require(_0xc571[3])[_0xc571[4]];var sequelize=require(_0xc571[3])[_0xc571[5]];var util=require(_0xc571[6]);exports[_0xc571[7]]=function(_0x4c03x6,_0x4c03x7){var _0x4c03x8=[_0xc571[8]];var _0x4c03x9=_0x4c03x6[_0xc571[10]][_0xc571[9]]?parseInt(_0x4c03x6[_0xc571[10]][_0xc571[9]],10):100;var _0x4c03xa=_0x4c03x6[_0xc571[10]][_0xc571[11]]?parseInt(_0x4c03x6[_0xc571[10]][_0xc571[11]],10):0;var _0x4c03xb={where:{IntervalId:null},limit:_0x4c03x9,offset:_0x4c03xa*_0x4c03x9};_[_0xc571[25]](_0x4c03x6[_0xc571[10]],function(_0x4c03xc,_0x4c03xd){switch(_0x4c03xd){case _0xc571[9]:;case _0xc571[11]:break ;;case _0xc571[14]:_0x4c03xb[_0xc571[12]]=util[_0xc571[17]](_0xc571[13],_0x4c03x6[_0xc571[10]][_0xc571[14]],_0x4c03x6[_0xc571[10]][_0xc571[15]]||_0xc571[16])||null;break ;;case _0xc571[15]:break ;;case _0xc571[23]:_0x4c03xb[_0xc571[19]][_0xc571[18]]=[];_0x4c03x8[_0xc571[22]](function(_0x4c03xe){var _0x4c03xf={};_0x4c03xf[_0x4c03xe]={$like:_0xc571[20]+_0x4c03xc+_0xc571[20]};_0x4c03xb[_0xc571[19]][_0xc571[18]][_0xc571[21]](_0x4c03xf);});break ;;default:_0x4c03xb[_0xc571[19]][_0x4c03xd]={$like:{}};_0x4c03xb[_0xc571[19]][_0x4c03xd][_0xc571[24]]=_0xc571[20]+_0x4c03xc+_0xc571[20];;}});Interval[_0xc571[30]](_0x4c03xb)[_0xc571[29]](function(_0x4c03x11){return _0x4c03x7[_0xc571[28]](200)[_0xc571[27]](_0x4c03x11)})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});};exports[_0xc571[31]]=function(_0x4c03x6,_0x4c03x7){Interval[_0xc571[32]]()[_0xc571[29]](function(_0x4c03x11){return _0x4c03x7[_0xc571[28]](200)[_0xc571[27]](_0x4c03x11)})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)})};exports[_0xc571[33]]=function(_0x4c03x6,_0x4c03x7){Interval[_0xc571[37]](_0x4c03x6[_0xc571[36]][_0xc571[35]],{include:[{all:true}]})[_0xc571[29]](function(_0x4c03x12){if(!_0x4c03x12){return _0x4c03x7[_0xc571[34]](404)};return _0x4c03x7[_0xc571[27]](_0x4c03x12);})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)})};exports[_0xc571[38]]=function(_0x4c03x6,_0x4c03x7){var _0x4c03x13={name:_0x4c03x6[_0xc571[39]][_0xc571[8]],IntervalId:_0x4c03x6[_0xc571[39]][_0xc571[40]]?_0x4c03x6[_0xc571[39]][_0xc571[40]]:null};if(_0x4c03x6[_0xc571[39]][_0xc571[35]]){_0x4c03x13[_0xc571[35]]={$ne:_0x4c03x6[_0xc571[39]][_0xc571[35]]}};console[_0xc571[41]](_0x4c03x6[_0xc571[39]]);Interval[_0xc571[32]]({where:_0x4c03x13})[_0xc571[29]](function(_0x4c03x11){if(!_0x4c03x11){return _0x4c03x7[_0xc571[34]](404)};return _0x4c03x7[_0xc571[27]](_0x4c03x11);})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});};exports[_0xc571[42]]=function(_0x4c03x6,_0x4c03x7){Interval[_0xc571[32]]({where:{name:_0x4c03x6[_0xc571[39]][_0xc571[8]],IntervalId:_0x4c03x6[_0xc571[39]][_0xc571[40]]?_0x4c03x6[_0xc571[39]][_0xc571[40]]:null}})[_0xc571[29]](function(_0x4c03x14){console[_0xc571[41]](_0x4c03x14);console[_0xc571[41]](_0xc571[43]);if(!_0x4c03x14){return _0x4c03x7[_0xc571[34]](404)};if(_0x4c03x14[_0xc571[44]]>0){return _0x4c03x7[_0xc571[28]](500)[_0xc571[27]]({message:_0x4c03x6[_0xc571[39]][_0xc571[40]]?_0xc571[45]:_0xc571[46]})};Interval[_0xc571[42]](_0x4c03x6[_0xc571[39]])[_0xc571[29]](function(_0x4c03x12){return _0x4c03x7[_0xc571[28]](201)[_0xc571[27]](_0x4c03x12)})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)})};exports[_0xc571[47]]=function(_0x4c03x6,_0x4c03x7){Interval[_0xc571[32]]({where:{name:_0x4c03x6[_0xc571[39]][_0xc571[8]],IntervalId:_0x4c03x6[_0xc571[39]][_0xc571[40]]?_0x4c03x6[_0xc571[39]][_0xc571[40]]:null,id:{$ne:_0x4c03x6[_0xc571[39]][_0xc571[35]]}}})[_0xc571[29]](function(_0x4c03x14){console[_0xc571[41]](_0x4c03x14);console[_0xc571[41]](_0xc571[43]);if(!_0x4c03x14){return _0x4c03x7[_0xc571[34]](404)};if(_0x4c03x14[_0xc571[44]]>0){return _0x4c03x7[_0xc571[28]](500)[_0xc571[27]]({message:_0x4c03x6[_0xc571[39]][_0xc571[40]]?_0xc571[45]:_0xc571[46]})};if(_0x4c03x6[_0xc571[39]][_0xc571[35]]){delete _0x4c03x6[_0xc571[39]][_0xc571[35]]};Interval[_0xc571[51]]({where:{id:_0x4c03x6[_0xc571[36]][_0xc571[35]]}})[_0xc571[29]](function(_0x4c03x12){if(!_0x4c03x12){return _0x4c03x7[_0xc571[34]](404)};var _0x4c03x15=_[_0xc571[48]](_0x4c03x12,_0x4c03x6[_0xc571[39]]);return sequelize[_0xc571[50]](function(_0x4c03x16){return _0x4c03x15[_0xc571[49]]({transaction:_0x4c03x16})[_0xc571[29]](function(_0x4c03x12){VoiceExtension[_0xc571[47]]({interval:_0x4c03x12[_0xc571[8]]},{where:{IntervalId:_0x4c03x12[_0xc571[35]]}},{transaction:_0x4c03x16})})})[_0xc571[29]](function(){return _0x4c03x7[_0xc571[28]](200)[_0xc571[27]](_0x4c03x12)})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)})};exports[_0xc571[52]]=function(_0x4c03x6,_0x4c03x7){Interval[_0xc571[37]](_0x4c03x6[_0xc571[36]][_0xc571[35]])[_0xc571[29]](function(_0x4c03x12){if(!_0x4c03x12){return _0x4c03x7[_0xc571[34]](404)};_0x4c03x12[_0xc571[54]]({where:{isApp:true}})[_0xc571[29]](function(_0x4c03x17){console[_0xc571[41]](_0x4c03x17[_0xc571[44]]);if(_0x4c03x17[_0xc571[44]]>0){return _0x4c03x7[_0xc571[28]](500)[_0xc571[27]]({message:_0xc571[53]})};_0x4c03x12[_0xc571[52]]()[_0xc571[29]](function(){return _0x4c03x7[_0xc571[34]](204)})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)})};exports[_0xc571[55]]=function(_0x4c03x6,_0x4c03x7){var _0x4c03x18=false;Interval[_0xc571[32]]({where:{id:_0x4c03x6[_0xc571[10]][_0xc571[35]]},include:[{all:true}]})[_0xc571[29]](function(_0x4c03x11){if(!_0x4c03x11){return _0x4c03x7[_0xc571[34]](404)};_0x4c03x11[_0xc571[22]](function(_0x4c03x19){if(_0x4c03x19[_0xc571[56]][_0xc571[44]]>0){_0x4c03x18=true}});if(_0x4c03x18){return _0x4c03x7[_0xc571[28]](500)[_0xc571[27]]({message:_0xc571[53]})};Interval[_0xc571[52]]({where:{id:_0x4c03x6[_0xc571[10]][_0xc571[35]]},individualHooks:true})[_0xc571[29]](function(){return _0x4c03x7[_0xc571[34]](204)})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});})[_0xc571[26]](function(_0x4c03x10){return handleError(_0x4c03x7,_0x4c03x10)});};function handleError(_0x4c03x7,_0x4c03x10){return _0x4c03x7[_0xc571[28]](500)[_0xc571[27]](_0x4c03x10)} \ No newline at end of file diff --git a/server/api/interval/interval.socket.js b/server/api/interval/interval.socket.js index d8aee27..7d9acb8 100644 --- a/server/api/interval/interval.socket.js +++ b/server/api/interval/interval.socket.js @@ -1,31 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Interval = require('../../models').Interval; - -exports.register = function(socket) { - Interval.afterCreate(function(doc) { - onSave(socket, doc); - }); - Interval.afterDestroy(function(doc) { - onRemove(socket, doc); - }); - Interval.afterUpdate(function(doc) { - onUpdate(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('interval:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('interval:remove', doc); -} - -function onUpdate(socket, doc, cb) { - socket.emit('interval:update', doc); -} +var _0x4f41=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x69\x6E\x74\x65\x72\x76\x61\x6C\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x69\x6E\x74\x65\x72\x76\x61\x6C\x3A\x72\x65\x6D\x6F\x76\x65","\x69\x6E\x74\x65\x72\x76\x61\x6C\x3A\x75\x70\x64\x61\x74\x65"];_0x4f41[0];var Interval=require(_0x4f41[2])[_0x4f41[1]];exports[_0x4f41[3]]=function(_0x1854x2){Interval[_0x4f41[4]](function(_0x1854x3){onSave(_0x1854x2,_0x1854x3)});Interval[_0x4f41[5]](function(_0x1854x3){onRemove(_0x1854x2,_0x1854x3)});Interval[_0x4f41[6]](function(_0x1854x3){onUpdate(_0x1854x2,_0x1854x3)});};function onSave(_0x1854x2,_0x1854x3,_0x1854x5){_0x1854x2[_0x4f41[8]](_0x4f41[7],_0x1854x3)}function onRemove(_0x1854x2,_0x1854x3,_0x1854x5){_0x1854x2[_0x4f41[8]](_0x4f41[9],_0x1854x3)}function onUpdate(_0x1854x2,_0x1854x3,_0x1854x5){_0x1854x2[_0x4f41[8]](_0x4f41[10],_0x1854x3)} \ No newline at end of file diff --git a/server/api/interval/interval.spec.js b/server/api/interval/interval.spec.js index 280cb64..dfd73ac 100644 --- a/server/api/interval/interval.spec.js +++ b/server/api/interval/interval.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/intervals', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/intervals') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x2e89=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x72\x76\x61\x6C\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x72\x76\x61\x6C\x73","\x67\x65\x74"];_0x2e89[0];var should=require(_0x2e89[1]);var app=require(_0x2e89[2]);var request=require(_0x2e89[3]);describe(_0x2e89[4],function(){it(_0x2e89[5],function(_0x1621x4){request(app)[_0x2e89[13]](_0x2e89[12])[_0x2e89[11]](200)[_0x2e89[11]](_0x2e89[10],/json/)[_0x2e89[9]](function(_0x1621x5,_0x1621x6){if(_0x1621x5){return _0x1621x4(_0x1621x5)};_0x1621x6[_0x2e89[8]][_0x2e89[1]][_0x2e89[7]][_0x2e89[6]](Array);_0x1621x4();})})}); \ No newline at end of file diff --git a/server/api/mail_account/index.js b/server/api/mail_account/index.js index 344873c..8efeee2 100644 --- a/server/api/mail_account/index.js +++ b/server/api/mail_account/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_account.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -// router.get('/:id/applications', controller.getApplications); -router.post('/', controller.create); -router.post('/:id/applications', controller.sortApplications); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/', controller.bulkDestroy); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x5492=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x3A\x69\x64\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x73\x6F\x72\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x5492[0];var express=require(_0x5492[1]);var controller=require(_0x5492[2]);var router=express.Router();router[_0x5492[5]](_0x5492[3],controller[_0x5492[4]]);router[_0x5492[5]](_0x5492[6],controller[_0x5492[7]]);router[_0x5492[9]](_0x5492[3],controller[_0x5492[8]]);router[_0x5492[9]](_0x5492[10],controller[_0x5492[11]]);router[_0x5492[13]](_0x5492[6],controller[_0x5492[12]]);router[_0x5492[14]](_0x5492[6],controller[_0x5492[12]]);router[_0x5492[16]](_0x5492[3],controller[_0x5492[15]]);router[_0x5492[16]](_0x5492[6],controller[_0x5492[17]]);module[_0x5492[18]]=router; \ No newline at end of file diff --git a/server/api/mail_account/mail_account.controller.js b/server/api/mail_account/mail_account.controller.js index 32461ae..b7e8de1 100644 --- a/server/api/mail_account/mail_account.controller.js +++ b/server/api/mail_account/mail_account.controller.js @@ -1,291 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var async = require('async'); - -// IMAP MODULES -// var Imap = require("mail-listener2"); -// SMTP MODULES -// var nodemailer = require('nodemailer'); -// var smtpTransport = require('nodemailer-smtp-transport'); - -var sequelize = require('../../models').sequelize; -var MailAccount = require('../../models').MailAccount; -var MailApplication = require('../../models').MailApplication; -var MailServerIn = require('../../models').MailServerIn; -var MailServerOut = require('../../models').MailServerOut; - -// Get list of mailAccounts -exports.index = function(req, res) { - - var attributes = ['description', 'name', 'address']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page, - include: [{ - all: true - }] - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - MailAccount - .findAndCountAll(query) - .then(function(result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single mailAccount -exports.show = function(req, res, next) { - MailAccount - .findById(req.params.id, { - include: [{ - all: true - }] - }) - .then(function(mailAccount) { - if (!mailAccount) { - return res.sendStatus(404); - } - return res.send(mailAccount); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Creates a new mailAccount in the DB. -exports.create = function(req, res, next) { - - return sequelize.transaction(function(t) { - - // chain all your queries here. make sure you return them. - return MailAccount - .create({ - name: req.body.name, - address: req.body.address, - description: req.body.description - }, { - transaction: t - }).then(function(mailAccount) { - // MAIL ACCOUNT ID SETUP - req.body.incoming.MailAccountId = mailAccount.id; - return MailServerIn - .create(req.body.incoming, { - transaction: t - }) - .then(function(mailServerIn) { - // MAIL ACCOUNT ID SETUP - req.body.outgoing.MailAccountId = mailAccount.id; - return MailServerOut - .create(req.body.outgoing, { - transaction: t - }) - }); - }); - }).then(function(result) { - return res.status(201).send(result); - }).catch(function(err) { - return next(err); - }); -}; - -// Updates an existing mailAccount in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - MailAccount - .findById(req.params.id) - .then(function(mailAccount) { - if (!mailAccount) { - return res.sendStatus(404); - } - var updated = _.merge(mailAccount, req.body); - updated - .save() - .then(function() { - return res.status(200).send(mailAccount); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Sort Mail Applications -exports.sortApplications = function(req, res, next) { - - MailApplication - .findAll({ - where: { - id: req.body.applications - } - }) - .then(function(mailApplications) { - var tmpMailApplications = mailApplications; - - async.waterfall([ - function(callback) { - MailApplication - .destroy({ - where: { - id: req.body.applications - } - }).then(function() { - console.log('destroy'); - callback(); - }) - .catch(function(err) { - callback(err); - }); - }, - function(callback) { - // arg1 now equals 'one' and arg2 now equals 'two' - var sortedApplications = []; - for (var i = 0; i < req.body.applications.length; i++) { - var tmpMailApplication = _.find(tmpMailApplications, { - 'id': req.body.applications[i] - }); - if (tmpMailApplication) { - tmpMailApplication.priority = i + 1; - sortedApplications.push(tmpMailApplication.dataValues); - } - } - - MailApplication - .bulkCreate(sortedApplications) - .then(function() { - console.log('bulkCreate'); - callback(); - }) - .catch(function(err) { - callback(err); - }); - }, - function(callback) { - // arg1 now equals 'three' - MailApplication - .findAll({ - where: { - id: req.body.applications - }, - order: 'priority', - include: [{ - all: true - }] - }) - .then(function(mailApplications) { - console.log(mailApplications); - callback(null, mailApplications); - }) - .catch(function(err) { - callback(err); - }); - } - ], function(err, result) { - // result now equals 'done' - if (err) { - return handleError(res, err); - } else { - return res.status(201).send(result); - } - }); - - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a mailAccount from the DB. -exports.destroy = function(req, res, next) { - MailAccount - .findById(req.params.id) - .then(function(mailAccount) { - if (!mailAccount) { - return res.sendStatus(404); - } - mailAccount.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return next(err); - }); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function(req, res) { - MailAccount - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x6348=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x61\x73\x79\x6E\x63","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x61\x64\x64\x72\x65\x73\x73","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x69\x6E\x63\x6F\x6D\x69\x6E\x67","\x62\x6F\x64\x79","\x6F\x75\x74\x67\x6F\x69\x6E\x67","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x73\x6F\x72\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x64\x65\x73\x74\x72\x6F\x79","\x6C\x6F\x67","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x6C\x65\x6E\x67\x74\x68","\x66\x69\x6E\x64","\x70\x72\x69\x6F\x72\x69\x74\x79","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x77\x61\x74\x65\x72\x66\x61\x6C\x6C","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x6348[0];var _=require(_0x6348[1]);var util=require(_0x6348[2]);var async=require(_0x6348[3]);var sequelize=require(_0x6348[5])[_0x6348[4]];var MailAccount=require(_0x6348[5])[_0x6348[6]];var MailApplication=require(_0x6348[5])[_0x6348[7]];var MailServerIn=require(_0x6348[5])[_0x6348[8]];var MailServerOut=require(_0x6348[5])[_0x6348[9]];exports[_0x6348[10]]=function(_0x6800x9,_0x6800xa){var _0x6800xb=[_0x6348[11],_0x6348[12],_0x6348[13]];var _0x6800xc=_0x6800x9[_0x6348[15]][_0x6348[14]]?parseInt(_0x6800x9[_0x6348[15]][_0x6348[14]],10):100;var _0x6800xd=_0x6800x9[_0x6348[15]][_0x6348[16]]?parseInt(_0x6800x9[_0x6348[15]][_0x6348[16]],10):0;var _0x6800xe={where:{},limit:_0x6800xc,offset:_0x6800xd*_0x6800xc,include:[{all:true}]};_[_0x6348[30]](_0x6800x9[_0x6348[15]],function(_0x6800xf,_0x6800x10){switch(_0x6800x10){case _0x6348[14]:;case _0x6348[16]:break ;;case _0x6348[19]:_0x6800xe[_0x6348[17]]=util[_0x6348[22]](_0x6348[18],_0x6800x9[_0x6348[15]][_0x6348[19]],_0x6800x9[_0x6348[15]][_0x6348[20]]||_0x6348[21])||null;break ;;case _0x6348[20]:break ;;case _0x6348[28]:_0x6800xe[_0x6348[24]][_0x6348[23]]=[];_0x6800xb[_0x6348[27]](function(_0x6800x11){var _0x6800x12={};_0x6800x12[_0x6800x11]={$like:_0x6348[25]+_0x6800xf+_0x6348[25]};_0x6800xe[_0x6348[24]][_0x6348[23]][_0x6348[26]](_0x6800x12);});break ;;default:_0x6800xe[_0x6348[24]][_0x6800x10]={$like:{}};_0x6800xe[_0x6348[24]][_0x6800x10][_0x6348[29]]=_0x6348[25]+_0x6800xf+_0x6348[25];;}});MailAccount[_0x6348[44]](_0x6800xe)[_0x6348[43]](function(_0x6800x14){var _0x6800x15=Math[_0x6348[33]](_0x6800x14[_0x6348[32]]/_0x6800xc);var _0x6800x16=_0x6800x15>(_0x6800xe[_0x6348[34]]+1)?util[_0x6348[22]](_0x6348[35],_0x6800x9[_0x6348[36]],_0x6800x9[_0x6348[38]][_0x6348[37]],_0x6800x9[_0x6348[39]],_0x6800xd+1):null;var _0x6800x17=_0x6800xd>0?util[_0x6348[22]](_0x6348[35],_0x6800x9[_0x6348[36]],_0x6800x9[_0x6348[38]][_0x6348[37]],_0x6800x9[_0x6348[39]],_0x6800xd-1):null;_0x6800xa[_0x6348[42]](200)[_0x6348[41]]({count:_0x6800x14[_0x6348[32]],rows:_0x6800x14[_0x6348[40]],next_page:_0x6800x16,previous_page:_0x6800x17,total_pages:_0x6800x15});})[_0x6348[31]](function(_0x6800x13){return handleError(_0x6800xa,_0x6800x13)});};exports[_0x6348[45]]=function(_0x6800x9,_0x6800xa,_0x6800x18){MailAccount[_0x6348[49]](_0x6800x9[_0x6348[48]][_0x6348[47]],{include:[{all:true}]})[_0x6348[43]](function(_0x6800x19){if(!_0x6800x19){return _0x6800xa[_0x6348[46]](404)};return _0x6800xa[_0x6348[41]](_0x6800x19);})[_0x6348[31]](function(_0x6800x13){return _0x6800x18(_0x6800x13)})};exports[_0x6348[50]]=function(_0x6800x9,_0x6800xa,_0x6800x18){return sequelize[_0x6348[55]](function(_0x6800x1a){return MailAccount[_0x6348[50]]({name:_0x6800x9[_0x6348[53]][_0x6348[12]],address:_0x6800x9[_0x6348[53]][_0x6348[13]],description:_0x6800x9[_0x6348[53]][_0x6348[11]]},{transaction:_0x6800x1a})[_0x6348[43]](function(_0x6800x19){_0x6800x9[_0x6348[53]][_0x6348[52]][_0x6348[51]]=_0x6800x19[_0x6348[47]];return MailServerIn[_0x6348[50]](_0x6800x9[_0x6348[53]][_0x6348[52]],{transaction:_0x6800x1a})[_0x6348[43]](function(_0x6800x1b){_0x6800x9[_0x6348[53]][_0x6348[54]][_0x6348[51]]=_0x6800x19[_0x6348[47]];return MailServerOut[_0x6348[50]](_0x6800x9[_0x6348[53]][_0x6348[54]],{transaction:_0x6800x1a});});})})[_0x6348[43]](function(_0x6800x14){return _0x6800xa[_0x6348[42]](201)[_0x6348[41]](_0x6800x14)})[_0x6348[31]](function(_0x6800x13){return _0x6800x18(_0x6800x13)})};exports[_0x6348[56]]=function(_0x6800x9,_0x6800xa){if(_0x6800x9[_0x6348[53]][_0x6348[47]]){delete _0x6800x9[_0x6348[53]][_0x6348[47]]};MailAccount[_0x6348[49]](_0x6800x9[_0x6348[48]][_0x6348[47]])[_0x6348[43]](function(_0x6800x19){if(!_0x6800x19){return _0x6800xa[_0x6348[46]](404)};var _0x6800x1c=_[_0x6348[57]](_0x6800x19,_0x6800x9[_0x6348[53]]);_0x6800x1c[_0x6348[58]]()[_0x6348[43]](function(){return _0x6800xa[_0x6348[42]](200)[_0x6348[41]](_0x6800x19)})[_0x6348[31]](function(_0x6800x13){return handleError(_0x6800xa,_0x6800x13)});})[_0x6348[31]](function(_0x6800x13){return handleError(_0x6800xa,_0x6800x13)});};exports[_0x6348[59]]=function(_0x6800x9,_0x6800xa,_0x6800x18){MailApplication[_0x6348[68]]({where:{id:_0x6800x9[_0x6348[53]][_0x6348[62]]}})[_0x6348[43]](function(_0x6800x1d){var _0x6800x1e=_0x6800x1d;async[_0x6348[69]]([function(_0x6800x1f){MailApplication[_0x6348[60]]({where:{id:_0x6800x9[_0x6348[53]][_0x6348[62]]}})[_0x6348[43]](function(){console[_0x6348[61]](_0x6348[60]);_0x6800x1f();})[_0x6348[31]](function(_0x6800x13){_0x6800x1f(_0x6800x13)})},function(_0x6800x1f){var _0x6800x20=[];for(var _0x6800x21=0;_0x6800x21<_0x6800x9[_0x6348[53]][_0x6348[62]][_0x6348[63]];_0x6800x21++){var _0x6800x22=_[_0x6348[64]](_0x6800x1e,{"\x69\x64":_0x6800x9[_0x6348[53]][_0x6348[62]][_0x6800x21]});if(_0x6800x22){_0x6800x22[_0x6348[65]]=_0x6800x21+1;_0x6800x20[_0x6348[26]](_0x6800x22[_0x6348[66]]);};};MailApplication[_0x6348[67]](_0x6800x20)[_0x6348[43]](function(){console[_0x6348[61]](_0x6348[67]);_0x6800x1f();})[_0x6348[31]](function(_0x6800x13){_0x6800x1f(_0x6800x13)});},function(_0x6800x1f){MailApplication[_0x6348[68]]({where:{id:_0x6800x9[_0x6348[53]][_0x6348[62]]},order:_0x6348[65],include:[{all:true}]})[_0x6348[43]](function(_0x6800x1d){console[_0x6348[61]](_0x6800x1d);_0x6800x1f(null,_0x6800x1d);})[_0x6348[31]](function(_0x6800x13){_0x6800x1f(_0x6800x13)})}],function(_0x6800x13,_0x6800x14){if(_0x6800x13){return handleError(_0x6800xa,_0x6800x13)}else {return _0x6800xa[_0x6348[42]](201)[_0x6348[41]](_0x6800x14)}});})[_0x6348[31]](function(_0x6800x13){return handleError(_0x6800xa,_0x6800x13)})};exports[_0x6348[60]]=function(_0x6800x9,_0x6800xa,_0x6800x18){MailAccount[_0x6348[49]](_0x6800x9[_0x6348[48]][_0x6348[47]])[_0x6348[43]](function(_0x6800x19){if(!_0x6800x19){return _0x6800xa[_0x6348[46]](404)};_0x6800x19[_0x6348[60]]()[_0x6348[43]](function(){return _0x6800xa[_0x6348[46]](204)})[_0x6348[31]](function(_0x6800x13){return _0x6800x18(_0x6800x13)});})[_0x6348[31]](function(_0x6800x13){return _0x6800x18(_0x6800x13)})};exports[_0x6348[70]]=function(_0x6800x9,_0x6800xa){MailAccount[_0x6348[60]]({where:{id:_0x6800x9[_0x6348[15]][_0x6348[47]]},individualHooks:true})[_0x6348[43]](function(){return _0x6800xa[_0x6348[46]](204)})[_0x6348[31]](function(_0x6800x13){return handleError(_0x6800xa,_0x6800x13)})};function handleError(_0x6800xa,_0x6800x13){return _0x6800xa[_0x6348[42]](500)[_0x6348[41]](_0x6800x13)} \ No newline at end of file diff --git a/server/api/mail_account/mail_account.socket.js b/server/api/mail_account/mail_account.socket.js index 5b51c79..6181822 100644 --- a/server/api/mail_account/mail_account.socket.js +++ b/server/api/mail_account/mail_account.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var MailAccount = require('../../models').MailAccount; - -exports.register = function(socket) { - MailAccount.afterCreate(function(doc) { - onSave(socket, doc); - }); - MailAccount.afterUpdate(function(doc) { - onSave(socket, doc); - }); - MailAccount.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_account:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_account:remove', doc); -} +var _0x8d37=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x8d37[0];var MailAccount=require(_0x8d37[2])[_0x8d37[1]];exports[_0x8d37[3]]=function(_0x6075x2){MailAccount[_0x8d37[4]](function(_0x6075x3){onSave(_0x6075x2,_0x6075x3)});MailAccount[_0x8d37[5]](function(_0x6075x3){onSave(_0x6075x2,_0x6075x3)});MailAccount[_0x8d37[6]](function(_0x6075x3){onRemove(_0x6075x2,_0x6075x3)});};function onSave(_0x6075x2,_0x6075x3,_0x6075x5){_0x6075x2[_0x8d37[8]](_0x8d37[7],_0x6075x3)}function onRemove(_0x6075x2,_0x6075x3,_0x6075x5){_0x6075x2[_0x8d37[8]](_0x8d37[9],_0x6075x3)} \ No newline at end of file diff --git a/server/api/mail_account/mail_account.spec.js b/server/api/mail_account/mail_account.spec.js index 80fd2bd..b51fac4 100644 --- a/server/api/mail_account/mail_account.spec.js +++ b/server/api/mail_account/mail_account.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/mail/accounts', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/mail/accounts') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x930c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x67\x65\x74"];_0x930c[0];var should=require(_0x930c[1]);var app=require(_0x930c[2]);var request=require(_0x930c[3]);describe(_0x930c[4],function(){it(_0x930c[5],function(_0x751fx4){request(app)[_0x930c[13]](_0x930c[12])[_0x930c[11]](200)[_0x930c[11]](_0x930c[10],/json/)[_0x930c[9]](function(_0x751fx5,_0x751fx6){if(_0x751fx5){return _0x751fx4(_0x751fx5)};_0x751fx6[_0x930c[8]][_0x930c[1]][_0x930c[7]][_0x930c[6]](Array);_0x751fx4();})})}); \ No newline at end of file diff --git a/server/api/mail_application/index.js b/server/api/mail_application/index.js index 3c132bb..850c40b 100644 --- a/server/api/mail_application/index.js +++ b/server/api/mail_application/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_application.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x49fa=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x49fa[0];var express=require(_0x49fa[1]);var controller=require(_0x49fa[2]);var router=express.Router();router[_0x49fa[5]](_0x49fa[3],controller[_0x49fa[4]]);router[_0x49fa[5]](_0x49fa[6],controller[_0x49fa[7]]);router[_0x49fa[9]](_0x49fa[3],controller[_0x49fa[8]]);router[_0x49fa[11]](_0x49fa[6],controller[_0x49fa[10]]);router[_0x49fa[12]](_0x49fa[6],controller[_0x49fa[10]]);router[_0x49fa[14]](_0x49fa[6],controller[_0x49fa[13]]);module[_0x49fa[15]]=router; \ No newline at end of file diff --git a/server/api/mail_application/mail_application.controller.js b/server/api/mail_application/mail_application.controller.js index 260557e..a4e8107 100644 --- a/server/api/mail_application/mail_application.controller.js +++ b/server/api/mail_application/mail_application.controller.js @@ -1,111 +1 @@ -'use strict'; -var _ = require('lodash'); -var MailApplication = require('../../models').MailApplication; -// Get list of mailApplications -exports.index = function(req, res, next) { - MailApplication - .findAll({ - where: req.query, - order: 'priority', - include: [{ - all: true - }] - }) - .then(function(mailApplications) { - return res.status(200).send(mailApplications); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Get a single mailApplication -exports.show = function(req, res, next) { - MailApplication - .findById(req.params.id, { - include: [{ - all: true - }] - }) - .then(function(mailApplication) { - if (!mailApplication) { - return res.sendStatus(404); - } - return res.send(mailApplication); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Creates a new mailApplication in the DB. -exports.create = function(req, res, next) { - MailApplication - .max('priority', { - where: { - MailAccountId: req.body.MailAccountId - } - }).then(function(max) { - // SET PRIORITY - req.body.priority = max ? ++max : 1; - MailApplication - .create(req.body) - .then(function(mailApplication) { - return res.status(201).send(mailApplication); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Updates an existing mailApplication in the DB. -exports.update = function(req, res, next) { - if (req.body.id) { - delete req.body.id; - } - MailApplication - .findById(req.params.id) - .then(function(mailApplication) { - if (!mailApplication) { - return res.sendStatus(404); - } - var updated = _.merge(mailApplication, req.body); - updated - .save() - .then(function() { - return res.status(200).send(mailApplication); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Deletes a mailApplication from the DB. -exports.destroy = function(req, res, next) { - MailApplication - .findById(req.params.id) - .then(function(mailApplication) { - if (!mailApplication) { - return res.sendStatus(404); - } - mailApplication - .destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x752b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x70\x72\x69\x6F\x72\x69\x74\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x6D\x61\x78","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x752b[0];var _=require(_0x752b[1]);var MailApplication=require(_0x752b[3])[_0x752b[2]];exports[_0x752b[4]]=function(_0xfa35x3,_0xfa35x4,_0xfa35x5){MailApplication[_0x752b[11]]({where:_0xfa35x3[_0x752b[9]],order:_0x752b[10],include:[{all:true}]})[_0x752b[8]](function(_0xfa35x7){return _0xfa35x4[_0x752b[7]](200)[_0x752b[6]](_0xfa35x7)})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)})};exports[_0x752b[12]]=function(_0xfa35x3,_0xfa35x4,_0xfa35x5){MailApplication[_0x752b[16]](_0xfa35x3[_0x752b[15]][_0x752b[14]],{include:[{all:true}]})[_0x752b[8]](function(_0xfa35x8){if(!_0xfa35x8){return _0xfa35x4[_0x752b[13]](404)};return _0xfa35x4[_0x752b[6]](_0xfa35x8);})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)})};exports[_0x752b[17]]=function(_0xfa35x3,_0xfa35x4,_0xfa35x5){MailApplication[_0x752b[20]](_0x752b[10],{where:{MailAccountId:_0xfa35x3[_0x752b[18]][_0x752b[19]]}})[_0x752b[8]](function(_0xfa35x9){_0xfa35x3[_0x752b[18]][_0x752b[10]]=_0xfa35x9?++_0xfa35x9:1;MailApplication[_0x752b[17]](_0xfa35x3[_0x752b[18]])[_0x752b[8]](function(_0xfa35x8){return _0xfa35x4[_0x752b[7]](201)[_0x752b[6]](_0xfa35x8)})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)});})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)})};exports[_0x752b[21]]=function(_0xfa35x3,_0xfa35x4,_0xfa35x5){if(_0xfa35x3[_0x752b[18]][_0x752b[14]]){delete _0xfa35x3[_0x752b[18]][_0x752b[14]]};MailApplication[_0x752b[16]](_0xfa35x3[_0x752b[15]][_0x752b[14]])[_0x752b[8]](function(_0xfa35x8){if(!_0xfa35x8){return _0xfa35x4[_0x752b[13]](404)};var _0xfa35xa=_[_0x752b[22]](_0xfa35x8,_0xfa35x3[_0x752b[18]]);_0xfa35xa[_0x752b[23]]()[_0x752b[8]](function(){return _0xfa35x4[_0x752b[7]](200)[_0x752b[6]](_0xfa35x8)})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)});})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)});};exports[_0x752b[24]]=function(_0xfa35x3,_0xfa35x4,_0xfa35x5){MailApplication[_0x752b[16]](_0xfa35x3[_0x752b[15]][_0x752b[14]])[_0x752b[8]](function(_0xfa35x8){if(!_0xfa35x8){return _0xfa35x4[_0x752b[13]](404)};_0xfa35x8[_0x752b[24]]()[_0x752b[8]](function(){return _0xfa35x4[_0x752b[13]](204)})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)});})[_0x752b[5]](function(_0xfa35x6){return handleError(_0xfa35x4,_0xfa35x6)})};function handleError(_0xfa35x4,_0xfa35x6){return _0xfa35x4[_0x752b[7]](500)[_0x752b[6]](_0xfa35x6)} \ No newline at end of file diff --git a/server/api/mail_application/mail_application.socket.js b/server/api/mail_application/mail_application.socket.js index ead0c90..b46fe54 100644 --- a/server/api/mail_application/mail_application.socket.js +++ b/server/api/mail_application/mail_application.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var mailApplication = require('../../models').MailApplication; - -exports.register = function(socket) { - mailApplication.afterCreate(function(doc) { - onSave(socket, doc); - }); - mailApplication.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_application:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_application:remove', doc); -} +var _0xa932=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xa932[0];var mailApplication=require(_0xa932[2])[_0xa932[1]];exports[_0xa932[3]]=function(_0xbea2x2){mailApplication[_0xa932[4]](function(_0xbea2x3){onSave(_0xbea2x2,_0xbea2x3)});mailApplication[_0xa932[5]](function(_0xbea2x3){onRemove(_0xbea2x2,_0xbea2x3)});};function onSave(_0xbea2x2,_0xbea2x3,_0xbea2x5){_0xbea2x2[_0xa932[7]](_0xa932[6],_0xbea2x3)}function onRemove(_0xbea2x2,_0xbea2x3,_0xbea2x5){_0xbea2x2[_0xa932[7]](_0xa932[8],_0xbea2x3)} \ No newline at end of file diff --git a/server/api/mail_application/mail_application.spec.js b/server/api/mail_application/mail_application.spec.js index 023b99b..ca78e82 100644 --- a/server/api/mail_application/mail_application.spec.js +++ b/server/api/mail_application/mail_application.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/mail/applications', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/mail/applications') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xac51=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0xac51[0];var should=require(_0xac51[1]);var app=require(_0xac51[2]);var request=require(_0xac51[3]);describe(_0xac51[4],function(){it(_0xac51[5],function(_0x68a2x4){request(app)[_0xac51[13]](_0xac51[12])[_0xac51[11]](200)[_0xac51[11]](_0xac51[10],/json/)[_0xac51[9]](function(_0x68a2x5,_0x68a2x6){if(_0x68a2x5){return _0x68a2x4(_0x68a2x5)};_0x68a2x6[_0xac51[8]][_0xac51[1]][_0xac51[7]][_0xac51[6]](Array);_0x68a2x4();})})}); \ No newline at end of file diff --git a/server/api/mail_attachment/index.js b/server/api/mail_attachment/index.js index f154de4..3009f98 100644 --- a/server/api/mail_attachment/index.js +++ b/server/api/mail_attachment/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_attachment.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x56e7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x56e7[0];var express=require(_0x56e7[1]);var controller=require(_0x56e7[2]);var router=express.Router();router[_0x56e7[5]](_0x56e7[3],controller[_0x56e7[4]]);router[_0x56e7[5]](_0x56e7[6],controller[_0x56e7[7]]);router[_0x56e7[9]](_0x56e7[3],controller[_0x56e7[8]]);router[_0x56e7[11]](_0x56e7[6],controller[_0x56e7[10]]);router[_0x56e7[12]](_0x56e7[6],controller[_0x56e7[10]]);router[_0x56e7[14]](_0x56e7[6],controller[_0x56e7[13]]);module[_0x56e7[15]]=router; \ No newline at end of file diff --git a/server/api/mail_attachment/mail_attachment.controller.js b/server/api/mail_attachment/mail_attachment.controller.js index f962782..ecf52aa 100644 --- a/server/api/mail_attachment/mail_attachment.controller.js +++ b/server/api/mail_attachment/mail_attachment.controller.js @@ -1,87 +1 @@ -'use strict'; - -var _ = require('lodash'); -var fs = require('fs'); -var MailAttachment = require('../../models').MailAttachment; - -// Get list of mailAttachments -exports.index = function (req, res, next) { - MailAttachment - .findAll() - .then(function (mailAttachments) { - return res.status(200).send(mailAttachments); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Get a single mailAttachment -exports.show = function (req, res, next) { - MailAttachment - .findById(req.params.id) - .then(function (mailAttachment) { - res.download(mailAttachment.path, mailAttachment.fileName); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Creates a new mailAttachment in the DB. -exports.create = function (req, res, next) { - MailAttachment - .create(req.body) - .then(function (mailAttachment) { - return res.status(201).send(mailAttachment); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Updates an existing mailAttachment in the DB. -exports.update = function (req, res, next) { - if (req.body.id) { - delete req.body.id; - } - MailAttachment - .findById(req.params.id) - .then(function (mailAttachment) { - if (!mailAttachment) { - return res.sendStatus(404); - } - var updated = _.merge(mailAttachment, req.body); - updated.save() - .then(function () { - return res.status(200).send(mailAttachment); - }) - .catch(function (err) { - return next(err); - }); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Deletes a mailAttachment from the DB. -exports.destroy = function (req, res, next) { - MailAttachment - .findById(req.params.id) - .then(function (mailAttachment) { - if (!mailAttachment) { - return res.sendStatus(404); - } - mailAttachment.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return next(err); - }); - }) - .catch(function (err) { - return next(err); - }); -}; +var _0xbd91=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x66\x73","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x70\x61\x74\x68","\x66\x69\x6C\x65\x4E\x61\x6D\x65","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xbd91[0];var _=require(_0xbd91[1]);var fs=require(_0xbd91[2]);var MailAttachment=require(_0xbd91[4])[_0xbd91[3]];exports[_0xbd91[5]]=function(_0x569ax4,_0x569ax5,_0x569ax6){MailAttachment[_0xbd91[10]]()[_0xbd91[9]](function(_0x569ax8){return _0x569ax5[_0xbd91[8]](200)[_0xbd91[7]](_0x569ax8)})[_0xbd91[6]](function(_0x569ax7){return _0x569ax6(_0x569ax7)})};exports[_0xbd91[11]]=function(_0x569ax4,_0x569ax5,_0x569ax6){MailAttachment[_0xbd91[17]](_0x569ax4[_0xbd91[16]][_0xbd91[15]])[_0xbd91[9]](function(_0x569ax9){_0x569ax5[_0xbd91[14]](_0x569ax9[_0xbd91[12]],_0x569ax9[_0xbd91[13]])})[_0xbd91[6]](function(_0x569ax7){return _0x569ax6(_0x569ax7)})};exports[_0xbd91[18]]=function(_0x569ax4,_0x569ax5,_0x569ax6){MailAttachment[_0xbd91[18]](_0x569ax4[_0xbd91[19]])[_0xbd91[9]](function(_0x569ax9){return _0x569ax5[_0xbd91[8]](201)[_0xbd91[7]](_0x569ax9)})[_0xbd91[6]](function(_0x569ax7){return _0x569ax6(_0x569ax7)})};exports[_0xbd91[20]]=function(_0x569ax4,_0x569ax5,_0x569ax6){if(_0x569ax4[_0xbd91[19]][_0xbd91[15]]){delete _0x569ax4[_0xbd91[19]][_0xbd91[15]]};MailAttachment[_0xbd91[17]](_0x569ax4[_0xbd91[16]][_0xbd91[15]])[_0xbd91[9]](function(_0x569ax9){if(!_0x569ax9){return _0x569ax5[_0xbd91[21]](404)};var _0x569axa=_[_0xbd91[22]](_0x569ax9,_0x569ax4[_0xbd91[19]]);_0x569axa[_0xbd91[23]]()[_0xbd91[9]](function(){return _0x569ax5[_0xbd91[8]](200)[_0xbd91[7]](_0x569ax9)})[_0xbd91[6]](function(_0x569ax7){return _0x569ax6(_0x569ax7)});})[_0xbd91[6]](function(_0x569ax7){return _0x569ax6(_0x569ax7)});};exports[_0xbd91[24]]=function(_0x569ax4,_0x569ax5,_0x569ax6){MailAttachment[_0xbd91[17]](_0x569ax4[_0xbd91[16]][_0xbd91[15]])[_0xbd91[9]](function(_0x569ax9){if(!_0x569ax9){return _0x569ax5[_0xbd91[21]](404)};_0x569ax9[_0xbd91[24]]()[_0xbd91[9]](function(){return _0x569ax5[_0xbd91[21]](204)})[_0xbd91[6]](function(_0x569ax7){return _0x569ax6(_0x569ax7)});})[_0xbd91[6]](function(_0x569ax7){return _0x569ax6(_0x569ax7)})}; \ No newline at end of file diff --git a/server/api/mail_attachment/mail_attachment.socket.js b/server/api/mail_attachment/mail_attachment.socket.js index 65c9085..bddea3b 100644 --- a/server/api/mail_attachment/mail_attachment.socket.js +++ b/server/api/mail_attachment/mail_attachment.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var mail_attachment = require('../../models').MailAttachment; - -exports.register = function(socket) { - mail_attachment.afterCreate(function (doc) { - onSave(socket, doc); - }); - mail_attachment.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_attachment:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_attachment:remove', doc); -} +var _0xfa6c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xfa6c[0];var mail_attachment=require(_0xfa6c[2])[_0xfa6c[1]];exports[_0xfa6c[3]]=function(_0x5bf9x2){mail_attachment[_0xfa6c[4]](function(_0x5bf9x3){onSave(_0x5bf9x2,_0x5bf9x3)});mail_attachment[_0xfa6c[5]](function(_0x5bf9x3){onRemove(_0x5bf9x2,_0x5bf9x3)});};function onSave(_0x5bf9x2,_0x5bf9x3,_0x5bf9x5){_0x5bf9x2[_0xfa6c[7]](_0xfa6c[6],_0x5bf9x3)}function onRemove(_0x5bf9x2,_0x5bf9x3,_0x5bf9x5){_0x5bf9x2[_0xfa6c[7]](_0xfa6c[8],_0x5bf9x3)} \ No newline at end of file diff --git a/server/api/mail_attachment/mail_attachment.spec.js b/server/api/mail_attachment/mail_attachment.spec.js index 026a5dc..916901a 100644 --- a/server/api/mail_attachment/mail_attachment.spec.js +++ b/server/api/mail_attachment/mail_attachment.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/mail/attachments', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/mail/attachments') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xc050=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x67\x65\x74"];_0xc050[0];var should=require(_0xc050[1]);var app=require(_0xc050[2]);var request=require(_0xc050[3]);describe(_0xc050[4],function(){it(_0xc050[5],function(_0x9557x4){request(app)[_0xc050[13]](_0xc050[12])[_0xc050[11]](200)[_0xc050[11]](_0xc050[10],/json/)[_0xc050[9]](function(_0x9557x5,_0x9557x6){if(_0x9557x5){return _0x9557x4(_0x9557x5)};_0x9557x6[_0xc050[8]][_0xc050[1]][_0xc050[7]][_0xc050[6]](Array);_0x9557x4();})})}); \ No newline at end of file diff --git a/server/api/mail_business_automation/index.js b/server/api/mail_business_automation/index.js index d8a2dc4..6a8eab7 100644 --- a/server/api/mail_business_automation/index.js +++ b/server/api/mail_business_automation/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_business_automation.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/', controller.bulkDestroy); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x4709=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x4709[0];var express=require(_0x4709[1]);var controller=require(_0x4709[2]);var router=express.Router();router[_0x4709[5]](_0x4709[3],controller[_0x4709[4]]);router[_0x4709[5]](_0x4709[6],controller[_0x4709[7]]);router[_0x4709[9]](_0x4709[3],controller[_0x4709[8]]);router[_0x4709[11]](_0x4709[6],controller[_0x4709[10]]);router[_0x4709[12]](_0x4709[6],controller[_0x4709[10]]);router[_0x4709[14]](_0x4709[3],controller[_0x4709[13]]);router[_0x4709[14]](_0x4709[6],controller[_0x4709[15]]);module[_0x4709[16]]=router; \ No newline at end of file diff --git a/server/api/mail_business_automation/mail_business_automation.controller.js b/server/api/mail_business_automation/mail_business_automation.controller.js index 5c49502..7d8e320 100644 --- a/server/api/mail_business_automation/mail_business_automation.controller.js +++ b/server/api/mail_business_automation/mail_business_automation.controller.js @@ -1,218 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var MailBusinessAutomation = require('../../models').MailBusinessAutomation; -var BusinessCondition = require('../../models').BusinessCondition; -var BusinessAction = require('../../models').BusinessAction; -var sequelize = require('../../models').sequelize; - -// Get list of agents -exports.index = function(req, res, next) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - MailBusinessAutomation - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - mailAutomations: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; -// Get a single mailBusinessAutomation -exports.show = function(req, res) { - MailBusinessAutomation - .findById(req.params.id, { - include: [{ - all: true - }] - }) - .then(function(mailBusinessAutomation) { - if (!mailBusinessAutomation) { - return res.sendStatus(404); - } - return res.send(mailBusinessAutomation); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new mailBusinessAutomation in the DB. -exports.create = function(req, res, next) { - - return sequelize.transaction(function(t) { - return MailBusinessAutomation - .create(req.body, { - transaction: t - }) - .then(function(mailBusinessAutomation) { - var conditions = []; - if (req.body.or) { - req.body.or.forEach(function(elm) { - elm.MailBusinessAutomationId = mailBusinessAutomation.id; - }); - conditions = conditions.concat(req.body.or); - } - - if (req.body.and) { - req.body.and.forEach(function(elm) { - elm.MailBusinessAutomationId = mailBusinessAutomation.id; - }); - conditions = conditions.concat(req.body.and); - } - - return BusinessCondition - .bulkCreate(conditions, { - transaction: t - }) - .then(function(businessCondtions) { - if (req.body.actions) { - req.body.actions.forEach(function(elm) { - elm.MailBusinessAutomationId = mailBusinessAutomation.id; - }); - } - - return BusinessAction - .bulkCreate(req.body.actions, { - transaction: t - }); - }); - }) - }) - .then(function() { - // Transaction has been committed - // result is whatever the result of the promise chain returned to the transaction callback - return res.sendStatus(201); - }).catch(function(err) { - // Transaction has been rolled back - // err is whatever rejected the promise chain returned to the transaction callback - return next(err); - }); -}; - -// Updates an existing mailBusinessAutomation in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - MailBusinessAutomation - .find({ - where: { - id: req.params.id - } - }) - .then(function(mailBusinessAutomation) { - if (!mailBusinessAutomation) { - return res.sendStatus(404); - } - var updated = _.merge(mailBusinessAutomation, req.body); - updated.save() - .then(function() { - return res.status(200).send(mailBusinessAutomation); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a mailBusinessAutomation from the DB. -exports.destroy = function(req, res) { - MailBusinessAutomation - .findById(req.params.id) - .then(function(mailBusinessAutomation) { - if (!mailBusinessAutomation) { - return res.sendStatus(404); - } - mailBusinessAutomation - .destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function(req, res) { - MailBusinessAutomation - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x3e44=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x4D\x61\x69\x6C\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x63\x74\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x6F\x72","\x62\x6F\x64\x79","\x4D\x61\x69\x6C\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x49\x64","\x63\x6F\x6E\x63\x61\x74","\x61\x6E\x64","\x61\x63\x74\x69\x6F\x6E\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x3e44[0];var _=require(_0x3e44[1]);var util=require(_0x3e44[2]);var MailBusinessAutomation=require(_0x3e44[4])[_0x3e44[3]];var BusinessCondition=require(_0x3e44[4])[_0x3e44[5]];var BusinessAction=require(_0x3e44[4])[_0x3e44[6]];var sequelize=require(_0x3e44[4])[_0x3e44[7]];exports[_0x3e44[8]]=function(_0x7d32x7,_0x7d32x8,_0x7d32x9){var _0x7d32xa=[_0x3e44[9],_0x3e44[10]];var _0x7d32xb=_0x7d32x7[_0x3e44[12]][_0x3e44[11]]?parseInt(_0x7d32x7[_0x3e44[12]][_0x3e44[11]],10):100;var _0x7d32xc=_0x7d32x7[_0x3e44[12]][_0x3e44[13]]?parseInt(_0x7d32x7[_0x3e44[12]][_0x3e44[13]],10):0;var _0x7d32xd={where:{},limit:_0x7d32xb,offset:_0x7d32xc*_0x7d32xb};_[_0x3e44[27]](_0x7d32x7[_0x3e44[12]],function(_0x7d32xe,_0x7d32xf){switch(_0x7d32xf){case _0x3e44[11]:;case _0x3e44[13]:break ;;case _0x3e44[16]:_0x7d32xd[_0x3e44[14]]=util[_0x3e44[19]](_0x3e44[15],_0x7d32x7[_0x3e44[12]][_0x3e44[16]],_0x7d32x7[_0x3e44[12]][_0x3e44[17]]||_0x3e44[18])||null;break ;;case _0x3e44[17]:break ;;case _0x3e44[25]:_0x7d32xd[_0x3e44[21]][_0x3e44[20]]=[];_0x7d32xa[_0x3e44[24]](function(_0x7d32x10){var _0x7d32x11={};_0x7d32x11[_0x7d32x10]={$like:_0x3e44[22]+_0x7d32xe+_0x3e44[22]};_0x7d32xd[_0x3e44[21]][_0x3e44[20]][_0x3e44[23]](_0x7d32x11);});break ;;default:_0x7d32xd[_0x3e44[21]][_0x7d32xf]={$like:{}};_0x7d32xd[_0x3e44[21]][_0x7d32xf][_0x3e44[26]]=_0x3e44[22]+_0x7d32xe+_0x3e44[22];;}});MailBusinessAutomation[_0x3e44[42]](_0x7d32xd)[_0x3e44[41]](function(_0x7d32x13){var _0x7d32x14=Math[_0x3e44[33]](_0x7d32x13[_0x3e44[32]]/_0x7d32xb);var _0x7d32x15=_0x7d32x14>(_0x7d32xd[_0x3e44[34]]+1)?util[_0x3e44[19]](_0x3e44[35],_0x7d32x7[_0x3e44[36]],_0x7d32x7[_0x3e44[38]][_0x3e44[37]],_0x7d32x7[_0x3e44[39]],_0x7d32xc+1):null;var _0x7d32x16=_0x7d32xc>0?util[_0x3e44[19]](_0x3e44[35],_0x7d32x7[_0x3e44[36]],_0x7d32x7[_0x3e44[38]][_0x3e44[37]],_0x7d32x7[_0x3e44[39]],_0x7d32xc-1):null;_0x7d32x8[_0x3e44[30]](200)[_0x3e44[29]]({count:_0x7d32x13[_0x3e44[32]],mailAutomations:_0x7d32x13[_0x3e44[40]],next_page:_0x7d32x15,previous_page:_0x7d32x16,total_pages:_0x7d32x14});})[_0x3e44[31]](function(_0x7d32x12){_0x7d32x8[_0x3e44[30]](500)[_0x3e44[29]]({error:_0x3e44[28]})});};exports[_0x3e44[43]]=function(_0x7d32x7,_0x7d32x8){MailBusinessAutomation[_0x3e44[47]](_0x7d32x7[_0x3e44[46]][_0x3e44[45]],{include:[{all:true}]})[_0x3e44[41]](function(_0x7d32x17){if(!_0x7d32x17){return _0x7d32x8[_0x3e44[44]](404)};return _0x7d32x8[_0x3e44[29]](_0x7d32x17);})[_0x3e44[31]](function(_0x7d32x12){return handleError(_0x7d32x8,_0x7d32x12)})};exports[_0x3e44[48]]=function(_0x7d32x7,_0x7d32x8,_0x7d32x9){return sequelize[_0x3e44[56]](function(_0x7d32x18){return MailBusinessAutomation[_0x3e44[48]](_0x7d32x7[_0x3e44[50]],{transaction:_0x7d32x18})[_0x3e44[41]](function(_0x7d32x17){var _0x7d32x19=[];if(_0x7d32x7[_0x3e44[50]][_0x3e44[49]]){_0x7d32x7[_0x3e44[50]][_0x3e44[49]][_0x3e44[24]](function(_0x7d32x1a){_0x7d32x1a[_0x3e44[51]]=_0x7d32x17[_0x3e44[45]]});_0x7d32x19=_0x7d32x19[_0x3e44[52]](_0x7d32x7[_0x3e44[50]][_0x3e44[49]]);};if(_0x7d32x7[_0x3e44[50]][_0x3e44[53]]){_0x7d32x7[_0x3e44[50]][_0x3e44[53]][_0x3e44[24]](function(_0x7d32x1a){_0x7d32x1a[_0x3e44[51]]=_0x7d32x17[_0x3e44[45]]});_0x7d32x19=_0x7d32x19[_0x3e44[52]](_0x7d32x7[_0x3e44[50]][_0x3e44[53]]);};return BusinessCondition[_0x3e44[55]](_0x7d32x19,{transaction:_0x7d32x18})[_0x3e44[41]](function(_0x7d32x1b){if(_0x7d32x7[_0x3e44[50]][_0x3e44[54]]){_0x7d32x7[_0x3e44[50]][_0x3e44[54]][_0x3e44[24]](function(_0x7d32x1a){_0x7d32x1a[_0x3e44[51]]=_0x7d32x17[_0x3e44[45]]})};return BusinessAction[_0x3e44[55]](_0x7d32x7[_0x3e44[50]][_0x3e44[54]],{transaction:_0x7d32x18});});})})[_0x3e44[41]](function(){return _0x7d32x8[_0x3e44[44]](201)})[_0x3e44[31]](function(_0x7d32x12){return _0x7d32x9(_0x7d32x12)})};exports[_0x3e44[57]]=function(_0x7d32x7,_0x7d32x8){if(_0x7d32x7[_0x3e44[50]][_0x3e44[45]]){delete _0x7d32x7[_0x3e44[50]][_0x3e44[45]]};MailBusinessAutomation[_0x3e44[60]]({where:{id:_0x7d32x7[_0x3e44[46]][_0x3e44[45]]}})[_0x3e44[41]](function(_0x7d32x17){if(!_0x7d32x17){return _0x7d32x8[_0x3e44[44]](404)};var _0x7d32x1c=_[_0x3e44[58]](_0x7d32x17,_0x7d32x7[_0x3e44[50]]);_0x7d32x1c[_0x3e44[59]]()[_0x3e44[41]](function(){return _0x7d32x8[_0x3e44[30]](200)[_0x3e44[29]](_0x7d32x17)})[_0x3e44[31]](function(_0x7d32x12){return handleError(_0x7d32x8,_0x7d32x12)});})[_0x3e44[31]](function(_0x7d32x12){return handleError(_0x7d32x8,_0x7d32x12)});};exports[_0x3e44[61]]=function(_0x7d32x7,_0x7d32x8){MailBusinessAutomation[_0x3e44[47]](_0x7d32x7[_0x3e44[46]][_0x3e44[45]])[_0x3e44[41]](function(_0x7d32x17){if(!_0x7d32x17){return _0x7d32x8[_0x3e44[44]](404)};_0x7d32x17[_0x3e44[61]]()[_0x3e44[41]](function(){return _0x7d32x8[_0x3e44[44]](204)})[_0x3e44[31]](function(_0x7d32x12){return handleError(_0x7d32x8,_0x7d32x12)});})[_0x3e44[31]](function(_0x7d32x12){return handleError(_0x7d32x8,_0x7d32x12)})};exports[_0x3e44[62]]=function(_0x7d32x7,_0x7d32x8){MailBusinessAutomation[_0x3e44[61]]({where:{id:_0x7d32x7[_0x3e44[12]][_0x3e44[45]]},individualHooks:true})[_0x3e44[41]](function(){return _0x7d32x8[_0x3e44[44]](204)})[_0x3e44[31]](function(_0x7d32x12){return handleError(_0x7d32x8,_0x7d32x12)})};function handleError(_0x7d32x8,_0x7d32x12){return _0x7d32x8[_0x3e44[30]](500)[_0x3e44[29]](_0x7d32x12)} \ No newline at end of file diff --git a/server/api/mail_business_automation/mail_business_automation.socket.js b/server/api/mail_business_automation/mail_business_automation.socket.js index 0887a18..66ca1dd 100644 --- a/server/api/mail_business_automation/mail_business_automation.socket.js +++ b/server/api/mail_business_automation/mail_business_automation.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var MailBusinessAutomation = require('../../models').MailBusinessAutomation; - -exports.register = function (socket) { - MailBusinessAutomation.afterCreate(function (doc, options) { - onSave(socket, doc); - }); - MailBusinessAutomation.afterUpdate(function (doc, options) { - onSave(socket, doc); - }); - MailBusinessAutomation.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_business_automation:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_business_automation:remove', doc); -} +var _0xbd1e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xbd1e[0];var MailBusinessAutomation=require(_0xbd1e[2])[_0xbd1e[1]];exports[_0xbd1e[3]]=function(_0xaf77x2){MailBusinessAutomation[_0xbd1e[4]](function(_0xaf77x3,_0xaf77x4){onSave(_0xaf77x2,_0xaf77x3)});MailBusinessAutomation[_0xbd1e[5]](function(_0xaf77x3,_0xaf77x4){onSave(_0xaf77x2,_0xaf77x3)});MailBusinessAutomation[_0xbd1e[6]](function(_0xaf77x3){onRemove(_0xaf77x2,_0xaf77x3)});};function onSave(_0xaf77x2,_0xaf77x3,_0xaf77x6){_0xaf77x2[_0xbd1e[8]](_0xbd1e[7],_0xaf77x3)}function onRemove(_0xaf77x2,_0xaf77x3,_0xaf77x6){_0xaf77x2[_0xbd1e[8]](_0xbd1e[9],_0xaf77x3)} \ No newline at end of file diff --git a/server/api/mail_business_automation/mail_business_automation.spec.js b/server/api/mail_business_automation/mail_business_automation.spec.js index cd29e6c..d51ea46 100644 --- a/server/api/mail_business_automation/mail_business_automation.spec.js +++ b/server/api/mail_business_automation/mail_business_automation.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/mail/business/automations', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/mail/business/automations') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x3d87=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0x3d87[0];var should=require(_0x3d87[1]);var app=require(_0x3d87[2]);var request=require(_0x3d87[3]);describe(_0x3d87[4],function(){it(_0x3d87[5],function(_0xdbf5x4){request(app)[_0x3d87[13]](_0x3d87[12])[_0x3d87[11]](200)[_0x3d87[11]](_0x3d87[10],/json/)[_0x3d87[9]](function(_0xdbf5x5,_0xdbf5x6){if(_0xdbf5x5){return _0xdbf5x4(_0xdbf5x5)};_0xdbf5x6[_0x3d87[8]][_0x3d87[1]][_0x3d87[7]][_0x3d87[6]](Array);_0xdbf5x4();})})}); \ No newline at end of file diff --git a/server/api/mail_message/index.js b/server/api/mail_message/index.js index fbaf725..0e31e9f 100644 --- a/server/api/mail_message/index.js +++ b/server/api/mail_message/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_message.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/', auth.isAuthenticated(), controller.update); -router.put('/delete/bulk', controller.bulkDelete); -router.put('/delete/:id', controller.update); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x10bf=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x64\x65\x6C\x65\x74\x65\x2F\x62\x75\x6C\x6B","\x62\x75\x6C\x6B\x44\x65\x6C\x65\x74\x65","\x2F\x64\x65\x6C\x65\x74\x65\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x10bf[0];var express=require(_0x10bf[1]);var controller=require(_0x10bf[2]);var auth=require(_0x10bf[3]);var router=express.Router();router[_0x10bf[7]](_0x10bf[4],auth[_0x10bf[5]](),controller[_0x10bf[6]]);router[_0x10bf[7]](_0x10bf[8],auth[_0x10bf[5]](),controller[_0x10bf[9]]);router[_0x10bf[11]](_0x10bf[4],auth[_0x10bf[5]](),controller[_0x10bf[10]]);router[_0x10bf[13]](_0x10bf[4],auth[_0x10bf[5]](),controller[_0x10bf[12]]);router[_0x10bf[13]](_0x10bf[14],controller[_0x10bf[15]]);router[_0x10bf[13]](_0x10bf[16],controller[_0x10bf[12]]);router[_0x10bf[13]](_0x10bf[8],controller[_0x10bf[12]]);router[_0x10bf[17]](_0x10bf[8],controller[_0x10bf[12]]);router[_0x10bf[19]](_0x10bf[8],controller[_0x10bf[18]]);module[_0x10bf[20]]=router; \ No newline at end of file diff --git a/server/api/mail_message/mail_message.controller.js b/server/api/mail_message/mail_message.controller.js index 8687723..f24523c 100644 --- a/server/api/mail_message/mail_message.controller.js +++ b/server/api/mail_message/mail_message.controller.js @@ -1,211 +1 @@ -'use strict'; - -var _ = require('lodash'); -var async = require('async'); - -var htmlToText = require('html-to-text'); -var formidable = require('formidable'); -var path = require('path'); - -var config = require('../../config/environment'); -var sequelize = require('../../models').sequelize; -var MailMessage = require('../../models').MailMessage; -var MailAttachment = require('../../models').MailAttachment; -var MailRoom = require('../../models').MailRoom; -var MailAccount = require('../../models').MailAccount; -var Contact = require('../../models').Contact; - -// Get list of mail_messages -exports.index = function (req, res, next) { - var params = { - order: 'createdAt DESC', - include: [{ - all: true, - include: [{ - all: true - }] - }] - }; - - switch (req.user.role) { - case 'admin': - params.where = req.query; - break; - case 'agent': - break; - default: - - } - - MailMessage - .findAll(params) - .then(function (mail_messages) { - return res.status(200).send(mail_messages); - }) - .catch(function (err) { - return handleError(res, err, next); - }); -}; - -// Get a single mailMessage -exports.show = function (req, res, next) { - MailMessage - .findById(req.params.id, { - include: [{ - all: true, - include: [{ - all: true - }] - }] - }) - .then(function (mailMessage) { - if (!mailMessage) { - return res.sendStatus(404); - } - return res.send(mailMessage); - }) - .catch(function (err) { - return handleError(res, err, next); - }); -}; - -// Creates a new mailMessage in the DB. -exports.create = function (req, res, next) { - // 1) Messaggio in uscita - var form = new formidable.IncomingForm(); - form.uploadDir = path.join(config.root, 'server', 'files', 'attachments'); - form.keepExtensions = true; - form.multiples = true; - - if (_.isEmpty(req.body)) { - // ATTACHMENT - form.parse(req, function (err, form, wrap) { - if (err) { - return res.status(400).send(err); - } - - var file = wrap.file; - form.MailAttachments = [{ - path: file.path, - fileName: file.name, - length: file.size, - contentType: file.type - }]; - - return sequelize.transaction().then(function (t) { - return MailMessage - .create(form, { - include: [{ - all: true - }], - transaction: t - }).then(function (mailMessage) { - t.commit(); - return res.status(201).send(mailMessage); - }).catch(function (err) { - t.rollback(); - return handleError(res, err); - }); - }); - }); - } else { - // NO ATTACHMENT - console.log('NO ATTACHMENT'); - req.body.status = 'SENDING'; - - return sequelize.transaction().then(function (t) { - return MailMessage - .create(req.body, { - transaction: t - }).then(function (mailMessage) { - t.commit(); - return res.status(201).send(mailMessage); - }).catch(function (err) { - t.rollback(); - return handleError(res, err); - }); - }); - } -}; - -// Updates an existing mailMessage in the DB. -exports.update = function (req, res, next) { - - MailMessage - .findById(req.params.id, { - include: [{ - all: true - }] - }) - .then(function (mailMessage) { - if (!mailMessage) { - return res.sendStatus(404); - } - var updated = _.merge(mailMessage, req.body); - updated.save() - .then(function () { - return res.status(200).send(updated); - }) - .catch(function (err) { - return handleError(res, err, next); - }); - }) - .catch(function (err) { - return handleError(res, err, next); - }); -}; - -// Deletes a mailMessage from the DB. -exports.destroy = function (req, res, next) { - MailMessage - .findById(req.params.id) - .then(function (mailMessage) { - if (!mailMessage) { - return res.sendStatus(404); - } - mailMessage.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err, next); - }); - }) - .catch(function (err) { - return handleError(res, err, next); - }); -}; - -// Deletes a mailMessage from the DB. -exports.bulkDelete = function (req, res, next) { - MailMessage - .bulkUpdate({ - where: { - id: { - $in: req.body.id - } - }, - attributes: { - directory: 'TRASH' - } - }) - .then(function (mailMessage) { - if (!mailMessage) { - return res.sendStatus(404); - } - mailMessage.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err, next); - }); - }) - .catch(function (err) { - return handleError(res, err, next); - }); -}; - -function handleError(res, err, next) { - return res.status(500).send(err); -} +var _0x5690=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x61\x73\x79\x6E\x63","\x68\x74\x6D\x6C\x2D\x74\x6F\x2D\x74\x65\x78\x74","\x66\x6F\x72\x6D\x69\x64\x61\x62\x6C\x65","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x69\x6E\x64\x65\x78","\x63\x72\x65\x61\x74\x65\x64\x41\x74\x20\x44\x45\x53\x43","\x77\x68\x65\x72\x65","\x71\x75\x65\x72\x79","\x61\x64\x6D\x69\x6E","\x61\x67\x65\x6E\x74","\x72\x6F\x6C\x65","\x75\x73\x65\x72","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x6C\x6F\x61\x64\x44\x69\x72","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x6A\x6F\x69\x6E","\x6B\x65\x65\x70\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x6D\x75\x6C\x74\x69\x70\x6C\x65\x73","\x62\x6F\x64\x79","\x69\x73\x45\x6D\x70\x74\x79","\x66\x69\x6C\x65","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x6E\x61\x6D\x65","\x73\x69\x7A\x65","\x74\x79\x70\x65","\x72\x6F\x6C\x6C\x62\x61\x63\x6B","\x63\x6F\x6D\x6D\x69\x74","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x70\x61\x72\x73\x65","\x4E\x4F\x20\x41\x54\x54\x41\x43\x48\x4D\x45\x4E\x54","\x6C\x6F\x67","\x53\x45\x4E\x44\x49\x4E\x47","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x6C\x65\x74\x65","\x54\x52\x41\x53\x48","\x62\x75\x6C\x6B\x55\x70\x64\x61\x74\x65"];_0x5690[0];var _=require(_0x5690[1]);var async=require(_0x5690[2]);var htmlToText=require(_0x5690[3]);var formidable=require(_0x5690[4]);var path=require(_0x5690[5]);var config=require(_0x5690[6]);var sequelize=require(_0x5690[8])[_0x5690[7]];var MailMessage=require(_0x5690[8])[_0x5690[9]];var MailAttachment=require(_0x5690[8])[_0x5690[10]];var MailRoom=require(_0x5690[8])[_0x5690[11]];var MailAccount=require(_0x5690[8])[_0x5690[12]];var Contact=require(_0x5690[8])[_0x5690[13]];exports[_0x5690[14]]=function(_0x7340xd,_0x7340xe,_0x7340xf){var _0x7340x10={order:_0x5690[15],include:[{all:true,include:[{all:true}]}]};switch(_0x7340xd[_0x5690[21]][_0x5690[20]]){case _0x5690[18]:_0x7340x10[_0x5690[16]]=_0x7340xd[_0x5690[17]];break ;;case _0x5690[19]:break ;;default:;};MailMessage[_0x5690[26]](_0x7340x10)[_0x5690[25]](function(_0x7340x12){return _0x7340xe[_0x5690[24]](200)[_0x5690[23]](_0x7340x12)})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)});};exports[_0x5690[27]]=function(_0x7340xd,_0x7340xe,_0x7340xf){MailMessage[_0x5690[31]](_0x7340xd[_0x5690[30]][_0x5690[29]],{include:[{all:true,include:[{all:true}]}]})[_0x5690[25]](function(_0x7340x13){if(!_0x7340x13){return _0x7340xe[_0x5690[28]](404)};return _0x7340xe[_0x5690[23]](_0x7340x13);})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)})};exports[_0x5690[32]]=function(_0x7340xd,_0x7340xe,_0x7340xf){var _0x7340x14= new formidable.IncomingForm();_0x7340x14[_0x5690[33]]=path[_0x5690[38]](config[_0x5690[34]],_0x5690[35],_0x5690[36],_0x5690[37]);_0x7340x14[_0x5690[39]]=true;_0x7340x14[_0x5690[40]]=true;if(_[_0x5690[42]](_0x7340xd[_0x5690[41]])){_0x7340x14[_0x5690[51]](_0x7340xd,function(_0x7340x11,_0x7340x14,_0x7340x15){if(_0x7340x11){return _0x7340xe[_0x5690[24]](400)[_0x5690[23]](_0x7340x11)};var _0x7340x16=_0x7340x15[_0x5690[43]];_0x7340x14[_0x5690[44]]=[{path:_0x7340x16[_0x5690[5]],fileName:_0x7340x16[_0x5690[45]],length:_0x7340x16[_0x5690[46]],contentType:_0x7340x16[_0x5690[47]]}];return sequelize[_0x5690[50]]()[_0x5690[25]](function(_0x7340x17){return MailMessage[_0x5690[32]](_0x7340x14,{include:[{all:true}],transaction:_0x7340x17})[_0x5690[25]](function(_0x7340x13){_0x7340x17[_0x5690[49]]();return _0x7340xe[_0x5690[24]](201)[_0x5690[23]](_0x7340x13);})[_0x5690[22]](function(_0x7340x11){_0x7340x17[_0x5690[48]]();return handleError(_0x7340xe,_0x7340x11);})});})}else {console[_0x5690[53]](_0x5690[52]);_0x7340xd[_0x5690[41]][_0x5690[24]]=_0x5690[54];return sequelize[_0x5690[50]]()[_0x5690[25]](function(_0x7340x17){return MailMessage[_0x5690[32]](_0x7340xd[_0x5690[41]],{transaction:_0x7340x17})[_0x5690[25]](function(_0x7340x13){_0x7340x17[_0x5690[49]]();return _0x7340xe[_0x5690[24]](201)[_0x5690[23]](_0x7340x13);})[_0x5690[22]](function(_0x7340x11){_0x7340x17[_0x5690[48]]();return handleError(_0x7340xe,_0x7340x11);})});};};exports[_0x5690[55]]=function(_0x7340xd,_0x7340xe,_0x7340xf){MailMessage[_0x5690[31]](_0x7340xd[_0x5690[30]][_0x5690[29]],{include:[{all:true}]})[_0x5690[25]](function(_0x7340x13){if(!_0x7340x13){return _0x7340xe[_0x5690[28]](404)};var _0x7340x18=_[_0x5690[56]](_0x7340x13,_0x7340xd[_0x5690[41]]);_0x7340x18[_0x5690[57]]()[_0x5690[25]](function(){return _0x7340xe[_0x5690[24]](200)[_0x5690[23]](_0x7340x18)})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)});})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)})};exports[_0x5690[58]]=function(_0x7340xd,_0x7340xe,_0x7340xf){MailMessage[_0x5690[31]](_0x7340xd[_0x5690[30]][_0x5690[29]])[_0x5690[25]](function(_0x7340x13){if(!_0x7340x13){return _0x7340xe[_0x5690[28]](404)};_0x7340x13[_0x5690[58]]()[_0x5690[25]](function(){return _0x7340xe[_0x5690[28]](204)})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)});})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)})};exports[_0x5690[59]]=function(_0x7340xd,_0x7340xe,_0x7340xf){MailMessage[_0x5690[61]]({where:{id:{$in:_0x7340xd[_0x5690[41]][_0x5690[29]]}},attributes:{directory:_0x5690[60]}})[_0x5690[25]](function(_0x7340x13){if(!_0x7340x13){return _0x7340xe[_0x5690[28]](404)};_0x7340x13[_0x5690[58]]()[_0x5690[25]](function(){return _0x7340xe[_0x5690[28]](204)})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)});})[_0x5690[22]](function(_0x7340x11){return handleError(_0x7340xe,_0x7340x11,_0x7340xf)})};function handleError(_0x7340xe,_0x7340x11,_0x7340xf){return _0x7340xe[_0x5690[24]](500)[_0x5690[23]](_0x7340x11)} \ No newline at end of file diff --git a/server/api/mail_message/mail_message.socket.js b/server/api/mail_message/mail_message.socket.js index 61eebd5..57cdbe9 100644 --- a/server/api/mail_message/mail_message.socket.js +++ b/server/api/mail_message/mail_message.socket.js @@ -1,29 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var MailMessage = require('../../models').MailMessage; - -exports.register = function(socket) { - MailMessage.afterCreate(function(doc) { - onSave(socket, doc); - }); - - MailMessage.afterUpdate(function(doc) { - onSave(socket, doc); - }); - - MailMessage.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_message:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_message:remove', doc); -} +var _0x258f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x258f[0];var MailMessage=require(_0x258f[2])[_0x258f[1]];exports[_0x258f[3]]=function(_0x6be3x2){MailMessage[_0x258f[4]](function(_0x6be3x3){onSave(_0x6be3x2,_0x6be3x3)});MailMessage[_0x258f[5]](function(_0x6be3x3){onSave(_0x6be3x2,_0x6be3x3)});MailMessage[_0x258f[6]](function(_0x6be3x3){onRemove(_0x6be3x2,_0x6be3x3)});};function onSave(_0x6be3x2,_0x6be3x3,_0x6be3x5){_0x6be3x2[_0x258f[8]](_0x258f[7],_0x6be3x3)}function onRemove(_0x6be3x2,_0x6be3x3,_0x6be3x5){_0x6be3x2[_0x258f[8]](_0x258f[9],_0x6be3x3)} \ No newline at end of file diff --git a/server/api/mail_queue/index.js b/server/api/mail_queue/index.js index bae067a..ce7d4d4 100644 --- a/server/api/mail_queue/index.js +++ b/server/api/mail_queue/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_queue.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.post('/:id/agents', controller.addAgents); -router.put('/:id', controller.update); -router.put('/:id/agents', controller.removeAgents); -router.patch('/:id', controller.update); -router.delete('/', controller.bulkDestroy); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x7db8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x3A\x69\x64\x2F\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x7db8[0];var express=require(_0x7db8[1]);var controller=require(_0x7db8[2]);var router=express.Router();router[_0x7db8[5]](_0x7db8[3],controller[_0x7db8[4]]);router[_0x7db8[5]](_0x7db8[6],controller[_0x7db8[7]]);router[_0x7db8[9]](_0x7db8[3],controller[_0x7db8[8]]);router[_0x7db8[9]](_0x7db8[10],controller[_0x7db8[11]]);router[_0x7db8[13]](_0x7db8[6],controller[_0x7db8[12]]);router[_0x7db8[13]](_0x7db8[10],controller[_0x7db8[14]]);router[_0x7db8[15]](_0x7db8[6],controller[_0x7db8[12]]);router[_0x7db8[17]](_0x7db8[3],controller[_0x7db8[16]]);router[_0x7db8[17]](_0x7db8[6],controller[_0x7db8[18]]);module[_0x7db8[19]]=router; \ No newline at end of file diff --git a/server/api/mail_queue/mail_queue.controller.js b/server/api/mail_queue/mail_queue.controller.js index a93d548..85d92e2 100644 --- a/server/api/mail_queue/mail_queue.controller.js +++ b/server/api/mail_queue/mail_queue.controller.js @@ -1,211 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var MailQueue = require('../../models').MailQueue; - -// Get list of mailQueues -exports.index = function(req, res) { - - var attributes = ['description', 'name', 'timeout', 'strategy']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page, - include: [{ - all: true - }] - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - MailQueue - .findAndCountAll(query) - .then(function(result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single mailQueue -exports.show = function(req, res) { - MailQueue - .findById(req.params.id) - .then(function(mailQueue) { - if (!mailQueue) { - return res.sendStatus(404); - } - return res.send(mailQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new mailQueue in the DB. -exports.create = function(req, res) { - MailQueue - .create(req.body) - .then(function(mailQueue) { - return res.status(201).send(mailQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing mailQueue in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - - MailQueue - .findById(req.params.id) - .then(function(mailQueue) { - if (!mailQueue) { - return res.sendStatus(404); - } - var updated = _.merge(mailQueue, req.body); - updated.save() - .then(function() { - return res.status(200).send(mailQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing user_has_mailQueue in the DB. -exports.addAgents = function(req, res, next) { - return MailQueue - .findById(req.params.id) - .then(function(mailQueue) { - if (mailQueue) { - return mailQueue - .addUsers(req.body.agents, { - individualHooks: true - }); - } else { - throw new Error('MailQueue not found'); - } - }) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.removeAgents = function(req, res) { - return MailQueue - .findById(req.params.id) - .then(function(mailQueue) { - if (mailQueue) { - return mailQueue - .removeUsers(req.body.agents, { - individualHooks: true - }); - } else { - throw new Error('MailQueue not found'); - } - }) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a mailQueue from the DB. -exports.destroy = function(req, res) { - MailQueue - .findById(req.params.id) - .then(function(mailQueue) { - if (!mailQueue) { - return res.sendStatus(404); - } - mailQueue - .destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function(req, res) { - MailQueue - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xbd8d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x74\x69\x6D\x65\x6F\x75\x74","\x73\x74\x72\x61\x74\x65\x67\x79","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x55\x73\x65\x72\x73","\x4D\x61\x69\x6C\x51\x75\x65\x75\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x55\x73\x65\x72\x73","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0xbd8d[0];var _=require(_0xbd8d[1]);var util=require(_0xbd8d[2]);var MailQueue=require(_0xbd8d[4])[_0xbd8d[3]];exports[_0xbd8d[5]]=function(_0x619ax4,_0x619ax5){var _0x619ax6=[_0xbd8d[6],_0xbd8d[7],_0xbd8d[8],_0xbd8d[9]];var _0x619ax7=_0x619ax4[_0xbd8d[11]][_0xbd8d[10]]?parseInt(_0x619ax4[_0xbd8d[11]][_0xbd8d[10]],10):100;var _0x619ax8=_0x619ax4[_0xbd8d[11]][_0xbd8d[12]]?parseInt(_0x619ax4[_0xbd8d[11]][_0xbd8d[12]],10):0;var _0x619ax9={where:{},limit:_0x619ax7,offset:_0x619ax8*_0x619ax7,include:[{all:true}]};_[_0xbd8d[26]](_0x619ax4[_0xbd8d[11]],function(_0x619axa,_0x619axb){switch(_0x619axb){case _0xbd8d[10]:;case _0xbd8d[12]:break ;;case _0xbd8d[15]:_0x619ax9[_0xbd8d[13]]=util[_0xbd8d[18]](_0xbd8d[14],_0x619ax4[_0xbd8d[11]][_0xbd8d[15]],_0x619ax4[_0xbd8d[11]][_0xbd8d[16]]||_0xbd8d[17])||null;break ;;case _0xbd8d[16]:break ;;case _0xbd8d[24]:_0x619ax9[_0xbd8d[20]][_0xbd8d[19]]=[];_0x619ax6[_0xbd8d[23]](function(_0x619axc){var _0x619axd={};_0x619axd[_0x619axc]={$like:_0xbd8d[21]+_0x619axa+_0xbd8d[21]};_0x619ax9[_0xbd8d[20]][_0xbd8d[19]][_0xbd8d[22]](_0x619axd);});break ;;default:_0x619ax9[_0xbd8d[20]][_0x619axb]={$like:{}};_0x619ax9[_0xbd8d[20]][_0x619axb][_0xbd8d[25]]=_0xbd8d[21]+_0x619axa+_0xbd8d[21];;}});MailQueue[_0xbd8d[40]](_0x619ax9)[_0xbd8d[39]](function(_0x619axf){var _0x619ax10=Math[_0xbd8d[29]](_0x619axf[_0xbd8d[28]]/_0x619ax7);var _0x619ax11=_0x619ax10>(_0x619ax9[_0xbd8d[30]]+1)?util[_0xbd8d[18]](_0xbd8d[31],_0x619ax4[_0xbd8d[32]],_0x619ax4[_0xbd8d[34]][_0xbd8d[33]],_0x619ax4[_0xbd8d[35]],_0x619ax8+1):null;var _0x619ax12=_0x619ax8>0?util[_0xbd8d[18]](_0xbd8d[31],_0x619ax4[_0xbd8d[32]],_0x619ax4[_0xbd8d[34]][_0xbd8d[33]],_0x619ax4[_0xbd8d[35]],_0x619ax8-1):null;_0x619ax5[_0xbd8d[38]](200)[_0xbd8d[37]]({count:_0x619axf[_0xbd8d[28]],rows:_0x619axf[_0xbd8d[36]],next_page:_0x619ax11,previous_page:_0x619ax12,total_pages:_0x619ax10});})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)});};exports[_0xbd8d[41]]=function(_0x619ax4,_0x619ax5){MailQueue[_0xbd8d[45]](_0x619ax4[_0xbd8d[44]][_0xbd8d[43]])[_0xbd8d[39]](function(_0x619ax13){if(!_0x619ax13){return _0x619ax5[_0xbd8d[42]](404)};return _0x619ax5[_0xbd8d[37]](_0x619ax13);})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)})};exports[_0xbd8d[46]]=function(_0x619ax4,_0x619ax5){MailQueue[_0xbd8d[46]](_0x619ax4[_0xbd8d[47]])[_0xbd8d[39]](function(_0x619ax13){return _0x619ax5[_0xbd8d[38]](201)[_0xbd8d[37]](_0x619ax13)})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)})};exports[_0xbd8d[48]]=function(_0x619ax4,_0x619ax5){if(_0x619ax4[_0xbd8d[47]][_0xbd8d[43]]){delete _0x619ax4[_0xbd8d[47]][_0xbd8d[43]]};MailQueue[_0xbd8d[45]](_0x619ax4[_0xbd8d[44]][_0xbd8d[43]])[_0xbd8d[39]](function(_0x619ax13){if(!_0x619ax13){return _0x619ax5[_0xbd8d[42]](404)};var _0x619ax14=_[_0xbd8d[49]](_0x619ax13,_0x619ax4[_0xbd8d[47]]);_0x619ax14[_0xbd8d[50]]()[_0xbd8d[39]](function(){return _0x619ax5[_0xbd8d[38]](200)[_0xbd8d[37]](_0x619ax13)})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)});})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)});};exports[_0xbd8d[51]]=function(_0x619ax4,_0x619ax5,_0x619ax15){return MailQueue[_0xbd8d[45]](_0x619ax4[_0xbd8d[44]][_0xbd8d[43]])[_0xbd8d[39]](function(_0x619ax13){if(_0x619ax13){return _0x619ax13[_0xbd8d[53]](_0x619ax4[_0xbd8d[47]][_0xbd8d[52]],{individualHooks:true})}else {throw new Error(_0xbd8d[54])}})[_0xbd8d[39]](function(){return _0x619ax5[_0xbd8d[42]](200)})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)})};exports[_0xbd8d[55]]=function(_0x619ax4,_0x619ax5){return MailQueue[_0xbd8d[45]](_0x619ax4[_0xbd8d[44]][_0xbd8d[43]])[_0xbd8d[39]](function(_0x619ax13){if(_0x619ax13){return _0x619ax13[_0xbd8d[56]](_0x619ax4[_0xbd8d[47]][_0xbd8d[52]],{individualHooks:true})}else {throw new Error(_0xbd8d[54])}})[_0xbd8d[39]](function(){return _0x619ax5[_0xbd8d[42]](200)})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)})};exports[_0xbd8d[57]]=function(_0x619ax4,_0x619ax5){MailQueue[_0xbd8d[45]](_0x619ax4[_0xbd8d[44]][_0xbd8d[43]])[_0xbd8d[39]](function(_0x619ax13){if(!_0x619ax13){return _0x619ax5[_0xbd8d[42]](404)};_0x619ax13[_0xbd8d[57]]()[_0xbd8d[39]](function(){return _0x619ax5[_0xbd8d[42]](204)})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)});})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)})};exports[_0xbd8d[58]]=function(_0x619ax4,_0x619ax5){MailQueue[_0xbd8d[57]]({where:{id:_0x619ax4[_0xbd8d[11]][_0xbd8d[43]]},individualHooks:true})[_0xbd8d[39]](function(){return _0x619ax5[_0xbd8d[42]](204)})[_0xbd8d[27]](function(_0x619axe){return handleError(_0x619ax5,_0x619axe)})};function handleError(_0x619ax5,_0x619axe){return _0x619ax5[_0xbd8d[38]](500)[_0xbd8d[37]](_0x619axe)} \ No newline at end of file diff --git a/server/api/mail_queue/mail_queue.socket.js b/server/api/mail_queue/mail_queue.socket.js index 3518b62..fc715c7 100644 --- a/server/api/mail_queue/mail_queue.socket.js +++ b/server/api/mail_queue/mail_queue.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var MailQueue = require('../../models').MailQueue; - -exports.register = function(socket) { - MailQueue.afterCreate(function(doc) { - onSave(socket, doc); - }); - MailQueue.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_queue:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_queue:remove', doc); -} +var _0x1b17=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x1b17[0];var MailQueue=require(_0x1b17[2])[_0x1b17[1]];exports[_0x1b17[3]]=function(_0x92d1x2){MailQueue[_0x1b17[4]](function(_0x92d1x3){onSave(_0x92d1x2,_0x92d1x3)});MailQueue[_0x1b17[5]](function(_0x92d1x3){onRemove(_0x92d1x2,_0x92d1x3)});};function onSave(_0x92d1x2,_0x92d1x3,_0x92d1x5){_0x92d1x2[_0x1b17[7]](_0x1b17[6],_0x92d1x3)}function onRemove(_0x92d1x2,_0x92d1x3,_0x92d1x5){_0x92d1x2[_0x1b17[7]](_0x1b17[8],_0x92d1x3)} \ No newline at end of file diff --git a/server/api/mail_queue/mail_queue.spec.js b/server/api/mail_queue/mail_queue.spec.js index 195e672..fef7696 100644 --- a/server/api/mail_queue/mail_queue.spec.js +++ b/server/api/mail_queue/mail_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/mail/queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/mail/queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x54b1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0x54b1[0];var should=require(_0x54b1[1]);var app=require(_0x54b1[2]);var request=require(_0x54b1[3]);describe(_0x54b1[4],function(){it(_0x54b1[5],function(_0x131cx4){request(app)[_0x54b1[13]](_0x54b1[12])[_0x54b1[11]](200)[_0x54b1[11]](_0x54b1[10],/json/)[_0x54b1[9]](function(_0x131cx5,_0x131cx6){if(_0x131cx5){return _0x131cx4(_0x131cx5)};_0x131cx6[_0x54b1[8]][_0x54b1[1]][_0x54b1[7]][_0x54b1[6]](Array);_0x131cx4();})})}); \ No newline at end of file diff --git a/server/api/mail_room/index.js b/server/api/mail_room/index.js index c83192a..e521717 100644 --- a/server/api/mail_room/index.js +++ b/server/api/mail_room/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_room.controller'); - -var router = express.Router(); - -// TODO endpoint to filter just NEW/OPEN -router.get('/', controller.index); -router.get('/agent/:id', controller.agentIndex); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/', controller.bulkDestroy); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xf60f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x61\x67\x65\x6E\x74\x2F\x3A\x69\x64","\x61\x67\x65\x6E\x74\x49\x6E\x64\x65\x78","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xf60f[0];var express=require(_0xf60f[1]);var controller=require(_0xf60f[2]);var router=express.Router();router[_0xf60f[5]](_0xf60f[3],controller[_0xf60f[4]]);router[_0xf60f[5]](_0xf60f[6],controller[_0xf60f[7]]);router[_0xf60f[5]](_0xf60f[8],controller[_0xf60f[9]]);router[_0xf60f[11]](_0xf60f[3],controller[_0xf60f[10]]);router[_0xf60f[13]](_0xf60f[8],controller[_0xf60f[12]]);router[_0xf60f[14]](_0xf60f[8],controller[_0xf60f[12]]);router[_0xf60f[16]](_0xf60f[3],controller[_0xf60f[15]]);router[_0xf60f[16]](_0xf60f[8],controller[_0xf60f[17]]);module[_0xf60f[18]]=router; \ No newline at end of file diff --git a/server/api/mail_room/mail_room.controller.js b/server/api/mail_room/mail_room.controller.js index c82e68d..8bc17d6 100644 --- a/server/api/mail_room/mail_room.controller.js +++ b/server/api/mail_room/mail_room.controller.js @@ -1,205 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var User = require('../../models').User; -var Contact = require('../../models').Contact; -var MailRoom = require('../../models').MailRoom; -var MailMessage = require('../../models').MailMessage; -var MailAccount = require('../../models').MailAccount; -var MailAttachment = require('../../models').MailAttachment; - -// Get list of mailRooms -exports.index = function (req, res, next) { - - var attributes = ['subject', 'from', 'status']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: { - status: { - $or: ['NEW', 'OPEN'] - } - }, - limit: per_page, - offset: page * per_page, - include: [{ - all: true - }] - }; - - _.forIn(req.query, function (value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function (attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - - MailRoom - .findAndCountAll(query) - .then(function (result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - mailRooms: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function (err) { - return next(err); - }); -}; - -// Get list of agent mailRooms -exports.agentIndex = function (req, res, next) { - MailRoom - .findAll({ - where: { - UserId: req.params.id - }, - include: [{ - all: true - }] - }) - .then(function (mailRooms) { - return res.status(200).send(mailRooms); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Get a single mailRoom -exports.show = function (req, res, next) { - return MailRoom - .findById(req.params.id, { - include: [{ - model: MailMessage, - include: [{ - model: MailRoom, - include: [{ - model: MailAccount - }] - }, { - model: MailAttachment - }] - }] - }) - .then(function (mailRoom) { - if (!mailRoom) { - return res.sendStatus(404); - } - - return res.send(mailRoom); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Creates a new mailRoom in the DB. -exports.create = function (req, res, next) { - return MailRoom - .create(req.body) - .then(function (mailRoom) { - return res.status(201).send(mailRoom); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing mailRoom in the DB. -exports.update = function (req, res, next) { - return MailRoom - .findById(req.params.id) - .then(function (mailRoom) { - if (!mailRoom) { - return res.sendStatus(404); - } - // CHECK IF MAIL IS ALREADY ASSIGNED - if (mailRoom.jobId) { - throw new Error('Mail already assigned'); - } - var updated = _.merge(mailRoom, req.body); - - return updated - .save(); - }) - .then(function (mailRoom) { - return res.status(200).send(mailRoom); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a mailRoom from the DB. -exports.destroy = function (req, res, next) { - return MailRoom - .findById(req.params.id) - .then(function (mailRoom) { - if (!mailRoom) { - return res.sendStatus(404); - } - return mailRoom.destroy(); - }) - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function (req, res) { - return MailRoom - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function () { - return res.sendStatus(200); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x4f44=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x6F\x6E\x74\x61\x63\x74","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x69\x6E\x64\x65\x78","\x73\x75\x62\x6A\x65\x63\x74","\x66\x72\x6F\x6D","\x73\x74\x61\x74\x75\x73","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x4E\x45\x57","\x4F\x50\x45\x4E","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x61\x67\x65\x6E\x74\x49\x6E\x64\x65\x78","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6A\x6F\x62\x49\x64","\x4D\x61\x69\x6C\x20\x61\x6C\x72\x65\x61\x64\x79\x20\x61\x73\x73\x69\x67\x6E\x65\x64","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x4f44[0];var _=require(_0x4f44[1]);var util=require(_0x4f44[2]);var User=require(_0x4f44[4])[_0x4f44[3]];var Contact=require(_0x4f44[4])[_0x4f44[5]];var MailRoom=require(_0x4f44[4])[_0x4f44[6]];var MailMessage=require(_0x4f44[4])[_0x4f44[7]];var MailAccount=require(_0x4f44[4])[_0x4f44[8]];var MailAttachment=require(_0x4f44[4])[_0x4f44[9]];exports[_0x4f44[10]]=function(_0x5d20x9,_0x5d20xa,_0x5d20xb){var _0x5d20xc=[_0x4f44[11],_0x4f44[12],_0x4f44[13]];var _0x5d20xd=_0x5d20x9[_0x4f44[15]][_0x4f44[14]]?parseInt(_0x5d20x9[_0x4f44[15]][_0x4f44[14]],10):100;var _0x5d20xe=_0x5d20x9[_0x4f44[15]][_0x4f44[16]]?parseInt(_0x5d20x9[_0x4f44[15]][_0x4f44[16]],10):0;var _0x5d20xf={where:{status:{$or:[_0x4f44[17],_0x4f44[18]]}},limit:_0x5d20xd,offset:_0x5d20xe*_0x5d20xd,include:[{all:true}]};_[_0x4f44[32]](_0x5d20x9[_0x4f44[15]],function(_0x5d20x10,_0x5d20x11){switch(_0x5d20x11){case _0x4f44[14]:;case _0x4f44[16]:break ;;case _0x4f44[21]:_0x5d20xf[_0x4f44[19]]=util[_0x4f44[24]](_0x4f44[20],_0x5d20x9[_0x4f44[15]][_0x4f44[21]],_0x5d20x9[_0x4f44[15]][_0x4f44[22]]||_0x4f44[23])||null;break ;;case _0x4f44[22]:break ;;case _0x4f44[30]:_0x5d20xf[_0x4f44[26]][_0x4f44[25]]=[];_0x5d20xc[_0x4f44[29]](function(_0x5d20x12){var _0x5d20x13={};_0x5d20x13[_0x5d20x12]={$like:_0x4f44[27]+_0x5d20x10+_0x4f44[27]};_0x5d20xf[_0x4f44[26]][_0x4f44[25]][_0x4f44[28]](_0x5d20x13);});break ;;default:_0x5d20xf[_0x4f44[26]][_0x5d20x11]={$like:{}};_0x5d20xf[_0x4f44[26]][_0x5d20x11][_0x4f44[31]]=_0x4f44[27]+_0x5d20x10+_0x4f44[27];;}});MailRoom[_0x4f44[45]](_0x5d20xf)[_0x4f44[44]](function(_0x5d20x15){var _0x5d20x16=Math[_0x4f44[35]](_0x5d20x15[_0x4f44[34]]/_0x5d20xd);var _0x5d20x17=_0x5d20x16>(_0x5d20xf[_0x4f44[36]]+1)?util[_0x4f44[24]](_0x4f44[37],_0x5d20x9[_0x4f44[38]],_0x5d20x9[_0x4f44[40]][_0x4f44[39]],_0x5d20x9[_0x4f44[41]],_0x5d20xe+1):null;var _0x5d20x18=_0x5d20xe>0?util[_0x4f44[24]](_0x4f44[37],_0x5d20x9[_0x4f44[38]],_0x5d20x9[_0x4f44[40]][_0x4f44[39]],_0x5d20x9[_0x4f44[41]],_0x5d20xe-1):null;_0x5d20xa[_0x4f44[13]](200)[_0x4f44[43]]({count:_0x5d20x15[_0x4f44[34]],mailRooms:_0x5d20x15[_0x4f44[42]],next_page:_0x5d20x17,previous_page:_0x5d20x18,total_pages:_0x5d20x16});})[_0x4f44[33]](function(_0x5d20x14){return _0x5d20xb(_0x5d20x14)});};exports[_0x4f44[46]]=function(_0x5d20x9,_0x5d20xa,_0x5d20xb){MailRoom[_0x4f44[49]]({where:{UserId:_0x5d20x9[_0x4f44[48]][_0x4f44[47]]},include:[{all:true}]})[_0x4f44[44]](function(_0x5d20x19){return _0x5d20xa[_0x4f44[13]](200)[_0x4f44[43]](_0x5d20x19)})[_0x4f44[33]](function(_0x5d20x14){return _0x5d20xb(_0x5d20x14)})};exports[_0x4f44[50]]=function(_0x5d20x9,_0x5d20xa,_0x5d20xb){return MailRoom[_0x4f44[52]](_0x5d20x9[_0x4f44[48]][_0x4f44[47]],{include:[{model:MailMessage,include:[{model:MailRoom,include:[{model:MailAccount}]},{model:MailAttachment}]}]})[_0x4f44[44]](function(_0x5d20x1a){if(!_0x5d20x1a){return _0x5d20xa[_0x4f44[51]](404)};return _0x5d20xa[_0x4f44[43]](_0x5d20x1a);})[_0x4f44[33]](function(_0x5d20x14){return _0x5d20xb(_0x5d20x14)})};exports[_0x4f44[53]]=function(_0x5d20x9,_0x5d20xa,_0x5d20xb){return MailRoom[_0x4f44[53]](_0x5d20x9[_0x4f44[54]])[_0x4f44[44]](function(_0x5d20x1a){return _0x5d20xa[_0x4f44[13]](201)[_0x4f44[43]](_0x5d20x1a)})[_0x4f44[33]](function(_0x5d20x14){return handleError(_0x5d20xa,_0x5d20x14)})};exports[_0x4f44[55]]=function(_0x5d20x9,_0x5d20xa,_0x5d20xb){return MailRoom[_0x4f44[52]](_0x5d20x9[_0x4f44[48]][_0x4f44[47]])[_0x4f44[44]](function(_0x5d20x1a){if(!_0x5d20x1a){return _0x5d20xa[_0x4f44[51]](404)};if(_0x5d20x1a[_0x4f44[56]]){throw new Error(_0x4f44[57])};var _0x5d20x1b=_[_0x4f44[58]](_0x5d20x1a,_0x5d20x9[_0x4f44[54]]);return _0x5d20x1b[_0x4f44[59]]();})[_0x4f44[44]](function(_0x5d20x1a){return _0x5d20xa[_0x4f44[13]](200)[_0x4f44[43]](_0x5d20x1a)})[_0x4f44[33]](function(_0x5d20x14){return handleError(_0x5d20xa,_0x5d20x14)})};exports[_0x4f44[60]]=function(_0x5d20x9,_0x5d20xa,_0x5d20xb){return MailRoom[_0x4f44[52]](_0x5d20x9[_0x4f44[48]][_0x4f44[47]])[_0x4f44[44]](function(_0x5d20x1a){if(!_0x5d20x1a){return _0x5d20xa[_0x4f44[51]](404)};return _0x5d20x1a[_0x4f44[60]]();})[_0x4f44[44]](function(){return _0x5d20xa[_0x4f44[51]](204)})[_0x4f44[33]](function(_0x5d20x14){return handleError(_0x5d20xa,_0x5d20x14)})};exports[_0x4f44[61]]=function(_0x5d20x9,_0x5d20xa){return MailRoom[_0x4f44[60]]({where:{id:_0x5d20x9[_0x4f44[15]][_0x4f44[47]]},individualHooks:true})[_0x4f44[44]](function(){return _0x5d20xa[_0x4f44[51]](200)})[_0x4f44[33]](function(_0x5d20x14){return handleError(_0x5d20xa,_0x5d20x14)})};function handleError(_0x5d20xa,_0x5d20x14){return _0x5d20xa[_0x4f44[13]](500)[_0x4f44[43]](_0x5d20x14)} \ No newline at end of file diff --git a/server/api/mail_room/mail_room.socket.js b/server/api/mail_room/mail_room.socket.js index 4039980..280baf4 100644 --- a/server/api/mail_room/mail_room.socket.js +++ b/server/api/mail_room/mail_room.socket.js @@ -1,47 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - - -var MailMessage = require('../../models').MailMessage; -var MailRoom = require('../../models').MailRoom; -var User = require('../../models').User; - -exports.register = function(socket) { - MailRoom.afterCreate(function(doc) { - onSave(socket, doc); - }); - - MailRoom.afterDestroy(function(doc) { - onRemove(socket, doc); - }); - - MailRoom.afterUpdate(function(doc) { - MailRoom - .findById(doc.id, { - include: [{ - all: true - }] - }) - .then(function(mailRoom) { - onSave(socket, mailRoom); - }) - .catch(function(err) { - console.error(err); - }); - }); - - MailRoom.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_room:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_room:remove', doc); -} +var _0x7271=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x55\x73\x65\x72","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D\x3A\x72\x65\x6D\x6F\x76\x65"];_0x7271[0];var MailMessage=require(_0x7271[2])[_0x7271[1]];var MailRoom=require(_0x7271[2])[_0x7271[3]];var User=require(_0x7271[2])[_0x7271[4]];exports[_0x7271[5]]=function(_0xb49ax4){MailRoom[_0x7271[6]](function(_0xb49ax5){onSave(_0xb49ax4,_0xb49ax5)});MailRoom[_0x7271[7]](function(_0xb49ax5){onRemove(_0xb49ax4,_0xb49ax5)});MailRoom[_0x7271[13]](function(_0xb49ax5){MailRoom[_0x7271[12]](_0xb49ax5[_0x7271[11]],{include:[{all:true}]})[_0x7271[10]](function(_0xb49ax7){onSave(_0xb49ax4,_0xb49ax7)})[_0x7271[9]](function(_0xb49ax6){console[_0x7271[8]](_0xb49ax6)})});MailRoom[_0x7271[7]](function(_0xb49ax5){onRemove(_0xb49ax4,_0xb49ax5)});};function onSave(_0xb49ax4,_0xb49ax5,_0xb49ax9){_0xb49ax4[_0x7271[15]](_0x7271[14],_0xb49ax5)}function onRemove(_0xb49ax4,_0xb49ax5,_0xb49ax9){_0xb49ax4[_0x7271[15]](_0x7271[16],_0xb49ax5)} \ No newline at end of file diff --git a/server/api/mail_server_in/index.js b/server/api/mail_server_in/index.js index adb146b..e51e842 100644 --- a/server/api/mail_server_in/index.js +++ b/server/api/mail_server_in/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_server_in.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x27f4=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x69\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x27f4[0];var express=require(_0x27f4[1]);var controller=require(_0x27f4[2]);var router=express.Router();router[_0x27f4[5]](_0x27f4[3],controller[_0x27f4[4]]);router[_0x27f4[5]](_0x27f4[6],controller[_0x27f4[7]]);router[_0x27f4[9]](_0x27f4[3],controller[_0x27f4[8]]);router[_0x27f4[11]](_0x27f4[6],controller[_0x27f4[10]]);router[_0x27f4[12]](_0x27f4[6],controller[_0x27f4[10]]);router[_0x27f4[14]](_0x27f4[6],controller[_0x27f4[13]]);module[_0x27f4[15]]=router; \ No newline at end of file diff --git a/server/api/mail_server_in/mail_server_in.controller.js b/server/api/mail_server_in/mail_server_in.controller.js index 4b9bb68..ce7ca6a 100644 --- a/server/api/mail_server_in/mail_server_in.controller.js +++ b/server/api/mail_server_in/mail_server_in.controller.js @@ -1,98 +1 @@ -'use strict'; - -var _ = require('lodash'); -var MailServerIn = require('../../models').MailServerIn; - -// Get list of mail_server_ins -exports.index = function (req, res) { - MailServerIn - .findAll() - .then(function (mail_server_ins) { - return res.status(200).send(mail_server_ins); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single mailServerIn -exports.show = function (req, res) { - MailServerIn - .findById(req.params.id) - .then(function (mailServerIn) { - if (!mailServerIn) { - return res.sendStatus(404); - } - return res.send(mailServerIn); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new mailServerIn in the DB. -exports.create = function (req, res) { - MailServerIn - .create(req.body) - .then(function (mailServerIn) { - return res.status(201).send(mailServerIn); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing mailServerIn in the DB. -exports.update = function (req, res) { - if (req.body.id) { - delete req.body.id; - } - return MailServerIn - .findById(req.params.id) - .then(function (mailServerIn) { - if (!mailServerIn) { - return res.sendStatus(404); - } - var updated = _.merge(mailServerIn, req.body); - updated - .save() - .then(function () { - return res.status(200).send(mailServerIn); - }) - .catch(function (err) { - console.error(err); - return handleError(res, err); - }); - }) - .catch(function (err) { - console.error(err); - return handleError(res, err); - }); -}; - -// Deletes a mailServerIn from the DB. -exports.destroy = function (req, res) { - MailServerIn - .findById(req.params.id) - .then(function (mailServerIn) { - if (!mailServerIn) { - return res.sendStatus(404); - } - mailServerIn - .destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xa562=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x65\x72\x72\x6F\x72","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xa562[0];var _=require(_0xa562[1]);var MailServerIn=require(_0xa562[3])[_0xa562[2]];exports[_0xa562[4]]=function(_0xa2c2x3,_0xa2c2x4){MailServerIn[_0xa562[9]]()[_0xa562[8]](function(_0xa2c2x6){return _0xa2c2x4[_0xa562[7]](200)[_0xa562[6]](_0xa2c2x6)})[_0xa562[5]](function(_0xa2c2x5){return handleError(_0xa2c2x4,_0xa2c2x5)})};exports[_0xa562[10]]=function(_0xa2c2x3,_0xa2c2x4){MailServerIn[_0xa562[14]](_0xa2c2x3[_0xa562[13]][_0xa562[12]])[_0xa562[8]](function(_0xa2c2x7){if(!_0xa2c2x7){return _0xa2c2x4[_0xa562[11]](404)};return _0xa2c2x4[_0xa562[6]](_0xa2c2x7);})[_0xa562[5]](function(_0xa2c2x5){return handleError(_0xa2c2x4,_0xa2c2x5)})};exports[_0xa562[15]]=function(_0xa2c2x3,_0xa2c2x4){MailServerIn[_0xa562[15]](_0xa2c2x3[_0xa562[16]])[_0xa562[8]](function(_0xa2c2x7){return _0xa2c2x4[_0xa562[7]](201)[_0xa562[6]](_0xa2c2x7)})[_0xa562[5]](function(_0xa2c2x5){return handleError(_0xa2c2x4,_0xa2c2x5)})};exports[_0xa562[17]]=function(_0xa2c2x3,_0xa2c2x4){if(_0xa2c2x3[_0xa562[16]][_0xa562[12]]){delete _0xa2c2x3[_0xa562[16]][_0xa562[12]]};return MailServerIn[_0xa562[14]](_0xa2c2x3[_0xa562[13]][_0xa562[12]])[_0xa562[8]](function(_0xa2c2x7){if(!_0xa2c2x7){return _0xa2c2x4[_0xa562[11]](404)};var _0xa2c2x8=_[_0xa562[19]](_0xa2c2x7,_0xa2c2x3[_0xa562[16]]);_0xa2c2x8[_0xa562[20]]()[_0xa562[8]](function(){return _0xa2c2x4[_0xa562[7]](200)[_0xa562[6]](_0xa2c2x7)})[_0xa562[5]](function(_0xa2c2x5){console[_0xa562[18]](_0xa2c2x5);return handleError(_0xa2c2x4,_0xa2c2x5);});})[_0xa562[5]](function(_0xa2c2x5){console[_0xa562[18]](_0xa2c2x5);return handleError(_0xa2c2x4,_0xa2c2x5);});};exports[_0xa562[21]]=function(_0xa2c2x3,_0xa2c2x4){MailServerIn[_0xa562[14]](_0xa2c2x3[_0xa562[13]][_0xa562[12]])[_0xa562[8]](function(_0xa2c2x7){if(!_0xa2c2x7){return _0xa2c2x4[_0xa562[11]](404)};_0xa2c2x7[_0xa562[21]]()[_0xa562[8]](function(){return _0xa2c2x4[_0xa562[11]](204)})[_0xa562[5]](function(_0xa2c2x5){return handleError(_0xa2c2x4,_0xa2c2x5)});})[_0xa562[5]](function(_0xa2c2x5){return handleError(_0xa2c2x4,_0xa2c2x5)})};function handleError(_0xa2c2x4,_0xa2c2x5){return _0xa2c2x4[_0xa562[7]](500)[_0xa562[6]](_0xa2c2x5)} \ No newline at end of file diff --git a/server/api/mail_server_in/mail_server_in.socket.js b/server/api/mail_server_in/mail_server_in.socket.js index 811977e..25cbac2 100644 --- a/server/api/mail_server_in/mail_server_in.socket.js +++ b/server/api/mail_server_in/mail_server_in.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var MailServerIn = require('../../models').MailServerIn; - -exports.register = function(socket) { - MailServerIn.afterCreate(function(doc) { - onSave(socket, doc); - }); - MailServerIn.afterUpdate(function(doc) { - onSave(socket, doc); - }); - MailServerIn.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_server_in:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_server_in:remove', doc); -} +var _0xac7c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x69\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x69\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0xac7c[0];var MailServerIn=require(_0xac7c[2])[_0xac7c[1]];exports[_0xac7c[3]]=function(_0xa555x2){MailServerIn[_0xac7c[4]](function(_0xa555x3){onSave(_0xa555x2,_0xa555x3)});MailServerIn[_0xac7c[5]](function(_0xa555x3){onSave(_0xa555x2,_0xa555x3)});MailServerIn[_0xac7c[6]](function(_0xa555x3){onRemove(_0xa555x2,_0xa555x3)});};function onSave(_0xa555x2,_0xa555x3,_0xa555x5){_0xa555x2[_0xac7c[8]](_0xac7c[7],_0xa555x3)}function onRemove(_0xa555x2,_0xa555x3,_0xa555x5){_0xa555x2[_0xac7c[8]](_0xac7c[9],_0xa555x3)} \ No newline at end of file diff --git a/server/api/mail_server_out/index.js b/server/api/mail_server_out/index.js index 687b16c..4f78a3a 100644 --- a/server/api/mail_server_out/index.js +++ b/server/api/mail_server_out/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_server_out.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/service', controller.indexService); -router.get('/:id', controller.show); -router.get('/:id/test', controller.test); -router.post('/', controller.create); -router.post('/test', controller.test); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x9ed3=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x6F\x75\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x73\x65\x72\x76\x69\x63\x65","\x69\x6E\x64\x65\x78\x53\x65\x72\x76\x69\x63\x65","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x74\x65\x73\x74","\x74\x65\x73\x74","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x74\x65\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x9ed3[0];var express=require(_0x9ed3[1]);var controller=require(_0x9ed3[2]);var router=express.Router();router[_0x9ed3[5]](_0x9ed3[3],controller[_0x9ed3[4]]);router[_0x9ed3[5]](_0x9ed3[6],controller[_0x9ed3[7]]);router[_0x9ed3[5]](_0x9ed3[8],controller[_0x9ed3[9]]);router[_0x9ed3[5]](_0x9ed3[10],controller[_0x9ed3[11]]);router[_0x9ed3[13]](_0x9ed3[3],controller[_0x9ed3[12]]);router[_0x9ed3[13]](_0x9ed3[14],controller[_0x9ed3[11]]);router[_0x9ed3[16]](_0x9ed3[8],controller[_0x9ed3[15]]);router[_0x9ed3[17]](_0x9ed3[8],controller[_0x9ed3[15]]);router[_0x9ed3[19]](_0x9ed3[8],controller[_0x9ed3[18]]);module[_0x9ed3[20]]=router; \ No newline at end of file diff --git a/server/api/mail_server_out/mail_server_out.controller.js b/server/api/mail_server_out/mail_server_out.controller.js index 8bcbcb5..512ea91 100644 --- a/server/api/mail_server_out/mail_server_out.controller.js +++ b/server/api/mail_server_out/mail_server_out.controller.js @@ -1,165 +1 @@ -'use strict'; - -var _ = require('lodash'); -var MailServerOut = require('../../models').MailServerOut; -var MailMessage = require('../../models').MailMessage; -var sequelize = require('../../models').sequelize; - -// Get list of mailServerOuts -exports.index = function (req, res) { - MailServerOut - .findAll() - .then(function (mailServerOuts) { - return res.status(200).send(mailServerOuts); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -exports.indexService = function (req, res) { - MailServerOut - .findAll({ - where: { - service: true - } - }) - .then(function (mailServerOuts) { - return res.status(200).send(mailServerOuts); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single mailServerOut -exports.show = function (req, res) { - MailServerOut - .findById(req.params.id) - .then(function (mailServerOut) { - if (!mailServerOut) { - return res.sendStatus(404); - } - return res.send(mailServerOut); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new mailServerOut in the DB. -exports.create = function (req, res) { - MailServerOut - .create(req.body) - .then(function (mailServerOut) { - return res.status(201).send(mailServerOut); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing mailServerOut in the DB. -exports.update = function (req, res) { - - if (req.body.id) { - delete req.body.id; - } - MailServerOut - .findById(req.params.id) - .then(function (mailServerOut) { - if (!mailServerOut) { - return res.sendStatus(404); - } - var updated = _.merge(mailServerOut, req.body); - updated - .save() - .then(function () { - return res.status(200).send(mailServerOut); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a mailServerOut from the DB. -exports.destroy = function (req, res) { - MailServerOut - .findById(req.params.id) - .then(function (mailServerOut) { - if (!mailServerOut) { - return res.sendStatus(404); - } - mailServerOut - .destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -exports.test = function (req, res) { - return sequelize.transaction().then(function (t) { - var _mailServerOut; - var _mailMessage; - - return MailServerOut - .findById(req.params.id) - .then(function (mailServerOut) { - if (!mailServerOut) { - t.rollback(); - return res.sendStatus(404); - } else { - return mailServerOut; - } - }) - .then(function (mailServerOut) { - _mailServerOut = mailServerOut; - return MailMessage - .create({ - subject: 'MailAccount ' + mailServerOut.username + ' test..', - text: 'MailAccount ' + mailServerOut.username + ' test..', - from: mailServerOut.username, - to: mailServerOut.username, - status: 'SENDING' - }, { - transaction: t - }); - }) - .then(function (mailMessage) { - _mailMessage = mailMessage; - return _mailServerOut - .update({ - state: 'CONNECTED', - }); - }) - .then(function () { - t.commit(); - return res.status(201).send(_mailMessage); - }) - .catch(function (err) { - _mailServerOut - .update({ - state: 'ERROR', - }) - .then(function () { - t.rollback(); - return handleError(res, err); - }) - }); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x14cc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x69\x6E\x64\x65\x78\x53\x65\x72\x76\x69\x63\x65","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x74\x65\x73\x74","\x72\x6F\x6C\x6C\x62\x61\x63\x6B","\x45\x52\x52\x4F\x52","\x63\x6F\x6D\x6D\x69\x74","\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x20","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x20\x74\x65\x73\x74\x2E\x2E","\x53\x45\x4E\x44\x49\x4E\x47","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E"];_0x14cc[0];var _=require(_0x14cc[1]);var MailServerOut=require(_0x14cc[3])[_0x14cc[2]];var MailMessage=require(_0x14cc[3])[_0x14cc[4]];var sequelize=require(_0x14cc[3])[_0x14cc[5]];exports[_0x14cc[6]]=function(_0x5d4bx5,_0x5d4bx6){MailServerOut[_0x14cc[11]]()[_0x14cc[10]](function(_0x5d4bx8){return _0x5d4bx6[_0x14cc[9]](200)[_0x14cc[8]](_0x5d4bx8)})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)})};exports[_0x14cc[12]]=function(_0x5d4bx5,_0x5d4bx6){MailServerOut[_0x14cc[11]]({where:{service:true}})[_0x14cc[10]](function(_0x5d4bx8){return _0x5d4bx6[_0x14cc[9]](200)[_0x14cc[8]](_0x5d4bx8)})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)})};exports[_0x14cc[13]]=function(_0x5d4bx5,_0x5d4bx6){MailServerOut[_0x14cc[17]](_0x5d4bx5[_0x14cc[16]][_0x14cc[15]])[_0x14cc[10]](function(_0x5d4bx9){if(!_0x5d4bx9){return _0x5d4bx6[_0x14cc[14]](404)};return _0x5d4bx6[_0x14cc[8]](_0x5d4bx9);})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)})};exports[_0x14cc[18]]=function(_0x5d4bx5,_0x5d4bx6){MailServerOut[_0x14cc[18]](_0x5d4bx5[_0x14cc[19]])[_0x14cc[10]](function(_0x5d4bx9){return _0x5d4bx6[_0x14cc[9]](201)[_0x14cc[8]](_0x5d4bx9)})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)})};exports[_0x14cc[20]]=function(_0x5d4bx5,_0x5d4bx6){if(_0x5d4bx5[_0x14cc[19]][_0x14cc[15]]){delete _0x5d4bx5[_0x14cc[19]][_0x14cc[15]]};MailServerOut[_0x14cc[17]](_0x5d4bx5[_0x14cc[16]][_0x14cc[15]])[_0x14cc[10]](function(_0x5d4bx9){if(!_0x5d4bx9){return _0x5d4bx6[_0x14cc[14]](404)};var _0x5d4bxa=_[_0x14cc[21]](_0x5d4bx9,_0x5d4bx5[_0x14cc[19]]);_0x5d4bxa[_0x14cc[22]]()[_0x14cc[10]](function(){return _0x5d4bx6[_0x14cc[9]](200)[_0x14cc[8]](_0x5d4bx9)})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)});})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)});};exports[_0x14cc[23]]=function(_0x5d4bx5,_0x5d4bx6){MailServerOut[_0x14cc[17]](_0x5d4bx5[_0x14cc[16]][_0x14cc[15]])[_0x14cc[10]](function(_0x5d4bx9){if(!_0x5d4bx9){return _0x5d4bx6[_0x14cc[14]](404)};_0x5d4bx9[_0x14cc[23]]()[_0x14cc[10]](function(){return _0x5d4bx6[_0x14cc[14]](204)})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)});})[_0x14cc[7]](function(_0x5d4bx7){return handleError(_0x5d4bx6,_0x5d4bx7)})};exports[_0x14cc[24]]=function(_0x5d4bx5,_0x5d4bx6){return sequelize[_0x14cc[33]]()[_0x14cc[10]](function(_0x5d4bxb){var _0x5d4bxc;var _0x5d4bxd;return MailServerOut[_0x14cc[17]](_0x5d4bx5[_0x14cc[16]][_0x14cc[15]])[_0x14cc[10]](function(_0x5d4bx9){if(!_0x5d4bx9){_0x5d4bxb[_0x14cc[25]]();return _0x5d4bx6[_0x14cc[14]](404);}else {return _0x5d4bx9}})[_0x14cc[10]](function(_0x5d4bx9){_0x5d4bxc=_0x5d4bx9;return MailMessage[_0x14cc[18]]({subject:_0x14cc[29]+_0x5d4bx9[_0x14cc[30]]+_0x14cc[31],text:_0x14cc[29]+_0x5d4bx9[_0x14cc[30]]+_0x14cc[31],from:_0x5d4bx9[_0x14cc[30]],to:_0x5d4bx9[_0x14cc[30]],status:_0x14cc[32]},{transaction:_0x5d4bxb});})[_0x14cc[10]](function(_0x5d4bxe){_0x5d4bxd=_0x5d4bxe;return _0x5d4bxc[_0x14cc[20]]({state:_0x14cc[28]});})[_0x14cc[10]](function(){_0x5d4bxb[_0x14cc[27]]();return _0x5d4bx6[_0x14cc[9]](201)[_0x14cc[8]](_0x5d4bxd);})[_0x14cc[7]](function(_0x5d4bx7){_0x5d4bxc[_0x14cc[20]]({state:_0x14cc[26]})[_0x14cc[10]](function(){_0x5d4bxb[_0x14cc[25]]();return handleError(_0x5d4bx6,_0x5d4bx7);})});})};function handleError(_0x5d4bx6,_0x5d4bx7){return _0x5d4bx6[_0x14cc[9]](500)[_0x14cc[8]](_0x5d4bx7)} \ No newline at end of file diff --git a/server/api/mail_server_out/mail_server_out.socket.js b/server/api/mail_server_out/mail_server_out.socket.js index d9e6e91..c025682 100644 --- a/server/api/mail_server_out/mail_server_out.socket.js +++ b/server/api/mail_server_out/mail_server_out.socket.js @@ -1,26 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var MailServerOut = require('../../models').MailServerOut; - -exports.register = function(socket) { - MailServerOut.afterCreate(function(doc) { - console.log('MailServerOut afterCreate'); - onSave(socket, doc); - }); - MailServerOut.afterDestroy(function(doc) { - console.log('MailServerOut afterDestroy'); - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_server_out:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_server_out:remove', doc); -} +var _0x6203=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74\x20\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x6C\x6F\x67","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74\x20\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x6F\x75\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x6F\x75\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x6203[0];var MailServerOut=require(_0x6203[2])[_0x6203[1]];exports[_0x6203[3]]=function(_0x904ax2){MailServerOut[_0x6203[6]](function(_0x904ax3){console[_0x6203[5]](_0x6203[4]);onSave(_0x904ax2,_0x904ax3);});MailServerOut[_0x6203[8]](function(_0x904ax3){console[_0x6203[5]](_0x6203[7]);onRemove(_0x904ax2,_0x904ax3);});};function onSave(_0x904ax2,_0x904ax3,_0x904ax5){_0x904ax2[_0x6203[10]](_0x6203[9],_0x904ax3)}function onRemove(_0x904ax2,_0x904ax3,_0x904ax5){_0x904ax2[_0x6203[10]](_0x6203[11],_0x904ax3)} \ No newline at end of file diff --git a/server/api/mail_template/index.js b/server/api/mail_template/index.js index cb8e0b2..310546b 100644 --- a/server/api/mail_template/index.js +++ b/server/api/mail_template/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./mail_template.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xb1f0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x61\x69\x6C\x5F\x74\x65\x6D\x70\x6C\x61\x74\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xb1f0[0];var express=require(_0xb1f0[1]);var controller=require(_0xb1f0[2]);var router=express.Router();router[_0xb1f0[5]](_0xb1f0[3],controller[_0xb1f0[4]]);router[_0xb1f0[5]](_0xb1f0[6],controller[_0xb1f0[7]]);router[_0xb1f0[9]](_0xb1f0[3],controller[_0xb1f0[8]]);router[_0xb1f0[11]](_0xb1f0[6],controller[_0xb1f0[10]]);router[_0xb1f0[12]](_0xb1f0[6],controller[_0xb1f0[10]]);router[_0xb1f0[14]](_0xb1f0[6],controller[_0xb1f0[13]]);module[_0xb1f0[15]]=router; \ No newline at end of file diff --git a/server/api/mail_template/mail_template.controller.js b/server/api/mail_template/mail_template.controller.js index cb8ae52..332aaf2 100644 --- a/server/api/mail_template/mail_template.controller.js +++ b/server/api/mail_template/mail_template.controller.js @@ -1,150 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var MailTemplate = require('../../models').MailTemplate; - -// Get list of mail_templates -// Get list of mailQueues -exports.index = function (req, res) { - - var attributes = ['description', 'name', 'timeout', 'strategy']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page, - include: [{ - all: true - }] - }; - - _.forIn(req.query, function (value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function (attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - MailTemplate - .findAndCountAll(query) - .then(function (result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single mail_template -exports.show = function (req, res) { - MailTemplate - .findById(req.params.id) - .then(function (mail_template) { - if (!mail_template) { - return res.sendStatus(404); - } - return res.send(mail_template); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new mail_template in the DB. -exports.create = function (req, res) { - MailTemplate - .create(req.body) - .then(function (mail_template) { - return res.status(201).send(mail_template); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing mail_template in the DB. -exports.update = function (req, res) { - if (req.body.id) { - delete req.body.id; - } - MailTemplate - .findById(req.params.id) - .then(function (mail_template) { - if (!mail_template) { - return res.sendStatus(404); - } - var updated = _.merge(mail_template, req.body); - updated.save() - .then(function () { - return res.status(200).send(mail_template); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a mail_template from the DB. -exports.destroy = function (req, res) { - MailTemplate - .findById(req.params.id) - .then(function (mail_template) { - if (!mail_template) { - return res.sendStatus(404); - } - mail_template.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xd0d7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x4D\x61\x69\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x74\x69\x6D\x65\x6F\x75\x74","\x73\x74\x72\x61\x74\x65\x67\x79","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xd0d7[0];var _=require(_0xd0d7[1]);var util=require(_0xd0d7[2]);var MailTemplate=require(_0xd0d7[4])[_0xd0d7[3]];exports[_0xd0d7[5]]=function(_0x590ax4,_0x590ax5){var _0x590ax6=[_0xd0d7[6],_0xd0d7[7],_0xd0d7[8],_0xd0d7[9]];var _0x590ax7=_0x590ax4[_0xd0d7[11]][_0xd0d7[10]]?parseInt(_0x590ax4[_0xd0d7[11]][_0xd0d7[10]],10):100;var _0x590ax8=_0x590ax4[_0xd0d7[11]][_0xd0d7[12]]?parseInt(_0x590ax4[_0xd0d7[11]][_0xd0d7[12]],10):0;var _0x590ax9={where:{},limit:_0x590ax7,offset:_0x590ax8*_0x590ax7,include:[{all:true}]};_[_0xd0d7[26]](_0x590ax4[_0xd0d7[11]],function(_0x590axa,_0x590axb){switch(_0x590axb){case _0xd0d7[10]:;case _0xd0d7[12]:break ;;case _0xd0d7[15]:_0x590ax9[_0xd0d7[13]]=util[_0xd0d7[18]](_0xd0d7[14],_0x590ax4[_0xd0d7[11]][_0xd0d7[15]],_0x590ax4[_0xd0d7[11]][_0xd0d7[16]]||_0xd0d7[17])||null;break ;;case _0xd0d7[16]:break ;;case _0xd0d7[24]:_0x590ax9[_0xd0d7[20]][_0xd0d7[19]]=[];_0x590ax6[_0xd0d7[23]](function(_0x590axc){var _0x590axd={};_0x590axd[_0x590axc]={$like:_0xd0d7[21]+_0x590axa+_0xd0d7[21]};_0x590ax9[_0xd0d7[20]][_0xd0d7[19]][_0xd0d7[22]](_0x590axd);});break ;;default:_0x590ax9[_0xd0d7[20]][_0x590axb]={$like:{}};_0x590ax9[_0xd0d7[20]][_0x590axb][_0xd0d7[25]]=_0xd0d7[21]+_0x590axa+_0xd0d7[21];;}});MailTemplate[_0xd0d7[40]](_0x590ax9)[_0xd0d7[39]](function(_0x590axf){var _0x590ax10=Math[_0xd0d7[29]](_0x590axf[_0xd0d7[28]]/_0x590ax7);var _0x590ax11=_0x590ax10>(_0x590ax9[_0xd0d7[30]]+1)?util[_0xd0d7[18]](_0xd0d7[31],_0x590ax4[_0xd0d7[32]],_0x590ax4[_0xd0d7[34]][_0xd0d7[33]],_0x590ax4[_0xd0d7[35]],_0x590ax8+1):null;var _0x590ax12=_0x590ax8>0?util[_0xd0d7[18]](_0xd0d7[31],_0x590ax4[_0xd0d7[32]],_0x590ax4[_0xd0d7[34]][_0xd0d7[33]],_0x590ax4[_0xd0d7[35]],_0x590ax8-1):null;_0x590ax5[_0xd0d7[38]](200)[_0xd0d7[37]]({count:_0x590axf[_0xd0d7[28]],rows:_0x590axf[_0xd0d7[36]],next_page:_0x590ax11,previous_page:_0x590ax12,total_pages:_0x590ax10});})[_0xd0d7[27]](function(_0x590axe){return handleError(_0x590ax5,_0x590axe)});};exports[_0xd0d7[41]]=function(_0x590ax4,_0x590ax5){MailTemplate[_0xd0d7[45]](_0x590ax4[_0xd0d7[44]][_0xd0d7[43]])[_0xd0d7[39]](function(_0x590ax13){if(!_0x590ax13){return _0x590ax5[_0xd0d7[42]](404)};return _0x590ax5[_0xd0d7[37]](_0x590ax13);})[_0xd0d7[27]](function(_0x590axe){return handleError(_0x590ax5,_0x590axe)})};exports[_0xd0d7[46]]=function(_0x590ax4,_0x590ax5){MailTemplate[_0xd0d7[46]](_0x590ax4[_0xd0d7[47]])[_0xd0d7[39]](function(_0x590ax13){return _0x590ax5[_0xd0d7[38]](201)[_0xd0d7[37]](_0x590ax13)})[_0xd0d7[27]](function(_0x590axe){return handleError(_0x590ax5,_0x590axe)})};exports[_0xd0d7[48]]=function(_0x590ax4,_0x590ax5){if(_0x590ax4[_0xd0d7[47]][_0xd0d7[43]]){delete _0x590ax4[_0xd0d7[47]][_0xd0d7[43]]};MailTemplate[_0xd0d7[45]](_0x590ax4[_0xd0d7[44]][_0xd0d7[43]])[_0xd0d7[39]](function(_0x590ax13){if(!_0x590ax13){return _0x590ax5[_0xd0d7[42]](404)};var _0x590ax14=_[_0xd0d7[49]](_0x590ax13,_0x590ax4[_0xd0d7[47]]);_0x590ax14[_0xd0d7[50]]()[_0xd0d7[39]](function(){return _0x590ax5[_0xd0d7[38]](200)[_0xd0d7[37]](_0x590ax13)})[_0xd0d7[27]](function(_0x590axe){return handleError(_0x590ax5,_0x590axe)});})[_0xd0d7[27]](function(_0x590axe){return handleError(_0x590ax5,_0x590axe)});};exports[_0xd0d7[51]]=function(_0x590ax4,_0x590ax5){MailTemplate[_0xd0d7[45]](_0x590ax4[_0xd0d7[44]][_0xd0d7[43]])[_0xd0d7[39]](function(_0x590ax13){if(!_0x590ax13){return _0x590ax5[_0xd0d7[42]](404)};_0x590ax13[_0xd0d7[51]]()[_0xd0d7[39]](function(){return _0x590ax5[_0xd0d7[42]](204)})[_0xd0d7[27]](function(_0x590axe){return handleError(_0x590ax5,_0x590axe)});})[_0xd0d7[27]](function(_0x590axe){return handleError(_0x590ax5,_0x590axe)})};function handleError(_0x590ax5,_0x590axe){return _0x590ax5[_0xd0d7[38]](500)[_0xd0d7[37]](_0x590axe)} \ No newline at end of file diff --git a/server/api/mail_template/mail_template.socket.js b/server/api/mail_template/mail_template.socket.js index a01fb2e..c57f0a0 100644 --- a/server/api/mail_template/mail_template.socket.js +++ b/server/api/mail_template/mail_template.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var MailTemplate = require('../../models').MailTemplate; - -exports.register = function(socket) { - MailTemplate.afterCreate(function (doc) { - onSave(socket, doc); - }); - MailTemplate.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('mail_template:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('mail_template:remove', doc); -} +var _0x5ad1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x61\x69\x6C\x5F\x74\x65\x6D\x70\x6C\x61\x74\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x61\x69\x6C\x5F\x74\x65\x6D\x70\x6C\x61\x74\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x5ad1[0];var MailTemplate=require(_0x5ad1[2])[_0x5ad1[1]];exports[_0x5ad1[3]]=function(_0xfe73x2){MailTemplate[_0x5ad1[4]](function(_0xfe73x3){onSave(_0xfe73x2,_0xfe73x3)});MailTemplate[_0x5ad1[5]](function(_0xfe73x3){onRemove(_0xfe73x2,_0xfe73x3)});};function onSave(_0xfe73x2,_0xfe73x3,_0xfe73x5){_0xfe73x2[_0x5ad1[7]](_0x5ad1[6],_0xfe73x3)}function onRemove(_0xfe73x2,_0xfe73x3,_0xfe73x5){_0xfe73x2[_0x5ad1[7]](_0x5ad1[8],_0xfe73x3)} \ No newline at end of file diff --git a/server/api/metric/index.js b/server/api/metric/index.js index 41fcceb..f8ec037 100644 --- a/server/api/metric/index.js +++ b/server/api/metric/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./metric.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.metricValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x91bb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x65\x74\x72\x69\x63\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x6D\x65\x74\x72\x69\x63\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x91bb[0];var express=require(_0x91bb[1]);var controller=require(_0x91bb[2]);var auth=require(_0x91bb[3]);var router=express.Router();router[_0x91bb[7]](_0x91bb[4],auth[_0x91bb[5]](),controller[_0x91bb[6]]);router[_0x91bb[7]](_0x91bb[8],auth[_0x91bb[5]](),controller[_0x91bb[9]]);router[_0x91bb[11]](_0x91bb[4],auth[_0x91bb[5]](),controller[_0x91bb[10]]);router[_0x91bb[11]](_0x91bb[12],auth[_0x91bb[5]](),controller[_0x91bb[13]]);router[_0x91bb[15]](_0x91bb[8],auth[_0x91bb[5]](),controller[_0x91bb[14]]);router[_0x91bb[16]](_0x91bb[8],auth[_0x91bb[5]](),controller[_0x91bb[14]]);router[_0x91bb[18]](_0x91bb[4],auth[_0x91bb[5]](),controller[_0x91bb[17]]);router[_0x91bb[18]](_0x91bb[8],auth[_0x91bb[5]](),controller[_0x91bb[19]]);module[_0x91bb[20]]=router; \ No newline at end of file diff --git a/server/api/metric/metric.controller.js b/server/api/metric/metric.controller.js index c6ef1d7..e39e282 100644 --- a/server/api/metric/metric.controller.js +++ b/server/api/metric/metric.controller.js @@ -1,220 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Metric = require('../../models').Metric; -var util = require('util'); - -// Get list of metrics -exports.index = function(req, res) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Metric - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -exports.metricValidation = function(req, res) { - console.log(req.body); - Metric - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(metrics) { - if (!metrics) { - return res.sendStatus(404); - } - return res.send(metrics); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single metric -exports.show = function(req, res) { - Metric - .findById(req.params.id) - .then(function(metric) { - if (!metric) { - return res.sendStatus(404); - } - return res.send(metric); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new metric in the DB. -exports.create = function(req, res) { - Metric - .create(req.body) - .then(function(metric) { - return res.status(201).send(metric); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing metric in the DB. -exports.update = function(req, res) { - Metric - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(metrics) { - if (!metrics) { - return res.sendStatus(404); - } - if (metrics.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_METRIC' - }) - } - if (req.body.id) { - delete req.body.id; - } - Metric - .find({ - where: { - id: req.params.id - } - }) - .then(function(metric) { - if (!metric) { - return res.sendStatus(404); - } - var updated = _.merge(metric, req.body); - updated.save() - .then(function() { - return res.status(200).send(metric); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a metric from the DB. -exports.destroy = function(req, res) { - Metric - .findById(req.params.id) - .then(function(metric) { - if (!metric) { - return res.sendStatus(404); - } - metric.getZendeskTexts() - .then(function(texts) { - if (texts.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_METRIC_CONFIGURATION_ASSOCIATED' - }); - } - metric.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDestroy = function(req, res) { - Metric - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x37ae=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x4D\x65\x74\x72\x69\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x6D\x65\x74\x72\x69\x63\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x4D\x45\x54\x52\x49\x43","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x4D\x45\x54\x52\x49\x43\x5F\x43\x4F\x4E\x46\x49\x47\x55\x52\x41\x54\x49\x4F\x4E\x5F\x41\x53\x53\x4F\x43\x49\x41\x54\x45\x44","\x67\x65\x74\x5A\x65\x6E\x64\x65\x73\x6B\x54\x65\x78\x74\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x37ae[0];var _=require(_0x37ae[1]);var Metric=require(_0x37ae[3])[_0x37ae[2]];var util=require(_0x37ae[4]);exports[_0x37ae[5]]=function(_0x8e30x4,_0x8e30x5){var _0x8e30x6=[_0x37ae[6],_0x37ae[7]];var _0x8e30x7=_0x8e30x4[_0x37ae[9]][_0x37ae[8]]?parseInt(_0x8e30x4[_0x37ae[9]][_0x37ae[8]],10):100;var _0x8e30x8=_0x8e30x4[_0x37ae[9]][_0x37ae[10]]?parseInt(_0x8e30x4[_0x37ae[9]][_0x37ae[10]],10):0;var _0x8e30x9={where:{},limit:_0x8e30x7,offset:_0x8e30x8*_0x8e30x7};_[_0x37ae[24]](_0x8e30x4[_0x37ae[9]],function(_0x8e30xa,_0x8e30xb){switch(_0x8e30xb){case _0x37ae[8]:;case _0x37ae[10]:break ;;case _0x37ae[13]:_0x8e30x9[_0x37ae[11]]=util[_0x37ae[16]](_0x37ae[12],_0x8e30x4[_0x37ae[9]][_0x37ae[13]],_0x8e30x4[_0x37ae[9]][_0x37ae[14]]||_0x37ae[15])||null;break ;;case _0x37ae[14]:break ;;case _0x37ae[22]:_0x8e30x9[_0x37ae[18]][_0x37ae[17]]=[];_0x8e30x6[_0x37ae[21]](function(_0x8e30xc){var _0x8e30xd={};_0x8e30xd[_0x8e30xc]={$like:_0x37ae[19]+_0x8e30xa+_0x37ae[19]};_0x8e30x9[_0x37ae[18]][_0x37ae[17]][_0x37ae[20]](_0x8e30xd);});break ;;default:_0x8e30x9[_0x37ae[18]][_0x8e30xb]={$like:{}};_0x8e30x9[_0x37ae[18]][_0x8e30xb][_0x37ae[23]]=_0x37ae[19]+_0x8e30xa+_0x37ae[19];;}});Metric[_0x37ae[39]](_0x8e30x9)[_0x37ae[38]](function(_0x8e30xf){var _0x8e30x10=Math[_0x37ae[30]](_0x8e30xf[_0x37ae[29]]/_0x8e30x7);var _0x8e30x11=_0x8e30x10>(_0x8e30x9[_0x37ae[31]]+1)?util[_0x37ae[16]](_0x37ae[32],_0x8e30x4[_0x37ae[33]],_0x8e30x4[_0x37ae[35]][_0x37ae[34]],_0x8e30x4[_0x37ae[36]],_0x8e30x8+1):null;var _0x8e30x12=_0x8e30x8>0?util[_0x37ae[16]](_0x37ae[32],_0x8e30x4[_0x37ae[33]],_0x8e30x4[_0x37ae[35]][_0x37ae[34]],_0x8e30x4[_0x37ae[36]],_0x8e30x8-1):null;_0x8e30x5[_0x37ae[27]](200)[_0x37ae[26]]({count:_0x8e30xf[_0x37ae[29]],rows:_0x8e30xf[_0x37ae[37]],next_page:_0x8e30x11,previous_page:_0x8e30x12,total_pages:_0x8e30x10});})[_0x37ae[28]](function(_0x8e30xe){_0x8e30x5[_0x37ae[27]](500)[_0x37ae[26]]({error:_0x37ae[25]})});};exports[_0x37ae[40]]=function(_0x8e30x4,_0x8e30x5){console[_0x37ae[42]](_0x8e30x4[_0x37ae[41]]);Metric[_0x37ae[44]]({where:{name:_0x8e30x4[_0x37ae[41]][_0x37ae[6]]}})[_0x37ae[38]](function(_0x8e30x13){if(!_0x8e30x13){return _0x8e30x5[_0x37ae[43]](404)};return _0x8e30x5[_0x37ae[26]](_0x8e30x13);})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)});};exports[_0x37ae[45]]=function(_0x8e30x4,_0x8e30x5){Metric[_0x37ae[48]](_0x8e30x4[_0x37ae[47]][_0x37ae[46]])[_0x37ae[38]](function(_0x8e30x14){if(!_0x8e30x14){return _0x8e30x5[_0x37ae[43]](404)};return _0x8e30x5[_0x37ae[26]](_0x8e30x14);})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)})};exports[_0x37ae[49]]=function(_0x8e30x4,_0x8e30x5){Metric[_0x37ae[49]](_0x8e30x4[_0x37ae[41]])[_0x37ae[38]](function(_0x8e30x14){return _0x8e30x5[_0x37ae[27]](201)[_0x37ae[26]](_0x8e30x14)})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)})};exports[_0x37ae[50]]=function(_0x8e30x4,_0x8e30x5){Metric[_0x37ae[44]]({where:{name:_0x8e30x4[_0x37ae[41]][_0x37ae[6]],id:{$ne:_0x8e30x4[_0x37ae[41]][_0x37ae[46]]}}})[_0x37ae[38]](function(_0x8e30x13){if(!_0x8e30x13){return _0x8e30x5[_0x37ae[43]](404)};if(_0x8e30x13[_0x37ae[51]]>0){return _0x8e30x5[_0x37ae[27]](500)[_0x37ae[26]]({message:_0x37ae[52]})};if(_0x8e30x4[_0x37ae[41]][_0x37ae[46]]){delete _0x8e30x4[_0x37ae[41]][_0x37ae[46]]};Metric[_0x37ae[55]]({where:{id:_0x8e30x4[_0x37ae[47]][_0x37ae[46]]}})[_0x37ae[38]](function(_0x8e30x14){if(!_0x8e30x14){return _0x8e30x5[_0x37ae[43]](404)};var _0x8e30x15=_[_0x37ae[53]](_0x8e30x14,_0x8e30x4[_0x37ae[41]]);_0x8e30x15[_0x37ae[54]]()[_0x37ae[38]](function(){return _0x8e30x5[_0x37ae[27]](200)[_0x37ae[26]](_0x8e30x14)})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)});})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)});})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)})};exports[_0x37ae[56]]=function(_0x8e30x4,_0x8e30x5){Metric[_0x37ae[48]](_0x8e30x4[_0x37ae[47]][_0x37ae[46]])[_0x37ae[38]](function(_0x8e30x14){if(!_0x8e30x14){return _0x8e30x5[_0x37ae[43]](404)};_0x8e30x14[_0x37ae[58]]()[_0x37ae[38]](function(_0x8e30x16){if(_0x8e30x16[_0x37ae[51]]>0){return _0x8e30x5[_0x37ae[27]](500)[_0x37ae[26]]({message:_0x37ae[57]})};_0x8e30x14[_0x37ae[56]]()[_0x37ae[38]](function(){return _0x8e30x5[_0x37ae[43]](204)})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)});})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)});})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)})};exports[_0x37ae[59]]=function(_0x8e30x4,_0x8e30x5){Metric[_0x37ae[56]]({where:{id:_0x8e30x4[_0x37ae[9]][_0x37ae[46]]},individualHooks:true})[_0x37ae[38]](function(){return _0x8e30x5[_0x37ae[43]](204)})[_0x37ae[28]](function(_0x8e30xe){return handleError(_0x8e30x5,_0x8e30xe)})};function handleError(_0x8e30x5,_0x8e30xe){return _0x8e30x5[_0x37ae[27]](500)[_0x37ae[26]](_0x8e30xe)} \ No newline at end of file diff --git a/server/api/metric/metric.socket.js b/server/api/metric/metric.socket.js index 059ce9c..bb92df5 100644 --- a/server/api/metric/metric.socket.js +++ b/server/api/metric/metric.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Metric = require('../../models').Metric; - -exports.register = function(socket) { - Metric.afterCreate(function(doc) { - onSave(socket, doc); - }); - Metric.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('metric:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('metric:remove', doc); -} +var _0x372f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x65\x74\x72\x69\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x65\x74\x72\x69\x63\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x65\x74\x72\x69\x63\x3A\x72\x65\x6D\x6F\x76\x65"];_0x372f[0];var Metric=require(_0x372f[2])[_0x372f[1]];exports[_0x372f[3]]=function(_0xec51x2){Metric[_0x372f[4]](function(_0xec51x3){onSave(_0xec51x2,_0xec51x3)});Metric[_0x372f[5]](function(_0xec51x3){onRemove(_0xec51x2,_0xec51x3)});};function onSave(_0xec51x2,_0xec51x3,_0xec51x5){_0xec51x2[_0x372f[7]](_0x372f[6],_0xec51x3)}function onRemove(_0xec51x2,_0xec51x3,_0xec51x5){_0xec51x2[_0x372f[7]](_0x372f[8],_0xec51x3)} \ No newline at end of file diff --git a/server/api/metric/metric.spec.js b/server/api/metric/metric.spec.js index 076cab1..bf848ca 100644 --- a/server/api/metric/metric.spec.js +++ b/server/api/metric/metric.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/analytics/metrics', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/analytics/metrics') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x65bb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x6D\x65\x74\x72\x69\x63\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x6D\x65\x74\x72\x69\x63\x73","\x67\x65\x74"];_0x65bb[0];var should=require(_0x65bb[1]);var app=require(_0x65bb[2]);var request=require(_0x65bb[3]);describe(_0x65bb[4],function(){it(_0x65bb[5],function(_0xa785x4){request(app)[_0x65bb[13]](_0x65bb[12])[_0x65bb[11]](200)[_0x65bb[11]](_0x65bb[10],/json/)[_0x65bb[9]](function(_0xa785x5,_0xa785x6){if(_0xa785x5){return _0xa785x4(_0xa785x5)};_0xa785x6[_0x65bb[8]][_0x65bb[1]][_0x65bb[7]][_0x65bb[6]](Array);_0xa785x4();})})}); \ No newline at end of file diff --git a/server/api/module/index.js b/server/api/module/index.js index 8204682..f35304b 100644 --- a/server/api/module/index.js +++ b/server/api/module/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./module.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xedfc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x6F\x64\x75\x6C\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xedfc[0];var express=require(_0xedfc[1]);var controller=require(_0xedfc[2]);var router=express.Router();router[_0xedfc[5]](_0xedfc[3],controller[_0xedfc[4]]);router[_0xedfc[5]](_0xedfc[6],controller[_0xedfc[7]]);router[_0xedfc[9]](_0xedfc[3],controller[_0xedfc[8]]);router[_0xedfc[11]](_0xedfc[6],controller[_0xedfc[10]]);router[_0xedfc[12]](_0xedfc[6],controller[_0xedfc[10]]);router[_0xedfc[14]](_0xedfc[6],controller[_0xedfc[13]]);module[_0xedfc[15]]=router; \ No newline at end of file diff --git a/server/api/module/module.controller.js b/server/api/module/module.controller.js index 9d6517c..707bdf7 100644 --- a/server/api/module/module.controller.js +++ b/server/api/module/module.controller.js @@ -1,92 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Module = require('../../models').Module; - -// Get list of modules -exports.index = function(req, res) { - Module - .findAll() - .then(function (modules) { - return res.status(200).send(modules); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single module -exports.show = function(req, res) { - var moduleId = req.params.id; - - Module - .findById(moduleId) - .then(function (module) { - if(!module) { return res.sendStatus(404); } - return res.send(module); - }) - .catch(function(err){ - return handleError(res, err); - }); -}; - -// Creates a new module in the DB. -exports.create = function(req, res) { - Module - .create(req.body) - .then(function(module) { - return res.status(201).send(module); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing module in the DB. -exports.update = function(req, res) { - var moduleId = req.body.id; - - if(req.body.id) { delete req.body.id; } - - Module - .findById(moduleId) - .then(function (module) { - if(!module) { return res.sendStatus(404); } - var updated = _.merge(module, req.body); - updated.save() - .then(function () { - return res.status(200).send(module); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a module from the DB. -exports.destroy = function(req, res) { - var moduleId = req.params.id; - - Module - .findById(moduleId) - .then(function (module) { - if(!module) { return res.sendStatus(404); } - module.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x6087=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x4D\x6F\x64\x75\x6C\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x6087[0];var _=require(_0x6087[1]);var Module=require(_0x6087[3])[_0x6087[2]];exports[_0x6087[4]]=function(_0x995dx3,_0x995dx4){Module[_0x6087[9]]()[_0x6087[8]](function(_0x995dx6){return _0x995dx4[_0x6087[7]](200)[_0x6087[6]](_0x995dx6)})[_0x6087[5]](function(_0x995dx5){return handleError(_0x995dx4,_0x995dx5)})};exports[_0x6087[10]]=function(_0x995dx3,_0x995dx4){var _0x995dx7=_0x995dx3[_0x6087[12]][_0x6087[11]];Module[_0x6087[14]](_0x995dx7)[_0x6087[8]](function(_0x995dx8){if(!_0x995dx8){return _0x995dx4[_0x6087[13]](404)};return _0x995dx4[_0x6087[6]](_0x995dx8);})[_0x6087[5]](function(_0x995dx5){return handleError(_0x995dx4,_0x995dx5)});};exports[_0x6087[15]]=function(_0x995dx3,_0x995dx4){Module[_0x6087[15]](_0x995dx3[_0x6087[16]])[_0x6087[8]](function(_0x995dx8){return _0x995dx4[_0x6087[7]](201)[_0x6087[6]](_0x995dx8)})[_0x6087[5]](function(_0x995dx5){return handleError(_0x995dx4,_0x995dx5)})};exports[_0x6087[17]]=function(_0x995dx3,_0x995dx4){var _0x995dx7=_0x995dx3[_0x6087[16]][_0x6087[11]];if(_0x995dx3[_0x6087[16]][_0x6087[11]]){delete _0x995dx3[_0x6087[16]][_0x6087[11]]};Module[_0x6087[14]](_0x995dx7)[_0x6087[8]](function(_0x995dx8){if(!_0x995dx8){return _0x995dx4[_0x6087[13]](404)};var _0x995dx9=_[_0x6087[18]](_0x995dx8,_0x995dx3[_0x6087[16]]);_0x995dx9[_0x6087[19]]()[_0x6087[8]](function(){return _0x995dx4[_0x6087[7]](200)[_0x6087[6]](_0x995dx8)})[_0x6087[5]](function(_0x995dx5){return handleError(_0x995dx4,_0x995dx5)});})[_0x6087[5]](function(_0x995dx5){return handleError(_0x995dx4,_0x995dx5)});};exports[_0x6087[20]]=function(_0x995dx3,_0x995dx4){var _0x995dx7=_0x995dx3[_0x6087[12]][_0x6087[11]];Module[_0x6087[14]](_0x995dx7)[_0x6087[8]](function(_0x995dx8){if(!_0x995dx8){return _0x995dx4[_0x6087[13]](404)};_0x995dx8[_0x6087[20]]()[_0x6087[8]](function(){return _0x995dx4[_0x6087[13]](204)})[_0x6087[5]](function(_0x995dx5){return handleError(_0x995dx4,_0x995dx5)});})[_0x6087[5]](function(_0x995dx5){return handleError(_0x995dx4,_0x995dx5)});};function handleError(_0x995dx4,_0x995dx5){return _0x995dx4[_0x6087[7]](500)[_0x6087[6]](_0x995dx5)} \ No newline at end of file diff --git a/server/api/module/module.socket.js b/server/api/module/module.socket.js index 0eade3b..198aca7 100644 --- a/server/api/module/module.socket.js +++ b/server/api/module/module.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var module = require('../../models').Module; - -exports.register = function(socket) { - module.afterCreate(function (doc) { - onSave(socket, doc); - }); - module.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('module:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('module:remove', doc); -} +var _0x54df=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x6F\x64\x75\x6C\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x6F\x64\x75\x6C\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x6F\x64\x75\x6C\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x54df[0];var module=require(_0x54df[2])[_0x54df[1]];exports[_0x54df[3]]=function(_0xf4e9x2){module[_0x54df[4]](function(_0xf4e9x3){onSave(_0xf4e9x2,_0xf4e9x3)});module[_0x54df[5]](function(_0xf4e9x3){onRemove(_0xf4e9x2,_0xf4e9x3)});};function onSave(_0xf4e9x2,_0xf4e9x3,_0xf4e9x5){_0xf4e9x2[_0x54df[7]](_0x54df[6],_0xf4e9x3)}function onRemove(_0xf4e9x2,_0xf4e9x3,_0xf4e9x5){_0xf4e9x2[_0x54df[7]](_0x54df[8],_0xf4e9x3)} \ No newline at end of file diff --git a/server/api/module/module.spec.js b/server/api/module/module.spec.js index 45aa629..f4c49a4 100644 --- a/server/api/module/module.spec.js +++ b/server/api/module/module.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/modules', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/modules') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xeb7e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x6F\x64\x75\x6C\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x6F\x64\x75\x6C\x65\x73","\x67\x65\x74"];_0xeb7e[0];var should=require(_0xeb7e[1]);var app=require(_0xeb7e[2]);var request=require(_0xeb7e[3]);describe(_0xeb7e[4],function(){it(_0xeb7e[5],function(_0xfe43x4){request(app)[_0xeb7e[13]](_0xeb7e[12])[_0xeb7e[11]](200)[_0xeb7e[11]](_0xeb7e[10],/json/)[_0xeb7e[9]](function(_0xfe43x5,_0xfe43x6){if(_0xfe43x5){return _0xfe43x4(_0xfe43x5)};_0xfe43x6[_0xeb7e[8]][_0xeb7e[1]][_0xeb7e[7]][_0xeb7e[6]](Array);_0xfe43x4();})})}); \ No newline at end of file diff --git a/server/api/module/setting/index.js b/server/api/module/setting/index.js index f341cb4..6dc6cf0 100644 --- a/server/api/module/setting/index.js +++ b/server/api/module/setting/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./setting.controller'); - -var router = express.Router(); - -// router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xfc0b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x73\x65\x74\x74\x69\x6E\x67\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x67\x65\x74","\x2F","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xfc0b[0];var express=require(_0xfc0b[1]);var controller=require(_0xfc0b[2]);var router=express.Router();router[_0xfc0b[5]](_0xfc0b[3],controller[_0xfc0b[4]]);router[_0xfc0b[8]](_0xfc0b[6],controller[_0xfc0b[7]]);router[_0xfc0b[10]](_0xfc0b[3],controller[_0xfc0b[9]]);router[_0xfc0b[11]](_0xfc0b[3],controller[_0xfc0b[9]]);router[_0xfc0b[13]](_0xfc0b[3],controller[_0xfc0b[12]]);module[_0xfc0b[14]]=router; \ No newline at end of file diff --git a/server/api/module/setting/setting.controller.js b/server/api/module/setting/setting.controller.js index 3ebcb5c..0d12611 100644 --- a/server/api/module/setting/setting.controller.js +++ b/server/api/module/setting/setting.controller.js @@ -1,110 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var crypto = require('crypto'); - -var Setting = require('../../models').Setting; - -// Get list of settings -exports.index = function(req, res) { - Setting - .findAll() - .then(function(settings) { - return res.status(200).send(settings); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single setting -exports.show = function(req, res) { - Setting - .findById(req.params.id) - .then(function(setting) { - if (!setting) { - return res.sendStatus(404); - } - - if (setting.license) { - setting.license = decrypt('aes-256-ctr', util.format('%s:%s:%s', - setting.address, setting.netmask, setting.mac), setting.license); - setting.license = JSON.parse(setting.license); - } - - return res.send(setting); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new setting in the DB. -exports.create = function(req, res) { - Setting - .create(req.body) - .then(function(setting) { - return res.status(201).send(setting); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing setting in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Setting - .findById(req.params.id) - .then(function(setting) { - if (!setting) { - return res.sendStatus(404); - } - var updated = _.merge(setting, req.body); - updated.save() - .then(function() { - return res.status(200).send(setting); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a setting from the DB. -exports.destroy = function(req, res) { - Setting - .findById(req.params.id) - .then(function(setting) { - if (!setting) { - return res.sendStatus(404); - } - setting.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} - -function decrypt(algorithm, password, text) { - var decipher = crypto.createDecipher(algorithm, password) - var dec = decipher.update(text, 'hex', 'utf8') - dec += decipher.final('utf8'); - return dec; -} +var _0x5e0e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x63\x72\x79\x70\x74\x6F","\x53\x65\x74\x74\x69\x6E\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x6C\x69\x63\x65\x6E\x73\x65","\x61\x65\x73\x2D\x32\x35\x36\x2D\x63\x74\x72","\x25\x73\x3A\x25\x73\x3A\x25\x73","\x61\x64\x64\x72\x65\x73\x73","\x6E\x65\x74\x6D\x61\x73\x6B","\x6D\x61\x63","\x66\x6F\x72\x6D\x61\x74","\x70\x61\x72\x73\x65","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x63\x72\x65\x61\x74\x65\x44\x65\x63\x69\x70\x68\x65\x72","\x68\x65\x78","\x75\x74\x66\x38","\x66\x69\x6E\x61\x6C"];_0x5e0e[0];var _=require(_0x5e0e[1]);var util=require(_0x5e0e[2]);var crypto=require(_0x5e0e[3]);var Setting=require(_0x5e0e[5])[_0x5e0e[4]];exports[_0x5e0e[6]]=function(_0x4238x5,_0x4238x6){Setting[_0x5e0e[11]]()[_0x5e0e[10]](function(_0x4238x8){return _0x4238x6[_0x5e0e[9]](200)[_0x5e0e[8]](_0x4238x8)})[_0x5e0e[7]](function(_0x4238x7){return handleError(_0x4238x6,_0x4238x7)})};exports[_0x5e0e[12]]=function(_0x4238x5,_0x4238x6){Setting[_0x5e0e[24]](_0x4238x5[_0x5e0e[23]][_0x5e0e[22]])[_0x5e0e[10]](function(_0x4238x9){if(!_0x4238x9){return _0x4238x6[_0x5e0e[13]](404)};if(_0x4238x9[_0x5e0e[14]]){_0x4238x9[_0x5e0e[14]]=decrypt(_0x5e0e[15],util[_0x5e0e[20]](_0x5e0e[16],_0x4238x9[_0x5e0e[17]],_0x4238x9[_0x5e0e[18]],_0x4238x9[_0x5e0e[19]]),_0x4238x9[_0x5e0e[14]]);_0x4238x9[_0x5e0e[14]]=JSON[_0x5e0e[21]](_0x4238x9[_0x5e0e[14]]);};return _0x4238x6[_0x5e0e[8]](_0x4238x9);})[_0x5e0e[7]](function(_0x4238x7){return handleError(_0x4238x6,_0x4238x7)})};exports[_0x5e0e[25]]=function(_0x4238x5,_0x4238x6){Setting[_0x5e0e[25]](_0x4238x5[_0x5e0e[26]])[_0x5e0e[10]](function(_0x4238x9){return _0x4238x6[_0x5e0e[9]](201)[_0x5e0e[8]](_0x4238x9)})[_0x5e0e[7]](function(_0x4238x7){return handleError(_0x4238x6,_0x4238x7)})};exports[_0x5e0e[27]]=function(_0x4238x5,_0x4238x6){if(_0x4238x5[_0x5e0e[26]][_0x5e0e[22]]){delete _0x4238x5[_0x5e0e[26]][_0x5e0e[22]]};Setting[_0x5e0e[24]](_0x4238x5[_0x5e0e[23]][_0x5e0e[22]])[_0x5e0e[10]](function(_0x4238x9){if(!_0x4238x9){return _0x4238x6[_0x5e0e[13]](404)};var _0x4238xa=_[_0x5e0e[28]](_0x4238x9,_0x4238x5[_0x5e0e[26]]);_0x4238xa[_0x5e0e[29]]()[_0x5e0e[10]](function(){return _0x4238x6[_0x5e0e[9]](200)[_0x5e0e[8]](_0x4238x9)})[_0x5e0e[7]](function(_0x4238x7){return handleError(_0x4238x6,_0x4238x7)});})[_0x5e0e[7]](function(_0x4238x7){return handleError(_0x4238x6,_0x4238x7)});};exports[_0x5e0e[30]]=function(_0x4238x5,_0x4238x6){Setting[_0x5e0e[24]](_0x4238x5[_0x5e0e[23]][_0x5e0e[22]])[_0x5e0e[10]](function(_0x4238x9){if(!_0x4238x9){return _0x4238x6[_0x5e0e[13]](404)};_0x4238x9[_0x5e0e[30]]()[_0x5e0e[10]](function(){return _0x4238x6[_0x5e0e[13]](204)})[_0x5e0e[7]](function(_0x4238x7){return handleError(_0x4238x6,_0x4238x7)});})[_0x5e0e[7]](function(_0x4238x7){return handleError(_0x4238x6,_0x4238x7)})};function handleError(_0x4238x6,_0x4238x7){return _0x4238x6[_0x5e0e[9]](500)[_0x5e0e[8]](_0x4238x7)}function decrypt(_0x4238xd,_0x4238xe,_0x4238xf){var _0x4238x10=crypto[_0x5e0e[31]](_0x4238xd,_0x4238xe);var _0x4238x11=_0x4238x10[_0x5e0e[27]](_0x4238xf,_0x5e0e[32],_0x5e0e[33]);_0x4238x11+=_0x4238x10[_0x5e0e[34]](_0x5e0e[33]);return _0x4238x11;} \ No newline at end of file diff --git a/server/api/module/setting/setting.socket.js b/server/api/module/setting/setting.socket.js index 0784c1f..ec56b3e 100644 --- a/server/api/module/setting/setting.socket.js +++ b/server/api/module/setting/setting.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Setting = require('../../models').Setting; - -exports.register = function(socket) { - Setting.afterCreate(function(doc) { - onSave(socket, doc); - }); - Setting.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('setting:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('setting:remove', doc); -} +var _0x1a9f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x65\x74\x74\x69\x6E\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x65\x74\x74\x69\x6E\x67\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x65\x74\x74\x69\x6E\x67\x3A\x72\x65\x6D\x6F\x76\x65"];_0x1a9f[0];var Setting=require(_0x1a9f[2])[_0x1a9f[1]];exports[_0x1a9f[3]]=function(_0x8690x2){Setting[_0x1a9f[4]](function(_0x8690x3){onSave(_0x8690x2,_0x8690x3)});Setting[_0x1a9f[5]](function(_0x8690x3){onRemove(_0x8690x2,_0x8690x3)});};function onSave(_0x8690x2,_0x8690x3,_0x8690x5){_0x8690x2[_0x1a9f[7]](_0x1a9f[6],_0x8690x3)}function onRemove(_0x8690x2,_0x8690x3,_0x8690x5){_0x8690x2[_0x1a9f[7]](_0x1a9f[8],_0x8690x3)} \ No newline at end of file diff --git a/server/api/module/setting/setting.spec.js b/server/api/module/setting/setting.spec.js index eec76c9..2881ad9 100644 --- a/server/api/module/setting/setting.spec.js +++ b/server/api/module/setting/setting.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/settings', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/settings') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x6270=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x65\x74\x74\x69\x6E\x67\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x73\x65\x74\x74\x69\x6E\x67\x73","\x67\x65\x74"];_0x6270[0];var should=require(_0x6270[1]);var app=require(_0x6270[2]);var request=require(_0x6270[3]);describe(_0x6270[4],function(){it(_0x6270[5],function(_0x6e63x4){request(app)[_0x6270[13]](_0x6270[12])[_0x6270[11]](200)[_0x6270[11]](_0x6270[10],/json/)[_0x6270[9]](function(_0x6e63x5,_0x6e63x6){if(_0x6e63x5){return _0x6e63x4(_0x6e63x5)};_0x6e63x6[_0x6270[8]][_0x6270[1]][_0x6270[7]][_0x6270[6]](Array);_0x6e63x4();})})}); \ No newline at end of file diff --git a/server/api/motionbar/index.js b/server/api/motionbar/index.js index fd9d420..3100bbb 100644 --- a/server/api/motionbar/index.js +++ b/server/api/motionbar/index.js @@ -1,11 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./motionbar.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/:action/:state', auth.isAuthenticated(), controller.action); - -module.exports = router; +var _0x2129=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F\x3A\x61\x63\x74\x69\x6F\x6E\x2F\x3A\x73\x74\x61\x74\x65","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x61\x63\x74\x69\x6F\x6E","\x67\x65\x74","\x65\x78\x70\x6F\x72\x74\x73"];_0x2129[0];var express=require(_0x2129[1]);var controller=require(_0x2129[2]);var auth=require(_0x2129[3]);var router=express.Router();router[_0x2129[7]](_0x2129[4],auth[_0x2129[5]](),controller[_0x2129[6]]);module[_0x2129[8]]=router; \ No newline at end of file diff --git a/server/api/motionbar/motionbar.controller.js b/server/api/motionbar/motionbar.controller.js index f0a79be..d9154c2 100644 --- a/server/api/motionbar/motionbar.controller.js +++ b/server/api/motionbar/motionbar.controller.js @@ -1,32 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Motionbar = require('../../models').Motionbar; - -// Get list of motionbars -exports.action = function(req, res) { - - if (!req.query.userId) { - return handleError(res, { - message: 'Use userId' - }); - } - - req.body.UserId = parseInt(req.query.userId, 10); - req.body.action = req.params.action; - req.body.state = req.params.state; - req.body.AdminId = req.user.id; - - Motionbar - .create(req.body) - .then(function(action) { - return res.status(201).send(action); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xeafd=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x4D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x61\x63\x74\x69\x6F\x6E","\x75\x73\x65\x72\x49\x64","\x71\x75\x65\x72\x79","\x55\x73\x65\x20\x75\x73\x65\x72\x49\x64","\x55\x73\x65\x72\x49\x64","\x62\x6F\x64\x79","\x70\x61\x72\x61\x6D\x73","\x73\x74\x61\x74\x65","\x41\x64\x6D\x69\x6E\x49\x64","\x69\x64","\x75\x73\x65\x72","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x63\x72\x65\x61\x74\x65"];_0xeafd[0];var _=require(_0xeafd[1]);var Motionbar=require(_0xeafd[3])[_0xeafd[2]];exports[_0xeafd[4]]=function(_0x55d1x3,_0x55d1x4){if(!_0x55d1x3[_0xeafd[6]][_0xeafd[5]]){return handleError(_0x55d1x4,{message:_0xeafd[7]})};_0x55d1x3[_0xeafd[9]][_0xeafd[8]]=parseInt(_0x55d1x3[_0xeafd[6]][_0xeafd[5]],10);_0x55d1x3[_0xeafd[9]][_0xeafd[4]]=_0x55d1x3[_0xeafd[10]][_0xeafd[4]];_0x55d1x3[_0xeafd[9]][_0xeafd[11]]=_0x55d1x3[_0xeafd[10]][_0xeafd[11]];_0x55d1x3[_0xeafd[9]][_0xeafd[12]]=_0x55d1x3[_0xeafd[14]][_0xeafd[13]];Motionbar[_0xeafd[19]](_0x55d1x3[_0xeafd[9]])[_0xeafd[18]](function(_0x55d1x6){return _0x55d1x4[_0xeafd[17]](201)[_0xeafd[16]](_0x55d1x6)})[_0xeafd[15]](function(_0x55d1x5){return handleError(_0x55d1x4,_0x55d1x5)});};function handleError(_0x55d1x4,_0x55d1x5){return _0x55d1x4[_0xeafd[17]](500)[_0xeafd[16]](_0x55d1x5)} \ No newline at end of file diff --git a/server/api/motionbar/motionbar.socket.js b/server/api/motionbar/motionbar.socket.js index 0eb15d4..7f3ff20 100644 --- a/server/api/motionbar/motionbar.socket.js +++ b/server/api/motionbar/motionbar.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Motionbar = require('../../models').Motionbar; - -exports.register = function(socket) { - Motionbar.afterCreate(function(doc) { - onSave(socket, doc); - }); - Motionbar.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - // doc.UserId is string. You don't use === - if (socket.userId == doc.UserId) { - socket.emit('motionbar:save', doc); - } -} - -function onRemove(socket, doc, cb) { - socket.emit('motionbar:remove', doc); -} +var _0x14ba=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x75\x73\x65\x72\x49\x64","\x55\x73\x65\x72\x49\x64","\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72\x3A\x72\x65\x6D\x6F\x76\x65"];_0x14ba[0];var Motionbar=require(_0x14ba[2])[_0x14ba[1]];exports[_0x14ba[3]]=function(_0xc962x2){Motionbar[_0x14ba[4]](function(_0xc962x3){onSave(_0xc962x2,_0xc962x3)});Motionbar[_0x14ba[5]](function(_0xc962x3){onRemove(_0xc962x2,_0xc962x3)});};function onSave(_0xc962x2,_0xc962x3,_0xc962x5){if(_0xc962x2[_0x14ba[6]]==_0xc962x3[_0x14ba[7]]){_0xc962x2[_0x14ba[9]](_0x14ba[8],_0xc962x3)}}function onRemove(_0xc962x2,_0xc962x3,_0xc962x5){_0xc962x2[_0x14ba[9]](_0x14ba[10],_0xc962x3)} \ No newline at end of file diff --git a/server/api/motionbar/motionbar.spec.js b/server/api/motionbar/motionbar.spec.js index bbbac7f..808097d 100644 --- a/server/api/motionbar/motionbar.spec.js +++ b/server/api/motionbar/motionbar.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/motionbar', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/motionbar') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xc466=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x67\x65\x74"];_0xc466[0];var should=require(_0xc466[1]);var app=require(_0xc466[2]);var request=require(_0xc466[3]);describe(_0xc466[4],function(){it(_0xc466[5],function(_0xa831x4){request(app)[_0xc466[13]](_0xc466[12])[_0xc466[11]](200)[_0xc466[11]](_0xc466[10],/json/)[_0xc466[9]](function(_0xa831x5,_0xa831x6){if(_0xa831x5){return _0xa831x4(_0xa831x5)};_0xa831x6[_0xc466[8]][_0xc466[1]][_0xc466[7]][_0xc466[6]](Array);_0xa831x4();})})}); \ No newline at end of file diff --git a/server/api/report_agent/index.js b/server/api/report_agent/index.js index 50a811f..5c5bf59 100644 --- a/server/api/report_agent/index.js +++ b/server/api/report_agent/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_agent.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xf5f3=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xf5f3[0];var express=require(_0xf5f3[1]);var controller=require(_0xf5f3[2]);var router=express.Router();router[_0xf5f3[5]](_0xf5f3[3],controller[_0xf5f3[4]]);router[_0xf5f3[5]](_0xf5f3[6],controller[_0xf5f3[7]]);router[_0xf5f3[9]](_0xf5f3[3],controller[_0xf5f3[8]]);router[_0xf5f3[11]](_0xf5f3[6],controller[_0xf5f3[10]]);router[_0xf5f3[12]](_0xf5f3[6],controller[_0xf5f3[10]]);router[_0xf5f3[14]](_0xf5f3[6],controller[_0xf5f3[13]]);module[_0xf5f3[15]]=router; \ No newline at end of file diff --git a/server/api/report_agent/report_agent.controller.js b/server/api/report_agent/report_agent.controller.js index 50134d6..480c1f6 100644 --- a/server/api/report_agent/report_agent.controller.js +++ b/server/api/report_agent/report_agent.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ReportAgent = require('../../models').ReportAgent; - -// Get list of report_agents -exports.index = function(req, res) { - ReportAgent - .findAll() - .then(function(report_agents) { - return res.status(200).send(report_agents); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single report_agent -exports.show = function(req, res) { - ReportAgent - .findById(req.params.id) - .then(function(report_agent) { - if (!report_agent) { - return res.sendStatus(404); - } - return res.send(report_agent); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new report_agent in the DB. -exports.create = function(req, res) { - ReportAgent - .create(req.body) - .then(function(report_agent) { - return res.status(201).send(report_agent); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report_agent in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ReportAgent - .findById(req.params.id) - .then(function(report_agent) { - if (!report_agent) { - return res.sendStatus(404); - } - var updated = _.merge(report_agent, req.body); - updated.save() - .then(function() { - return res.status(200).send(report_agent); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a report_agent from the DB. -exports.destroy = function(req, res) { - ReportAgent - .findById(req.params.id) - .then(function(report_agent) { - if (!report_agent) { - return res.sendStatus(404); - } - report_agent.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xdfdc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xdfdc[0];var _=require(_0xdfdc[1]);var ReportAgent=require(_0xdfdc[3])[_0xdfdc[2]];exports[_0xdfdc[4]]=function(_0x8cf6x3,_0x8cf6x4){ReportAgent[_0xdfdc[9]]()[_0xdfdc[8]](function(_0x8cf6x6){return _0x8cf6x4[_0xdfdc[7]](200)[_0xdfdc[6]](_0x8cf6x6)})[_0xdfdc[5]](function(_0x8cf6x5){return handleError(_0x8cf6x4,_0x8cf6x5)})};exports[_0xdfdc[10]]=function(_0x8cf6x3,_0x8cf6x4){ReportAgent[_0xdfdc[14]](_0x8cf6x3[_0xdfdc[13]][_0xdfdc[12]])[_0xdfdc[8]](function(_0x8cf6x7){if(!_0x8cf6x7){return _0x8cf6x4[_0xdfdc[11]](404)};return _0x8cf6x4[_0xdfdc[6]](_0x8cf6x7);})[_0xdfdc[5]](function(_0x8cf6x5){return handleError(_0x8cf6x4,_0x8cf6x5)})};exports[_0xdfdc[15]]=function(_0x8cf6x3,_0x8cf6x4){ReportAgent[_0xdfdc[15]](_0x8cf6x3[_0xdfdc[16]])[_0xdfdc[8]](function(_0x8cf6x7){return _0x8cf6x4[_0xdfdc[7]](201)[_0xdfdc[6]](_0x8cf6x7)})[_0xdfdc[5]](function(_0x8cf6x5){return handleError(_0x8cf6x4,_0x8cf6x5)})};exports[_0xdfdc[17]]=function(_0x8cf6x3,_0x8cf6x4){if(_0x8cf6x3[_0xdfdc[16]][_0xdfdc[12]]){delete _0x8cf6x3[_0xdfdc[16]][_0xdfdc[12]]};ReportAgent[_0xdfdc[14]](_0x8cf6x3[_0xdfdc[13]][_0xdfdc[12]])[_0xdfdc[8]](function(_0x8cf6x7){if(!_0x8cf6x7){return _0x8cf6x4[_0xdfdc[11]](404)};var _0x8cf6x8=_[_0xdfdc[18]](_0x8cf6x7,_0x8cf6x3[_0xdfdc[16]]);_0x8cf6x8[_0xdfdc[19]]()[_0xdfdc[8]](function(){return _0x8cf6x4[_0xdfdc[7]](200)[_0xdfdc[6]](_0x8cf6x7)})[_0xdfdc[5]](function(_0x8cf6x5){return handleError(_0x8cf6x4,_0x8cf6x5)});})[_0xdfdc[5]](function(_0x8cf6x5){return handleError(_0x8cf6x4,_0x8cf6x5)});};exports[_0xdfdc[20]]=function(_0x8cf6x3,_0x8cf6x4){ReportAgent[_0xdfdc[14]](_0x8cf6x3[_0xdfdc[13]][_0xdfdc[12]])[_0xdfdc[8]](function(_0x8cf6x7){if(!_0x8cf6x7){return _0x8cf6x4[_0xdfdc[11]](404)};_0x8cf6x7[_0xdfdc[20]]()[_0xdfdc[8]](function(){return _0x8cf6x4[_0xdfdc[11]](204)})[_0xdfdc[5]](function(_0x8cf6x5){return handleError(_0x8cf6x4,_0x8cf6x5)});})[_0xdfdc[5]](function(_0x8cf6x5){return handleError(_0x8cf6x4,_0x8cf6x5)})};function handleError(_0x8cf6x4,_0x8cf6x5){return _0x8cf6x4[_0xdfdc[7]](500)[_0xdfdc[6]](_0x8cf6x5)} \ No newline at end of file diff --git a/server/api/report_agent/report_agent.socket.js b/server/api/report_agent/report_agent.socket.js index f6d496d..642a37a 100644 --- a/server/api/report_agent/report_agent.socket.js +++ b/server/api/report_agent/report_agent.socket.js @@ -1,50 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ReportAgent = require('../../models').ReportAgent; - -exports.register = function(socket) { - ReportAgent.afterCreate(function(doc) { - onSave(socket, doc); - }); - ReportAgent.afterUpdate(function(doc) { - onSave(socket, doc); - }); - ReportAgent.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - // socket.emit('report_agent:save', { - // id: doc.id, - // uniqueid: doc.uniqueid, - // calleridnum: doc.callerinum, - // calleridname: doc.calleridname, - // queue: doc.queue, - // interface: doc.interface, - // membername: doc.membername, - // agentcalledAt: doc.agentcalledAt, - // agentconnectAt: doc.agentconnectAt, - // holdtime: doc.holdtime, - // agentcomplete: doc.agentcomplete, - // agentcompleteAt: doc.agentcompleteAt, - // talktime: doc.talktime, - // agentacw: doc.agentacw, - // acwtime: doc.acwtime, - // agentringnoanswer: doc.agentringnoanswer, - // agentringnoanswerAt: doc.agentringnoanswerAt, - // lastevent: doc.lastevent - // }); - if (socket.name === doc.membername || socket.role === 'admin') { - socket.emit('report_agent:save', doc); - } - -} - -function onRemove(socket, doc, cb) { - socket.emit('report_agent:remove', doc); -} +var _0xb973=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6E\x61\x6D\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x72\x6F\x6C\x65","\x61\x64\x6D\x69\x6E","\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xb973[0];var ReportAgent=require(_0xb973[2])[_0xb973[1]];exports[_0xb973[3]]=function(_0xa6c5x2){ReportAgent[_0xb973[4]](function(_0xa6c5x3){onSave(_0xa6c5x2,_0xa6c5x3)});ReportAgent[_0xb973[5]](function(_0xa6c5x3){onSave(_0xa6c5x2,_0xa6c5x3)});ReportAgent[_0xb973[6]](function(_0xa6c5x3){onRemove(_0xa6c5x2,_0xa6c5x3)});};function onSave(_0xa6c5x2,_0xa6c5x3,_0xa6c5x5){if(_0xa6c5x2[_0xb973[7]]===_0xa6c5x3[_0xb973[8]]||_0xa6c5x2[_0xb973[9]]===_0xb973[10]){_0xa6c5x2[_0xb973[12]](_0xb973[11],_0xa6c5x3)}}function onRemove(_0xa6c5x2,_0xa6c5x3,_0xa6c5x5){_0xa6c5x2[_0xb973[12]](_0xb973[13],_0xa6c5x3)} \ No newline at end of file diff --git a/server/api/report_chat/index.js b/server/api/report_chat/index.js index 6de144c..9d2a740 100644 --- a/server/api/report_chat/index.js +++ b/server/api/report_chat/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_chat.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xd738=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xd738[0];var express=require(_0xd738[1]);var controller=require(_0xd738[2]);var router=express.Router();router[_0xd738[5]](_0xd738[3],controller[_0xd738[4]]);router[_0xd738[5]](_0xd738[6],controller[_0xd738[7]]);router[_0xd738[9]](_0xd738[3],controller[_0xd738[8]]);router[_0xd738[11]](_0xd738[6],controller[_0xd738[10]]);router[_0xd738[12]](_0xd738[6],controller[_0xd738[10]]);router[_0xd738[14]](_0xd738[6],controller[_0xd738[13]]);module[_0xd738[15]]=router; \ No newline at end of file diff --git a/server/api/report_chat/report_chat.controller.js b/server/api/report_chat/report_chat.controller.js index d727f82..bf58c93 100644 --- a/server/api/report_chat/report_chat.controller.js +++ b/server/api/report_chat/report_chat.controller.js @@ -1,96 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ReportChat = require('../../models').ReportChat; -var sequelize = require('../../models').sequelize; - -// Get list of report_chats -exports.index = function (req, res) { - ReportChat - .findAll() - .then(function (report_chats) { - return res.status(200).send(report_chats); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single reportChat -exports.show = function (req, res) { - ReportChat - .findById(req.params.id) - .then(function (reportChat) { - if (!reportChat) { - return res.sendStatus(404); - } - return res.send(reportChat); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Creates a new reportChat in the DB. -exports.create = function (req, res) { - ReportChat - .create(req.body) - .then(function (reportChat) { - return res.status(201).send(reportChat); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing reportChat in the DB. -exports.update = function (req, res, next) { - if (req.body.id) { - delete req.body.id; - } - - return ReportChat - .findById(req.params.id) - .then(function (reportChat) { - if (!reportChat) { - return res.sendStatus(404); - } - var updated = _.merge(reportChat, req.body); - return updated - .save() - .then(function () { - return res.status(200).send(reportChat); - }); - }) - .catch(sequelize.ValidationError, function (err) { - return handleError(res, err); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Deletes a reportChat from the DB. -exports.destroy = function (req, res) { - ReportChat - .findById(req.params.id) - .then(function (reportChat) { - if (!reportChat) { - return res.sendStatus(404); - } - reportChat.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xad59=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xad59[0];var _=require(_0xad59[1]);var ReportChat=require(_0xad59[3])[_0xad59[2]];var sequelize=require(_0xad59[3])[_0xad59[4]];exports[_0xad59[5]]=function(_0x3fc9x4,_0x3fc9x5){ReportChat[_0xad59[10]]()[_0xad59[9]](function(_0x3fc9x7){return _0x3fc9x5[_0xad59[8]](200)[_0xad59[7]](_0x3fc9x7)})[_0xad59[6]](function(_0x3fc9x6){return handleError(_0x3fc9x5,_0x3fc9x6)})};exports[_0xad59[11]]=function(_0x3fc9x4,_0x3fc9x5){ReportChat[_0xad59[15]](_0x3fc9x4[_0xad59[14]][_0xad59[13]])[_0xad59[9]](function(_0x3fc9x8){if(!_0x3fc9x8){return _0x3fc9x5[_0xad59[12]](404)};return _0x3fc9x5[_0xad59[7]](_0x3fc9x8);})[_0xad59[6]](function(_0x3fc9x6){return handleError(_0x3fc9x5,_0x3fc9x6)})};exports[_0xad59[16]]=function(_0x3fc9x4,_0x3fc9x5){ReportChat[_0xad59[16]](_0x3fc9x4[_0xad59[17]])[_0xad59[9]](function(_0x3fc9x8){return _0x3fc9x5[_0xad59[8]](201)[_0xad59[7]](_0x3fc9x8)})[_0xad59[6]](function(_0x3fc9x6){return handleError(_0x3fc9x5,_0x3fc9x6)})};exports[_0xad59[18]]=function(_0x3fc9x4,_0x3fc9x5,_0x3fc9x9){if(_0x3fc9x4[_0xad59[17]][_0xad59[13]]){delete _0x3fc9x4[_0xad59[17]][_0xad59[13]]};return ReportChat[_0xad59[15]](_0x3fc9x4[_0xad59[14]][_0xad59[13]])[_0xad59[9]](function(_0x3fc9x8){if(!_0x3fc9x8){return _0x3fc9x5[_0xad59[12]](404)};var _0x3fc9xa=_[_0xad59[19]](_0x3fc9x8,_0x3fc9x4[_0xad59[17]]);return _0x3fc9xa[_0xad59[20]]()[_0xad59[9]](function(){return _0x3fc9x5[_0xad59[8]](200)[_0xad59[7]](_0x3fc9x8)});})[_0xad59[6]](sequelize.ValidationError,function(_0x3fc9x6){return handleError(_0x3fc9x5,_0x3fc9x6)})[_0xad59[6]](function(_0x3fc9x6){return handleError(_0x3fc9x5,_0x3fc9x6)});};exports[_0xad59[21]]=function(_0x3fc9x4,_0x3fc9x5){ReportChat[_0xad59[15]](_0x3fc9x4[_0xad59[14]][_0xad59[13]])[_0xad59[9]](function(_0x3fc9x8){if(!_0x3fc9x8){return _0x3fc9x5[_0xad59[12]](404)};_0x3fc9x8[_0xad59[21]]()[_0xad59[9]](function(){return _0x3fc9x5[_0xad59[12]](204)})[_0xad59[6]](function(_0x3fc9x6){return handleError(_0x3fc9x5,_0x3fc9x6)});})[_0xad59[6]](function(_0x3fc9x6){return handleError(_0x3fc9x5,_0x3fc9x6)})};function handleError(_0x3fc9x5,_0x3fc9x6){return _0x3fc9x5[_0xad59[8]](500)[_0xad59[7]](_0x3fc9x6)} \ No newline at end of file diff --git a/server/api/report_chat/report_chat.socket.js b/server/api/report_chat/report_chat.socket.js index 21c35bc..74b10b7 100644 --- a/server/api/report_chat/report_chat.socket.js +++ b/server/api/report_chat/report_chat.socket.js @@ -1,39 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ReportChat = require('../../models').ReportChat; - -exports.register = function (socket) { - ReportChat.afterCreate(function (doc) { - onSave(socket, doc); - }); - ReportChat.afterUpdate(function (doc) { - onUpdate(socket, doc); - }); - ReportChat.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - if (socket.name === doc.membername || socket.role === 'admin') { - socket.emit('report_chat:save', doc); - } -} - -function onUpdate(socket, doc, cb) { - if (socket.name === doc.membername || socket.role === 'admin') { - if (doc.changed('agentid')) { - socket.emit('report_chat:assignment', doc); - } else { - socket.emit('report_chat:update', doc); - } - } -} - -function onRemove(socket, doc, cb) { - socket.emit('report_chat:remove', doc); -} +var _0x1d2d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6E\x61\x6D\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x72\x6F\x6C\x65","\x61\x64\x6D\x69\x6E","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x61\x67\x65\x6E\x74\x69\x64","\x63\x68\x61\x6E\x67\x65\x64","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x3A\x61\x73\x73\x69\x67\x6E\x6D\x65\x6E\x74","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x3A\x75\x70\x64\x61\x74\x65","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x1d2d[0];var ReportChat=require(_0x1d2d[2])[_0x1d2d[1]];exports[_0x1d2d[3]]=function(_0x58dcx2){ReportChat[_0x1d2d[4]](function(_0x58dcx3){onSave(_0x58dcx2,_0x58dcx3)});ReportChat[_0x1d2d[5]](function(_0x58dcx3){onUpdate(_0x58dcx2,_0x58dcx3)});ReportChat[_0x1d2d[6]](function(_0x58dcx3){onRemove(_0x58dcx2,_0x58dcx3)});};function onSave(_0x58dcx2,_0x58dcx3,_0x58dcx5){if(_0x58dcx2[_0x1d2d[7]]===_0x58dcx3[_0x1d2d[8]]||_0x58dcx2[_0x1d2d[9]]===_0x1d2d[10]){_0x58dcx2[_0x1d2d[12]](_0x1d2d[11],_0x58dcx3)}}function onUpdate(_0x58dcx2,_0x58dcx3,_0x58dcx5){if(_0x58dcx2[_0x1d2d[7]]===_0x58dcx3[_0x1d2d[8]]||_0x58dcx2[_0x1d2d[9]]===_0x1d2d[10]){if(_0x58dcx3[_0x1d2d[14]](_0x1d2d[13])){_0x58dcx2[_0x1d2d[12]](_0x1d2d[15],_0x58dcx3)}else {_0x58dcx2[_0x1d2d[12]](_0x1d2d[16],_0x58dcx3)}}}function onRemove(_0x58dcx2,_0x58dcx3,_0x58dcx5){_0x58dcx2[_0x1d2d[12]](_0x1d2d[17],_0x58dcx3)} \ No newline at end of file diff --git a/server/api/report_chat/report_chat.spec.js b/server/api/report_chat/report_chat.spec.js index df7a454..e2cd642 100644 --- a/server/api/report_chat/report_chat.spec.js +++ b/server/api/report_chat/report_chat.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/report/chats', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/report/chats') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xe796=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x63\x68\x61\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x63\x68\x61\x74\x73","\x67\x65\x74"];_0xe796[0];var should=require(_0xe796[1]);var app=require(_0xe796[2]);var request=require(_0xe796[3]);describe(_0xe796[4],function(){it(_0xe796[5],function(_0x1ba9x4){request(app)[_0xe796[13]](_0xe796[12])[_0xe796[11]](200)[_0xe796[11]](_0xe796[10],/json/)[_0xe796[9]](function(_0x1ba9x5,_0x1ba9x6){if(_0x1ba9x5){return _0x1ba9x4(_0x1ba9x5)};_0x1ba9x6[_0xe796[8]][_0xe796[1]][_0xe796[7]][_0xe796[6]](Array);_0x1ba9x4();})})}); \ No newline at end of file diff --git a/server/api/report_chat_session/index.js b/server/api/report_chat_session/index.js index b302795..b4bb065 100644 --- a/server/api/report_chat_session/index.js +++ b/server/api/report_chat_session/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_chat_session.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x9d68=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x5F\x73\x65\x73\x73\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x9d68[0];var express=require(_0x9d68[1]);var controller=require(_0x9d68[2]);var router=express.Router();router[_0x9d68[5]](_0x9d68[3],controller[_0x9d68[4]]);router[_0x9d68[5]](_0x9d68[6],controller[_0x9d68[7]]);router[_0x9d68[9]](_0x9d68[3],controller[_0x9d68[8]]);router[_0x9d68[11]](_0x9d68[6],controller[_0x9d68[10]]);router[_0x9d68[12]](_0x9d68[6],controller[_0x9d68[10]]);router[_0x9d68[14]](_0x9d68[6],controller[_0x9d68[13]]);module[_0x9d68[15]]=router; \ No newline at end of file diff --git a/server/api/report_chat_session/report_chat_session.controller.js b/server/api/report_chat_session/report_chat_session.controller.js index 1232f8c..3adc922 100644 --- a/server/api/report_chat_session/report_chat_session.controller.js +++ b/server/api/report_chat_session/report_chat_session.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ReportChatSession = require('../../models').ReportChatSession; - -// Get list of report_chat_sessions -exports.index = function(req, res) { - ReportChatSession - .findAll() - .then(function (report_chat_sessions) { - return res.status(200).send(report_chat_sessions); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single report_chat_session -exports.show = function(req, res) { - ReportChatSession - .findById(req.params.id) - .then(function (report_chat_session) { - if(!report_chat_session) { return res.sendStatus(404); } - return res.send(report_chat_session); - }) - .catch(function(err){ - return handleError(res, err); - }); -}; - -// Creates a new report_chat_session in the DB. -exports.create = function(req, res) { - ReportChatSession - .create(req.body) - .then(function(report_chat_session) { - return res.status(201).send(report_chat_session); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report_chat_session in the DB. -exports.update = function(req, res) { - if(req.body.id) { delete req.body.id; } - ReportChatSession - .find({ - where: { - id: req.params.id - } - }) - .then(function (report_chat_session) { - if(!report_chat_session) { return res.sendStatus(404); } - var updated = _.merge(report_chat_session, req.body); - updated.save() - .then(function () { - return res.status(200).send(report_chat_session); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a report_chat_session from the DB. -exports.destroy = function(req, res) { - ReportChatSession - .find({ - where: { - id: req.params.id - } - }) - .then(function (report_chat_session) { - if(!report_chat_session) { return res.sendStatus(404); } - report_chat_session.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x6183=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x53\x65\x73\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x6183[0];var _=require(_0x6183[1]);var ReportChatSession=require(_0x6183[3])[_0x6183[2]];exports[_0x6183[4]]=function(_0x7246x3,_0x7246x4){ReportChatSession[_0x6183[9]]()[_0x6183[8]](function(_0x7246x6){return _0x7246x4[_0x6183[7]](200)[_0x6183[6]](_0x7246x6)})[_0x6183[5]](function(_0x7246x5){return handleError(_0x7246x4,_0x7246x5)})};exports[_0x6183[10]]=function(_0x7246x3,_0x7246x4){ReportChatSession[_0x6183[14]](_0x7246x3[_0x6183[13]][_0x6183[12]])[_0x6183[8]](function(_0x7246x7){if(!_0x7246x7){return _0x7246x4[_0x6183[11]](404)};return _0x7246x4[_0x6183[6]](_0x7246x7);})[_0x6183[5]](function(_0x7246x5){return handleError(_0x7246x4,_0x7246x5)})};exports[_0x6183[15]]=function(_0x7246x3,_0x7246x4){ReportChatSession[_0x6183[15]](_0x7246x3[_0x6183[16]])[_0x6183[8]](function(_0x7246x7){return _0x7246x4[_0x6183[7]](201)[_0x6183[6]](_0x7246x7)})[_0x6183[5]](function(_0x7246x5){return handleError(_0x7246x4,_0x7246x5)})};exports[_0x6183[17]]=function(_0x7246x3,_0x7246x4){if(_0x7246x3[_0x6183[16]][_0x6183[12]]){delete _0x7246x3[_0x6183[16]][_0x6183[12]]};ReportChatSession[_0x6183[20]]({where:{id:_0x7246x3[_0x6183[13]][_0x6183[12]]}})[_0x6183[8]](function(_0x7246x7){if(!_0x7246x7){return _0x7246x4[_0x6183[11]](404)};var _0x7246x8=_[_0x6183[18]](_0x7246x7,_0x7246x3[_0x6183[16]]);_0x7246x8[_0x6183[19]]()[_0x6183[8]](function(){return _0x7246x4[_0x6183[7]](200)[_0x6183[6]](_0x7246x7)})[_0x6183[5]](function(_0x7246x5){return handleError(_0x7246x4,_0x7246x5)});})[_0x6183[5]](function(_0x7246x5){return handleError(_0x7246x4,_0x7246x5)});};exports[_0x6183[21]]=function(_0x7246x3,_0x7246x4){ReportChatSession[_0x6183[20]]({where:{id:_0x7246x3[_0x6183[13]][_0x6183[12]]}})[_0x6183[8]](function(_0x7246x7){if(!_0x7246x7){return _0x7246x4[_0x6183[11]](404)};_0x7246x7[_0x6183[21]]()[_0x6183[8]](function(){return _0x7246x4[_0x6183[11]](204)})[_0x6183[5]](function(_0x7246x5){return handleError(_0x7246x4,_0x7246x5)});})[_0x6183[5]](function(_0x7246x5){return handleError(_0x7246x4,_0x7246x5)})};function handleError(_0x7246x4,_0x7246x5){return _0x7246x4[_0x6183[7]](500)[_0x6183[6]](_0x7246x5)} \ No newline at end of file diff --git a/server/api/report_chat_session/report_chat_session.socket.js b/server/api/report_chat_session/report_chat_session.socket.js index a378e10..806ad85 100644 --- a/server/api/report_chat_session/report_chat_session.socket.js +++ b/server/api/report_chat_session/report_chat_session.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ReportChatSession = require('../../models').ReportChatSession; - -exports.register = function(socket) { - ReportChatSession.afterCreate(function(doc) { - onSave(socket, doc); - }); - ReportChatSession.afterUpdate(function(doc) { - onSave(socket, doc); - }); - ReportChatSession.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('report_chat_session:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('report_chat_session:remove', doc); -} +var _0x581a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x53\x65\x73\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x5F\x73\x65\x73\x73\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x5F\x73\x65\x73\x73\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x581a[0];var ReportChatSession=require(_0x581a[2])[_0x581a[1]];exports[_0x581a[3]]=function(_0xebf0x2){ReportChatSession[_0x581a[4]](function(_0xebf0x3){onSave(_0xebf0x2,_0xebf0x3)});ReportChatSession[_0x581a[5]](function(_0xebf0x3){onSave(_0xebf0x2,_0xebf0x3)});ReportChatSession[_0x581a[6]](function(_0xebf0x3){onRemove(_0xebf0x2,_0xebf0x3)});};function onSave(_0xebf0x2,_0xebf0x3,_0xebf0x5){_0xebf0x2[_0x581a[8]](_0x581a[7],_0xebf0x3)}function onRemove(_0xebf0x2,_0xebf0x3,_0xebf0x5){_0xebf0x2[_0x581a[8]](_0x581a[9],_0xebf0x3)} \ No newline at end of file diff --git a/server/api/report_chat_session/report_chat_session.spec.js b/server/api/report_chat_session/report_chat_session.spec.js index f58cff0..10f0b43 100644 --- a/server/api/report_chat_session/report_chat_session.spec.js +++ b/server/api/report_chat_session/report_chat_session.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/report/chat/sessions', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/report/chat/sessions') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xbe7c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x63\x68\x61\x74\x2F\x73\x65\x73\x73\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x63\x68\x61\x74\x2F\x73\x65\x73\x73\x69\x6F\x6E\x73","\x67\x65\x74"];_0xbe7c[0];var should=require(_0xbe7c[1]);var app=require(_0xbe7c[2]);var request=require(_0xbe7c[3]);describe(_0xbe7c[4],function(){it(_0xbe7c[5],function(_0x7b23x4){request(app)[_0xbe7c[13]](_0xbe7c[12])[_0xbe7c[11]](200)[_0xbe7c[11]](_0xbe7c[10],/json/)[_0xbe7c[9]](function(_0x7b23x5,_0x7b23x6){if(_0x7b23x5){return _0x7b23x4(_0x7b23x5)};_0x7b23x6[_0xbe7c[8]][_0xbe7c[1]][_0xbe7c[7]][_0xbe7c[6]](Array);_0x7b23x4();})})}); \ No newline at end of file diff --git a/server/api/report_integration/index.js b/server/api/report_integration/index.js index 3485189..6d97da0 100644 --- a/server/api/report_integration/index.js +++ b/server/api/report_integration/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_integration.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x97eb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x97eb[0];var express=require(_0x97eb[1]);var controller=require(_0x97eb[2]);var router=express.Router();router[_0x97eb[5]](_0x97eb[3],controller[_0x97eb[4]]);router[_0x97eb[5]](_0x97eb[6],controller[_0x97eb[7]]);router[_0x97eb[9]](_0x97eb[3],controller[_0x97eb[8]]);router[_0x97eb[11]](_0x97eb[6],controller[_0x97eb[10]]);router[_0x97eb[12]](_0x97eb[6],controller[_0x97eb[10]]);router[_0x97eb[14]](_0x97eb[6],controller[_0x97eb[13]]);module[_0x97eb[15]]=router; \ No newline at end of file diff --git a/server/api/report_integration/report_integration.controller.js b/server/api/report_integration/report_integration.controller.js index 345115e..7100234 100644 --- a/server/api/report_integration/report_integration.controller.js +++ b/server/api/report_integration/report_integration.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ReportIntegration = require('../../models').ReportIntegration; - -// Get list of report_integrations -exports.index = function(req, res) { - ReportIntegration - .findAll() - .then(function(report_integrations) { - return res.status(200).send(report_integrations); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single report_integration -exports.show = function(req, res) { - ReportIntegration - .findById(req.params.id) - .then(function(report_integration) { - if (!report_integration) { - return res.sendStatus(404); - } - return res.send(report_integration); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new report_integration in the DB. -exports.create = function(req, res) { - ReportIntegration - .create(req.body) - .then(function(report_integration) { - return res.status(201).send(report_integration); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report_integration in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ReportIntegration - .findById(req.params.id) - .then(function(report_integration) { - if (!report_integration) { - return res.sendStatus(404); - } - var updated = _.merge(report_integration, req.body); - updated.save() - .then(function() { - return res.status(200).send(report_integration); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a report_integration from the DB. -exports.destroy = function(req, res) { - ReportIntegration - .findById(req.params.id) - .then(function(report_integration) { - if (!report_integration) { - return res.sendStatus(404); - } - report_integration.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xac9c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xac9c[0];var _=require(_0xac9c[1]);var ReportIntegration=require(_0xac9c[3])[_0xac9c[2]];exports[_0xac9c[4]]=function(_0xde4bx3,_0xde4bx4){ReportIntegration[_0xac9c[9]]()[_0xac9c[8]](function(_0xde4bx6){return _0xde4bx4[_0xac9c[7]](200)[_0xac9c[6]](_0xde4bx6)})[_0xac9c[5]](function(_0xde4bx5){return handleError(_0xde4bx4,_0xde4bx5)})};exports[_0xac9c[10]]=function(_0xde4bx3,_0xde4bx4){ReportIntegration[_0xac9c[14]](_0xde4bx3[_0xac9c[13]][_0xac9c[12]])[_0xac9c[8]](function(_0xde4bx7){if(!_0xde4bx7){return _0xde4bx4[_0xac9c[11]](404)};return _0xde4bx4[_0xac9c[6]](_0xde4bx7);})[_0xac9c[5]](function(_0xde4bx5){return handleError(_0xde4bx4,_0xde4bx5)})};exports[_0xac9c[15]]=function(_0xde4bx3,_0xde4bx4){ReportIntegration[_0xac9c[15]](_0xde4bx3[_0xac9c[16]])[_0xac9c[8]](function(_0xde4bx7){return _0xde4bx4[_0xac9c[7]](201)[_0xac9c[6]](_0xde4bx7)})[_0xac9c[5]](function(_0xde4bx5){return handleError(_0xde4bx4,_0xde4bx5)})};exports[_0xac9c[17]]=function(_0xde4bx3,_0xde4bx4){if(_0xde4bx3[_0xac9c[16]][_0xac9c[12]]){delete _0xde4bx3[_0xac9c[16]][_0xac9c[12]]};ReportIntegration[_0xac9c[14]](_0xde4bx3[_0xac9c[13]][_0xac9c[12]])[_0xac9c[8]](function(_0xde4bx7){if(!_0xde4bx7){return _0xde4bx4[_0xac9c[11]](404)};var _0xde4bx8=_[_0xac9c[18]](_0xde4bx7,_0xde4bx3[_0xac9c[16]]);_0xde4bx8[_0xac9c[19]]()[_0xac9c[8]](function(){return _0xde4bx4[_0xac9c[7]](200)[_0xac9c[6]](_0xde4bx7)})[_0xac9c[5]](function(_0xde4bx5){return handleError(_0xde4bx4,_0xde4bx5)});})[_0xac9c[5]](function(_0xde4bx5){return handleError(_0xde4bx4,_0xde4bx5)});};exports[_0xac9c[20]]=function(_0xde4bx3,_0xde4bx4){ReportIntegration[_0xac9c[14]](_0xde4bx3[_0xac9c[13]][_0xac9c[12]])[_0xac9c[8]](function(_0xde4bx7){if(!_0xde4bx7){return _0xde4bx4[_0xac9c[11]](404)};_0xde4bx7[_0xac9c[20]]()[_0xac9c[8]](function(){return _0xde4bx4[_0xac9c[11]](204)})[_0xac9c[5]](function(_0xde4bx5){return handleError(_0xde4bx4,_0xde4bx5)});})[_0xac9c[5]](function(_0xde4bx5){return handleError(_0xde4bx4,_0xde4bx5)})};function handleError(_0xde4bx4,_0xde4bx5){return _0xde4bx4[_0xac9c[7]](500)[_0xac9c[6]](_0xde4bx5)} \ No newline at end of file diff --git a/server/api/report_integration/report_integration.socket.js b/server/api/report_integration/report_integration.socket.js index dd557b8..9671e44 100644 --- a/server/api/report_integration/report_integration.socket.js +++ b/server/api/report_integration/report_integration.socket.js @@ -1,20 +1 @@ -/** - * Broadcast integrations update when the model changes - */ - -'use strict'; - -var util = require('util'); -var ReportIntegration = require('../../models').ReportIntegration; - -exports.register = function(socket) { - ReportIntegration.afterCreate(function(doc) { - onSave(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - if (socket.name === doc.membername) { - socket.emit(util.format('report_integration:%s', doc.integration), doc); - } -} +var _0x174d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x75\x74\x69\x6C","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x6E\x61\x6D\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x3A\x25\x73","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x66\x6F\x72\x6D\x61\x74","\x65\x6D\x69\x74"];_0x174d[0];var util=require(_0x174d[1]);var ReportIntegration=require(_0x174d[3])[_0x174d[2]];exports[_0x174d[4]]=function(_0x6128x3){ReportIntegration[_0x174d[5]](function(_0x6128x4){onSave(_0x6128x3,_0x6128x4)})};function onSave(_0x6128x3,_0x6128x4,_0x6128x6){if(_0x6128x3[_0x174d[6]]===_0x6128x4[_0x174d[7]]){_0x6128x3[_0x174d[11]](util[_0x174d[10]](_0x174d[8],_0x6128x4[_0x174d[9]]),_0x6128x4)}} \ No newline at end of file diff --git a/server/api/report_mail/index.js b/server/api/report_mail/index.js index c895f2a..fb1f089 100644 --- a/server/api/report_mail/index.js +++ b/server/api/report_mail/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_mail.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x1144=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x1144[0];var express=require(_0x1144[1]);var controller=require(_0x1144[2]);var router=express.Router();router[_0x1144[5]](_0x1144[3],controller[_0x1144[4]]);router[_0x1144[5]](_0x1144[6],controller[_0x1144[7]]);router[_0x1144[9]](_0x1144[3],controller[_0x1144[8]]);router[_0x1144[11]](_0x1144[6],controller[_0x1144[10]]);router[_0x1144[12]](_0x1144[6],controller[_0x1144[10]]);router[_0x1144[14]](_0x1144[6],controller[_0x1144[13]]);module[_0x1144[15]]=router; \ No newline at end of file diff --git a/server/api/report_mail/report_mail.controller.js b/server/api/report_mail/report_mail.controller.js index ccc28b5..03c8972 100644 --- a/server/api/report_mail/report_mail.controller.js +++ b/server/api/report_mail/report_mail.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ReportMail = require('../../models').ReportMail; - -// Get list of report_mails -exports.index = function(req, res) { - ReportMail - .findAll() - .then(function(report_mails) { - return res.status(200).send(report_mails); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single reportMail -exports.show = function(req, res) { - ReportMail - .findById(req.params.id) - .then(function(reportMail) { - if (!reportMail) { - return res.sendStatus(404); - } - return res.send(reportMail); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new reportMail in the DB. -exports.create = function(req, res) { - ReportMail - .create(req.body) - .then(function(reportMail) { - return res.status(201).send(reportMail); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing reportMail in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ReportMail - .findById(req.params.id) - .then(function(reportMail) { - if (!reportMail) { - return res.sendStatus(404); - } - var updated = _.merge(reportMail, req.body); - updated.save() - .then(function() { - return res.status(200).send(reportMail); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a reportMail from the DB. -exports.destroy = function(req, res) { - ReportMail - .findById(req.params.id) - .then(function(reportMail) { - if (!reportMail) { - return res.sendStatus(404); - } - reportMail.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x22bf=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x22bf[0];var _=require(_0x22bf[1]);var ReportMail=require(_0x22bf[3])[_0x22bf[2]];exports[_0x22bf[4]]=function(_0x1f93x3,_0x1f93x4){ReportMail[_0x22bf[9]]()[_0x22bf[8]](function(_0x1f93x6){return _0x1f93x4[_0x22bf[7]](200)[_0x22bf[6]](_0x1f93x6)})[_0x22bf[5]](function(_0x1f93x5){return handleError(_0x1f93x4,_0x1f93x5)})};exports[_0x22bf[10]]=function(_0x1f93x3,_0x1f93x4){ReportMail[_0x22bf[14]](_0x1f93x3[_0x22bf[13]][_0x22bf[12]])[_0x22bf[8]](function(_0x1f93x7){if(!_0x1f93x7){return _0x1f93x4[_0x22bf[11]](404)};return _0x1f93x4[_0x22bf[6]](_0x1f93x7);})[_0x22bf[5]](function(_0x1f93x5){return handleError(_0x1f93x4,_0x1f93x5)})};exports[_0x22bf[15]]=function(_0x1f93x3,_0x1f93x4){ReportMail[_0x22bf[15]](_0x1f93x3[_0x22bf[16]])[_0x22bf[8]](function(_0x1f93x7){return _0x1f93x4[_0x22bf[7]](201)[_0x22bf[6]](_0x1f93x7)})[_0x22bf[5]](function(_0x1f93x5){return handleError(_0x1f93x4,_0x1f93x5)})};exports[_0x22bf[17]]=function(_0x1f93x3,_0x1f93x4){if(_0x1f93x3[_0x22bf[16]][_0x22bf[12]]){delete _0x1f93x3[_0x22bf[16]][_0x22bf[12]]};ReportMail[_0x22bf[14]](_0x1f93x3[_0x22bf[13]][_0x22bf[12]])[_0x22bf[8]](function(_0x1f93x7){if(!_0x1f93x7){return _0x1f93x4[_0x22bf[11]](404)};var _0x1f93x8=_[_0x22bf[18]](_0x1f93x7,_0x1f93x3[_0x22bf[16]]);_0x1f93x8[_0x22bf[19]]()[_0x22bf[8]](function(){return _0x1f93x4[_0x22bf[7]](200)[_0x22bf[6]](_0x1f93x7)})[_0x22bf[5]](function(_0x1f93x5){return handleError(_0x1f93x4,_0x1f93x5)});})[_0x22bf[5]](function(_0x1f93x5){return handleError(_0x1f93x4,_0x1f93x5)});};exports[_0x22bf[20]]=function(_0x1f93x3,_0x1f93x4){ReportMail[_0x22bf[14]](_0x1f93x3[_0x22bf[13]][_0x22bf[12]])[_0x22bf[8]](function(_0x1f93x7){if(!_0x1f93x7){return _0x1f93x4[_0x22bf[11]](404)};_0x1f93x7[_0x22bf[20]]()[_0x22bf[8]](function(){return _0x1f93x4[_0x22bf[11]](204)})[_0x22bf[5]](function(_0x1f93x5){return handleError(_0x1f93x4,_0x1f93x5)});})[_0x22bf[5]](function(_0x1f93x5){return handleError(_0x1f93x4,_0x1f93x5)})};function handleError(_0x1f93x4,_0x1f93x5){return _0x1f93x4[_0x22bf[7]](500)[_0x22bf[6]](_0x1f93x5)} \ No newline at end of file diff --git a/server/api/report_mail/report_mail.socket.js b/server/api/report_mail/report_mail.socket.js index 1fec069..523c8dc 100644 --- a/server/api/report_mail/report_mail.socket.js +++ b/server/api/report_mail/report_mail.socket.js @@ -1,35 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ReportMail = require('../../models').ReportMail; - -exports.register = function(socket) { - ReportMail.afterCreate(function(doc) { - onSave(socket, doc); - }); - ReportMail.afterUpdate(function(doc) { - onUpdate(socket, doc); - }); - ReportMail.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - if (socket.name === doc.membername || socket.role === 'admin') { - socket.emit('report_mail:save', doc); - } -} - -function onUpdate(socket, doc, cb) { - if (socket.name === doc.membername || socket.role === 'admin') { - socket.emit('report_mail:update', doc); - } -} - -function onRemove(socket, doc, cb) { - socket.emit('report_mail:remove', doc); -} +var _0x5377=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6E\x61\x6D\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x72\x6F\x6C\x65","\x61\x64\x6D\x69\x6E","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x3A\x75\x70\x64\x61\x74\x65","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x3A\x72\x65\x6D\x6F\x76\x65"];_0x5377[0];var ReportMail=require(_0x5377[2])[_0x5377[1]];exports[_0x5377[3]]=function(_0x9e48x2){ReportMail[_0x5377[4]](function(_0x9e48x3){onSave(_0x9e48x2,_0x9e48x3)});ReportMail[_0x5377[5]](function(_0x9e48x3){onUpdate(_0x9e48x2,_0x9e48x3)});ReportMail[_0x5377[6]](function(_0x9e48x3){onRemove(_0x9e48x2,_0x9e48x3)});};function onSave(_0x9e48x2,_0x9e48x3,_0x9e48x5){if(_0x9e48x2[_0x5377[7]]===_0x9e48x3[_0x5377[8]]||_0x9e48x2[_0x5377[9]]===_0x5377[10]){_0x9e48x2[_0x5377[12]](_0x5377[11],_0x9e48x3)}}function onUpdate(_0x9e48x2,_0x9e48x3,_0x9e48x5){if(_0x9e48x2[_0x5377[7]]===_0x9e48x3[_0x5377[8]]||_0x9e48x2[_0x5377[9]]===_0x5377[10]){_0x9e48x2[_0x5377[12]](_0x5377[13],_0x9e48x3)}}function onRemove(_0x9e48x2,_0x9e48x3,_0x9e48x5){_0x9e48x2[_0x5377[12]](_0x5377[14],_0x9e48x3)} \ No newline at end of file diff --git a/server/api/report_mail/report_mail.spec.js b/server/api/report_mail/report_mail.spec.js index 80e5153..c5bec13 100644 --- a/server/api/report_mail/report_mail.spec.js +++ b/server/api/report_mail/report_mail.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/report/mails', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/report/mails') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xb0db=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x6D\x61\x69\x6C\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x6D\x61\x69\x6C\x73","\x67\x65\x74"];_0xb0db[0];var should=require(_0xb0db[1]);var app=require(_0xb0db[2]);var request=require(_0xb0db[3]);describe(_0xb0db[4],function(){it(_0xb0db[5],function(_0xa491x4){request(app)[_0xb0db[13]](_0xb0db[12])[_0xb0db[11]](200)[_0xb0db[11]](_0xb0db[10],/json/)[_0xb0db[9]](function(_0xa491x5,_0xa491x6){if(_0xa491x5){return _0xa491x4(_0xa491x5)};_0xa491x6[_0xb0db[8]][_0xb0db[1]][_0xb0db[7]][_0xb0db[6]](Array);_0xa491x4();})})}); \ No newline at end of file diff --git a/server/api/report_mail_session/index.js b/server/api/report_mail_session/index.js index ecd3edc..e808c30 100644 --- a/server/api/report_mail_session/index.js +++ b/server/api/report_mail_session/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_mail_session.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x317b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x317b[0];var express=require(_0x317b[1]);var controller=require(_0x317b[2]);var router=express.Router();router[_0x317b[5]](_0x317b[3],controller[_0x317b[4]]);router[_0x317b[5]](_0x317b[6],controller[_0x317b[7]]);router[_0x317b[9]](_0x317b[3],controller[_0x317b[8]]);router[_0x317b[11]](_0x317b[6],controller[_0x317b[10]]);router[_0x317b[12]](_0x317b[6],controller[_0x317b[10]]);router[_0x317b[14]](_0x317b[6],controller[_0x317b[13]]);module[_0x317b[15]]=router; \ No newline at end of file diff --git a/server/api/report_mail_session/report_mail_session.controller.js b/server/api/report_mail_session/report_mail_session.controller.js index d218fae..515787f 100644 --- a/server/api/report_mail_session/report_mail_session.controller.js +++ b/server/api/report_mail_session/report_mail_session.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ReportMailSession = require('../../models').ReportMailSession; - -// Get list of report_mail_sessions -exports.index = function(req, res) { - ReportMailSession - .findAll() - .then(function (report_mail_sessions) { - return res.status(200).send(report_mail_sessions); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single report_mail_session -exports.show = function(req, res) { - ReportMailSession - .findById(req.params.id) - .then(function (report_mail_session) { - if(!report_mail_session) { return res.sendStatus(404); } - return res.send(report_mail_session); - }) - .catch(function(err){ - return handleError(res, err); - }); -}; - -// Creates a new report_mail_session in the DB. -exports.create = function(req, res) { - ReportMailSession - .create(req.body) - .then(function(report_mail_session) { - return res.status(201).send(report_mail_session); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report_mail_session in the DB. -exports.update = function(req, res) { - if(req.body.id) { delete req.body.id; } - ReportMailSession - .find({ - where: { - id: req.params.id - } - }) - .then(function (report_mail_session) { - if(!report_mail_session) { return res.sendStatus(404); } - var updated = _.merge(report_mail_session, req.body); - updated.save() - .then(function () { - return res.status(200).send(report_mail_session); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a report_mail_session from the DB. -exports.destroy = function(req, res) { - ReportMailSession - .find({ - where: { - id: req.params.id - } - }) - .then(function (report_mail_session) { - if(!report_mail_session) { return res.sendStatus(404); } - report_mail_session.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x9036=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x9036[0];var _=require(_0x9036[1]);var ReportMailSession=require(_0x9036[3])[_0x9036[2]];exports[_0x9036[4]]=function(_0xfa82x3,_0xfa82x4){ReportMailSession[_0x9036[9]]()[_0x9036[8]](function(_0xfa82x6){return _0xfa82x4[_0x9036[7]](200)[_0x9036[6]](_0xfa82x6)})[_0x9036[5]](function(_0xfa82x5){return handleError(_0xfa82x4,_0xfa82x5)})};exports[_0x9036[10]]=function(_0xfa82x3,_0xfa82x4){ReportMailSession[_0x9036[14]](_0xfa82x3[_0x9036[13]][_0x9036[12]])[_0x9036[8]](function(_0xfa82x7){if(!_0xfa82x7){return _0xfa82x4[_0x9036[11]](404)};return _0xfa82x4[_0x9036[6]](_0xfa82x7);})[_0x9036[5]](function(_0xfa82x5){return handleError(_0xfa82x4,_0xfa82x5)})};exports[_0x9036[15]]=function(_0xfa82x3,_0xfa82x4){ReportMailSession[_0x9036[15]](_0xfa82x3[_0x9036[16]])[_0x9036[8]](function(_0xfa82x7){return _0xfa82x4[_0x9036[7]](201)[_0x9036[6]](_0xfa82x7)})[_0x9036[5]](function(_0xfa82x5){return handleError(_0xfa82x4,_0xfa82x5)})};exports[_0x9036[17]]=function(_0xfa82x3,_0xfa82x4){if(_0xfa82x3[_0x9036[16]][_0x9036[12]]){delete _0xfa82x3[_0x9036[16]][_0x9036[12]]};ReportMailSession[_0x9036[20]]({where:{id:_0xfa82x3[_0x9036[13]][_0x9036[12]]}})[_0x9036[8]](function(_0xfa82x7){if(!_0xfa82x7){return _0xfa82x4[_0x9036[11]](404)};var _0xfa82x8=_[_0x9036[18]](_0xfa82x7,_0xfa82x3[_0x9036[16]]);_0xfa82x8[_0x9036[19]]()[_0x9036[8]](function(){return _0xfa82x4[_0x9036[7]](200)[_0x9036[6]](_0xfa82x7)})[_0x9036[5]](function(_0xfa82x5){return handleError(_0xfa82x4,_0xfa82x5)});})[_0x9036[5]](function(_0xfa82x5){return handleError(_0xfa82x4,_0xfa82x5)});};exports[_0x9036[21]]=function(_0xfa82x3,_0xfa82x4){ReportMailSession[_0x9036[20]]({where:{id:_0xfa82x3[_0x9036[13]][_0x9036[12]]}})[_0x9036[8]](function(_0xfa82x7){if(!_0xfa82x7){return _0xfa82x4[_0x9036[11]](404)};_0xfa82x7[_0x9036[21]]()[_0x9036[8]](function(){return _0xfa82x4[_0x9036[11]](204)})[_0x9036[5]](function(_0xfa82x5){return handleError(_0xfa82x4,_0xfa82x5)});})[_0x9036[5]](function(_0xfa82x5){return handleError(_0xfa82x4,_0xfa82x5)})};function handleError(_0xfa82x4,_0xfa82x5){return _0xfa82x4[_0x9036[7]](500)[_0x9036[6]](_0xfa82x5)} \ No newline at end of file diff --git a/server/api/report_mail_session/report_mail_session.socket.js b/server/api/report_mail_session/report_mail_session.socket.js index 6489a0d..4042787 100644 --- a/server/api/report_mail_session/report_mail_session.socket.js +++ b/server/api/report_mail_session/report_mail_session.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ReportMailSession = require('../../models').ReportMailSession; - -exports.register = function(socket) { - ReportMailSession.afterCreate(function(doc) { - onSave(socket, doc); - }); - ReportMailSession.afterUpdate(function(doc) { - onSave(socket, doc); - }); - ReportMailSession.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('report_mail_session:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('report_mail_session:remove', doc); -} +var _0x61a1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x61a1[0];var ReportMailSession=require(_0x61a1[2])[_0x61a1[1]];exports[_0x61a1[3]]=function(_0x1e28x2){ReportMailSession[_0x61a1[4]](function(_0x1e28x3){onSave(_0x1e28x2,_0x1e28x3)});ReportMailSession[_0x61a1[5]](function(_0x1e28x3){onSave(_0x1e28x2,_0x1e28x3)});ReportMailSession[_0x61a1[6]](function(_0x1e28x3){onRemove(_0x1e28x2,_0x1e28x3)});};function onSave(_0x1e28x2,_0x1e28x3,_0x1e28x5){_0x1e28x2[_0x61a1[8]](_0x61a1[7],_0x1e28x3)}function onRemove(_0x1e28x2,_0x1e28x3,_0x1e28x5){_0x1e28x2[_0x61a1[8]](_0x61a1[9],_0x1e28x3)} \ No newline at end of file diff --git a/server/api/report_mail_session/report_mail_session.spec.js b/server/api/report_mail_session/report_mail_session.spec.js index d528b0c..31fc9a5 100644 --- a/server/api/report_mail_session/report_mail_session.spec.js +++ b/server/api/report_mail_session/report_mail_session.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/report/mail/sessions', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/report/mail/sessions') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x2b7f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x6D\x61\x69\x6C\x2F\x73\x65\x73\x73\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x6D\x61\x69\x6C\x2F\x73\x65\x73\x73\x69\x6F\x6E\x73","\x67\x65\x74"];_0x2b7f[0];var should=require(_0x2b7f[1]);var app=require(_0x2b7f[2]);var request=require(_0x2b7f[3]);describe(_0x2b7f[4],function(){it(_0x2b7f[5],function(_0x123fx4){request(app)[_0x2b7f[13]](_0x2b7f[12])[_0x2b7f[11]](200)[_0x2b7f[11]](_0x2b7f[10],/json/)[_0x2b7f[9]](function(_0x123fx5,_0x123fx6){if(_0x123fx5){return _0x123fx4(_0x123fx5)};_0x123fx6[_0x2b7f[8]][_0x2b7f[1]][_0x2b7f[7]][_0x2b7f[6]](Array);_0x123fx4();})})}); \ No newline at end of file diff --git a/server/api/report_queue/index.js b/server/api/report_queue/index.js index 613730a..7bd3db6 100644 --- a/server/api/report_queue/index.js +++ b/server/api/report_queue/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_queue.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x96b4=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x96b4[0];var express=require(_0x96b4[1]);var controller=require(_0x96b4[2]);var router=express.Router();router[_0x96b4[5]](_0x96b4[3],controller[_0x96b4[4]]);router[_0x96b4[5]](_0x96b4[6],controller[_0x96b4[7]]);router[_0x96b4[9]](_0x96b4[3],controller[_0x96b4[8]]);router[_0x96b4[11]](_0x96b4[6],controller[_0x96b4[10]]);router[_0x96b4[12]](_0x96b4[6],controller[_0x96b4[10]]);router[_0x96b4[14]](_0x96b4[6],controller[_0x96b4[13]]);module[_0x96b4[15]]=router; \ No newline at end of file diff --git a/server/api/report_queue/report_queue.controller.js b/server/api/report_queue/report_queue.controller.js index 2d7ce21..00e9d39 100644 --- a/server/api/report_queue/report_queue.controller.js +++ b/server/api/report_queue/report_queue.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ReportQueue = require('../../models').ReportQueue; - -// Get list of report_queues -exports.index = function(req, res) { - ReportQueue - .findAll() - .then(function(report_queues) { - return res.status(200).send(report_queues); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single report_queue -exports.show = function(req, res) { - ReportQueue - .findById(req.params.id) - .then(function(report_queue) { - if (!report_queue) { - return res.sendStatus(404); - } - return res.send(report_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new report_queue in the DB. -exports.create = function(req, res) { - ReportQueue - .create(req.body) - .then(function(report_queue) { - return res.status(201).send(report_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report_queue in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ReportQueue - .findById(req.params.id) - .then(function(report_queue) { - if (!report_queue) { - return res.sendStatus(404); - } - var updated = _.merge(report_queue, req.body); - updated.save() - .then(function() { - return res.status(200).send(report_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a report_queue from the DB. -exports.destroy = function(req, res) { - ReportQueue - .findById(req.params.id) - .then(function(report_queue) { - if (!report_queue) { - return res.sendStatus(404); - } - report_queue.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xdf46=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0xdf46[0];var _=require(_0xdf46[1]);var ReportQueue=require(_0xdf46[3])[_0xdf46[2]];exports[_0xdf46[4]]=function(_0x431fx3,_0x431fx4){ReportQueue[_0xdf46[9]]()[_0xdf46[8]](function(_0x431fx6){return _0x431fx4[_0xdf46[7]](200)[_0xdf46[6]](_0x431fx6)})[_0xdf46[5]](function(_0x431fx5){return handleError(_0x431fx4,_0x431fx5)})};exports[_0xdf46[10]]=function(_0x431fx3,_0x431fx4){ReportQueue[_0xdf46[14]](_0x431fx3[_0xdf46[13]][_0xdf46[12]])[_0xdf46[8]](function(_0x431fx7){if(!_0x431fx7){return _0x431fx4[_0xdf46[11]](404)};return _0x431fx4[_0xdf46[6]](_0x431fx7);})[_0xdf46[5]](function(_0x431fx5){return handleError(_0x431fx4,_0x431fx5)})};exports[_0xdf46[15]]=function(_0x431fx3,_0x431fx4){ReportQueue[_0xdf46[15]](_0x431fx3[_0xdf46[16]])[_0xdf46[8]](function(_0x431fx7){return _0x431fx4[_0xdf46[7]](201)[_0xdf46[6]](_0x431fx7)})[_0xdf46[5]](function(_0x431fx5){return handleError(_0x431fx4,_0x431fx5)})};exports[_0xdf46[17]]=function(_0x431fx3,_0x431fx4){if(_0x431fx3[_0xdf46[16]][_0xdf46[12]]){delete _0x431fx3[_0xdf46[16]][_0xdf46[12]]};ReportQueue[_0xdf46[14]](_0x431fx3[_0xdf46[13]][_0xdf46[12]])[_0xdf46[8]](function(_0x431fx7){if(!_0x431fx7){return _0x431fx4[_0xdf46[11]](404)};var _0x431fx8=_[_0xdf46[18]](_0x431fx7,_0x431fx3[_0xdf46[16]]);_0x431fx8[_0xdf46[19]]()[_0xdf46[8]](function(){return _0x431fx4[_0xdf46[7]](200)[_0xdf46[6]](_0x431fx7)})[_0xdf46[5]](function(_0x431fx5){return handleError(_0x431fx4,_0x431fx5)});})[_0xdf46[5]](function(_0x431fx5){return handleError(_0x431fx4,_0x431fx5)});};exports[_0xdf46[20]]=function(_0x431fx3,_0x431fx4){ReportQueue[_0xdf46[14]](_0x431fx3[_0xdf46[13]][_0xdf46[12]])[_0xdf46[8]](function(_0x431fx7){if(!_0x431fx7){return _0x431fx4[_0xdf46[11]](404)};_0x431fx7[_0xdf46[20]]()[_0xdf46[8]](function(){return _0x431fx4[_0xdf46[11]](204)})[_0xdf46[5]](function(_0x431fx5){return handleError(_0x431fx4,_0x431fx5)});})[_0xdf46[5]](function(_0x431fx5){return handleError(_0x431fx4,_0x431fx5)})};function handleError(_0x431fx4,_0x431fx5){return _0x431fx4[_0xdf46[7]](500)[_0xdf46[6]](_0x431fx5)} \ No newline at end of file diff --git a/server/api/report_queue/report_queue.socket.js b/server/api/report_queue/report_queue.socket.js index 9f57869..c73c0b5 100644 --- a/server/api/report_queue/report_queue.socket.js +++ b/server/api/report_queue/report_queue.socket.js @@ -1,29 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ReportQueue = require('../../models').ReportQueue; - -exports.register = function(socket) { - ReportQueue.afterCreate(function(doc) { - onSave(socket, doc); - }); - ReportQueue.afterUpdate(function(doc) { - onSave(socket, doc); - }); - ReportQueue.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - if (socket.role === 'admin') { - socket.emit('report_queue:save', doc); - } -} - -function onRemove(socket, doc, cb) { - socket.emit('report_queue:remove', doc); -} +var _0x2949=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x72\x6F\x6C\x65","\x61\x64\x6D\x69\x6E","\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x2949[0];var ReportQueue=require(_0x2949[2])[_0x2949[1]];exports[_0x2949[3]]=function(_0x155fx2){ReportQueue[_0x2949[4]](function(_0x155fx3){onSave(_0x155fx2,_0x155fx3)});ReportQueue[_0x2949[5]](function(_0x155fx3){onSave(_0x155fx2,_0x155fx3)});ReportQueue[_0x2949[6]](function(_0x155fx3){onRemove(_0x155fx2,_0x155fx3)});};function onSave(_0x155fx2,_0x155fx3,_0x155fx5){if(_0x155fx2[_0x2949[7]]===_0x2949[8]){_0x155fx2[_0x2949[10]](_0x2949[9],_0x155fx3)}}function onRemove(_0x155fx2,_0x155fx3,_0x155fx5){_0x155fx2[_0x2949[10]](_0x2949[11],_0x155fx3)} \ No newline at end of file diff --git a/server/api/report_tree/index.js b/server/api/report_tree/index.js index 75fa91c..db9419b 100644 --- a/server/api/report_tree/index.js +++ b/server/api/report_tree/index.js @@ -1,12 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./report_tree.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); - -module.exports = router; +var _0x2808=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x65\x78\x70\x6F\x72\x74\x73"];_0x2808[0];var express=require(_0x2808[1]);var controller=require(_0x2808[2]);var router=express.Router();router[_0x2808[5]](_0x2808[3],controller[_0x2808[4]]);router[_0x2808[8]](_0x2808[6],controller[_0x2808[7]]);router[_0x2808[9]](_0x2808[6],controller[_0x2808[7]]);module[_0x2808[10]]=router; \ No newline at end of file diff --git a/server/api/report_tree/report_tree.controller.js b/server/api/report_tree/report_tree.controller.js index a6b11b0..4ac8adc 100644 --- a/server/api/report_tree/report_tree.controller.js +++ b/server/api/report_tree/report_tree.controller.js @@ -1,46 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var ReportTree = require('../../models').ReportTree; - -// Get the reports trees -exports.index = function(req, res) { - ReportTree - .findAll() - .then(function(trees) { - if (!trees) { - return res.sendStatus(404); - } - return res.status(200).send(trees); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing report in the DB. -exports.update = function(req, res) { - ReportTree - .findById(req.params.id) - .then(function(tree) { - if (!tree) { - return res.sendStatus(404); - } - var updated = _.merge(tree, req.body); - updated.save() - .then(function() { - return res.status(200).send(tree); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x193a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x52\x65\x70\x6F\x72\x74\x54\x72\x65\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x75\x70\x64\x61\x74\x65","\x62\x6F\x64\x79","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64"];_0x193a[0];var _=require(_0x193a[1]);var util=require(_0x193a[2]);var ReportTree=require(_0x193a[4])[_0x193a[3]];exports[_0x193a[5]]=function(_0xf4b9x4,_0xf4b9x5){ReportTree[_0x193a[11]]()[_0x193a[10]](function(_0xf4b9x7){if(!_0xf4b9x7){return _0xf4b9x5[_0x193a[7]](404)};return _0xf4b9x5[_0x193a[9]](200)[_0x193a[8]](_0xf4b9x7);})[_0x193a[6]](function(_0xf4b9x6){return handleError(_0xf4b9x5,_0xf4b9x6)})};exports[_0x193a[12]]=function(_0xf4b9x4,_0xf4b9x5){ReportTree[_0x193a[18]](_0xf4b9x4[_0x193a[17]][_0x193a[16]])[_0x193a[10]](function(_0xf4b9x8){if(!_0xf4b9x8){return _0xf4b9x5[_0x193a[7]](404)};var _0xf4b9x9=_[_0x193a[14]](_0xf4b9x8,_0xf4b9x4[_0x193a[13]]);_0xf4b9x9[_0x193a[15]]()[_0x193a[10]](function(){return _0xf4b9x5[_0x193a[9]](200)[_0x193a[8]](_0xf4b9x8)})[_0x193a[6]](function(_0xf4b9x6){return handleError(_0xf4b9x5,_0xf4b9x6)});})[_0x193a[6]](function(_0xf4b9x6){return handleError(_0xf4b9x5,_0xf4b9x6)})};function handleError(_0xf4b9x5,_0xf4b9x6){return _0xf4b9x5[_0x193a[9]](500)[_0x193a[8]](_0xf4b9x6)} \ No newline at end of file diff --git a/server/api/report_tree/report_tree.socket.js b/server/api/report_tree/report_tree.socket.js index 389fa7a..07e82ed 100644 --- a/server/api/report_tree/report_tree.socket.js +++ b/server/api/report_tree/report_tree.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ReportTree = require('../../models').ReportTree; - -exports.register = function(socket) { - ReportTree.afterCreate(function(doc) { - onSave(socket, doc); - }); - ReportTree.afterUpdate(function(doc) { - onSave(socket, doc); - }); - ReportTree.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('report_tree:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('report_tree:remove', doc); -} +var _0x7ca4=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x52\x65\x70\x6F\x72\x74\x54\x72\x65\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x7ca4[0];var ReportTree=require(_0x7ca4[2])[_0x7ca4[1]];exports[_0x7ca4[3]]=function(_0x83dbx2){ReportTree[_0x7ca4[4]](function(_0x83dbx3){onSave(_0x83dbx2,_0x83dbx3)});ReportTree[_0x7ca4[5]](function(_0x83dbx3){onSave(_0x83dbx2,_0x83dbx3)});ReportTree[_0x7ca4[6]](function(_0x83dbx3){onRemove(_0x83dbx2,_0x83dbx3)});};function onSave(_0x83dbx2,_0x83dbx3,_0x83dbx5){_0x83dbx2[_0x7ca4[8]](_0x7ca4[7],_0x83dbx3)}function onRemove(_0x83dbx2,_0x83dbx3,_0x83dbx5){_0x83dbx2[_0x7ca4[8]](_0x7ca4[9],_0x83dbx3)} \ No newline at end of file diff --git a/server/api/report_tree/report_tree.spec.js b/server/api/report_tree/report_tree.spec.js index 37d897a..47203c0 100644 --- a/server/api/report_tree/report_tree.spec.js +++ b/server/api/report_tree/report_tree.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/analytics/reports/trees', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/analytic/reports/trees') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x646b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x74\x72\x65\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x74\x72\x65\x65\x73","\x67\x65\x74"];_0x646b[0];var should=require(_0x646b[1]);var app=require(_0x646b[2]);var request=require(_0x646b[3]);describe(_0x646b[4],function(){it(_0x646b[5],function(_0x6470x4){request(app)[_0x646b[13]](_0x646b[12])[_0x646b[11]](200)[_0x646b[11]](_0x646b[10],/json/)[_0x646b[9]](function(_0x6470x5,_0x6470x6){if(_0x6470x5){return _0x6470x4(_0x6470x5)};_0x6470x6[_0x646b[8]][_0x646b[1]][_0x646b[7]][_0x646b[6]](Array);_0x6470x4();})})}); \ No newline at end of file diff --git a/server/api/salesforce_account/index.js b/server/api/salesforce_account/index.js index d8b47b0..144e23f 100644 --- a/server/api/salesforce_account/index.js +++ b/server/api/salesforce_account/index.js @@ -1,21 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./salesforce_account.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount); -router.get('/:id/fields', auth.isAuthenticated(), controller.getFields); -router.post('/validate/:field', auth.isAuthenticated(), controller.accountValidation); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0xaf5a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x63\x68\x65\x63\x6B","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2F\x3A\x69\x64\x2F\x66\x69\x65\x6C\x64\x73","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65\x2F\x3A\x66\x69\x65\x6C\x64","\x61\x63\x63\x6F\x75\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xaf5a[0];var express=require(_0xaf5a[1]);var auth=require(_0xaf5a[2]);var controller=require(_0xaf5a[3]);var router=express.Router();router[_0xaf5a[7]](_0xaf5a[4],auth[_0xaf5a[5]](),controller[_0xaf5a[6]]);router[_0xaf5a[7]](_0xaf5a[8],auth[_0xaf5a[5]](),controller[_0xaf5a[9]]);router[_0xaf5a[7]](_0xaf5a[10],auth[_0xaf5a[5]](),controller[_0xaf5a[11]]);router[_0xaf5a[7]](_0xaf5a[12],auth[_0xaf5a[5]](),controller[_0xaf5a[13]]);router[_0xaf5a[16]](_0xaf5a[14],auth[_0xaf5a[5]](),controller[_0xaf5a[15]]);router[_0xaf5a[16]](_0xaf5a[4],auth[_0xaf5a[5]](),controller[_0xaf5a[17]]);router[_0xaf5a[19]](_0xaf5a[8],auth[_0xaf5a[5]](),controller[_0xaf5a[18]]);router[_0xaf5a[20]](_0xaf5a[8],auth[_0xaf5a[5]](),controller[_0xaf5a[18]]);router[_0xaf5a[22]](_0xaf5a[4],auth[_0xaf5a[5]](),controller[_0xaf5a[21]]);router[_0xaf5a[22]](_0xaf5a[8],auth[_0xaf5a[5]](),controller[_0xaf5a[23]]);module[_0xaf5a[24]]=router; \ No newline at end of file diff --git a/server/api/salesforce_account/index.spec.js b/server/api/salesforce_account/index.spec.js index a03b303..5e1e213 100644 --- a/server/api/salesforce_account/index.spec.js +++ b/server/api/salesforce_account/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var salesforceAccountCtrlStub = { - index: 'salesforceAccountCtrl.index', - show: 'salesforceAccountCtrl.show', - create: 'salesforceAccountCtrl.create', - update: 'salesforceAccountCtrl.update', - destroy: 'salesforceAccountCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var salesforceAccountIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './salesforce_account.controller': salesforceAccountCtrlStub -}); - -describe('SalesforceAccount API Router:', function() { - - it('should return an express router instance', function() { - expect(salesforceAccountIndex).to.equal(routerStub); - }); - - describe('GET /api/salesforce/accounts', function() { - - it('should route to salesforceAccount.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'salesforceAccountCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/salesforce/accounts/:id', function() { - - it('should route to salesforceAccount.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'salesforceAccountCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/salesforce/accounts', function() { - - it('should route to salesforceAccount.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'salesforceAccountCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/salesforce/accounts/:id', function() { - - it('should route to salesforceAccount.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'salesforceAccountCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/salesforce/accounts/:id', function() { - - it('should route to salesforceAccount.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'salesforceAccountCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/salesforce/accounts/:id', function() { - - it('should route to salesforceAccount.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'salesforceAccountCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0x2a3a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0x2a3a[0];var proxyquire=require(_0x2a3a[2])[_0x2a3a[1]]();var salesforceAccountCtrlStub={index:_0x2a3a[3],show:_0x2a3a[4],create:_0x2a3a[5],update:_0x2a3a[6],destroy:_0x2a3a[7]};var routerStub={get:sinon[_0x2a3a[8]](),put:sinon[_0x2a3a[8]](),patch:sinon[_0x2a3a[8]](),post:sinon[_0x2a3a[8]](),delete:sinon[_0x2a3a[8]]()};var salesforceAccountIndex=proxyquire(_0x2a3a[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":salesforceAccountCtrlStub});describe(_0x2a3a[10],function(){it(_0x2a3a[11],function(){expect(salesforceAccountIndex)[_0x2a3a[13]][_0x2a3a[12]](routerStub)});describe(_0x2a3a[14],function(){it(_0x2a3a[15],function(){expect(routerStub[_0x2a3a[21]][_0x2a3a[20]](_0x2a3a[19],_0x2a3a[3]))[_0x2a3a[13]][_0x2a3a[18]][_0x2a3a[17]][_0x2a3a[16]]})});describe(_0x2a3a[22],function(){it(_0x2a3a[23],function(){expect(routerStub[_0x2a3a[21]][_0x2a3a[20]](_0x2a3a[24],_0x2a3a[4]))[_0x2a3a[13]][_0x2a3a[18]][_0x2a3a[17]][_0x2a3a[16]]})});describe(_0x2a3a[25],function(){it(_0x2a3a[26],function(){expect(routerStub[_0x2a3a[27]][_0x2a3a[20]](_0x2a3a[19],_0x2a3a[5]))[_0x2a3a[13]][_0x2a3a[18]][_0x2a3a[17]][_0x2a3a[16]]})});describe(_0x2a3a[28],function(){it(_0x2a3a[29],function(){expect(routerStub[_0x2a3a[30]][_0x2a3a[20]](_0x2a3a[24],_0x2a3a[6]))[_0x2a3a[13]][_0x2a3a[18]][_0x2a3a[17]][_0x2a3a[16]]})});describe(_0x2a3a[31],function(){it(_0x2a3a[29],function(){expect(routerStub[_0x2a3a[32]][_0x2a3a[20]](_0x2a3a[24],_0x2a3a[6]))[_0x2a3a[13]][_0x2a3a[18]][_0x2a3a[17]][_0x2a3a[16]]})});describe(_0x2a3a[33],function(){it(_0x2a3a[34],function(){expect(routerStub[_0x2a3a[35]][_0x2a3a[20]](_0x2a3a[24],_0x2a3a[7]))[_0x2a3a[13]][_0x2a3a[18]][_0x2a3a[17]][_0x2a3a[16]]})});}); \ No newline at end of file diff --git a/server/api/salesforce_account/salesforce_account.controller.js b/server/api/salesforce_account/salesforce_account.controller.js index 69c55e6..1b9122b 100644 --- a/server/api/salesforce_account/salesforce_account.controller.js +++ b/server/api/salesforce_account/salesforce_account.controller.js @@ -1,253 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/salesforce/accounts -> index - * POST /api/salesforce/accounts -> create - * GET /api/salesforce/accounts/:id -> show - * PUT /api/salesforce/accounts/:id -> update - * DELETE /api/salesforce/accounts/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); -var util = require('util'); -var jsforce = require('jsforce'); - -var SalesforceAccount = require('../../models').SalesforceAccount; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of SalesforceAccounts -exports.index = function(req, res) { - var attributes = ['description', 'name', 'username', 'remoteUri']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - SalesforceAccount - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - return res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return res.status(500).send({ - error: 'Something blew up!' - }); - }); -} - -// Gets a single SalesforceAccount from the DB -exports.show = function(req, res) { - SalesforceAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new SalesforceAccount in the DB -exports.create = function(req, res) { - SalesforceAccount.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing SalesforceAccount in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - SalesforceAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a SalesforceAccount from the DB -exports.destroy = function(req, res) { - SalesforceAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} - -exports.checkAccount = function(req, res) { - SalesforceAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(account) { - var conn = new jsforce.Connection({ - oauth2: { - loginUrl: account.remoteUri, - clientId: account.clientId, - clientSecret: account.clientSecret, - } - }); - var pwd = account.password.concat(account.securityToken); - conn.login(account.username, pwd, function(err, userInfo) { - if (err) { - return res.status(400).send(err); - } - return res.sendStatus(200); - }); - }) - .catch(handleError(res)); -} - -exports.accountValidation = function(req, res) { - var where = {}; - where[req.params.field] = req.body.value; - SalesforceAccount - .findAndCountAll({ - where: where - }) - .then(function(result) { - if (result.count) { - return res.status(200).send({ - isValid: false, - value: req.body.value - }); - } - return res.status(200).send({ - isValid: true, - value: req.body.value - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getFields = function(req, res) { - SalesforceAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(account) { - var conn = new jsforce.Connection({ - oauth2: { - loginUrl: account.remoteUri, - clientId: account.clientId, - clientSecret: account.clientSecret, - } - }); - var pwd = account.password.concat(account.securityToken); - conn.login(account.username, pwd, function(err, userInfo) { - if (err) { - return res.status(400).send(err); - } - conn.sobject("Task").describe(function(err, meta) { - if (err) { - return res.status(400).send(err); - } - return res.status(200).send(meta.fields); - }); - }); - }) - .catch(handleError(res)); -}; - -exports.bulkDestroy = function(req, res) { - SalesforceAccount - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; +var _0xc60e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x6A\x73\x66\x6F\x72\x63\x65","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x63\x6C\x69\x65\x6E\x74\x49\x64","\x63\x6C\x69\x65\x6E\x74\x53\x65\x63\x72\x65\x74","\x73\x65\x63\x75\x72\x69\x74\x79\x54\x6F\x6B\x65\x6E","\x63\x6F\x6E\x63\x61\x74","\x70\x61\x73\x73\x77\x6F\x72\x64","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x6C\x6F\x67\x69\x6E","\x61\x63\x63\x6F\x75\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x66\x69\x65\x6C\x64\x73","\x64\x65\x73\x63\x72\x69\x62\x65","\x54\x61\x73\x6B","\x73\x6F\x62\x6A\x65\x63\x74","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0xc60e[0];var _=require(_0xc60e[1]);var util=require(_0xc60e[2]);var jsforce=require(_0xc60e[3]);var SalesforceAccount=require(_0xc60e[5])[_0xc60e[4]];function handleError(_0x22dax6,_0x22dax7){_0x22dax7=_0x22dax7||500;return function(_0x22dax8){_0x22dax6[_0xc60e[7]](_0x22dax7)[_0xc60e[6]](_0x22dax8)};}function responseWithResult(_0x22dax6,_0x22dax7){_0x22dax7=_0x22dax7||200;return function(_0x22daxa){if(_0x22daxa){_0x22dax6[_0xc60e[7]](_0x22dax7)[_0xc60e[8]](_0x22daxa)}};}function handleEntityNotFound(_0x22dax6){return function(_0x22daxa){if(!_0x22daxa){_0x22dax6[_0xc60e[7]](404)[_0xc60e[9]]();return null;};return _0x22daxa;}}function saveUpdates(_0x22daxd){return function(_0x22daxa){return _0x22daxa[_0xc60e[11]](_0x22daxd)[_0xc60e[10]](function(_0x22daxe){return _0x22daxe})}}function removeEntity(_0x22dax6){return function(_0x22daxa){if(_0x22daxa){return _0x22daxa[_0xc60e[12]]()[_0xc60e[10]](function(){_0x22dax6[_0xc60e[7]](204)[_0xc60e[9]]()})}}}exports[_0xc60e[13]]=function(_0x22dax10,_0x22dax6){var _0x22dax11=[_0xc60e[14],_0xc60e[15],_0xc60e[16],_0xc60e[17]];var _0x22dax12=_0x22dax10[_0xc60e[19]][_0xc60e[18]]?parseInt(_0x22dax10[_0xc60e[19]][_0xc60e[18]],10):100;var _0x22dax13=_0x22dax10[_0xc60e[19]][_0xc60e[20]]?parseInt(_0x22dax10[_0xc60e[19]][_0xc60e[20]],10):0;var _0x22dax14={where:{},limit:_0x22dax12,offset:_0x22dax13*_0x22dax12};_[_0xc60e[34]](_0x22dax10[_0xc60e[19]],function(_0x22dax15,_0x22dax16){switch(_0x22dax16){case _0xc60e[18]:;case _0xc60e[20]:break ;;case _0xc60e[23]:_0x22dax14[_0xc60e[21]]=util[_0xc60e[26]](_0xc60e[22],_0x22dax10[_0xc60e[19]][_0xc60e[23]],_0x22dax10[_0xc60e[19]][_0xc60e[24]]||_0xc60e[25])||null;break ;;case _0xc60e[24]:break ;;case _0xc60e[32]:_0x22dax14[_0xc60e[28]][_0xc60e[27]]=[];_0x22dax11[_0xc60e[31]](function(_0x22dax17){var _0x22dax18={};_0x22dax18[_0x22dax17]={$like:_0xc60e[29]+_0x22dax15+_0xc60e[29]};_0x22dax14[_0xc60e[28]][_0xc60e[27]][_0xc60e[30]](_0x22dax18);});break ;;default:_0x22dax14[_0xc60e[28]][_0x22dax16]={$like:{}};_0x22dax14[_0xc60e[28]][_0x22dax16][_0xc60e[33]]=_0xc60e[29]+_0x22dax15+_0xc60e[29];;}});SalesforceAccount[_0xc60e[46]](_0x22dax14)[_0xc60e[10]](function(_0x22dax19){var _0x22dax1a=Math[_0xc60e[38]](_0x22dax19[_0xc60e[37]]/_0x22dax12);var _0x22dax1b=_0x22dax1a>(_0x22dax14[_0xc60e[39]]+1)?util[_0xc60e[26]](_0xc60e[40],_0x22dax10[_0xc60e[41]],_0x22dax10[_0xc60e[43]][_0xc60e[42]],_0x22dax10[_0xc60e[44]],_0x22dax13+1):null;var _0x22dax1c=_0x22dax13>0?util[_0xc60e[26]](_0xc60e[40],_0x22dax10[_0xc60e[41]],_0x22dax10[_0xc60e[43]][_0xc60e[42]],_0x22dax10[_0xc60e[44]],_0x22dax13-1):null;return _0x22dax6[_0xc60e[7]](200)[_0xc60e[6]]({count:_0x22dax19[_0xc60e[37]],rows:_0x22dax19[_0xc60e[45]],next_page:_0x22dax1b,previous_page:_0x22dax1c,total_pages:_0x22dax1a});})[_0xc60e[36]](function(_0x22dax8){return _0x22dax6[_0xc60e[7]](500)[_0xc60e[6]]({error:_0xc60e[35]})});};exports[_0xc60e[47]]=function(_0x22dax10,_0x22dax6){SalesforceAccount[_0xc60e[50]](_0x22dax10[_0xc60e[49]][_0xc60e[48]])[_0xc60e[10]](handleEntityNotFound(_0x22dax6))[_0xc60e[10]](responseWithResult(_0x22dax6))[_0xc60e[36]](handleError(_0x22dax6))};exports[_0xc60e[51]]=function(_0x22dax10,_0x22dax6){SalesforceAccount[_0xc60e[51]](_0x22dax10[_0xc60e[52]])[_0xc60e[10]](responseWithResult(_0x22dax6,201))[_0xc60e[36]](handleError(_0x22dax6))};exports[_0xc60e[53]]=function(_0x22dax10,_0x22dax6){if(_0x22dax10[_0xc60e[52]][_0xc60e[48]]){delete _0x22dax10[_0xc60e[52]][_0xc60e[48]]};SalesforceAccount[_0xc60e[50]](_0x22dax10[_0xc60e[49]][_0xc60e[48]])[_0xc60e[10]](handleEntityNotFound(_0x22dax6))[_0xc60e[10]](saveUpdates(_0x22dax10[_0xc60e[52]]))[_0xc60e[10]](responseWithResult(_0x22dax6))[_0xc60e[36]](handleError(_0x22dax6));};exports[_0xc60e[12]]=function(_0x22dax10,_0x22dax6){SalesforceAccount[_0xc60e[50]](_0x22dax10[_0xc60e[49]][_0xc60e[48]])[_0xc60e[10]](handleEntityNotFound(_0x22dax6))[_0xc60e[10]](removeEntity(_0x22dax6))[_0xc60e[36]](handleError(_0x22dax6))};exports[_0xc60e[54]]=function(_0x22dax10,_0x22dax6){SalesforceAccount[_0xc60e[50]](_0x22dax10[_0xc60e[49]][_0xc60e[48]])[_0xc60e[10]](handleEntityNotFound(_0x22dax6))[_0xc60e[10]](function(_0x22dax1d){var _0x22dax1e= new jsforce.Connection({oauth2:{loginUrl:_0x22dax1d[_0xc60e[17]],clientId:_0x22dax1d[_0xc60e[55]],clientSecret:_0x22dax1d[_0xc60e[56]]}});var _0x22dax1f=_0x22dax1d[_0xc60e[59]][_0xc60e[58]](_0x22dax1d[_0xc60e[57]]);_0x22dax1e[_0xc60e[61]](_0x22dax1d[_0xc60e[16]],_0x22dax1f,function(_0x22dax8,_0x22dax20){if(_0x22dax8){return _0x22dax6[_0xc60e[7]](400)[_0xc60e[6]](_0x22dax8)};return _0x22dax6[_0xc60e[60]](200);});})[_0xc60e[36]](handleError(_0x22dax6))};exports[_0xc60e[62]]=function(_0x22dax10,_0x22dax6){var _0x22dax21={};_0x22dax21[_0x22dax10[_0xc60e[49]][_0xc60e[63]]]=_0x22dax10[_0xc60e[52]][_0xc60e[64]];SalesforceAccount[_0xc60e[46]]({where:_0x22dax21})[_0xc60e[10]](function(_0x22dax19){if(_0x22dax19[_0xc60e[37]]){return _0x22dax6[_0xc60e[7]](200)[_0xc60e[6]]({isValid:false,value:_0x22dax10[_0xc60e[52]][_0xc60e[64]]})};return _0x22dax6[_0xc60e[7]](200)[_0xc60e[6]]({isValid:true,value:_0x22dax10[_0xc60e[52]][_0xc60e[64]]});})[_0xc60e[36]](function(_0x22dax8){return handleError(_0x22dax6,_0x22dax8)});};exports[_0xc60e[65]]=function(_0x22dax10,_0x22dax6){SalesforceAccount[_0xc60e[50]](_0x22dax10[_0xc60e[49]][_0xc60e[48]])[_0xc60e[10]](handleEntityNotFound(_0x22dax6))[_0xc60e[10]](function(_0x22dax1d){var _0x22dax1e= new jsforce.Connection({oauth2:{loginUrl:_0x22dax1d[_0xc60e[17]],clientId:_0x22dax1d[_0xc60e[55]],clientSecret:_0x22dax1d[_0xc60e[56]]}});var _0x22dax1f=_0x22dax1d[_0xc60e[59]][_0xc60e[58]](_0x22dax1d[_0xc60e[57]]);_0x22dax1e[_0xc60e[61]](_0x22dax1d[_0xc60e[16]],_0x22dax1f,function(_0x22dax8,_0x22dax20){if(_0x22dax8){return _0x22dax6[_0xc60e[7]](400)[_0xc60e[6]](_0x22dax8)};_0x22dax1e[_0xc60e[69]](_0xc60e[68])[_0xc60e[67]](function(_0x22dax8,_0x22dax22){if(_0x22dax8){return _0x22dax6[_0xc60e[7]](400)[_0xc60e[6]](_0x22dax8)};return _0x22dax6[_0xc60e[7]](200)[_0xc60e[6]](_0x22dax22[_0xc60e[66]]);});});})[_0xc60e[36]](handleError(_0x22dax6))};exports[_0xc60e[70]]=function(_0x22dax10,_0x22dax6){SalesforceAccount[_0xc60e[12]]({where:{id:_0x22dax10[_0xc60e[19]][_0xc60e[48]]},individualHooks:true})[_0xc60e[10]](function(){return _0x22dax6[_0xc60e[60]](204)})[_0xc60e[36]](function(_0x22dax8){return handleError(_0x22dax6,_0x22dax8)})}; \ No newline at end of file diff --git a/server/api/salesforce_account/salesforce_account.socket.js b/server/api/salesforce_account/salesforce_account.socket.js index 2c58d15..9c7a995 100644 --- a/server/api/salesforce_account/salesforce_account.socket.js +++ b/server/api/salesforce_account/salesforce_account.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SalesforceAccount = require('../../models').SalesforceAccount; - -exports.register = function(socket) { - SalesforceAccount.afterCreate(function(doc) { - onSave(socket, doc); - }); - SalesforceAccount.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('salesforce_account:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('salesforce_account:remove', doc); -} +var _0x3bd8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x3bd8[0];var SalesforceAccount=require(_0x3bd8[2])[_0x3bd8[1]];exports[_0x3bd8[3]]=function(_0xc1a2x2){SalesforceAccount[_0x3bd8[4]](function(_0xc1a2x3){onSave(_0xc1a2x2,_0xc1a2x3)});SalesforceAccount[_0x3bd8[5]](function(_0xc1a2x3){onRemove(_0xc1a2x2,_0xc1a2x3)});};function onSave(_0xc1a2x2,_0xc1a2x3,_0xc1a2x5){_0xc1a2x2[_0x3bd8[7]](_0x3bd8[6],_0xc1a2x3)}function onRemove(_0xc1a2x2,_0xc1a2x3,_0xc1a2x5){_0xc1a2x2[_0x3bd8[7]](_0x3bd8[8],_0xc1a2x3)} \ No newline at end of file diff --git a/server/api/salesforce_configuration/index.js b/server/api/salesforce_configuration/index.js index 7936a09..f0fbfcf 100644 --- a/server/api/salesforce_configuration/index.js +++ b/server/api/salesforce_configuration/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./salesforce_configuration.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); - -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0xc3bb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x3A\x69\x64\x2F\x3A\x74\x79\x70\x65","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xc3bb[0];var express=require(_0xc3bb[1]);var auth=require(_0xc3bb[2]);var controller=require(_0xc3bb[3]);var router=express.Router();router[_0xc3bb[7]](_0xc3bb[4],auth[_0xc3bb[5]](),controller[_0xc3bb[6]]);router[_0xc3bb[7]](_0xc3bb[8],auth[_0xc3bb[5]](),controller[_0xc3bb[9]]);router[_0xc3bb[11]](_0xc3bb[4],auth[_0xc3bb[5]](),controller[_0xc3bb[10]]);router[_0xc3bb[13]](_0xc3bb[8],auth[_0xc3bb[5]](),controller[_0xc3bb[12]]);router[_0xc3bb[11]](_0xc3bb[14],auth[_0xc3bb[5]](),controller[_0xc3bb[15]]);router[_0xc3bb[16]](_0xc3bb[8],auth[_0xc3bb[5]](),controller[_0xc3bb[12]]);router[_0xc3bb[18]](_0xc3bb[8],auth[_0xc3bb[5]](),controller[_0xc3bb[17]]);module[_0xc3bb[19]]=router; \ No newline at end of file diff --git a/server/api/salesforce_configuration/index.spec.js b/server/api/salesforce_configuration/index.spec.js index 0d1e211..2eeb54b 100644 --- a/server/api/salesforce_configuration/index.spec.js +++ b/server/api/salesforce_configuration/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var salesforceConfigurationCtrlStub = { - index: 'salesforceConfigurationCtrl.index', - show: 'salesforceConfigurationCtrl.show', - create: 'salesforceConfigurationCtrl.create', - update: 'salesforceConfigurationCtrl.update', - destroy: 'salesforceConfigurationCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var salesforceConfigurationIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './salesforce_configuration.controller': salesforceConfigurationCtrlStub -}); - -describe('SalesforceConfiguration API Router:', function() { - - it('should return an express router instance', function() { - expect(salesforceConfigurationIndex).to.equal(routerStub); - }); - - describe('GET /api/salesforce/configurations', function() { - - it('should route to salesforceConfiguration.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'salesforceConfigurationCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/salesforce/configurations/:id', function() { - - it('should route to salesforceConfiguration.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'salesforceConfigurationCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/salesforce/configurations', function() { - - it('should route to salesforceConfiguration.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'salesforceConfigurationCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/salesforce/configurations/:id', function() { - - it('should route to salesforceConfiguration.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'salesforceConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/salesforce/configurations/:id', function() { - - it('should route to salesforceConfiguration.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'salesforceConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/salesforce/configurations/:id', function() { - - it('should route to salesforceConfiguration.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'salesforceConfigurationCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0x81c7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0x81c7[0];var proxyquire=require(_0x81c7[2])[_0x81c7[1]]();var salesforceConfigurationCtrlStub={index:_0x81c7[3],show:_0x81c7[4],create:_0x81c7[5],update:_0x81c7[6],destroy:_0x81c7[7]};var routerStub={get:sinon[_0x81c7[8]](),put:sinon[_0x81c7[8]](),patch:sinon[_0x81c7[8]](),post:sinon[_0x81c7[8]](),delete:sinon[_0x81c7[8]]()};var salesforceConfigurationIndex=proxyquire(_0x81c7[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":salesforceConfigurationCtrlStub});describe(_0x81c7[10],function(){it(_0x81c7[11],function(){expect(salesforceConfigurationIndex)[_0x81c7[13]][_0x81c7[12]](routerStub)});describe(_0x81c7[14],function(){it(_0x81c7[15],function(){expect(routerStub[_0x81c7[21]][_0x81c7[20]](_0x81c7[19],_0x81c7[3]))[_0x81c7[13]][_0x81c7[18]][_0x81c7[17]][_0x81c7[16]]})});describe(_0x81c7[22],function(){it(_0x81c7[23],function(){expect(routerStub[_0x81c7[21]][_0x81c7[20]](_0x81c7[24],_0x81c7[4]))[_0x81c7[13]][_0x81c7[18]][_0x81c7[17]][_0x81c7[16]]})});describe(_0x81c7[25],function(){it(_0x81c7[26],function(){expect(routerStub[_0x81c7[27]][_0x81c7[20]](_0x81c7[19],_0x81c7[5]))[_0x81c7[13]][_0x81c7[18]][_0x81c7[17]][_0x81c7[16]]})});describe(_0x81c7[28],function(){it(_0x81c7[29],function(){expect(routerStub[_0x81c7[30]][_0x81c7[20]](_0x81c7[24],_0x81c7[6]))[_0x81c7[13]][_0x81c7[18]][_0x81c7[17]][_0x81c7[16]]})});describe(_0x81c7[31],function(){it(_0x81c7[29],function(){expect(routerStub[_0x81c7[32]][_0x81c7[20]](_0x81c7[24],_0x81c7[6]))[_0x81c7[13]][_0x81c7[18]][_0x81c7[17]][_0x81c7[16]]})});describe(_0x81c7[33],function(){it(_0x81c7[34],function(){expect(routerStub[_0x81c7[35]][_0x81c7[20]](_0x81c7[24],_0x81c7[7]))[_0x81c7[13]][_0x81c7[18]][_0x81c7[17]][_0x81c7[16]]})});}); \ No newline at end of file diff --git a/server/api/salesforce_configuration/salesforce_configuration.controller.js b/server/api/salesforce_configuration/salesforce_configuration.controller.js index 523aef6..46304ed 100644 --- a/server/api/salesforce_configuration/salesforce_configuration.controller.js +++ b/server/api/salesforce_configuration/salesforce_configuration.controller.js @@ -1,147 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/salesforce/configurations -> index - * POST /api/salesforce/configurations -> create - * GET /api/salesforce/configurations/:id -> show - * PUT /api/salesforce/configurations/:id -> update - * DELETE /api/salesforce/configurations/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); - -var SalesforceConfiguration = require('../../models').SalesforceConfiguration; -var SalesforceField = require('../../models').SalesforceField; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of SalesforceConfigurations -exports.index = function(req, res) { - SalesforceConfiguration.findAll({ - where: req.query - }) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single SalesforceConfiguration from the DB -exports.show = function(req, res) { - SalesforceConfiguration.find({ - where: { - id: req.params.id - }, - include: [{ - model: SalesforceField, - as: 'Subject' - }, { - model: SalesforceField, - as: 'Description' - }, { - model: SalesforceField, - as: 'Field' - }] - }) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new SalesforceConfiguration in the DB -exports.create = function(req, res) { - SalesforceConfiguration.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing SalesforceConfiguration in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - SalesforceConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a SalesforceConfiguration from the DB -exports.destroy = function(req, res) { - SalesforceConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} - -exports.addConfigurationField = function(req, res, next) { - // console.log(req.params); - var salesforceConfiguration; - SalesforceConfiguration - .findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(salesforce_configuration) { - salesforceConfiguration = salesforce_configuration; - return SalesforceField.create(req.body) - }) - .then(function(salesforceField) { - switch (req.params.type) { - case 'subject': - return [salesforceConfiguration.addSubject(salesforceField), salesforceField]; - case 'description': - return [salesforceConfiguration.addDescription(salesforceField), salesforceField]; - case 'field': - return [salesforceConfiguration.addField(salesforceField), salesforceField]; - } - }) - .spread(function(data, salesforceField) { - return res.status(201).json(salesforceField); - }) - .catch(handleError(res)); -}; +var _0xa2c2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x53\x75\x62\x6A\x65\x63\x74","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x46\x69\x65\x6C\x64","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x73\x70\x72\x65\x61\x64","\x61\x64\x64\x53\x75\x62\x6A\x65\x63\x74","\x73\x75\x62\x6A\x65\x63\x74","\x61\x64\x64\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x61\x64\x64\x46\x69\x65\x6C\x64","\x66\x69\x65\x6C\x64","\x74\x79\x70\x65"];_0xa2c2[0];var _=require(_0xa2c2[1]);var SalesforceConfiguration=require(_0xa2c2[3])[_0xa2c2[2]];var SalesforceField=require(_0xa2c2[3])[_0xa2c2[4]];function handleError(_0x60ccx5,_0x60ccx6){_0x60ccx6=_0x60ccx6||500;return function(_0x60ccx7){_0x60ccx5[_0xa2c2[6]](_0x60ccx6)[_0xa2c2[5]](_0x60ccx7)};}function responseWithResult(_0x60ccx5,_0x60ccx6){_0x60ccx6=_0x60ccx6||200;return function(_0x60ccx9){if(_0x60ccx9){_0x60ccx5[_0xa2c2[6]](_0x60ccx6)[_0xa2c2[7]](_0x60ccx9)}};}function handleEntityNotFound(_0x60ccx5){return function(_0x60ccx9){if(!_0x60ccx9){_0x60ccx5[_0xa2c2[6]](404)[_0xa2c2[8]]();return null;};return _0x60ccx9;}}function saveUpdates(_0x60ccxc){return function(_0x60ccx9){return _0x60ccx9[_0xa2c2[10]](_0x60ccxc)[_0xa2c2[9]](function(_0x60ccxd){return _0x60ccxd})}}function removeEntity(_0x60ccx5){return function(_0x60ccx9){if(_0x60ccx9){return _0x60ccx9[_0xa2c2[11]]()[_0xa2c2[9]](function(){_0x60ccx5[_0xa2c2[6]](204)[_0xa2c2[8]]()})}}}exports[_0xa2c2[12]]=function(_0x60ccxf,_0x60ccx5){SalesforceConfiguration[_0xa2c2[15]]({where:_0x60ccxf[_0xa2c2[14]]})[_0xa2c2[9]](responseWithResult(_0x60ccx5))[_0xa2c2[13]](handleError(_0x60ccx5))};exports[_0xa2c2[16]]=function(_0x60ccxf,_0x60ccx5){SalesforceConfiguration[_0xa2c2[22]]({where:{id:_0x60ccxf[_0xa2c2[18]][_0xa2c2[17]]},include:[{model:SalesforceField,as:_0xa2c2[19]},{model:SalesforceField,as:_0xa2c2[20]},{model:SalesforceField,as:_0xa2c2[21]}]})[_0xa2c2[9]](handleEntityNotFound(_0x60ccx5))[_0xa2c2[9]](responseWithResult(_0x60ccx5))[_0xa2c2[13]](handleError(_0x60ccx5))};exports[_0xa2c2[23]]=function(_0x60ccxf,_0x60ccx5){SalesforceConfiguration[_0xa2c2[23]](_0x60ccxf[_0xa2c2[24]])[_0xa2c2[9]](responseWithResult(_0x60ccx5,201))[_0xa2c2[13]](handleError(_0x60ccx5))};exports[_0xa2c2[25]]=function(_0x60ccxf,_0x60ccx5){if(_0x60ccxf[_0xa2c2[24]][_0xa2c2[17]]){delete _0x60ccxf[_0xa2c2[24]][_0xa2c2[17]]};SalesforceConfiguration[_0xa2c2[26]](_0x60ccxf[_0xa2c2[18]][_0xa2c2[17]])[_0xa2c2[9]](handleEntityNotFound(_0x60ccx5))[_0xa2c2[9]](saveUpdates(_0x60ccxf[_0xa2c2[24]]))[_0xa2c2[9]](responseWithResult(_0x60ccx5))[_0xa2c2[13]](handleError(_0x60ccx5));};exports[_0xa2c2[11]]=function(_0x60ccxf,_0x60ccx5){SalesforceConfiguration[_0xa2c2[26]](_0x60ccxf[_0xa2c2[18]][_0xa2c2[17]])[_0xa2c2[9]](handleEntityNotFound(_0x60ccx5))[_0xa2c2[9]](removeEntity(_0x60ccx5))[_0xa2c2[13]](handleError(_0x60ccx5))};exports[_0xa2c2[27]]=function(_0x60ccxf,_0x60ccx5,_0x60ccx10){var _0x60ccx11;SalesforceConfiguration[_0xa2c2[26]](_0x60ccxf[_0xa2c2[18]][_0xa2c2[17]])[_0xa2c2[9]](handleEntityNotFound(_0x60ccx5))[_0xa2c2[9]](function(_0x60ccx14){_0x60ccx11=_0x60ccx14;return SalesforceField[_0xa2c2[23]](_0x60ccxf[_0xa2c2[24]]);})[_0xa2c2[9]](function(_0x60ccx13){switch(_0x60ccxf[_0xa2c2[18]][_0xa2c2[35]]){case _0xa2c2[30]:return [_0x60ccx11[_0xa2c2[29]](_0x60ccx13),_0x60ccx13];;case _0xa2c2[32]:return [_0x60ccx11[_0xa2c2[31]](_0x60ccx13),_0x60ccx13];;case _0xa2c2[34]:return [_0x60ccx11[_0xa2c2[33]](_0x60ccx13),_0x60ccx13];;}})[_0xa2c2[28]](function(_0x60ccx12,_0x60ccx13){return _0x60ccx5[_0xa2c2[6]](201)[_0xa2c2[7]](_0x60ccx13)})[_0xa2c2[13]](handleError(_0x60ccx5));}; \ No newline at end of file diff --git a/server/api/salesforce_configuration/salesforce_configuration.socket.js b/server/api/salesforce_configuration/salesforce_configuration.socket.js index c45a482..dc0b677 100644 --- a/server/api/salesforce_configuration/salesforce_configuration.socket.js +++ b/server/api/salesforce_configuration/salesforce_configuration.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SalesforceConfiguration = require('../../models').SalesforceConfiguration; - -exports.register = function(socket) { - SalesforceConfiguration.afterCreate(function(doc) { - onSave(socket, doc); - }); - SalesforceConfiguration.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('salesforce_configuration:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('salesforce_configuration:remove', doc); -} +var _0x6993=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x6993[0];var SalesforceConfiguration=require(_0x6993[2])[_0x6993[1]];exports[_0x6993[3]]=function(_0x64eax2){SalesforceConfiguration[_0x6993[4]](function(_0x64eax3){onSave(_0x64eax2,_0x64eax3)});SalesforceConfiguration[_0x6993[5]](function(_0x64eax3){onRemove(_0x64eax2,_0x64eax3)});};function onSave(_0x64eax2,_0x64eax3,_0x64eax5){_0x64eax2[_0x6993[7]](_0x6993[6],_0x64eax3)}function onRemove(_0x64eax2,_0x64eax3,_0x64eax5){_0x64eax2[_0x6993[7]](_0x6993[8],_0x64eax3)} \ No newline at end of file diff --git a/server/api/salesforce_field/index.js b/server/api/salesforce_field/index.js index 4a0ccb2..a358ab6 100644 --- a/server/api/salesforce_field/index.js +++ b/server/api/salesforce_field/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./salesforce_field.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); - -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0x12f1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x12f1[0];var express=require(_0x12f1[1]);var auth=require(_0x12f1[2]);var controller=require(_0x12f1[3]);var router=express.Router();router[_0x12f1[7]](_0x12f1[4],auth[_0x12f1[5]](),controller[_0x12f1[6]]);router[_0x12f1[7]](_0x12f1[8],auth[_0x12f1[5]](),controller[_0x12f1[9]]);router[_0x12f1[11]](_0x12f1[4],auth[_0x12f1[5]](),controller[_0x12f1[10]]);router[_0x12f1[13]](_0x12f1[8],auth[_0x12f1[5]](),controller[_0x12f1[12]]);router[_0x12f1[14]](_0x12f1[8],auth[_0x12f1[5]](),controller[_0x12f1[12]]);router[_0x12f1[16]](_0x12f1[8],auth[_0x12f1[5]](),controller[_0x12f1[15]]);module[_0x12f1[17]]=router; \ No newline at end of file diff --git a/server/api/salesforce_field/index.spec.js b/server/api/salesforce_field/index.spec.js index 639e318..9dafd56 100644 --- a/server/api/salesforce_field/index.spec.js +++ b/server/api/salesforce_field/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var salesforceFieldCtrlStub = { - index: 'salesforceFieldCtrl.index', - show: 'salesforceFieldCtrl.show', - create: 'salesforceFieldCtrl.create', - update: 'salesforceFieldCtrl.update', - destroy: 'salesforceFieldCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var salesforceFieldIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './salesforce_field.controller': salesforceFieldCtrlStub -}); - -describe('SalesforceField API Router:', function() { - - it('should return an express router instance', function() { - expect(salesforceFieldIndex).to.equal(routerStub); - }); - - describe('GET /api/salesforce/fields', function() { - - it('should route to salesforceField.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'salesforceFieldCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/salesforce/fields/:id', function() { - - it('should route to salesforceField.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'salesforceFieldCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/salesforce/fields', function() { - - it('should route to salesforceField.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'salesforceFieldCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/salesforce/fields/:id', function() { - - it('should route to salesforceField.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'salesforceFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/salesforce/fields/:id', function() { - - it('should route to salesforceField.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'salesforceFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/salesforce/fields/:id', function() { - - it('should route to salesforceField.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'salesforceFieldCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0xfb88=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0xfb88[0];var proxyquire=require(_0xfb88[2])[_0xfb88[1]]();var salesforceFieldCtrlStub={index:_0xfb88[3],show:_0xfb88[4],create:_0xfb88[5],update:_0xfb88[6],destroy:_0xfb88[7]};var routerStub={get:sinon[_0xfb88[8]](),put:sinon[_0xfb88[8]](),patch:sinon[_0xfb88[8]](),post:sinon[_0xfb88[8]](),delete:sinon[_0xfb88[8]]()};var salesforceFieldIndex=proxyquire(_0xfb88[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":salesforceFieldCtrlStub});describe(_0xfb88[10],function(){it(_0xfb88[11],function(){expect(salesforceFieldIndex)[_0xfb88[13]][_0xfb88[12]](routerStub)});describe(_0xfb88[14],function(){it(_0xfb88[15],function(){expect(routerStub[_0xfb88[21]][_0xfb88[20]](_0xfb88[19],_0xfb88[3]))[_0xfb88[13]][_0xfb88[18]][_0xfb88[17]][_0xfb88[16]]})});describe(_0xfb88[22],function(){it(_0xfb88[23],function(){expect(routerStub[_0xfb88[21]][_0xfb88[20]](_0xfb88[24],_0xfb88[4]))[_0xfb88[13]][_0xfb88[18]][_0xfb88[17]][_0xfb88[16]]})});describe(_0xfb88[25],function(){it(_0xfb88[26],function(){expect(routerStub[_0xfb88[27]][_0xfb88[20]](_0xfb88[19],_0xfb88[5]))[_0xfb88[13]][_0xfb88[18]][_0xfb88[17]][_0xfb88[16]]})});describe(_0xfb88[28],function(){it(_0xfb88[29],function(){expect(routerStub[_0xfb88[30]][_0xfb88[20]](_0xfb88[24],_0xfb88[6]))[_0xfb88[13]][_0xfb88[18]][_0xfb88[17]][_0xfb88[16]]})});describe(_0xfb88[31],function(){it(_0xfb88[29],function(){expect(routerStub[_0xfb88[32]][_0xfb88[20]](_0xfb88[24],_0xfb88[6]))[_0xfb88[13]][_0xfb88[18]][_0xfb88[17]][_0xfb88[16]]})});describe(_0xfb88[33],function(){it(_0xfb88[34],function(){expect(routerStub[_0xfb88[35]][_0xfb88[20]](_0xfb88[24],_0xfb88[7]))[_0xfb88[13]][_0xfb88[18]][_0xfb88[17]][_0xfb88[16]]})});}); \ No newline at end of file diff --git a/server/api/salesforce_field/salesforce_field.controller.js b/server/api/salesforce_field/salesforce_field.controller.js index bab61d7..ef06633 100644 --- a/server/api/salesforce_field/salesforce_field.controller.js +++ b/server/api/salesforce_field/salesforce_field.controller.js @@ -1,104 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/salesforce/fields -> index - * POST /api/salesforce/fields -> create - * GET /api/salesforce/fields/:id -> show - * PUT /api/salesforce/fields/:id -> update - * DELETE /api/salesforce/fields/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); - -var SalesforceField = require('../../models').SalesforceField; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of SalesforceFields -exports.index = function(req, res) { - SalesforceField.findAll() - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single SalesforceField from the DB -exports.show = function(req, res) { - SalesforceField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new SalesforceField in the DB -exports.create = function(req, res) { - SalesforceField.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing SalesforceField in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - SalesforceField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a SalesforceField from the DB -exports.destroy = function(req, res) { - SalesforceField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} +var _0xa817=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65"];_0xa817[0];var _=require(_0xa817[1]);var SalesforceField=require(_0xa817[3])[_0xa817[2]];function handleError(_0xbce3x4,_0xbce3x5){_0xbce3x5=_0xbce3x5||500;return function(_0xbce3x6){_0xbce3x4[_0xa817[5]](_0xbce3x5)[_0xa817[4]](_0xbce3x6)};}function responseWithResult(_0xbce3x4,_0xbce3x5){_0xbce3x5=_0xbce3x5||200;return function(_0xbce3x8){if(_0xbce3x8){_0xbce3x4[_0xa817[5]](_0xbce3x5)[_0xa817[6]](_0xbce3x8)}};}function handleEntityNotFound(_0xbce3x4){return function(_0xbce3x8){if(!_0xbce3x8){_0xbce3x4[_0xa817[5]](404)[_0xa817[7]]();return null;};return _0xbce3x8;}}function saveUpdates(_0xbce3xb){return function(_0xbce3x8){return _0xbce3x8[_0xa817[9]](_0xbce3xb)[_0xa817[8]](function(_0xbce3xc){return _0xbce3xc})}}function removeEntity(_0xbce3x4){return function(_0xbce3x8){if(_0xbce3x8){return _0xbce3x8[_0xa817[10]]()[_0xa817[8]](function(){_0xbce3x4[_0xa817[5]](204)[_0xa817[7]]()})}}}exports[_0xa817[11]]=function(_0xbce3xe,_0xbce3x4){SalesforceField[_0xa817[13]]()[_0xa817[8]](responseWithResult(_0xbce3x4))[_0xa817[12]](handleError(_0xbce3x4))};exports[_0xa817[14]]=function(_0xbce3xe,_0xbce3x4){SalesforceField[_0xa817[17]](_0xbce3xe[_0xa817[16]][_0xa817[15]])[_0xa817[8]](handleEntityNotFound(_0xbce3x4))[_0xa817[8]](responseWithResult(_0xbce3x4))[_0xa817[12]](handleError(_0xbce3x4))};exports[_0xa817[18]]=function(_0xbce3xe,_0xbce3x4){SalesforceField[_0xa817[18]](_0xbce3xe[_0xa817[19]])[_0xa817[8]](responseWithResult(_0xbce3x4,201))[_0xa817[12]](handleError(_0xbce3x4))};exports[_0xa817[20]]=function(_0xbce3xe,_0xbce3x4){if(_0xbce3xe[_0xa817[19]][_0xa817[15]]){delete _0xbce3xe[_0xa817[19]][_0xa817[15]]};SalesforceField[_0xa817[17]](_0xbce3xe[_0xa817[16]][_0xa817[15]])[_0xa817[8]](handleEntityNotFound(_0xbce3x4))[_0xa817[8]](saveUpdates(_0xbce3xe[_0xa817[19]]))[_0xa817[8]](responseWithResult(_0xbce3x4))[_0xa817[12]](handleError(_0xbce3x4));};exports[_0xa817[10]]=function(_0xbce3xe,_0xbce3x4){SalesforceField[_0xa817[17]](_0xbce3xe[_0xa817[16]][_0xa817[15]])[_0xa817[8]](handleEntityNotFound(_0xbce3x4))[_0xa817[8]](removeEntity(_0xbce3x4))[_0xa817[12]](handleError(_0xbce3x4))}; \ No newline at end of file diff --git a/server/api/salesforce_field/salesforce_field.socket.js b/server/api/salesforce_field/salesforce_field.socket.js index b3f5775..4fb61ef 100644 --- a/server/api/salesforce_field/salesforce_field.socket.js +++ b/server/api/salesforce_field/salesforce_field.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SalesforceField = require('../../models').SalesforceField; - -exports.register = function(socket) { - SalesforceField.afterCreate(function(doc) { - onSave(socket, doc); - }); - SalesforceField.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('salesforce_field:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('salesforce_field:remove', doc); -} +var _0xc743=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0xc743[0];var SalesforceField=require(_0xc743[2])[_0xc743[1]];exports[_0xc743[3]]=function(_0x8812x2){SalesforceField[_0xc743[4]](function(_0x8812x3){onSave(_0x8812x2,_0x8812x3)});SalesforceField[_0xc743[5]](function(_0x8812x3){onRemove(_0x8812x2,_0x8812x3)});};function onSave(_0x8812x2,_0x8812x3,_0x8812x5){_0x8812x2[_0xc743[7]](_0xc743[6],_0x8812x3)}function onRemove(_0x8812x2,_0x8812x3,_0x8812x5){_0x8812x2[_0xc743[7]](_0xc743[8],_0x8812x3)} \ No newline at end of file diff --git a/server/api/setting/index.js b/server/api/setting/index.js index d39a451..4578edd 100644 --- a/server/api/setting/index.js +++ b/server/api/setting/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./setting.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/internal', auth.isAuthenticated(), controller.getInternal); -router.get('/info', controller.getInfo); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0xa7a9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x73\x65\x74\x74\x69\x6E\x67\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x67\x65\x74\x49\x6E\x74\x65\x72\x6E\x61\x6C","\x2F\x69\x6E\x66\x6F","\x67\x65\x74\x49\x6E\x66\x6F","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xa7a9[0];var express=require(_0xa7a9[1]);var controller=require(_0xa7a9[2]);var auth=require(_0xa7a9[3]);var router=express.Router();router[_0xa7a9[7]](_0xa7a9[4],auth[_0xa7a9[5]](),controller[_0xa7a9[6]]);router[_0xa7a9[7]](_0xa7a9[8],auth[_0xa7a9[5]](),controller[_0xa7a9[9]]);router[_0xa7a9[7]](_0xa7a9[10],controller[_0xa7a9[11]]);router[_0xa7a9[7]](_0xa7a9[12],auth[_0xa7a9[5]](),controller[_0xa7a9[13]]);router[_0xa7a9[15]](_0xa7a9[4],auth[_0xa7a9[5]](),controller[_0xa7a9[14]]);router[_0xa7a9[17]](_0xa7a9[12],auth[_0xa7a9[5]](),controller[_0xa7a9[16]]);router[_0xa7a9[18]](_0xa7a9[12],auth[_0xa7a9[5]](),controller[_0xa7a9[16]]);router[_0xa7a9[20]](_0xa7a9[12],auth[_0xa7a9[5]](),controller[_0xa7a9[19]]);module[_0xa7a9[21]]=router; \ No newline at end of file diff --git a/server/api/setting/setting.controller.js b/server/api/setting/setting.controller.js index 4cbb858..8e7cdff 100644 --- a/server/api/setting/setting.controller.js +++ b/server/api/setting/setting.controller.js @@ -1,152 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Settings = require('../../models').Settings; -var Agent = require('../../models').User; - -// Get list of settings -exports.index = function(req, res) { - Settings - .findAll() - .then(function(settings) { - return res.status(200).send(settings); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get list of settings -exports.getInternal = function(req, res) { - Settings - .findOne() - .then(function(result) { - Agent - .findAll({ - where: { - internal: { - $gte: result.min_internal - } - } - }) - .then(function(internals) { - var pluckdInternals = _.pluck(_.pluck(internals, 'dataValues'), 'internal'); - var lastChecked = result.min_internal; - var internalNumber = { - value: null - }; - do { - if (pluckdInternals.indexOf(lastChecked) === -1) { - internalNumber.value = lastChecked; - } else { - lastChecked++; - } - } while (!internalNumber.value) - return res.status(200).send(internalNumber); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get list of settings -exports.getInfo = function(req, res) { - - var info = require('../../../package.json'); - - return res.status(200).send({ - name: info.name, - version: info.version, - engines: info.engines - }); -}; - -// Get a single setting -exports.show = function(req, res) { - Settings - .findById(req.params.id) - .then(function(setting) { - if (!setting) { - return res.sendStatus(404); - } - return res.send(setting); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new setting in the DB. -exports.create = function(req, res) { - Settings - .create(req.body) - .then(function(setting) { - return res.status(201).send(setting); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing setting in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Settings - .find({ - where: { - id: req.params.id - } - }) - .then(function(setting) { - if (!setting) { - return res.sendStatus(404); - } - var updated = _.merge(setting, req.body); - updated.save() - .then(function() { - return res.status(200).send(setting); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a setting from the DB. -exports.destroy = function(req, res) { - Settings - .find({ - where: { - id: req.params.id - } - }) - .then(function(setting) { - if (!setting) { - return res.sendStatus(404); - } - setting.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x51e0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x65\x74\x74\x69\x6E\x67\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x67\x65\x74\x49\x6E\x74\x65\x72\x6E\x61\x6C","\x6C\x6F\x67","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x6C\x75\x63\x6B","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x6D\x69\x6E\x5F\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x69\x6E\x64\x65\x78\x4F\x66","\x76\x61\x6C\x75\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x67\x65\x74\x49\x6E\x66\x6F","\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x70\x61\x63\x6B\x61\x67\x65\x2E\x6A\x73\x6F\x6E","\x6E\x61\x6D\x65","\x76\x65\x72\x73\x69\x6F\x6E","\x65\x6E\x67\x69\x6E\x65\x73","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x51e0[0];var _=require(_0x51e0[1]);var Settings=require(_0x51e0[3])[_0x51e0[2]];var Agent=require(_0x51e0[3])[_0x51e0[4]];exports[_0x51e0[5]]=function(_0x13edx4,_0x13edx5){Settings[_0x51e0[10]]()[_0x51e0[9]](function(_0x13edx7){return _0x13edx5[_0x51e0[8]](200)[_0x51e0[7]](_0x13edx7)})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)})};exports[_0x51e0[11]]=function(_0x13edx4,_0x13edx5){Settings[_0x51e0[19]]()[_0x51e0[9]](function(_0x13edx8){Agent[_0x51e0[10]]({where:{internal:{$gte:_0x13edx8[_0x51e0[16]]}}})[_0x51e0[9]](function(_0x13edx9){var _0x13edxa=_[_0x51e0[14]](_[_0x51e0[14]](_0x13edx9,_0x51e0[13]),_0x51e0[15]);var _0x13edxb=_0x13edx8[_0x51e0[16]];var _0x13edxc={value:null};do{if(_0x13edxa[_0x51e0[17]](_0x13edxb)=== -1){_0x13edxc[_0x51e0[18]]=_0x13edxb}else {_0x13edxb++}}while(!_0x13edxc[_0x51e0[18]]);;return _0x13edx5[_0x51e0[8]](200)[_0x51e0[7]](_0x13edxc);})[_0x51e0[6]](function(_0x13edx6){console[_0x51e0[12]](_0x13edx6);return handleError(_0x13edx5,_0x13edx6);})})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)})};exports[_0x51e0[20]]=function(_0x13edx4,_0x13edx5){var _0x13edxd=require(_0x51e0[21]);return _0x13edx5[_0x51e0[8]](200)[_0x51e0[7]]({name:_0x13edxd[_0x51e0[22]],version:_0x13edxd[_0x51e0[23]],engines:_0x13edxd[_0x51e0[24]]});};exports[_0x51e0[25]]=function(_0x13edx4,_0x13edx5){Settings[_0x51e0[29]](_0x13edx4[_0x51e0[28]][_0x51e0[27]])[_0x51e0[9]](function(_0x13edxe){if(!_0x13edxe){return _0x13edx5[_0x51e0[26]](404)};return _0x13edx5[_0x51e0[7]](_0x13edxe);})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)})};exports[_0x51e0[30]]=function(_0x13edx4,_0x13edx5){Settings[_0x51e0[30]](_0x13edx4[_0x51e0[31]])[_0x51e0[9]](function(_0x13edxe){return _0x13edx5[_0x51e0[8]](201)[_0x51e0[7]](_0x13edxe)})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)})};exports[_0x51e0[32]]=function(_0x13edx4,_0x13edx5){if(_0x13edx4[_0x51e0[31]][_0x51e0[27]]){delete _0x13edx4[_0x51e0[31]][_0x51e0[27]]};Settings[_0x51e0[35]]({where:{id:_0x13edx4[_0x51e0[28]][_0x51e0[27]]}})[_0x51e0[9]](function(_0x13edxe){if(!_0x13edxe){return _0x13edx5[_0x51e0[26]](404)};var _0x13edxf=_[_0x51e0[33]](_0x13edxe,_0x13edx4[_0x51e0[31]]);_0x13edxf[_0x51e0[34]]()[_0x51e0[9]](function(){return _0x13edx5[_0x51e0[8]](200)[_0x51e0[7]](_0x13edxe)})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)});})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)});};exports[_0x51e0[36]]=function(_0x13edx4,_0x13edx5){Settings[_0x51e0[35]]({where:{id:_0x13edx4[_0x51e0[28]][_0x51e0[27]]}})[_0x51e0[9]](function(_0x13edxe){if(!_0x13edxe){return _0x13edx5[_0x51e0[26]](404)};_0x13edxe[_0x51e0[36]]()[_0x51e0[9]](function(){return _0x13edx5[_0x51e0[26]](204)})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)});})[_0x51e0[6]](function(_0x13edx6){return handleError(_0x13edx5,_0x13edx6)})};function handleError(_0x13edx5,_0x13edx6){return _0x13edx5[_0x51e0[8]](500)[_0x51e0[7]](_0x13edx6)} \ No newline at end of file diff --git a/server/api/setting/setting.socket.js b/server/api/setting/setting.socket.js index 611827e..40b29c7 100644 --- a/server/api/setting/setting.socket.js +++ b/server/api/setting/setting.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Settings = require('../../models').Settings; - -exports.register = function(socket) { - Settings.afterCreate(function(doc) { - onSave(socket, doc); - }); - Settings.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('setting:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('setting:remove', doc); -} +var _0x24bb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x65\x74\x74\x69\x6E\x67\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x65\x74\x74\x69\x6E\x67\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x65\x74\x74\x69\x6E\x67\x3A\x72\x65\x6D\x6F\x76\x65"];_0x24bb[0];var Settings=require(_0x24bb[2])[_0x24bb[1]];exports[_0x24bb[3]]=function(_0x9b4cx2){Settings[_0x24bb[4]](function(_0x9b4cx3){onSave(_0x9b4cx2,_0x9b4cx3)});Settings[_0x24bb[5]](function(_0x9b4cx3){onRemove(_0x9b4cx2,_0x9b4cx3)});};function onSave(_0x9b4cx2,_0x9b4cx3,_0x9b4cx5){_0x9b4cx2[_0x24bb[7]](_0x24bb[6],_0x9b4cx3)}function onRemove(_0x9b4cx2,_0x9b4cx3,_0x9b4cx5){_0x9b4cx2[_0x24bb[7]](_0x24bb[8],_0x9b4cx3)} \ No newline at end of file diff --git a/server/api/setting/setting.spec.js b/server/api/setting/setting.spec.js index eec76c9..9952cdc 100644 --- a/server/api/setting/setting.spec.js +++ b/server/api/setting/setting.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/settings', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/settings') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xde11=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x65\x74\x74\x69\x6E\x67\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x73\x65\x74\x74\x69\x6E\x67\x73","\x67\x65\x74"];_0xde11[0];var should=require(_0xde11[1]);var app=require(_0xde11[2]);var request=require(_0xde11[3]);describe(_0xde11[4],function(){it(_0xde11[5],function(_0xc104x4){request(app)[_0xde11[13]](_0xde11[12])[_0xde11[11]](200)[_0xde11[11]](_0xde11[10],/json/)[_0xde11[9]](function(_0xc104x5,_0xc104x6){if(_0xc104x5){return _0xc104x4(_0xc104x5)};_0xc104x6[_0xde11[8]][_0xde11[1]][_0xde11[7]][_0xde11[6]](Array);_0xc104x4();})})}); \ No newline at end of file diff --git a/server/api/square_odbc/index.js b/server/api/square_odbc/index.js index 9d53bf8..5b86f05 100644 --- a/server/api/square_odbc/index.js +++ b/server/api/square_odbc/index.js @@ -1,17 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./square_odbc.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.odbcValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x2fe7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x73\x71\x75\x61\x72\x65\x5F\x6F\x64\x62\x63\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x6F\x64\x62\x63\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x2fe7[0];var express=require(_0x2fe7[1]);var controller=require(_0x2fe7[2]);var auth=require(_0x2fe7[3]);var router=express.Router();router[_0x2fe7[7]](_0x2fe7[4],auth[_0x2fe7[5]](),controller[_0x2fe7[6]]);router[_0x2fe7[7]](_0x2fe7[8],auth[_0x2fe7[5]](),controller[_0x2fe7[9]]);router[_0x2fe7[11]](_0x2fe7[4],auth[_0x2fe7[5]](),controller[_0x2fe7[10]]);router[_0x2fe7[11]](_0x2fe7[12],auth[_0x2fe7[5]](),controller[_0x2fe7[13]]);router[_0x2fe7[15]](_0x2fe7[8],auth[_0x2fe7[5]](),controller[_0x2fe7[14]]);router[_0x2fe7[16]](_0x2fe7[8],auth[_0x2fe7[5]](),controller[_0x2fe7[14]]);router[_0x2fe7[18]](_0x2fe7[8],auth[_0x2fe7[5]](),controller[_0x2fe7[17]]);module[_0x2fe7[19]]=router; \ No newline at end of file diff --git a/server/api/square_odbc/square_odbc.controller.js b/server/api/square_odbc/square_odbc.controller.js index a444b26..4e8e764 100644 --- a/server/api/square_odbc/square_odbc.controller.js +++ b/server/api/square_odbc/square_odbc.controller.js @@ -1,209 +1 @@ -'use strict'; - -var _ = require('lodash'); -var SquareOdbc = require('../../models').SquareOdbc; -var util = require('util'); - -// Get list of square_odbcs -exports.index = function(req, res) { - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - SquareOdbc - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -exports.odbcValidation = function(req, res) { - console.log(req.body); - SquareOdbc - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(square_odbcs) { - if (!square_odbcs) { - return res.sendStatus(404); - } - return res.send(square_odbcs); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single square_odbc -exports.show = function(req, res) { - SquareOdbc - .findById(req.params.id) - .then(function(square_odbc) { - if (!square_odbc) { - return res.sendStatus(404); - } - return res.send(square_odbc); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new square_odbc in the DB. -exports.create = function(req, res) { - SquareOdbc - .create(req.body) - .then(function(square_odbc) { - return res.status(201).send(square_odbc); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing square_odbc in the DB. -exports.update = function(req, res) { - SquareOdbc - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(square_odbcs) { - if (!square_odbcs) { - return res.sendStatus(404); - } - if (square_odbcs.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_ODBC' - }) - } - if (req.body.id) { - delete req.body.id; - } - SquareOdbc - .findById(req.params.id) - .then(function(square_odbc) { - if (!square_odbc) { - return res.sendStatus(404); - } - var updated = _.merge(square_odbc, req.body); - updated.save() - .then(function() { - return res.status(200).send(square_odbc); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a square_odbc from the DB. -exports.destroy = function(req, res) { - SquareOdbc - .find({ - where: { - id: req.params.id - } - }) - .then(function(square_odbc) { - if (!square_odbc) { - return res.sendStatus(404); - } - square_odbc.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a square_project from the DB. -exports.bulkDestroy = function(req, res) { - SquareOdbc - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xc512=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x71\x75\x61\x72\x65\x4F\x64\x62\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x6F\x64\x62\x63\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x4F\x44\x42\x43","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0xc512[0];var _=require(_0xc512[1]);var SquareOdbc=require(_0xc512[3])[_0xc512[2]];var util=require(_0xc512[4]);exports[_0xc512[5]]=function(_0x53ddx4,_0x53ddx5){var _0x53ddx6=[_0xc512[6],_0xc512[7]];var _0x53ddx7=_0x53ddx4[_0xc512[9]][_0xc512[8]]?parseInt(_0x53ddx4[_0xc512[9]][_0xc512[8]],10):100;var _0x53ddx8=_0x53ddx4[_0xc512[9]][_0xc512[10]]?parseInt(_0x53ddx4[_0xc512[9]][_0xc512[10]],10):0;var _0x53ddx9={where:{},limit:_0x53ddx7,offset:_0x53ddx8*_0x53ddx7};_[_0xc512[24]](_0x53ddx4[_0xc512[9]],function(_0x53ddxa,_0x53ddxb){switch(_0x53ddxb){case _0xc512[8]:;case _0xc512[10]:break ;;case _0xc512[13]:_0x53ddx9[_0xc512[11]]=util[_0xc512[16]](_0xc512[12],_0x53ddx4[_0xc512[9]][_0xc512[13]],_0x53ddx4[_0xc512[9]][_0xc512[14]]||_0xc512[15])||null;break ;;case _0xc512[14]:break ;;case _0xc512[22]:_0x53ddx9[_0xc512[18]][_0xc512[17]]=[];_0x53ddx6[_0xc512[21]](function(_0x53ddxc){var _0x53ddxd={};_0x53ddxd[_0x53ddxc]={$like:_0xc512[19]+_0x53ddxa+_0xc512[19]};_0x53ddx9[_0xc512[18]][_0xc512[17]][_0xc512[20]](_0x53ddxd);});break ;;default:_0x53ddx9[_0xc512[18]][_0x53ddxb]={$like:{}};_0x53ddx9[_0xc512[18]][_0x53ddxb][_0xc512[23]]=_0xc512[19]+_0x53ddxa+_0xc512[19];;}});SquareOdbc[_0xc512[39]](_0x53ddx9)[_0xc512[38]](function(_0x53ddxf){var _0x53ddx10=Math[_0xc512[30]](_0x53ddxf[_0xc512[29]]/_0x53ddx7);var _0x53ddx11=_0x53ddx10>(_0x53ddx9[_0xc512[31]]+1)?util[_0xc512[16]](_0xc512[32],_0x53ddx4[_0xc512[33]],_0x53ddx4[_0xc512[35]][_0xc512[34]],_0x53ddx4[_0xc512[36]],_0x53ddx8+1):null;var _0x53ddx12=_0x53ddx8>0?util[_0xc512[16]](_0xc512[32],_0x53ddx4[_0xc512[33]],_0x53ddx4[_0xc512[35]][_0xc512[34]],_0x53ddx4[_0xc512[36]],_0x53ddx8-1):null;_0x53ddx5[_0xc512[27]](200)[_0xc512[26]]({count:_0x53ddxf[_0xc512[29]],rows:_0x53ddxf[_0xc512[37]],next_page:_0x53ddx11,previous_page:_0x53ddx12,total_pages:_0x53ddx10});})[_0xc512[28]](function(_0x53ddxe){_0x53ddx5[_0xc512[27]](500)[_0xc512[26]]({error:_0xc512[25]})});};exports[_0xc512[40]]=function(_0x53ddx4,_0x53ddx5){console[_0xc512[42]](_0x53ddx4[_0xc512[41]]);SquareOdbc[_0xc512[44]]({where:{name:_0x53ddx4[_0xc512[41]][_0xc512[6]]}})[_0xc512[38]](function(_0x53ddx13){if(!_0x53ddx13){return _0x53ddx5[_0xc512[43]](404)};return _0x53ddx5[_0xc512[26]](_0x53ddx13);})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)});};exports[_0xc512[45]]=function(_0x53ddx4,_0x53ddx5){SquareOdbc[_0xc512[48]](_0x53ddx4[_0xc512[47]][_0xc512[46]])[_0xc512[38]](function(_0x53ddx14){if(!_0x53ddx14){return _0x53ddx5[_0xc512[43]](404)};return _0x53ddx5[_0xc512[26]](_0x53ddx14);})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)})};exports[_0xc512[49]]=function(_0x53ddx4,_0x53ddx5){SquareOdbc[_0xc512[49]](_0x53ddx4[_0xc512[41]])[_0xc512[38]](function(_0x53ddx14){return _0x53ddx5[_0xc512[27]](201)[_0xc512[26]](_0x53ddx14)})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)})};exports[_0xc512[50]]=function(_0x53ddx4,_0x53ddx5){SquareOdbc[_0xc512[44]]({where:{name:_0x53ddx4[_0xc512[41]][_0xc512[6]],id:{$ne:_0x53ddx4[_0xc512[41]][_0xc512[46]]}}})[_0xc512[38]](function(_0x53ddx13){if(!_0x53ddx13){return _0x53ddx5[_0xc512[43]](404)};if(_0x53ddx13[_0xc512[51]]>0){return _0x53ddx5[_0xc512[27]](500)[_0xc512[26]]({message:_0xc512[52]})};if(_0x53ddx4[_0xc512[41]][_0xc512[46]]){delete _0x53ddx4[_0xc512[41]][_0xc512[46]]};SquareOdbc[_0xc512[48]](_0x53ddx4[_0xc512[47]][_0xc512[46]])[_0xc512[38]](function(_0x53ddx14){if(!_0x53ddx14){return _0x53ddx5[_0xc512[43]](404)};var _0x53ddx15=_[_0xc512[53]](_0x53ddx14,_0x53ddx4[_0xc512[41]]);_0x53ddx15[_0xc512[54]]()[_0xc512[38]](function(){return _0x53ddx5[_0xc512[27]](200)[_0xc512[26]](_0x53ddx14)})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)});})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)});})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)})};exports[_0xc512[55]]=function(_0x53ddx4,_0x53ddx5){SquareOdbc[_0xc512[56]]({where:{id:_0x53ddx4[_0xc512[47]][_0xc512[46]]}})[_0xc512[38]](function(_0x53ddx14){if(!_0x53ddx14){return _0x53ddx5[_0xc512[43]](404)};_0x53ddx14[_0xc512[55]]()[_0xc512[38]](function(){return _0x53ddx5[_0xc512[43]](204)})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)});})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)})};exports[_0xc512[57]]=function(_0x53ddx4,_0x53ddx5){SquareOdbc[_0xc512[55]]({where:{id:_0x53ddx4[_0xc512[9]][_0xc512[46]]},individualHooks:true})[_0xc512[38]](function(){return _0x53ddx5[_0xc512[43]](204)})[_0xc512[28]](function(_0x53ddxe){return handleError(_0x53ddx5,_0x53ddxe)})};function handleError(_0x53ddx5,_0x53ddxe){return _0x53ddx5[_0xc512[27]](500)[_0xc512[26]](_0x53ddxe)} \ No newline at end of file diff --git a/server/api/square_odbc/square_odbc.socket.js b/server/api/square_odbc/square_odbc.socket.js index af0c04a..b88ccd1 100644 --- a/server/api/square_odbc/square_odbc.socket.js +++ b/server/api/square_odbc/square_odbc.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SquareOdbc = require('../../models').SquareOdbc; - -exports.register = function(socket) { - SquareOdbc.afterCreate(function(doc) { - onSave(socket, doc); - }); - SquareOdbc.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('square_odbc:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('square_odbc:remove', doc); -} +var _0xabd0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x71\x75\x61\x72\x65\x4F\x64\x62\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x71\x75\x61\x72\x65\x5F\x6F\x64\x62\x63\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x71\x75\x61\x72\x65\x5F\x6F\x64\x62\x63\x3A\x72\x65\x6D\x6F\x76\x65"];_0xabd0[0];var SquareOdbc=require(_0xabd0[2])[_0xabd0[1]];exports[_0xabd0[3]]=function(_0x60eex2){SquareOdbc[_0xabd0[4]](function(_0x60eex3){onSave(_0x60eex2,_0x60eex3)});SquareOdbc[_0xabd0[5]](function(_0x60eex3){onRemove(_0x60eex2,_0x60eex3)});};function onSave(_0x60eex2,_0x60eex3,_0x60eex5){_0x60eex2[_0xabd0[7]](_0xabd0[6],_0x60eex3)}function onRemove(_0x60eex2,_0x60eex3,_0x60eex5){_0x60eex2[_0xabd0[7]](_0xabd0[8],_0x60eex3)} \ No newline at end of file diff --git a/server/api/square_odbc/square_odbc.spec.js b/server/api/square_odbc/square_odbc.spec.js index ce9350c..56cd55b 100644 --- a/server/api/square_odbc/square_odbc.spec.js +++ b/server/api/square_odbc/square_odbc.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/square/odbc', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/square/odbc') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xb209=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x2F\x6F\x64\x62\x63","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x2F\x6F\x64\x62\x63","\x67\x65\x74"];_0xb209[0];var should=require(_0xb209[1]);var app=require(_0xb209[2]);var request=require(_0xb209[3]);describe(_0xb209[4],function(){it(_0xb209[5],function(_0x3e87x4){request(app)[_0xb209[13]](_0xb209[12])[_0xb209[11]](200)[_0xb209[11]](_0xb209[10],/json/)[_0xb209[9]](function(_0x3e87x5,_0x3e87x6){if(_0x3e87x5){return _0x3e87x4(_0x3e87x5)};_0x3e87x6[_0xb209[8]][_0xb209[1]][_0xb209[7]][_0xb209[6]](Array);_0x3e87x4();})})}); \ No newline at end of file diff --git a/server/api/square_project/index.js b/server/api/square_project/index.js index e242768..5c39ce1 100644 --- a/server/api/square_project/index.js +++ b/server/api/square_project/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./square_project.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/download', controller.download); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.projectValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x6a47=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x73\x71\x75\x61\x72\x65\x5F\x70\x72\x6F\x6A\x65\x63\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x70\x72\x6F\x6A\x65\x63\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x6a47[0];var express=require(_0x6a47[1]);var controller=require(_0x6a47[2]);var auth=require(_0x6a47[3]);var router=express.Router();router[_0x6a47[7]](_0x6a47[4],auth[_0x6a47[5]](),controller[_0x6a47[6]]);router[_0x6a47[7]](_0x6a47[8],auth[_0x6a47[5]](),controller[_0x6a47[9]]);router[_0x6a47[7]](_0x6a47[10],controller[_0x6a47[11]]);router[_0x6a47[13]](_0x6a47[4],auth[_0x6a47[5]](),controller[_0x6a47[12]]);router[_0x6a47[13]](_0x6a47[14],auth[_0x6a47[5]](),controller[_0x6a47[15]]);router[_0x6a47[17]](_0x6a47[8],auth[_0x6a47[5]](),controller[_0x6a47[16]]);router[_0x6a47[18]](_0x6a47[8],auth[_0x6a47[5]](),controller[_0x6a47[16]]);router[_0x6a47[20]](_0x6a47[4],auth[_0x6a47[5]](),controller[_0x6a47[19]]);router[_0x6a47[20]](_0x6a47[8],auth[_0x6a47[5]](),controller[_0x6a47[21]]);module[_0x6a47[22]]=router; \ No newline at end of file diff --git a/server/api/square_project/square_project.controller.js b/server/api/square_project/square_project.controller.js index 40dc276..ef4b86e 100644 --- a/server/api/square_project/square_project.controller.js +++ b/server/api/square_project/square_project.controller.js @@ -1,211 +1 @@ -'use strict'; - -var _ = require('lodash'); -var path = require('path'); -var config = require('../../config/environment'); -var util = require('util'); - -var SquareProject = require('../../models').SquareProject; - -// Get list of square_projects -exports.index = function(req, res) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - SquareProject - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -exports.projectValidation = function(req, res) { - console.log(req.body); - SquareProject - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(square_projects) { - if (!square_projects) { - return res.sendStatus(404); - } - return res.send(square_projects); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single square_project -exports.show = function(req, res) { - SquareProject - .findById(req.params.id) - .then(function(square_project) { - if (!square_project) { - return res.sendStatus(404); - } - return res.send(square_project); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new square_project in the DB. -exports.create = function(req, res) { - SquareProject - .create(req.body) - .then(function(square_project) { - return res.status(201).send(square_project); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing square_project in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - SquareProject - .findById(req.params.id) - .then(function(square_project) { - if (!square_project) { - return res.sendStatus(404); - } - var updated = _.merge(square_project, req.body); - updated.save() - .then(function() { - return res.status(200).send(square_project); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a square_project from the DB. -exports.destroy = function(req, res) { - SquareProject - .find({ - where: { - id: req.params.id - } - }) - .then(function(square_project) { - if (!square_project) { - return res.sendStatus(404); - } - square_project.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a square_project from the DB. -exports.bulkDestroy = function(req, res) { - SquareProject - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.download = function(req, res, next) { - SquareProject - .findById(req.params.id) - .then(function(square_project) { - if (!square_project) { - return res.sendStatus(404); - } - console.log(req.query.filename); - res.set({ - "Content-Disposition": "attachment; filename=\"" + req.query.filename + - ".xml\"", - "Content-Type": "txt/xml" - }); - return res.send(square_project.preproduction); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x47c3=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x75\x74\x69\x6C","\x53\x71\x75\x61\x72\x65\x50\x72\x6F\x6A\x65\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x70\x72\x6F\x6A\x65\x63\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x3B\x20\x66\x69\x6C\x65\x6E\x61\x6D\x65\x3D\x22","\x2E\x78\x6D\x6C\x22","\x74\x78\x74\x2F\x78\x6D\x6C","\x73\x65\x74","\x70\x72\x65\x70\x72\x6F\x64\x75\x63\x74\x69\x6F\x6E"];_0x47c3[0];var _=require(_0x47c3[1]);var path=require(_0x47c3[2]);var config=require(_0x47c3[3]);var util=require(_0x47c3[4]);var SquareProject=require(_0x47c3[6])[_0x47c3[5]];exports[_0x47c3[7]]=function(_0xffcdx6,_0xffcdx7){var _0xffcdx8=[_0x47c3[8],_0x47c3[9]];var _0xffcdx9=_0xffcdx6[_0x47c3[11]][_0x47c3[10]]?parseInt(_0xffcdx6[_0x47c3[11]][_0x47c3[10]],10):100;var _0xffcdxa=_0xffcdx6[_0x47c3[11]][_0x47c3[12]]?parseInt(_0xffcdx6[_0x47c3[11]][_0x47c3[12]],10):0;var _0xffcdxb={where:{},limit:_0xffcdx9,offset:_0xffcdxa*_0xffcdx9};_[_0x47c3[26]](_0xffcdx6[_0x47c3[11]],function(_0xffcdxc,_0xffcdxd){switch(_0xffcdxd){case _0x47c3[10]:;case _0x47c3[12]:break ;;case _0x47c3[15]:_0xffcdxb[_0x47c3[13]]=util[_0x47c3[18]](_0x47c3[14],_0xffcdx6[_0x47c3[11]][_0x47c3[15]],_0xffcdx6[_0x47c3[11]][_0x47c3[16]]||_0x47c3[17])||null;break ;;case _0x47c3[16]:break ;;case _0x47c3[24]:_0xffcdxb[_0x47c3[20]][_0x47c3[19]]=[];_0xffcdx8[_0x47c3[23]](function(_0xffcdxe){var _0xffcdxf={};_0xffcdxf[_0xffcdxe]={$like:_0x47c3[21]+_0xffcdxc+_0x47c3[21]};_0xffcdxb[_0x47c3[20]][_0x47c3[19]][_0x47c3[22]](_0xffcdxf);});break ;;default:_0xffcdxb[_0x47c3[20]][_0xffcdxd]={$like:{}};_0xffcdxb[_0x47c3[20]][_0xffcdxd][_0x47c3[25]]=_0x47c3[21]+_0xffcdxc+_0x47c3[21];;}});SquareProject[_0x47c3[41]](_0xffcdxb)[_0x47c3[40]](function(_0xffcdx11){var _0xffcdx12=Math[_0x47c3[32]](_0xffcdx11[_0x47c3[31]]/_0xffcdx9);var _0xffcdx13=_0xffcdx12>(_0xffcdxb[_0x47c3[33]]+1)?util[_0x47c3[18]](_0x47c3[34],_0xffcdx6[_0x47c3[35]],_0xffcdx6[_0x47c3[37]][_0x47c3[36]],_0xffcdx6[_0x47c3[38]],_0xffcdxa+1):null;var _0xffcdx14=_0xffcdxa>0?util[_0x47c3[18]](_0x47c3[34],_0xffcdx6[_0x47c3[35]],_0xffcdx6[_0x47c3[37]][_0x47c3[36]],_0xffcdx6[_0x47c3[38]],_0xffcdxa-1):null;_0xffcdx7[_0x47c3[29]](200)[_0x47c3[28]]({count:_0xffcdx11[_0x47c3[31]],rows:_0xffcdx11[_0x47c3[39]],next_page:_0xffcdx13,previous_page:_0xffcdx14,total_pages:_0xffcdx12});})[_0x47c3[30]](function(_0xffcdx10){_0xffcdx7[_0x47c3[29]](500)[_0x47c3[28]]({error:_0x47c3[27]})});};exports[_0x47c3[42]]=function(_0xffcdx6,_0xffcdx7){console[_0x47c3[44]](_0xffcdx6[_0x47c3[43]]);SquareProject[_0x47c3[46]]({where:{name:_0xffcdx6[_0x47c3[43]][_0x47c3[8]]}})[_0x47c3[40]](function(_0xffcdx15){if(!_0xffcdx15){return _0xffcdx7[_0x47c3[45]](404)};return _0xffcdx7[_0x47c3[28]](_0xffcdx15);})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)});};exports[_0x47c3[47]]=function(_0xffcdx6,_0xffcdx7){SquareProject[_0x47c3[50]](_0xffcdx6[_0x47c3[49]][_0x47c3[48]])[_0x47c3[40]](function(_0xffcdx16){if(!_0xffcdx16){return _0xffcdx7[_0x47c3[45]](404)};return _0xffcdx7[_0x47c3[28]](_0xffcdx16);})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)})};exports[_0x47c3[51]]=function(_0xffcdx6,_0xffcdx7){SquareProject[_0x47c3[51]](_0xffcdx6[_0x47c3[43]])[_0x47c3[40]](function(_0xffcdx16){return _0xffcdx7[_0x47c3[29]](201)[_0x47c3[28]](_0xffcdx16)})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)})};exports[_0x47c3[52]]=function(_0xffcdx6,_0xffcdx7){if(_0xffcdx6[_0x47c3[43]][_0x47c3[48]]){delete _0xffcdx6[_0x47c3[43]][_0x47c3[48]]};SquareProject[_0x47c3[50]](_0xffcdx6[_0x47c3[49]][_0x47c3[48]])[_0x47c3[40]](function(_0xffcdx16){if(!_0xffcdx16){return _0xffcdx7[_0x47c3[45]](404)};var _0xffcdx17=_[_0x47c3[53]](_0xffcdx16,_0xffcdx6[_0x47c3[43]]);_0xffcdx17[_0x47c3[54]]()[_0x47c3[40]](function(){return _0xffcdx7[_0x47c3[29]](200)[_0x47c3[28]](_0xffcdx16)})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)});})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)});};exports[_0x47c3[55]]=function(_0xffcdx6,_0xffcdx7){SquareProject[_0x47c3[56]]({where:{id:_0xffcdx6[_0x47c3[49]][_0x47c3[48]]}})[_0x47c3[40]](function(_0xffcdx16){if(!_0xffcdx16){return _0xffcdx7[_0x47c3[45]](404)};_0xffcdx16[_0x47c3[55]]()[_0x47c3[40]](function(){return _0xffcdx7[_0x47c3[45]](204)})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)});})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)})};exports[_0x47c3[57]]=function(_0xffcdx6,_0xffcdx7){SquareProject[_0x47c3[55]]({where:{id:_0xffcdx6[_0x47c3[11]][_0x47c3[48]]},individualHooks:true})[_0x47c3[40]](function(){return _0xffcdx7[_0x47c3[45]](204)})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)})};exports[_0x47c3[58]]=function(_0xffcdx6,_0xffcdx7,_0xffcdx18){SquareProject[_0x47c3[50]](_0xffcdx6[_0x47c3[49]][_0x47c3[48]])[_0x47c3[40]](function(_0xffcdx16){if(!_0xffcdx16){return _0xffcdx7[_0x47c3[45]](404)};console[_0x47c3[44]](_0xffcdx6[_0x47c3[11]][_0x47c3[59]]);_0xffcdx7[_0x47c3[63]]({"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E":_0x47c3[60]+_0xffcdx6[_0x47c3[11]][_0x47c3[59]]+_0x47c3[61],"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65":_0x47c3[62]});return _0xffcdx7[_0x47c3[28]](_0xffcdx16[_0x47c3[64]]);})[_0x47c3[30]](function(_0xffcdx10){return handleError(_0xffcdx7,_0xffcdx10)})};function handleError(_0xffcdx7,_0xffcdx10){return _0xffcdx7[_0x47c3[29]](500)[_0x47c3[28]](_0xffcdx10)} \ No newline at end of file diff --git a/server/api/square_project/square_project.socket.js b/server/api/square_project/square_project.socket.js index bc43e25..b1b0151 100644 --- a/server/api/square_project/square_project.socket.js +++ b/server/api/square_project/square_project.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SquareProject = require('../../models').SquareProject; - -exports.register = function(socket) { - SquareProject.afterCreate(function(doc) { - onSave(socket, doc); - }); - SquareProject.afterUpdate(function(doc) { - onSave(socket, doc); - }); - SquareProject.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('square_project:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('square_project:remove', doc); -} +var _0xb432=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x71\x75\x61\x72\x65\x50\x72\x6F\x6A\x65\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x71\x75\x61\x72\x65\x5F\x70\x72\x6F\x6A\x65\x63\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x71\x75\x61\x72\x65\x5F\x70\x72\x6F\x6A\x65\x63\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xb432[0];var SquareProject=require(_0xb432[2])[_0xb432[1]];exports[_0xb432[3]]=function(_0x7ce2x2){SquareProject[_0xb432[4]](function(_0x7ce2x3){onSave(_0x7ce2x2,_0x7ce2x3)});SquareProject[_0xb432[5]](function(_0x7ce2x3){onSave(_0x7ce2x2,_0x7ce2x3)});SquareProject[_0xb432[6]](function(_0x7ce2x3){onRemove(_0x7ce2x2,_0x7ce2x3)});};function onSave(_0x7ce2x2,_0x7ce2x3,_0x7ce2x5){_0x7ce2x2[_0xb432[8]](_0xb432[7],_0x7ce2x3)}function onRemove(_0x7ce2x2,_0x7ce2x3,_0x7ce2x5){_0x7ce2x2[_0xb432[8]](_0xb432[9],_0x7ce2x3)} \ No newline at end of file diff --git a/server/api/square_project/square_project.spec.js b/server/api/square_project/square_project.spec.js index 10a8297..93582d9 100644 --- a/server/api/square_project/square_project.spec.js +++ b/server/api/square_project/square_project.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/square/projects', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/square/projects') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xcb74=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x2F\x70\x72\x6F\x6A\x65\x63\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x2F\x70\x72\x6F\x6A\x65\x63\x74\x73","\x67\x65\x74"];_0xcb74[0];var should=require(_0xcb74[1]);var app=require(_0xcb74[2]);var request=require(_0xcb74[3]);describe(_0xcb74[4],function(){it(_0xcb74[5],function(_0xdb2cx4){request(app)[_0xcb74[13]](_0xcb74[12])[_0xcb74[11]](200)[_0xcb74[11]](_0xcb74[10],/json/)[_0xcb74[9]](function(_0xdb2cx5,_0xdb2cx6){if(_0xdb2cx5){return _0xdb2cx4(_0xdb2cx5)};_0xdb2cx6[_0xcb74[8]][_0xcb74[1]][_0xcb74[7]][_0xcb74[6]](Array);_0xdb2cx4();})})}); \ No newline at end of file diff --git a/server/api/sugarcrm_account/index.js b/server/api/sugarcrm_account/index.js index e87249c..a37c5c8 100644 --- a/server/api/sugarcrm_account/index.js +++ b/server/api/sugarcrm_account/index.js @@ -1,21 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./sugarcrm_account.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount); -router.get('/:id/fields', auth.isAuthenticated(), controller.getFields); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/validate/:field', auth.isAuthenticated(), controller.accountValidation); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0xe9b7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64\x2F\x63\x68\x65\x63\x6B","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2F\x3A\x69\x64\x2F\x66\x69\x65\x6C\x64\x73","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65\x2F\x3A\x66\x69\x65\x6C\x64","\x61\x63\x63\x6F\x75\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xe9b7[0];var express=require(_0xe9b7[1]);var auth=require(_0xe9b7[2]);var controller=require(_0xe9b7[3]);var router=express.Router();router[_0xe9b7[7]](_0xe9b7[4],auth[_0xe9b7[5]](),controller[_0xe9b7[6]]);router[_0xe9b7[7]](_0xe9b7[8],auth[_0xe9b7[5]](),controller[_0xe9b7[9]]);router[_0xe9b7[7]](_0xe9b7[10],auth[_0xe9b7[5]](),controller[_0xe9b7[11]]);router[_0xe9b7[7]](_0xe9b7[12],auth[_0xe9b7[5]](),controller[_0xe9b7[13]]);router[_0xe9b7[16]](_0xe9b7[14],auth[_0xe9b7[5]](),controller[_0xe9b7[15]]);router[_0xe9b7[16]](_0xe9b7[4],auth[_0xe9b7[5]](),controller[_0xe9b7[17]]);router[_0xe9b7[19]](_0xe9b7[12],auth[_0xe9b7[5]](),controller[_0xe9b7[18]]);router[_0xe9b7[20]](_0xe9b7[12],auth[_0xe9b7[5]](),controller[_0xe9b7[18]]);router[_0xe9b7[22]](_0xe9b7[4],auth[_0xe9b7[5]](),controller[_0xe9b7[21]]);router[_0xe9b7[22]](_0xe9b7[12],auth[_0xe9b7[5]](),controller[_0xe9b7[23]]);module[_0xe9b7[24]]=router; \ No newline at end of file diff --git a/server/api/sugarcrm_account/index.spec.js b/server/api/sugarcrm_account/index.spec.js index 758de1a..4713a81 100644 --- a/server/api/sugarcrm_account/index.spec.js +++ b/server/api/sugarcrm_account/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var sugarcrmAccountCtrlStub = { - index: 'sugarcrmAccountCtrl.index', - show: 'sugarcrmAccountCtrl.show', - create: 'sugarcrmAccountCtrl.create', - update: 'sugarcrmAccountCtrl.update', - destroy: 'sugarcrmAccountCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var sugarcrmAccountIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './sugarcrm_account.controller': sugarcrmAccountCtrlStub -}); - -describe('SugarcrmAccount API Router:', function() { - - it('should return an express router instance', function() { - expect(sugarcrmAccountIndex).to.equal(routerStub); - }); - - describe('GET /api/sugarcrm/accounts', function() { - - it('should route to sugarcrmAccount.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'sugarcrmAccountCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/sugarcrm/accounts/:id', function() { - - it('should route to sugarcrmAccount.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'sugarcrmAccountCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/sugarcrm/accounts', function() { - - it('should route to sugarcrmAccount.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'sugarcrmAccountCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/sugarcrm/accounts/:id', function() { - - it('should route to sugarcrmAccount.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'sugarcrmAccountCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/sugarcrm/accounts/:id', function() { - - it('should route to sugarcrmAccount.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'sugarcrmAccountCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/sugarcrm/accounts/:id', function() { - - it('should route to sugarcrmAccount.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'sugarcrmAccountCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0xe54a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x53\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0xe54a[0];var proxyquire=require(_0xe54a[2])[_0xe54a[1]]();var sugarcrmAccountCtrlStub={index:_0xe54a[3],show:_0xe54a[4],create:_0xe54a[5],update:_0xe54a[6],destroy:_0xe54a[7]};var routerStub={get:sinon[_0xe54a[8]](),put:sinon[_0xe54a[8]](),patch:sinon[_0xe54a[8]](),post:sinon[_0xe54a[8]](),delete:sinon[_0xe54a[8]]()};var sugarcrmAccountIndex=proxyquire(_0xe54a[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":sugarcrmAccountCtrlStub});describe(_0xe54a[10],function(){it(_0xe54a[11],function(){expect(sugarcrmAccountIndex)[_0xe54a[13]][_0xe54a[12]](routerStub)});describe(_0xe54a[14],function(){it(_0xe54a[15],function(){expect(routerStub[_0xe54a[21]][_0xe54a[20]](_0xe54a[19],_0xe54a[3]))[_0xe54a[13]][_0xe54a[18]][_0xe54a[17]][_0xe54a[16]]})});describe(_0xe54a[22],function(){it(_0xe54a[23],function(){expect(routerStub[_0xe54a[21]][_0xe54a[20]](_0xe54a[24],_0xe54a[4]))[_0xe54a[13]][_0xe54a[18]][_0xe54a[17]][_0xe54a[16]]})});describe(_0xe54a[25],function(){it(_0xe54a[26],function(){expect(routerStub[_0xe54a[27]][_0xe54a[20]](_0xe54a[19],_0xe54a[5]))[_0xe54a[13]][_0xe54a[18]][_0xe54a[17]][_0xe54a[16]]})});describe(_0xe54a[28],function(){it(_0xe54a[29],function(){expect(routerStub[_0xe54a[30]][_0xe54a[20]](_0xe54a[24],_0xe54a[6]))[_0xe54a[13]][_0xe54a[18]][_0xe54a[17]][_0xe54a[16]]})});describe(_0xe54a[31],function(){it(_0xe54a[29],function(){expect(routerStub[_0xe54a[32]][_0xe54a[20]](_0xe54a[24],_0xe54a[6]))[_0xe54a[13]][_0xe54a[18]][_0xe54a[17]][_0xe54a[16]]})});describe(_0xe54a[33],function(){it(_0xe54a[34],function(){expect(routerStub[_0xe54a[35]][_0xe54a[20]](_0xe54a[24],_0xe54a[7]))[_0xe54a[13]][_0xe54a[18]][_0xe54a[17]][_0xe54a[16]]})});}); \ No newline at end of file diff --git a/server/api/sugarcrm_account/sugarcrm_account.controller.js b/server/api/sugarcrm_account/sugarcrm_account.controller.js index cb7d78d..d8175ae 100644 --- a/server/api/sugarcrm_account/sugarcrm_account.controller.js +++ b/server/api/sugarcrm_account/sugarcrm_account.controller.js @@ -1,259 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/sugarcrm/accounts -> index - * POST /api/sugarcrm/accounts -> create - * GET /api/sugarcrm/accounts/:id -> show - * PUT /api/sugarcrm/accounts/:id -> update - * DELETE /api/sugarcrm/accounts/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); -var util = require('util'); - -var SugarcrmAccount = require('../../models').SugarcrmAccount; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of SugarcrmAccounts -exports.index = function(req, res) { - var attributes = ['description', 'name', 'username', 'remoteUri']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - SugarcrmAccount - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - return res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return res.status(500).send({ - error: 'Something blew up!' - }); - }); -} - -// Gets a single SugarcrmAccount from the DB -exports.show = function(req, res) { - SugarcrmAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new SugarcrmAccount in the DB -exports.create = function(req, res) { - SugarcrmAccount.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing SugarcrmAccount in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - SugarcrmAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a SugarcrmAccount from the DB -exports.destroy = function(req, res) { - SugarcrmAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} - -exports.checkAccount = function(req, res) { - SugarcrmAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(account) { - var sugar = require('node-sugarcrm-client'); - sugar.init({ - apiURL: stripTrailingSlash(account.remoteUri) + "/service/v4_1/rest.php", - login: account.username, - passwd: account.password - }); - sugar.login(function(sessionId) { - if (!sessionId) { - return res.sendStatus(400); - } - return res.sendStatus(200); - }); - }) - .catch(handleError(res)); -} - -exports.bulkDestroy = function(req, res) { - SugarcrmAccount - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.accountValidation = function(req, res) { - var where = {}; - where[req.params.field] = req.body.value; - SugarcrmAccount - .findAndCountAll({ - where: where - }) - .then(function(result) { - if (result.count) { - return res.status(200).send({ - isValid: false, - value: req.body.value - }); - } - return res.status(200).send({ - isValid: true, - value: req.body.value - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getFields = function(req, res) { - var sugar = require('node-sugarcrm-client'); - SugarcrmAccount.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(account) { - sugar.init({ - apiURL: stripTrailingSlash(account.remoteUri) + "/service/v4_1/rest.php", - login: account.username, - passwd: account.password - }); - sugar.login(function(sessionId) { - if (!sessionId) { - return res.sendStatus(400); - } - var params = { - session: sessionId, - module_name: "Cases" - }; - sugar.call("get_module_fields", params, function(result, err) { - if (err) { - return res.sendStatus(400); - } - return res.status(200).send(result.module_fields); - }); - }); - }) - .catch(handleError(res)); -}; - -function stripTrailingSlash(str) { - if (str.substr(-1) === '/') { - return str.substr(0, str.length - 1); - } - return str; -} +var _0x3b2e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x53\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x6E\x6F\x64\x65\x2D\x73\x75\x67\x61\x72\x63\x72\x6D\x2D\x63\x6C\x69\x65\x6E\x74","\x2F\x73\x65\x72\x76\x69\x63\x65\x2F\x76\x34\x5F\x31\x2F\x72\x65\x73\x74\x2E\x70\x68\x70","\x70\x61\x73\x73\x77\x6F\x72\x64","\x69\x6E\x69\x74","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x6C\x6F\x67\x69\x6E","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x61\x63\x63\x6F\x75\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x43\x61\x73\x65\x73","\x67\x65\x74\x5F\x6D\x6F\x64\x75\x6C\x65\x5F\x66\x69\x65\x6C\x64\x73","\x6D\x6F\x64\x75\x6C\x65\x5F\x66\x69\x65\x6C\x64\x73","\x63\x61\x6C\x6C","\x73\x75\x62\x73\x74\x72","\x2F","\x6C\x65\x6E\x67\x74\x68"];_0x3b2e[0];var _=require(_0x3b2e[1]);var util=require(_0x3b2e[2]);var SugarcrmAccount=require(_0x3b2e[4])[_0x3b2e[3]];function handleError(_0xff13x5,_0xff13x6){_0xff13x6=_0xff13x6||500;return function(_0xff13x7){_0xff13x5[_0x3b2e[6]](_0xff13x6)[_0x3b2e[5]](_0xff13x7)};}function responseWithResult(_0xff13x5,_0xff13x6){_0xff13x6=_0xff13x6||200;return function(_0xff13x9){if(_0xff13x9){_0xff13x5[_0x3b2e[6]](_0xff13x6)[_0x3b2e[7]](_0xff13x9)}};}function handleEntityNotFound(_0xff13x5){return function(_0xff13x9){if(!_0xff13x9){_0xff13x5[_0x3b2e[6]](404)[_0x3b2e[8]]();return null;};return _0xff13x9;}}function saveUpdates(_0xff13xc){return function(_0xff13x9){return _0xff13x9[_0x3b2e[10]](_0xff13xc)[_0x3b2e[9]](function(_0xff13xd){return _0xff13xd})}}function removeEntity(_0xff13x5){return function(_0xff13x9){if(_0xff13x9){return _0xff13x9[_0x3b2e[11]]()[_0x3b2e[9]](function(){_0xff13x5[_0x3b2e[6]](204)[_0x3b2e[8]]()})}}}exports[_0x3b2e[12]]=function(_0xff13xf,_0xff13x5){var _0xff13x10=[_0x3b2e[13],_0x3b2e[14],_0x3b2e[15],_0x3b2e[16]];var _0xff13x11=_0xff13xf[_0x3b2e[18]][_0x3b2e[17]]?parseInt(_0xff13xf[_0x3b2e[18]][_0x3b2e[17]],10):100;var _0xff13x12=_0xff13xf[_0x3b2e[18]][_0x3b2e[19]]?parseInt(_0xff13xf[_0x3b2e[18]][_0x3b2e[19]],10):0;var _0xff13x13={where:{},limit:_0xff13x11,offset:_0xff13x12*_0xff13x11};_[_0x3b2e[33]](_0xff13xf[_0x3b2e[18]],function(_0xff13x14,_0xff13x15){switch(_0xff13x15){case _0x3b2e[17]:;case _0x3b2e[19]:break ;;case _0x3b2e[22]:_0xff13x13[_0x3b2e[20]]=util[_0x3b2e[25]](_0x3b2e[21],_0xff13xf[_0x3b2e[18]][_0x3b2e[22]],_0xff13xf[_0x3b2e[18]][_0x3b2e[23]]||_0x3b2e[24])||null;break ;;case _0x3b2e[23]:break ;;case _0x3b2e[31]:_0xff13x13[_0x3b2e[27]][_0x3b2e[26]]=[];_0xff13x10[_0x3b2e[30]](function(_0xff13x16){var _0xff13x17={};_0xff13x17[_0xff13x16]={$like:_0x3b2e[28]+_0xff13x14+_0x3b2e[28]};_0xff13x13[_0x3b2e[27]][_0x3b2e[26]][_0x3b2e[29]](_0xff13x17);});break ;;default:_0xff13x13[_0x3b2e[27]][_0xff13x15]={$like:{}};_0xff13x13[_0x3b2e[27]][_0xff13x15][_0x3b2e[32]]=_0x3b2e[28]+_0xff13x14+_0x3b2e[28];;}});SugarcrmAccount[_0x3b2e[45]](_0xff13x13)[_0x3b2e[9]](function(_0xff13x18){var _0xff13x19=Math[_0x3b2e[37]](_0xff13x18[_0x3b2e[36]]/_0xff13x11);var _0xff13x1a=_0xff13x19>(_0xff13x13[_0x3b2e[38]]+1)?util[_0x3b2e[25]](_0x3b2e[39],_0xff13xf[_0x3b2e[40]],_0xff13xf[_0x3b2e[42]][_0x3b2e[41]],_0xff13xf[_0x3b2e[43]],_0xff13x12+1):null;var _0xff13x1b=_0xff13x12>0?util[_0x3b2e[25]](_0x3b2e[39],_0xff13xf[_0x3b2e[40]],_0xff13xf[_0x3b2e[42]][_0x3b2e[41]],_0xff13xf[_0x3b2e[43]],_0xff13x12-1):null;return _0xff13x5[_0x3b2e[6]](200)[_0x3b2e[5]]({count:_0xff13x18[_0x3b2e[36]],rows:_0xff13x18[_0x3b2e[44]],next_page:_0xff13x1a,previous_page:_0xff13x1b,total_pages:_0xff13x19});})[_0x3b2e[35]](function(_0xff13x7){return _0xff13x5[_0x3b2e[6]](500)[_0x3b2e[5]]({error:_0x3b2e[34]})});};exports[_0x3b2e[46]]=function(_0xff13xf,_0xff13x5){SugarcrmAccount[_0x3b2e[49]](_0xff13xf[_0x3b2e[48]][_0x3b2e[47]])[_0x3b2e[9]](handleEntityNotFound(_0xff13x5))[_0x3b2e[9]](responseWithResult(_0xff13x5))[_0x3b2e[35]](handleError(_0xff13x5))};exports[_0x3b2e[50]]=function(_0xff13xf,_0xff13x5){SugarcrmAccount[_0x3b2e[50]](_0xff13xf[_0x3b2e[51]])[_0x3b2e[9]](responseWithResult(_0xff13x5,201))[_0x3b2e[35]](handleError(_0xff13x5))};exports[_0x3b2e[52]]=function(_0xff13xf,_0xff13x5){if(_0xff13xf[_0x3b2e[51]][_0x3b2e[47]]){delete _0xff13xf[_0x3b2e[51]][_0x3b2e[47]]};SugarcrmAccount[_0x3b2e[49]](_0xff13xf[_0x3b2e[48]][_0x3b2e[47]])[_0x3b2e[9]](handleEntityNotFound(_0xff13x5))[_0x3b2e[9]](saveUpdates(_0xff13xf[_0x3b2e[51]]))[_0x3b2e[9]](responseWithResult(_0xff13x5))[_0x3b2e[35]](handleError(_0xff13x5));};exports[_0x3b2e[11]]=function(_0xff13xf,_0xff13x5){SugarcrmAccount[_0x3b2e[49]](_0xff13xf[_0x3b2e[48]][_0x3b2e[47]])[_0x3b2e[9]](handleEntityNotFound(_0xff13x5))[_0x3b2e[9]](removeEntity(_0xff13x5))[_0x3b2e[35]](handleError(_0xff13x5))};exports[_0x3b2e[53]]=function(_0xff13xf,_0xff13x5){SugarcrmAccount[_0x3b2e[49]](_0xff13xf[_0x3b2e[48]][_0x3b2e[47]])[_0x3b2e[9]](handleEntityNotFound(_0xff13x5))[_0x3b2e[9]](function(_0xff13x1c){var _0xff13x1d=require(_0x3b2e[54]);_0xff13x1d[_0x3b2e[57]]({apiURL:stripTrailingSlash(_0xff13x1c[_0x3b2e[16]])+_0x3b2e[55],login:_0xff13x1c[_0x3b2e[15]],passwd:_0xff13x1c[_0x3b2e[56]]});_0xff13x1d[_0x3b2e[59]](function(_0xff13x1e){if(!_0xff13x1e){return _0xff13x5[_0x3b2e[58]](400)};return _0xff13x5[_0x3b2e[58]](200);});})[_0x3b2e[35]](handleError(_0xff13x5))};exports[_0x3b2e[60]]=function(_0xff13xf,_0xff13x5){SugarcrmAccount[_0x3b2e[11]]({where:{id:_0xff13xf[_0x3b2e[18]][_0x3b2e[47]]},individualHooks:true})[_0x3b2e[9]](function(){return _0xff13x5[_0x3b2e[58]](204)})[_0x3b2e[35]](function(_0xff13x7){return handleError(_0xff13x5,_0xff13x7)})};exports[_0x3b2e[61]]=function(_0xff13xf,_0xff13x5){var _0xff13x1f={};_0xff13x1f[_0xff13xf[_0x3b2e[48]][_0x3b2e[62]]]=_0xff13xf[_0x3b2e[51]][_0x3b2e[63]];SugarcrmAccount[_0x3b2e[45]]({where:_0xff13x1f})[_0x3b2e[9]](function(_0xff13x18){if(_0xff13x18[_0x3b2e[36]]){return _0xff13x5[_0x3b2e[6]](200)[_0x3b2e[5]]({isValid:false,value:_0xff13xf[_0x3b2e[51]][_0x3b2e[63]]})};return _0xff13x5[_0x3b2e[6]](200)[_0x3b2e[5]]({isValid:true,value:_0xff13xf[_0x3b2e[51]][_0x3b2e[63]]});})[_0x3b2e[35]](function(_0xff13x7){return handleError(_0xff13x5,_0xff13x7)});};exports[_0x3b2e[64]]=function(_0xff13xf,_0xff13x5){var _0xff13x1d=require(_0x3b2e[54]);SugarcrmAccount[_0x3b2e[49]](_0xff13xf[_0x3b2e[48]][_0x3b2e[47]])[_0x3b2e[9]](handleEntityNotFound(_0xff13x5))[_0x3b2e[9]](function(_0xff13x1c){_0xff13x1d[_0x3b2e[57]]({apiURL:stripTrailingSlash(_0xff13x1c[_0x3b2e[16]])+_0x3b2e[55],login:_0xff13x1c[_0x3b2e[15]],passwd:_0xff13x1c[_0x3b2e[56]]});_0xff13x1d[_0x3b2e[59]](function(_0xff13x1e){if(!_0xff13x1e){return _0xff13x5[_0x3b2e[58]](400)};var _0xff13x20={session:_0xff13x1e,module_name:_0x3b2e[65]};_0xff13x1d[_0x3b2e[68]](_0x3b2e[66],_0xff13x20,function(_0xff13x18,_0xff13x7){if(_0xff13x7){return _0xff13x5[_0x3b2e[58]](400)};return _0xff13x5[_0x3b2e[6]](200)[_0x3b2e[5]](_0xff13x18[_0x3b2e[67]]);});});})[_0x3b2e[35]](handleError(_0xff13x5));};function stripTrailingSlash(_0xff13x22){if(_0xff13x22[_0x3b2e[69]](-1)===_0x3b2e[70]){return _0xff13x22[_0x3b2e[69]](0,_0xff13x22[_0x3b2e[71]]-1)};return _0xff13x22;} \ No newline at end of file diff --git a/server/api/sugarcrm_account/sugarcrm_account.socket.js b/server/api/sugarcrm_account/sugarcrm_account.socket.js index 859bf6d..ba4ac57 100644 --- a/server/api/sugarcrm_account/sugarcrm_account.socket.js +++ b/server/api/sugarcrm_account/sugarcrm_account.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SugarcrmAccount = require('../../models').SugarcrmAccount; - -exports.register = function(socket) { - SugarcrmAccount.afterCreate(function(doc) { - onSave(socket, doc); - }); - SugarcrmAccount.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('sugarcrm_account:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('sugarcrm_account:remove', doc); -} +var _0xc6b2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xc6b2[0];var SugarcrmAccount=require(_0xc6b2[2])[_0xc6b2[1]];exports[_0xc6b2[3]]=function(_0xfbe4x2){SugarcrmAccount[_0xc6b2[4]](function(_0xfbe4x3){onSave(_0xfbe4x2,_0xfbe4x3)});SugarcrmAccount[_0xc6b2[5]](function(_0xfbe4x3){onRemove(_0xfbe4x2,_0xfbe4x3)});};function onSave(_0xfbe4x2,_0xfbe4x3,_0xfbe4x5){_0xfbe4x2[_0xc6b2[7]](_0xc6b2[6],_0xfbe4x3)}function onRemove(_0xfbe4x2,_0xfbe4x3,_0xfbe4x5){_0xfbe4x2[_0xc6b2[7]](_0xc6b2[8],_0xfbe4x3)} \ No newline at end of file diff --git a/server/api/sugarcrm_configuration/index.js b/server/api/sugarcrm_configuration/index.js index 90111bf..04e2705 100644 --- a/server/api/sugarcrm_configuration/index.js +++ b/server/api/sugarcrm_configuration/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./sugarcrm_configuration.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0x20a6=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x3A\x69\x64\x2F\x3A\x74\x79\x70\x65","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x20a6[0];var express=require(_0x20a6[1]);var auth=require(_0x20a6[2]);var controller=require(_0x20a6[3]);var router=express.Router();router[_0x20a6[7]](_0x20a6[4],auth[_0x20a6[5]](),controller[_0x20a6[6]]);router[_0x20a6[7]](_0x20a6[8],auth[_0x20a6[5]](),controller[_0x20a6[9]]);router[_0x20a6[11]](_0x20a6[4],auth[_0x20a6[5]](),controller[_0x20a6[10]]);router[_0x20a6[13]](_0x20a6[8],auth[_0x20a6[5]](),controller[_0x20a6[12]]);router[_0x20a6[11]](_0x20a6[14],auth[_0x20a6[5]](),controller[_0x20a6[15]]);router[_0x20a6[16]](_0x20a6[8],auth[_0x20a6[5]](),controller[_0x20a6[12]]);router[_0x20a6[18]](_0x20a6[8],auth[_0x20a6[5]](),controller[_0x20a6[17]]);module[_0x20a6[19]]=router; \ No newline at end of file diff --git a/server/api/sugarcrm_configuration/index.spec.js b/server/api/sugarcrm_configuration/index.spec.js index ba1b022..e4e163f 100644 --- a/server/api/sugarcrm_configuration/index.spec.js +++ b/server/api/sugarcrm_configuration/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var sugarcrmConfigurationCtrlStub = { - index: 'sugarcrmConfigurationCtrl.index', - show: 'sugarcrmConfigurationCtrl.show', - create: 'sugarcrmConfigurationCtrl.create', - update: 'sugarcrmConfigurationCtrl.update', - destroy: 'sugarcrmConfigurationCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var sugarcrmConfigurationIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './sugarcrm_configuration.controller': sugarcrmConfigurationCtrlStub -}); - -describe('SugarcrmConfiguration API Router:', function() { - - it('should return an express router instance', function() { - expect(sugarcrmConfigurationIndex).to.equal(routerStub); - }); - - describe('GET /api/sugarcrm/configurations', function() { - - it('should route to sugarcrmConfiguration.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'sugarcrmConfigurationCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/sugarcrm/configurations/:id', function() { - - it('should route to sugarcrmConfiguration.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'sugarcrmConfigurationCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/sugarcrm/configurations', function() { - - it('should route to sugarcrmConfiguration.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'sugarcrmConfigurationCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/sugarcrm/configurations/:id', function() { - - it('should route to sugarcrmConfiguration.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'sugarcrmConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/sugarcrm/configurations/:id', function() { - - it('should route to sugarcrmConfiguration.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'sugarcrmConfigurationCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/sugarcrm/configurations/:id', function() { - - it('should route to sugarcrmConfiguration.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'sugarcrmConfigurationCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0xcbcc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x53\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0xcbcc[0];var proxyquire=require(_0xcbcc[2])[_0xcbcc[1]]();var sugarcrmConfigurationCtrlStub={index:_0xcbcc[3],show:_0xcbcc[4],create:_0xcbcc[5],update:_0xcbcc[6],destroy:_0xcbcc[7]};var routerStub={get:sinon[_0xcbcc[8]](),put:sinon[_0xcbcc[8]](),patch:sinon[_0xcbcc[8]](),post:sinon[_0xcbcc[8]](),delete:sinon[_0xcbcc[8]]()};var sugarcrmConfigurationIndex=proxyquire(_0xcbcc[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":sugarcrmConfigurationCtrlStub});describe(_0xcbcc[10],function(){it(_0xcbcc[11],function(){expect(sugarcrmConfigurationIndex)[_0xcbcc[13]][_0xcbcc[12]](routerStub)});describe(_0xcbcc[14],function(){it(_0xcbcc[15],function(){expect(routerStub[_0xcbcc[21]][_0xcbcc[20]](_0xcbcc[19],_0xcbcc[3]))[_0xcbcc[13]][_0xcbcc[18]][_0xcbcc[17]][_0xcbcc[16]]})});describe(_0xcbcc[22],function(){it(_0xcbcc[23],function(){expect(routerStub[_0xcbcc[21]][_0xcbcc[20]](_0xcbcc[24],_0xcbcc[4]))[_0xcbcc[13]][_0xcbcc[18]][_0xcbcc[17]][_0xcbcc[16]]})});describe(_0xcbcc[25],function(){it(_0xcbcc[26],function(){expect(routerStub[_0xcbcc[27]][_0xcbcc[20]](_0xcbcc[19],_0xcbcc[5]))[_0xcbcc[13]][_0xcbcc[18]][_0xcbcc[17]][_0xcbcc[16]]})});describe(_0xcbcc[28],function(){it(_0xcbcc[29],function(){expect(routerStub[_0xcbcc[30]][_0xcbcc[20]](_0xcbcc[24],_0xcbcc[6]))[_0xcbcc[13]][_0xcbcc[18]][_0xcbcc[17]][_0xcbcc[16]]})});describe(_0xcbcc[31],function(){it(_0xcbcc[29],function(){expect(routerStub[_0xcbcc[32]][_0xcbcc[20]](_0xcbcc[24],_0xcbcc[6]))[_0xcbcc[13]][_0xcbcc[18]][_0xcbcc[17]][_0xcbcc[16]]})});describe(_0xcbcc[33],function(){it(_0xcbcc[34],function(){expect(routerStub[_0xcbcc[35]][_0xcbcc[20]](_0xcbcc[24],_0xcbcc[7]))[_0xcbcc[13]][_0xcbcc[18]][_0xcbcc[17]][_0xcbcc[16]]})});}); \ No newline at end of file diff --git a/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js b/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js index 5918283..2eb5fcf 100644 --- a/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js +++ b/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js @@ -1,145 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/sugarcrm/configurations -> index - * POST /api/sugarcrm/configurations -> create - * GET /api/sugarcrm/configurations/:id -> show - * PUT /api/sugarcrm/configurations/:id -> update - * DELETE /api/sugarcrm/configurations/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); - -var SugarcrmConfiguration = require('../../models').SugarcrmConfiguration; -var SugarcrmField = require('../../models').SugarcrmField; - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of SugarcrmConfigurations -exports.index = function(req, res) { - SugarcrmConfiguration.findAll({ - where: req.query - }) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single SugarcrmConfiguration from the DB -exports.show = function(req, res) { - SugarcrmConfiguration.find({ - where: { - id: req.params.id - }, - include: [{ - model: SugarcrmField, - as: 'Subject' - }, { - model: SugarcrmField, - as: 'Description' - }, { - model: SugarcrmField, - as: 'Field' - }] - }) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new SugarcrmConfiguration in the DB -exports.create = function(req, res) { - SugarcrmConfiguration.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing SugarcrmConfiguration in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - SugarcrmConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a SugarcrmConfiguration from the DB -exports.destroy = function(req, res) { - SugarcrmConfiguration.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} - -exports.addConfigurationField = function(req, res, next) { - var sugarcrmConfiguration; - SugarcrmConfiguration - .findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(function(sugarcrm_configuration) { - sugarcrmConfiguration = sugarcrm_configuration; - return SugarcrmField.create(req.body) - }) - .then(function(sugarcrmField) { - switch (req.params.type) { - case 'subject': - return [sugarcrmConfiguration.addSubject(sugarcrmField), sugarcrmField]; - case 'description': - return [sugarcrmConfiguration.addDescription(sugarcrmField), sugarcrmField]; - case 'field': - return [sugarcrmConfiguration.addField(sugarcrmField), sugarcrmField]; - } - }) - .spread(function(data, sugarcrmField) { - return res.status(201).json(sugarcrmField); - }) - .catch(handleError(res)); -}; +var _0xf8a9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x53\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x53\x75\x62\x6A\x65\x63\x74","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x46\x69\x65\x6C\x64","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x73\x70\x72\x65\x61\x64","\x61\x64\x64\x53\x75\x62\x6A\x65\x63\x74","\x73\x75\x62\x6A\x65\x63\x74","\x61\x64\x64\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x61\x64\x64\x46\x69\x65\x6C\x64","\x66\x69\x65\x6C\x64","\x74\x79\x70\x65"];_0xf8a9[0];var _=require(_0xf8a9[1]);var SugarcrmConfiguration=require(_0xf8a9[3])[_0xf8a9[2]];var SugarcrmField=require(_0xf8a9[3])[_0xf8a9[4]];function handleError(_0x7975x5,_0x7975x6){_0x7975x6=_0x7975x6||500;return function(_0x7975x7){_0x7975x5[_0xf8a9[6]](_0x7975x6)[_0xf8a9[5]](_0x7975x7)};}function responseWithResult(_0x7975x5,_0x7975x6){_0x7975x6=_0x7975x6||200;return function(_0x7975x9){if(_0x7975x9){_0x7975x5[_0xf8a9[6]](_0x7975x6)[_0xf8a9[7]](_0x7975x9)}};}function handleEntityNotFound(_0x7975x5){return function(_0x7975x9){if(!_0x7975x9){_0x7975x5[_0xf8a9[6]](404)[_0xf8a9[8]]();return null;};return _0x7975x9;}}function saveUpdates(_0x7975xc){return function(_0x7975x9){return _0x7975x9[_0xf8a9[10]](_0x7975xc)[_0xf8a9[9]](function(_0x7975xd){return _0x7975xd})}}function removeEntity(_0x7975x5){return function(_0x7975x9){if(_0x7975x9){return _0x7975x9[_0xf8a9[11]]()[_0xf8a9[9]](function(){_0x7975x5[_0xf8a9[6]](204)[_0xf8a9[8]]()})}}}exports[_0xf8a9[12]]=function(_0x7975xf,_0x7975x5){SugarcrmConfiguration[_0xf8a9[15]]({where:_0x7975xf[_0xf8a9[14]]})[_0xf8a9[9]](responseWithResult(_0x7975x5))[_0xf8a9[13]](handleError(_0x7975x5))};exports[_0xf8a9[16]]=function(_0x7975xf,_0x7975x5){SugarcrmConfiguration[_0xf8a9[22]]({where:{id:_0x7975xf[_0xf8a9[18]][_0xf8a9[17]]},include:[{model:SugarcrmField,as:_0xf8a9[19]},{model:SugarcrmField,as:_0xf8a9[20]},{model:SugarcrmField,as:_0xf8a9[21]}]})[_0xf8a9[9]](handleEntityNotFound(_0x7975x5))[_0xf8a9[9]](responseWithResult(_0x7975x5))[_0xf8a9[13]](handleError(_0x7975x5))};exports[_0xf8a9[23]]=function(_0x7975xf,_0x7975x5){SugarcrmConfiguration[_0xf8a9[23]](_0x7975xf[_0xf8a9[24]])[_0xf8a9[9]](responseWithResult(_0x7975x5,201))[_0xf8a9[13]](handleError(_0x7975x5))};exports[_0xf8a9[25]]=function(_0x7975xf,_0x7975x5){if(_0x7975xf[_0xf8a9[24]][_0xf8a9[17]]){delete _0x7975xf[_0xf8a9[24]][_0xf8a9[17]]};SugarcrmConfiguration[_0xf8a9[26]](_0x7975xf[_0xf8a9[18]][_0xf8a9[17]])[_0xf8a9[9]](handleEntityNotFound(_0x7975x5))[_0xf8a9[9]](saveUpdates(_0x7975xf[_0xf8a9[24]]))[_0xf8a9[9]](responseWithResult(_0x7975x5))[_0xf8a9[13]](handleError(_0x7975x5));};exports[_0xf8a9[11]]=function(_0x7975xf,_0x7975x5){SugarcrmConfiguration[_0xf8a9[26]](_0x7975xf[_0xf8a9[18]][_0xf8a9[17]])[_0xf8a9[9]](handleEntityNotFound(_0x7975x5))[_0xf8a9[9]](removeEntity(_0x7975x5))[_0xf8a9[13]](handleError(_0x7975x5))};exports[_0xf8a9[27]]=function(_0x7975xf,_0x7975x5,_0x7975x10){var _0x7975x11;SugarcrmConfiguration[_0xf8a9[26]](_0x7975xf[_0xf8a9[18]][_0xf8a9[17]])[_0xf8a9[9]](handleEntityNotFound(_0x7975x5))[_0xf8a9[9]](function(_0x7975x14){_0x7975x11=_0x7975x14;return SugarcrmField[_0xf8a9[23]](_0x7975xf[_0xf8a9[24]]);})[_0xf8a9[9]](function(_0x7975x13){switch(_0x7975xf[_0xf8a9[18]][_0xf8a9[35]]){case _0xf8a9[30]:return [_0x7975x11[_0xf8a9[29]](_0x7975x13),_0x7975x13];;case _0xf8a9[32]:return [_0x7975x11[_0xf8a9[31]](_0x7975x13),_0x7975x13];;case _0xf8a9[34]:return [_0x7975x11[_0xf8a9[33]](_0x7975x13),_0x7975x13];;}})[_0xf8a9[28]](function(_0x7975x12,_0x7975x13){return _0x7975x5[_0xf8a9[6]](201)[_0xf8a9[7]](_0x7975x13)})[_0xf8a9[13]](handleError(_0x7975x5));}; \ No newline at end of file diff --git a/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js b/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js index c4464da..9cb3d62 100644 --- a/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js +++ b/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SugarcrmConfiguration = require('../../models').SugarcrmConfiguration; - -exports.register = function(socket) { - SugarcrmConfiguration.afterCreate(function(doc) { - onSave(socket, doc); - }); - SugarcrmConfiguration.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('sugarcrm_configuration:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('sugarcrm_configuration:remove', doc); -} +var _0x4eb1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x4eb1[0];var SugarcrmConfiguration=require(_0x4eb1[2])[_0x4eb1[1]];exports[_0x4eb1[3]]=function(_0x3864x2){SugarcrmConfiguration[_0x4eb1[4]](function(_0x3864x3){onSave(_0x3864x2,_0x3864x3)});SugarcrmConfiguration[_0x4eb1[5]](function(_0x3864x3){onRemove(_0x3864x2,_0x3864x3)});};function onSave(_0x3864x2,_0x3864x3,_0x3864x5){_0x3864x2[_0x4eb1[7]](_0x4eb1[6],_0x3864x3)}function onRemove(_0x3864x2,_0x3864x3,_0x3864x5){_0x3864x2[_0x4eb1[7]](_0x4eb1[8],_0x3864x3)} \ No newline at end of file diff --git a/server/api/sugarcrm_field/index.js b/server/api/sugarcrm_field/index.js index edc0dc9..ba74cb2 100644 --- a/server/api/sugarcrm_field/index.js +++ b/server/api/sugarcrm_field/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./sugarcrm_field.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); - -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - - -module.exports = router; +var _0xfd79=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xfd79[0];var express=require(_0xfd79[1]);var auth=require(_0xfd79[2]);var controller=require(_0xfd79[3]);var router=express.Router();router[_0xfd79[7]](_0xfd79[4],auth[_0xfd79[5]](),controller[_0xfd79[6]]);router[_0xfd79[7]](_0xfd79[8],auth[_0xfd79[5]](),controller[_0xfd79[9]]);router[_0xfd79[11]](_0xfd79[4],auth[_0xfd79[5]](),controller[_0xfd79[10]]);router[_0xfd79[13]](_0xfd79[8],auth[_0xfd79[5]](),controller[_0xfd79[12]]);router[_0xfd79[14]](_0xfd79[8],auth[_0xfd79[5]](),controller[_0xfd79[12]]);router[_0xfd79[16]](_0xfd79[8],auth[_0xfd79[5]](),controller[_0xfd79[15]]);module[_0xfd79[17]]=router; \ No newline at end of file diff --git a/server/api/sugarcrm_field/index.spec.js b/server/api/sugarcrm_field/index.spec.js index f8a20f7..04bdd3b 100644 --- a/server/api/sugarcrm_field/index.spec.js +++ b/server/api/sugarcrm_field/index.spec.js @@ -1,97 +1 @@ -'use strict'; - -var proxyquire = require('proxyquire').noPreserveCache(); - -var sugarcrmFieldCtrlStub = { - index: 'sugarcrmFieldCtrl.index', - show: 'sugarcrmFieldCtrl.show', - create: 'sugarcrmFieldCtrl.create', - update: 'sugarcrmFieldCtrl.update', - destroy: 'sugarcrmFieldCtrl.destroy' -}; - -var routerStub = { - get: sinon.spy(), - put: sinon.spy(), - patch: sinon.spy(), - post: sinon.spy(), - delete: sinon.spy() -}; - -// require the index with our stubbed out modules -var sugarcrmFieldIndex = proxyquire('./index.js', { - 'express': { - Router: function() { - return routerStub; - } - }, - './sugarcrm_field.controller': sugarcrmFieldCtrlStub -}); - -describe('SugarcrmField API Router:', function() { - - it('should return an express router instance', function() { - expect(sugarcrmFieldIndex).to.equal(routerStub); - }); - - describe('GET /api/sugarcrm/fields', function() { - - it('should route to sugarcrmField.controller.index', function() { - expect(routerStub.get - .withArgs('/', 'sugarcrmFieldCtrl.index') - ).to.have.been.calledOnce; - }); - - }); - - describe('GET /api/sugarcrm/fields/:id', function() { - - it('should route to sugarcrmField.controller.show', function() { - expect(routerStub.get - .withArgs('/:id', 'sugarcrmFieldCtrl.show') - ).to.have.been.calledOnce; - }); - - }); - - describe('POST /api/sugarcrm/fields', function() { - - it('should route to sugarcrmField.controller.create', function() { - expect(routerStub.post - .withArgs('/', 'sugarcrmFieldCtrl.create') - ).to.have.been.calledOnce; - }); - - }); - - describe('PUT /api/sugarcrm/fields/:id', function() { - - it('should route to sugarcrmField.controller.update', function() { - expect(routerStub.put - .withArgs('/:id', 'sugarcrmFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('PATCH /api/sugarcrm/fields/:id', function() { - - it('should route to sugarcrmField.controller.update', function() { - expect(routerStub.patch - .withArgs('/:id', 'sugarcrmFieldCtrl.update') - ).to.have.been.calledOnce; - }); - - }); - - describe('DELETE /api/sugarcrm/fields/:id', function() { - - it('should route to sugarcrmField.controller.destroy', function() { - expect(routerStub.delete - .withArgs('/:id', 'sugarcrmFieldCtrl.destroy') - ).to.have.been.calledOnce; - }); - - }); - -}); +var _0x9458=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6E\x6F\x50\x72\x65\x73\x65\x72\x76\x65\x43\x61\x63\x68\x65","\x70\x72\x6F\x78\x79\x71\x75\x69\x72\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x69\x6E\x64\x65\x78","\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x73\x68\x6F\x77","\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x63\x72\x65\x61\x74\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x75\x70\x64\x61\x74\x65","\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x43\x74\x72\x6C\x2E\x64\x65\x73\x74\x72\x6F\x79","\x73\x70\x79","\x2E\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x53\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x20\x41\x50\x49\x20\x52\x6F\x75\x74\x65\x72\x3A","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x74\x75\x72\x6E\x20\x61\x6E\x20\x65\x78\x70\x72\x65\x73\x73\x20\x72\x6F\x75\x74\x65\x72\x20\x69\x6E\x73\x74\x61\x6E\x63\x65","\x65\x71\x75\x61\x6C","\x74\x6F","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x69\x6E\x64\x65\x78","\x63\x61\x6C\x6C\x65\x64\x4F\x6E\x63\x65","\x62\x65\x65\x6E","\x68\x61\x76\x65","\x2F","\x77\x69\x74\x68\x41\x72\x67\x73","\x67\x65\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x50\x4F\x53\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x50\x55\x54\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x50\x41\x54\x43\x48\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x44\x45\x4C\x45\x54\x45\x20\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x66\x69\x65\x6C\x64\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x6F\x75\x74\x65\x20\x74\x6F\x20\x73\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65"];_0x9458[0];var proxyquire=require(_0x9458[2])[_0x9458[1]]();var sugarcrmFieldCtrlStub={index:_0x9458[3],show:_0x9458[4],create:_0x9458[5],update:_0x9458[6],destroy:_0x9458[7]};var routerStub={get:sinon[_0x9458[8]](),put:sinon[_0x9458[8]](),patch:sinon[_0x9458[8]](),post:sinon[_0x9458[8]](),delete:sinon[_0x9458[8]]()};var sugarcrmFieldIndex=proxyquire(_0x9458[9],{"\x65\x78\x70\x72\x65\x73\x73":{Router:function(){return routerStub}},"\x2E\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72":sugarcrmFieldCtrlStub});describe(_0x9458[10],function(){it(_0x9458[11],function(){expect(sugarcrmFieldIndex)[_0x9458[13]][_0x9458[12]](routerStub)});describe(_0x9458[14],function(){it(_0x9458[15],function(){expect(routerStub[_0x9458[21]][_0x9458[20]](_0x9458[19],_0x9458[3]))[_0x9458[13]][_0x9458[18]][_0x9458[17]][_0x9458[16]]})});describe(_0x9458[22],function(){it(_0x9458[23],function(){expect(routerStub[_0x9458[21]][_0x9458[20]](_0x9458[24],_0x9458[4]))[_0x9458[13]][_0x9458[18]][_0x9458[17]][_0x9458[16]]})});describe(_0x9458[25],function(){it(_0x9458[26],function(){expect(routerStub[_0x9458[27]][_0x9458[20]](_0x9458[19],_0x9458[5]))[_0x9458[13]][_0x9458[18]][_0x9458[17]][_0x9458[16]]})});describe(_0x9458[28],function(){it(_0x9458[29],function(){expect(routerStub[_0x9458[30]][_0x9458[20]](_0x9458[24],_0x9458[6]))[_0x9458[13]][_0x9458[18]][_0x9458[17]][_0x9458[16]]})});describe(_0x9458[31],function(){it(_0x9458[29],function(){expect(routerStub[_0x9458[32]][_0x9458[20]](_0x9458[24],_0x9458[6]))[_0x9458[13]][_0x9458[18]][_0x9458[17]][_0x9458[16]]})});describe(_0x9458[33],function(){it(_0x9458[34],function(){expect(routerStub[_0x9458[35]][_0x9458[20]](_0x9458[24],_0x9458[7]))[_0x9458[13]][_0x9458[18]][_0x9458[17]][_0x9458[16]]})});}); \ No newline at end of file diff --git a/server/api/sugarcrm_field/sugarcrm_field.controller.js b/server/api/sugarcrm_field/sugarcrm_field.controller.js index eb6fe3d..54de92d 100644 --- a/server/api/sugarcrm_field/sugarcrm_field.controller.js +++ b/server/api/sugarcrm_field/sugarcrm_field.controller.js @@ -1,104 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /api/sugarcrm/fields -> index - * POST /api/sugarcrm/fields -> create - * GET /api/sugarcrm/fields/:id -> show - * PUT /api/sugarcrm/fields/:id -> update - * DELETE /api/sugarcrm/fields/:id -> destroy - */ - -'use strict'; - - -var _ = require('lodash'); - -var SugarcrmField = require('../../models').SugarcrmField; - - -function handleError(res, statusCode) { - statusCode = statusCode || 500; - return function(err) { - res.status(statusCode).send(err); - }; -} - -function responseWithResult(res, statusCode) { - statusCode = statusCode || 200; - return function(entity) { - if (entity) { - res.status(statusCode).json(entity); - } - }; -} - -function handleEntityNotFound(res) { - return function(entity) { - if (!entity) { - res.status(404).end(); - return null; - } - return entity; - }; -} - -function saveUpdates(updates) { - return function(entity) { - return entity.updateAttributes(updates) - .then(function(updated) { - return updated; - }); - }; -} - -function removeEntity(res) { - return function(entity) { - if (entity) { - return entity.destroy() - .then(function() { - res.status(204).end(); - }); - } - }; -} - -// Gets a list of SugarcrmFields -exports.index = function(req, res) { - SugarcrmField.findAll() - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Gets a single SugarcrmField from the DB -exports.show = function(req, res) { - SugarcrmField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Creates a new SugarcrmField in the DB -exports.create = function(req, res) { - SugarcrmField.create(req.body) - .then(responseWithResult(res, 201)) - .catch(handleError(res)); -} - -// Updates an existing SugarcrmField in the DB -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - SugarcrmField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(saveUpdates(req.body)) - .then(responseWithResult(res)) - .catch(handleError(res)); -} - -// Deletes a SugarcrmField from the DB -exports.destroy = function(req, res) { - SugarcrmField.findById(req.params.id) - .then(handleEntityNotFound(res)) - .then(removeEntity(res)) - .catch(handleError(res)); -} +var _0x8bc3=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65"];_0x8bc3[0];var _=require(_0x8bc3[1]);var SugarcrmField=require(_0x8bc3[3])[_0x8bc3[2]];function handleError(_0x3b86x4,_0x3b86x5){_0x3b86x5=_0x3b86x5||500;return function(_0x3b86x6){_0x3b86x4[_0x8bc3[5]](_0x3b86x5)[_0x8bc3[4]](_0x3b86x6)};}function responseWithResult(_0x3b86x4,_0x3b86x5){_0x3b86x5=_0x3b86x5||200;return function(_0x3b86x8){if(_0x3b86x8){_0x3b86x4[_0x8bc3[5]](_0x3b86x5)[_0x8bc3[6]](_0x3b86x8)}};}function handleEntityNotFound(_0x3b86x4){return function(_0x3b86x8){if(!_0x3b86x8){_0x3b86x4[_0x8bc3[5]](404)[_0x8bc3[7]]();return null;};return _0x3b86x8;}}function saveUpdates(_0x3b86xb){return function(_0x3b86x8){return _0x3b86x8[_0x8bc3[9]](_0x3b86xb)[_0x8bc3[8]](function(_0x3b86xc){return _0x3b86xc})}}function removeEntity(_0x3b86x4){return function(_0x3b86x8){if(_0x3b86x8){return _0x3b86x8[_0x8bc3[10]]()[_0x8bc3[8]](function(){_0x3b86x4[_0x8bc3[5]](204)[_0x8bc3[7]]()})}}}exports[_0x8bc3[11]]=function(_0x3b86xe,_0x3b86x4){SugarcrmField[_0x8bc3[13]]()[_0x8bc3[8]](responseWithResult(_0x3b86x4))[_0x8bc3[12]](handleError(_0x3b86x4))};exports[_0x8bc3[14]]=function(_0x3b86xe,_0x3b86x4){SugarcrmField[_0x8bc3[17]](_0x3b86xe[_0x8bc3[16]][_0x8bc3[15]])[_0x8bc3[8]](handleEntityNotFound(_0x3b86x4))[_0x8bc3[8]](responseWithResult(_0x3b86x4))[_0x8bc3[12]](handleError(_0x3b86x4))};exports[_0x8bc3[18]]=function(_0x3b86xe,_0x3b86x4){SugarcrmField[_0x8bc3[18]](_0x3b86xe[_0x8bc3[19]])[_0x8bc3[8]](responseWithResult(_0x3b86x4,201))[_0x8bc3[12]](handleError(_0x3b86x4))};exports[_0x8bc3[20]]=function(_0x3b86xe,_0x3b86x4){if(_0x3b86xe[_0x8bc3[19]][_0x8bc3[15]]){delete _0x3b86xe[_0x8bc3[19]][_0x8bc3[15]]};SugarcrmField[_0x8bc3[17]](_0x3b86xe[_0x8bc3[16]][_0x8bc3[15]])[_0x8bc3[8]](handleEntityNotFound(_0x3b86x4))[_0x8bc3[8]](saveUpdates(_0x3b86xe[_0x8bc3[19]]))[_0x8bc3[8]](responseWithResult(_0x3b86x4))[_0x8bc3[12]](handleError(_0x3b86x4));};exports[_0x8bc3[10]]=function(_0x3b86xe,_0x3b86x4){SugarcrmField[_0x8bc3[17]](_0x3b86xe[_0x8bc3[16]][_0x8bc3[15]])[_0x8bc3[8]](handleEntityNotFound(_0x3b86x4))[_0x8bc3[8]](removeEntity(_0x3b86x4))[_0x8bc3[12]](handleError(_0x3b86x4))}; \ No newline at end of file diff --git a/server/api/sugarcrm_field/sugarcrm_field.socket.js b/server/api/sugarcrm_field/sugarcrm_field.socket.js index bcc89cc..763e1e1 100644 --- a/server/api/sugarcrm_field/sugarcrm_field.socket.js +++ b/server/api/sugarcrm_field/sugarcrm_field.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var SugarcrmField = require('../../models').SugarcrmField; - -exports.register = function(socket) { - SugarcrmField.afterCreate(function(doc) { - onSave(socket, doc); - }); - SugarcrmField.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -}; - -function onSave(socket, doc, cb) { - socket.emit('sugarcrm_field:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('sugarcrm_field:remove', doc); -} +var _0x224e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0x224e[0];var SugarcrmField=require(_0x224e[2])[_0x224e[1]];exports[_0x224e[3]]=function(_0x5f51x2){SugarcrmField[_0x224e[4]](function(_0x5f51x3){onSave(_0x5f51x2,_0x5f51x3)});SugarcrmField[_0x224e[5]](function(_0x5f51x3){onRemove(_0x5f51x2,_0x5f51x3)});};function onSave(_0x5f51x2,_0x5f51x3,_0x5f51x5){_0x5f51x2[_0x224e[7]](_0x224e[6],_0x5f51x3)}function onRemove(_0x5f51x2,_0x5f51x3,_0x5f51x5){_0x5f51x2[_0x224e[7]](_0x224e[8],_0x5f51x3)} \ No newline at end of file diff --git a/server/api/tag/index.js b/server/api/tag/index.js index 10661b9..b8e8ffc 100644 --- a/server/api/tag/index.js +++ b/server/api/tag/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./tag.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.tagValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x4a4c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x74\x61\x67\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x74\x61\x67\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x4a4c[0];var express=require(_0x4a4c[1]);var controller=require(_0x4a4c[2]);var auth=require(_0x4a4c[3]);var router=express.Router();router[_0x4a4c[7]](_0x4a4c[4],auth[_0x4a4c[5]](),controller[_0x4a4c[6]]);router[_0x4a4c[7]](_0x4a4c[8],auth[_0x4a4c[5]](),controller[_0x4a4c[9]]);router[_0x4a4c[11]](_0x4a4c[4],auth[_0x4a4c[5]](),controller[_0x4a4c[10]]);router[_0x4a4c[11]](_0x4a4c[12],auth[_0x4a4c[5]](),controller[_0x4a4c[13]]);router[_0x4a4c[15]](_0x4a4c[8],auth[_0x4a4c[5]](),controller[_0x4a4c[14]]);router[_0x4a4c[16]](_0x4a4c[8],auth[_0x4a4c[5]](),controller[_0x4a4c[14]]);router[_0x4a4c[18]](_0x4a4c[4],auth[_0x4a4c[5]](),controller[_0x4a4c[17]]);router[_0x4a4c[18]](_0x4a4c[8],auth[_0x4a4c[5]](),controller[_0x4a4c[19]]);module[_0x4a4c[20]]=router; \ No newline at end of file diff --git a/server/api/tag/tag.controller.js b/server/api/tag/tag.controller.js index d7ba837..0248b44 100644 --- a/server/api/tag/tag.controller.js +++ b/server/api/tag/tag.controller.js @@ -1,210 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Tag = require('../../models').Tag; -var util = require('util'); - -// Get list of tags -exports.index = function(req, res) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - console.log(query); - - Tag - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -exports.tagValidation = function(req, res) { - console.log(req.body); - Tag - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(tags) { - if (!tags) { - return res.sendStatus(404); - } - return res.send(tags); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single tag -exports.show = function(req, res) { - Tag - .findById(req.params.id) - .then(function(tag) { - if (!tag) { - return res.sendStatus(404); - } - return res.send(tag); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new tag in the DB. -exports.create = function(req, res) { - Tag - .create(req.body) - .then(function(tag) { - return res.status(201).send(tag); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing tag in the DB. -exports.update = function(req, res) { - Tag - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(tags) { - if (!tags) { - return res.sendStatus(404); - } - if (tags.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_TAG' - }) - } - if (req.body.id) { - delete req.body.id; - } - Tag - .find({ - where: { - id: req.params.id - } - }) - .then(function(tag) { - if (!tag) { - return res.sendStatus(404); - } - var updated = _.merge(tag, req.body); - updated.save() - .then(function() { - return res.status(200).send(tag); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a tag from the DB. -exports.destroy = function(req, res) { - Tag - .findById(req.params.id) - .then(function(tag) { - if (!tag) { - return res.sendStatus(404); - } - tag.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDestroy = function(req, res) { - Tag - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x54cf=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x54\x61\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x6C\x6F\x67","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x74\x61\x67\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x54\x41\x47","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x54cf[0];var _=require(_0x54cf[1]);var Tag=require(_0x54cf[3])[_0x54cf[2]];var util=require(_0x54cf[4]);exports[_0x54cf[5]]=function(_0xd450x4,_0xd450x5){var _0xd450x6=[_0x54cf[6],_0x54cf[7]];var _0xd450x7=_0xd450x4[_0x54cf[9]][_0x54cf[8]]?parseInt(_0xd450x4[_0x54cf[9]][_0x54cf[8]],10):100;var _0xd450x8=_0xd450x4[_0x54cf[9]][_0x54cf[10]]?parseInt(_0xd450x4[_0x54cf[9]][_0x54cf[10]],10):0;var _0xd450x9={where:{},limit:_0xd450x7,offset:_0xd450x8*_0xd450x7};_[_0x54cf[24]](_0xd450x4[_0x54cf[9]],function(_0xd450xa,_0xd450xb){switch(_0xd450xb){case _0x54cf[8]:;case _0x54cf[10]:break ;;case _0x54cf[13]:_0xd450x9[_0x54cf[11]]=util[_0x54cf[16]](_0x54cf[12],_0xd450x4[_0x54cf[9]][_0x54cf[13]],_0xd450x4[_0x54cf[9]][_0x54cf[14]]||_0x54cf[15])||null;break ;;case _0x54cf[14]:break ;;case _0x54cf[22]:_0xd450x9[_0x54cf[18]][_0x54cf[17]]=[];_0xd450x6[_0x54cf[21]](function(_0xd450xc){var _0xd450xd={};_0xd450xd[_0xd450xc]={$like:_0x54cf[19]+_0xd450xa+_0x54cf[19]};_0xd450x9[_0x54cf[18]][_0x54cf[17]][_0x54cf[20]](_0xd450xd);});break ;;default:_0xd450x9[_0x54cf[18]][_0xd450xb]={$like:{}};_0xd450x9[_0x54cf[18]][_0xd450xb][_0x54cf[23]]=_0x54cf[19]+_0xd450xa+_0x54cf[19];;}});console[_0x54cf[25]](_0xd450x9);Tag[_0x54cf[40]](_0xd450x9)[_0x54cf[39]](function(_0xd450xf){var _0xd450x10=Math[_0x54cf[31]](_0xd450xf[_0x54cf[30]]/_0xd450x7);var _0xd450x11=_0xd450x10>(_0xd450x9[_0x54cf[32]]+1)?util[_0x54cf[16]](_0x54cf[33],_0xd450x4[_0x54cf[34]],_0xd450x4[_0x54cf[36]][_0x54cf[35]],_0xd450x4[_0x54cf[37]],_0xd450x8+1):null;var _0xd450x12=_0xd450x8>0?util[_0x54cf[16]](_0x54cf[33],_0xd450x4[_0x54cf[34]],_0xd450x4[_0x54cf[36]][_0x54cf[35]],_0xd450x4[_0x54cf[37]],_0xd450x8-1):null;_0xd450x5[_0x54cf[28]](200)[_0x54cf[27]]({count:_0xd450xf[_0x54cf[30]],rows:_0xd450xf[_0x54cf[38]],next_page:_0xd450x11,previous_page:_0xd450x12,total_pages:_0xd450x10});})[_0x54cf[29]](function(_0xd450xe){_0xd450x5[_0x54cf[28]](500)[_0x54cf[27]]({error:_0x54cf[26]})});};exports[_0x54cf[41]]=function(_0xd450x4,_0xd450x5){console[_0x54cf[25]](_0xd450x4[_0x54cf[42]]);Tag[_0x54cf[44]]({where:{name:_0xd450x4[_0x54cf[42]][_0x54cf[6]]}})[_0x54cf[39]](function(_0xd450x13){if(!_0xd450x13){return _0xd450x5[_0x54cf[43]](404)};return _0xd450x5[_0x54cf[27]](_0xd450x13);})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)});};exports[_0x54cf[45]]=function(_0xd450x4,_0xd450x5){Tag[_0x54cf[48]](_0xd450x4[_0x54cf[47]][_0x54cf[46]])[_0x54cf[39]](function(_0xd450x14){if(!_0xd450x14){return _0xd450x5[_0x54cf[43]](404)};return _0xd450x5[_0x54cf[27]](_0xd450x14);})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)})};exports[_0x54cf[49]]=function(_0xd450x4,_0xd450x5){Tag[_0x54cf[49]](_0xd450x4[_0x54cf[42]])[_0x54cf[39]](function(_0xd450x14){return _0xd450x5[_0x54cf[28]](201)[_0x54cf[27]](_0xd450x14)})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)})};exports[_0x54cf[50]]=function(_0xd450x4,_0xd450x5){Tag[_0x54cf[44]]({where:{name:_0xd450x4[_0x54cf[42]][_0x54cf[6]],id:{$ne:_0xd450x4[_0x54cf[42]][_0x54cf[46]]}}})[_0x54cf[39]](function(_0xd450x13){if(!_0xd450x13){return _0xd450x5[_0x54cf[43]](404)};if(_0xd450x13[_0x54cf[51]]>0){return _0xd450x5[_0x54cf[28]](500)[_0x54cf[27]]({message:_0x54cf[52]})};if(_0xd450x4[_0x54cf[42]][_0x54cf[46]]){delete _0xd450x4[_0x54cf[42]][_0x54cf[46]]};Tag[_0x54cf[55]]({where:{id:_0xd450x4[_0x54cf[47]][_0x54cf[46]]}})[_0x54cf[39]](function(_0xd450x14){if(!_0xd450x14){return _0xd450x5[_0x54cf[43]](404)};var _0xd450x15=_[_0x54cf[53]](_0xd450x14,_0xd450x4[_0x54cf[42]]);_0xd450x15[_0x54cf[54]]()[_0x54cf[39]](function(){return _0xd450x5[_0x54cf[28]](200)[_0x54cf[27]](_0xd450x14)})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)});})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)});})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)})};exports[_0x54cf[56]]=function(_0xd450x4,_0xd450x5){Tag[_0x54cf[48]](_0xd450x4[_0x54cf[47]][_0x54cf[46]])[_0x54cf[39]](function(_0xd450x14){if(!_0xd450x14){return _0xd450x5[_0x54cf[43]](404)};_0xd450x14[_0x54cf[56]]()[_0x54cf[39]](function(){return _0xd450x5[_0x54cf[43]](204)})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)});})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)})};exports[_0x54cf[57]]=function(_0xd450x4,_0xd450x5){Tag[_0x54cf[56]]({where:{id:_0xd450x4[_0x54cf[9]][_0x54cf[46]]},individualHooks:true})[_0x54cf[39]](function(){return _0xd450x5[_0x54cf[43]](204)})[_0x54cf[29]](function(_0xd450xe){return handleError(_0xd450x5,_0xd450xe)})};function handleError(_0xd450x5,_0xd450xe){return _0xd450x5[_0x54cf[28]](500)[_0x54cf[27]](_0xd450xe)} \ No newline at end of file diff --git a/server/api/tag/tag.socket.js b/server/api/tag/tag.socket.js index 790b0a2..0d5ee51 100644 --- a/server/api/tag/tag.socket.js +++ b/server/api/tag/tag.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Tag = require('../../models').Tag; - -exports.register = function(socket) { - Tag.afterCreate(function(doc) { - onSave(socket, doc); - }); - Tag.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('tag:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('tag:remove', doc); -} +var _0xa43a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x54\x61\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x74\x61\x67\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x74\x61\x67\x3A\x72\x65\x6D\x6F\x76\x65"];_0xa43a[0];var Tag=require(_0xa43a[2])[_0xa43a[1]];exports[_0xa43a[3]]=function(_0x5d66x2){Tag[_0xa43a[4]](function(_0x5d66x3){onSave(_0x5d66x2,_0x5d66x3)});Tag[_0xa43a[5]](function(_0x5d66x3){onRemove(_0x5d66x2,_0x5d66x3)});};function onSave(_0x5d66x2,_0x5d66x3,_0x5d66x5){_0x5d66x2[_0xa43a[7]](_0xa43a[6],_0x5d66x3)}function onRemove(_0x5d66x2,_0x5d66x3,_0x5d66x5){_0x5d66x2[_0xa43a[7]](_0xa43a[8],_0x5d66x3)} \ No newline at end of file diff --git a/server/api/tag/tag.spec.js b/server/api/tag/tag.spec.js index 794a03a..d65af4d 100644 --- a/server/api/tag/tag.spec.js +++ b/server/api/tag/tag.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/tags', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/tags') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0xee82=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x74\x61\x67\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x74\x61\x67\x73","\x67\x65\x74"];_0xee82[0];var should=require(_0xee82[1]);var app=require(_0xee82[2]);var request=require(_0xee82[3]);describe(_0xee82[4],function(){it(_0xee82[5],function(_0x6ecbx4){request(app)[_0xee82[13]](_0xee82[12])[_0xee82[11]](200)[_0xee82[11]](_0xee82[10],/json/)[_0xee82[9]](function(_0x6ecbx5,_0x6ecbx6){if(_0x6ecbx5){return _0x6ecbx4(_0x6ecbx5)};_0x6ecbx6[_0xee82[8]][_0xee82[1]][_0xee82[7]][_0xee82[6]](Array);_0x6ecbx4();})})}); \ No newline at end of file diff --git a/server/api/team/index.js b/server/api/team/index.js index 1bb002a..d7b968c 100644 --- a/server/api/team/index.js +++ b/server/api/team/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./team.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/:id/agents', auth.isAuthenticated(), controller.addAgents); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.put('/:id/agents', auth.isAuthenticated(), controller.removeAgents); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x2340=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x74\x65\x61\x6D\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x3A\x69\x64\x2F\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x2340[0];var express=require(_0x2340[1]);var controller=require(_0x2340[2]);var auth=require(_0x2340[3]);var router=express.Router();router[_0x2340[7]](_0x2340[4],auth[_0x2340[5]](),controller[_0x2340[6]]);router[_0x2340[7]](_0x2340[8],auth[_0x2340[5]](),controller[_0x2340[9]]);router[_0x2340[11]](_0x2340[4],auth[_0x2340[5]](),controller[_0x2340[10]]);router[_0x2340[11]](_0x2340[12],auth[_0x2340[5]](),controller[_0x2340[13]]);router[_0x2340[15]](_0x2340[8],auth[_0x2340[5]](),controller[_0x2340[14]]);router[_0x2340[15]](_0x2340[12],auth[_0x2340[5]](),controller[_0x2340[16]]);router[_0x2340[17]](_0x2340[8],auth[_0x2340[5]](),controller[_0x2340[14]]);router[_0x2340[19]](_0x2340[4],auth[_0x2340[5]](),controller[_0x2340[18]]);router[_0x2340[19]](_0x2340[8],auth[_0x2340[5]](),controller[_0x2340[20]]);module[_0x2340[21]]=router; \ No newline at end of file diff --git a/server/api/team/team.controller.js b/server/api/team/team.controller.js index 7e39dde..51daa76 100644 --- a/server/api/team/team.controller.js +++ b/server/api/team/team.controller.js @@ -1,232 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var Team = require('../../models').Team; -var User = require('../../models').User; - -// Get list of teams -exports.index = function(req, res) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - include: [{ - all: true - }], - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Team - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single team -exports.show = function(req, res) { - Team - .find({ - where: { - id: req.params.id - }, - include: [User] - }) - .then(function(team) { - if (!team) { - return res.sendStatus(404); - } - return res.send(team); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new team in the DB. -exports.create = function(req, res) { - Team - .create(req.body) - .then(function(team) { - return res.status(201).send(team); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing team in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Team - .find({ - where: { - id: req.params.id - } - }) - .then(function(team) { - if (!team) { - return res.sendStatus(404); - } - var updated = _.merge(team, req.body); - updated.save() - .then(function() { - return res.status(200).send(team); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a team from the DB. -exports.destroy = function(req, res) { - Team - .find({ - where: { - id: req.params.id - } - }) - .then(function(team) { - if (!team) { - return res.sendStatus(404); - } - team.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function(req, res) { - Team - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing user_has_mail_queue in the DB. -exports.addAgents = function(req, res, next) { - Team - .findById(req.params.id) - .then(function(team) { - if (team) { - // QUEUE FOUND - // ADD AGENTS - team - .addUsers(req.body.agents) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return next(err); - }); - } else { - return next(new Error('no mail queue found')); - } - }) - .catch(function(err) { - return next(err); - }); -}; - -exports.removeAgents = function(req, res, next) { - Team - .findById(req.params.id) - .then(function(team) { - if (team) { - // QUEUE FOUND - // REMOVE AGENTS - team - .removeUsers(req.body.agents) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return next(err); - }); - } else { - return next(new Error('no mail queue found')); - } - }) - .catch(function(err) { - return next(err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xaf0e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x54\x65\x61\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x55\x73\x65\x72\x73","\x6E\x6F\x20\x6D\x61\x69\x6C\x20\x71\x75\x65\x75\x65\x20\x66\x6F\x75\x6E\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x55\x73\x65\x72\x73"];_0xaf0e[0];var _=require(_0xaf0e[1]);var util=require(_0xaf0e[2]);var Team=require(_0xaf0e[4])[_0xaf0e[3]];var User=require(_0xaf0e[4])[_0xaf0e[5]];exports[_0xaf0e[6]]=function(_0x2826x5,_0x2826x6){var _0x2826x7=[_0xaf0e[7],_0xaf0e[8]];var _0x2826x8=_0x2826x5[_0xaf0e[10]][_0xaf0e[9]]?parseInt(_0x2826x5[_0xaf0e[10]][_0xaf0e[9]],10):100;var _0x2826x9=_0x2826x5[_0xaf0e[10]][_0xaf0e[11]]?parseInt(_0x2826x5[_0xaf0e[10]][_0xaf0e[11]],10):0;var _0x2826xa={where:{},include:[{all:true}],limit:_0x2826x8,offset:_0x2826x9*_0x2826x8};_[_0xaf0e[25]](_0x2826x5[_0xaf0e[10]],function(_0x2826xb,_0x2826xc){switch(_0x2826xc){case _0xaf0e[9]:;case _0xaf0e[11]:break ;;case _0xaf0e[14]:_0x2826xa[_0xaf0e[12]]=util[_0xaf0e[17]](_0xaf0e[13],_0x2826x5[_0xaf0e[10]][_0xaf0e[14]],_0x2826x5[_0xaf0e[10]][_0xaf0e[15]]||_0xaf0e[16])||null;break ;;case _0xaf0e[15]:break ;;case _0xaf0e[23]:_0x2826xa[_0xaf0e[19]][_0xaf0e[18]]=[];_0x2826x7[_0xaf0e[22]](function(_0x2826xd){var _0x2826xe={};_0x2826xe[_0x2826xd]={$like:_0xaf0e[20]+_0x2826xb+_0xaf0e[20]};_0x2826xa[_0xaf0e[19]][_0xaf0e[18]][_0xaf0e[21]](_0x2826xe);});break ;;default:_0x2826xa[_0xaf0e[19]][_0x2826xc]={$like:{}};_0x2826xa[_0xaf0e[19]][_0x2826xc][_0xaf0e[24]]=_0xaf0e[20]+_0x2826xb+_0xaf0e[20];;}});Team[_0xaf0e[40]](_0x2826xa)[_0xaf0e[39]](function(_0x2826x10){var _0x2826x11=Math[_0xaf0e[31]](_0x2826x10[_0xaf0e[30]]/_0x2826x8);var _0x2826x12=_0x2826x11>(_0x2826xa[_0xaf0e[32]]+1)?util[_0xaf0e[17]](_0xaf0e[33],_0x2826x5[_0xaf0e[34]],_0x2826x5[_0xaf0e[36]][_0xaf0e[35]],_0x2826x5[_0xaf0e[37]],_0x2826x9+1):null;var _0x2826x13=_0x2826x9>0?util[_0xaf0e[17]](_0xaf0e[33],_0x2826x5[_0xaf0e[34]],_0x2826x5[_0xaf0e[36]][_0xaf0e[35]],_0x2826x5[_0xaf0e[37]],_0x2826x9-1):null;_0x2826x6[_0xaf0e[28]](200)[_0xaf0e[27]]({count:_0x2826x10[_0xaf0e[30]],rows:_0x2826x10[_0xaf0e[38]],next_page:_0x2826x12,previous_page:_0x2826x13,total_pages:_0x2826x11});})[_0xaf0e[29]](function(_0x2826xf){_0x2826x6[_0xaf0e[28]](500)[_0xaf0e[27]]({error:_0xaf0e[26]})});};exports[_0xaf0e[41]]=function(_0x2826x5,_0x2826x6){Team[_0xaf0e[45]]({where:{id:_0x2826x5[_0xaf0e[44]][_0xaf0e[43]]},include:[User]})[_0xaf0e[39]](function(_0x2826x14){if(!_0x2826x14){return _0x2826x6[_0xaf0e[42]](404)};return _0x2826x6[_0xaf0e[27]](_0x2826x14);})[_0xaf0e[29]](function(_0x2826xf){return handleError(_0x2826x6,_0x2826xf)})};exports[_0xaf0e[46]]=function(_0x2826x5,_0x2826x6){Team[_0xaf0e[46]](_0x2826x5[_0xaf0e[47]])[_0xaf0e[39]](function(_0x2826x14){return _0x2826x6[_0xaf0e[28]](201)[_0xaf0e[27]](_0x2826x14)})[_0xaf0e[29]](function(_0x2826xf){return handleError(_0x2826x6,_0x2826xf)})};exports[_0xaf0e[48]]=function(_0x2826x5,_0x2826x6){if(_0x2826x5[_0xaf0e[47]][_0xaf0e[43]]){delete _0x2826x5[_0xaf0e[47]][_0xaf0e[43]]};Team[_0xaf0e[45]]({where:{id:_0x2826x5[_0xaf0e[44]][_0xaf0e[43]]}})[_0xaf0e[39]](function(_0x2826x14){if(!_0x2826x14){return _0x2826x6[_0xaf0e[42]](404)};var _0x2826x15=_[_0xaf0e[49]](_0x2826x14,_0x2826x5[_0xaf0e[47]]);_0x2826x15[_0xaf0e[50]]()[_0xaf0e[39]](function(){return _0x2826x6[_0xaf0e[28]](200)[_0xaf0e[27]](_0x2826x14)})[_0xaf0e[29]](function(_0x2826xf){return handleError(_0x2826x6,_0x2826xf)});})[_0xaf0e[29]](function(_0x2826xf){return handleError(_0x2826x6,_0x2826xf)});};exports[_0xaf0e[51]]=function(_0x2826x5,_0x2826x6){Team[_0xaf0e[45]]({where:{id:_0x2826x5[_0xaf0e[44]][_0xaf0e[43]]}})[_0xaf0e[39]](function(_0x2826x14){if(!_0x2826x14){return _0x2826x6[_0xaf0e[42]](404)};_0x2826x14[_0xaf0e[51]]()[_0xaf0e[39]](function(){return _0x2826x6[_0xaf0e[42]](204)})[_0xaf0e[29]](function(_0x2826xf){return handleError(_0x2826x6,_0x2826xf)});})[_0xaf0e[29]](function(_0x2826xf){return handleError(_0x2826x6,_0x2826xf)})};exports[_0xaf0e[52]]=function(_0x2826x5,_0x2826x6){Team[_0xaf0e[51]]({where:{id:_0x2826x5[_0xaf0e[10]][_0xaf0e[43]]},individualHooks:true})[_0xaf0e[39]](function(){return _0x2826x6[_0xaf0e[42]](204)})[_0xaf0e[29]](function(_0x2826xf){return handleError(_0x2826x6,_0x2826xf)})};exports[_0xaf0e[53]]=function(_0x2826x5,_0x2826x6,_0x2826x16){Team[_0xaf0e[57]](_0x2826x5[_0xaf0e[44]][_0xaf0e[43]])[_0xaf0e[39]](function(_0x2826x14){if(_0x2826x14){_0x2826x14[_0xaf0e[55]](_0x2826x5[_0xaf0e[47]][_0xaf0e[54]])[_0xaf0e[39]](function(){return _0x2826x6[_0xaf0e[42]](200)})[_0xaf0e[29]](function(_0x2826xf){return _0x2826x16(_0x2826xf)})}else {return _0x2826x16( new Error(_0xaf0e[56]))}})[_0xaf0e[29]](function(_0x2826xf){return _0x2826x16(_0x2826xf)})};exports[_0xaf0e[58]]=function(_0x2826x5,_0x2826x6,_0x2826x16){Team[_0xaf0e[57]](_0x2826x5[_0xaf0e[44]][_0xaf0e[43]])[_0xaf0e[39]](function(_0x2826x14){if(_0x2826x14){_0x2826x14[_0xaf0e[59]](_0x2826x5[_0xaf0e[47]][_0xaf0e[54]])[_0xaf0e[39]](function(){return _0x2826x6[_0xaf0e[42]](200)})[_0xaf0e[29]](function(_0x2826xf){return _0x2826x16(_0x2826xf)})}else {return _0x2826x16( new Error(_0xaf0e[56]))}})[_0xaf0e[29]](function(_0x2826xf){return _0x2826x16(_0x2826xf)})};function handleError(_0x2826x6,_0x2826xf){return _0x2826x6[_0xaf0e[28]](500)[_0xaf0e[27]](_0x2826xf)} \ No newline at end of file diff --git a/server/api/team/team.socket.js b/server/api/team/team.socket.js index 3f89dc2..3f66f00 100644 --- a/server/api/team/team.socket.js +++ b/server/api/team/team.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var team = require('../../models').Team; - -exports.register = function(socket) { - team.afterCreate(function(doc) { - onSave(socket, doc); - }); - team.afterUpdate(function(doc) { - onSave(socket, doc); - }); - team.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('team:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('team:remove', doc); -} +var _0x7893=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x54\x65\x61\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x74\x65\x61\x6D\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x74\x65\x61\x6D\x3A\x72\x65\x6D\x6F\x76\x65"];_0x7893[0];var team=require(_0x7893[2])[_0x7893[1]];exports[_0x7893[3]]=function(_0x1aa5x2){team[_0x7893[4]](function(_0x1aa5x3){onSave(_0x1aa5x2,_0x1aa5x3)});team[_0x7893[5]](function(_0x1aa5x3){onSave(_0x1aa5x2,_0x1aa5x3)});team[_0x7893[6]](function(_0x1aa5x3){onRemove(_0x1aa5x2,_0x1aa5x3)});};function onSave(_0x1aa5x2,_0x1aa5x3,_0x1aa5x5){_0x1aa5x2[_0x7893[8]](_0x7893[7],_0x1aa5x3)}function onRemove(_0x1aa5x2,_0x1aa5x3,_0x1aa5x5){_0x1aa5x2[_0x7893[8]](_0x7893[9],_0x1aa5x3)} \ No newline at end of file diff --git a/server/api/team/team.spec.js b/server/api/team/team.spec.js index b76928a..816b6c7 100644 --- a/server/api/team/team.spec.js +++ b/server/api/team/team.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/teams', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/teams') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x13e9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x74\x65\x61\x6D\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x74\x65\x61\x6D\x73","\x67\x65\x74"];_0x13e9[0];var should=require(_0x13e9[1]);var app=require(_0x13e9[2]);var request=require(_0x13e9[3]);describe(_0x13e9[4],function(){it(_0x13e9[5],function(_0xaea2x4){request(app)[_0x13e9[13]](_0x13e9[12])[_0x13e9[11]](200)[_0x13e9[11]](_0x13e9[10],/json/)[_0x13e9[9]](function(_0xaea2x5,_0xaea2x6){if(_0xaea2x5){return _0xaea2x4(_0xaea2x5)};_0xaea2x6[_0x13e9[8]][_0x13e9[1]][_0x13e9[7]][_0x13e9[6]](Array);_0xaea2x4();})})}); \ No newline at end of file diff --git a/server/api/thing/index.js b/server/api/thing/index.js index 845c9f0..f55aaa2 100644 --- a/server/api/thing/index.js +++ b/server/api/thing/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./thing.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xaa80=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x74\x68\x69\x6E\x67\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xaa80[0];var express=require(_0xaa80[1]);var controller=require(_0xaa80[2]);var router=express.Router();router[_0xaa80[5]](_0xaa80[3],controller[_0xaa80[4]]);router[_0xaa80[5]](_0xaa80[6],controller[_0xaa80[7]]);router[_0xaa80[9]](_0xaa80[3],controller[_0xaa80[8]]);router[_0xaa80[11]](_0xaa80[6],controller[_0xaa80[10]]);router[_0xaa80[12]](_0xaa80[6],controller[_0xaa80[10]]);router[_0xaa80[14]](_0xaa80[6],controller[_0xaa80[13]]);module[_0xaa80[15]]=router; \ No newline at end of file diff --git a/server/api/thing/thing.controller.js b/server/api/thing/thing.controller.js index 7d4d710..a00d1cb 100644 --- a/server/api/thing/thing.controller.js +++ b/server/api/thing/thing.controller.js @@ -1,98 +1 @@ -/** - * Using Rails-like standard naming convention for endpoints. - * GET /things -> index - * POST /things -> create - * GET /things/:id -> show - * PUT /things/:id -> update - * DELETE /things/:id -> destroy - */ - -'use strict'; - -var _ = require('lodash'); -var Thing = require('../../models').Thing; - -// Get list of things -exports.index = function(req, res, next) { - Thing - .findAll() - .then(function(things) { - return res.status(200).send(things); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Get a single thing -exports.show = function(req, res, next) { - Thing - .findById(req.params.id) - .then(function(thing) { - if (!thing) { - return res.sendStatus(404); - } - return res.send(thing); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Creates a new thing in the DB. -exports.create = function(req, res, next) { - Thing - .create(req.body) - .then(function(thing) { - return res.status(201).send(thing); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Updates an existing thing in the DB. -exports.update = function(req, res, next) { - if (req.body.id) { - delete req.body.id; - } - Thing - .findById(req.params.id) - .then(function(thing) { - if (!thing) { - return res.sendStatus(404); - } - var updated = _.merge(thing, req.body); - updated.save() - .then(function() { - return res.status(200).send(thing); - }) - .catch(function(err) { - return next(err); - }); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Deletes a thing from the DB. -exports.destroy = function(req, res, next) { - Thing - .findById(req.params.id) - .then(function(thing) { - if (!thing) { - return res.sendStatus(404); - } - thing.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return next(err); - }); - }) - .catch(function(err) { - return next(err); - }); -}; +var _0x343c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x54\x68\x69\x6E\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x343c[0];var _=require(_0x343c[1]);var Thing=require(_0x343c[3])[_0x343c[2]];exports[_0x343c[4]]=function(_0x434ax3,_0x434ax4,_0x434ax5){Thing[_0x343c[9]]()[_0x343c[8]](function(_0x434ax7){return _0x434ax4[_0x343c[7]](200)[_0x343c[6]](_0x434ax7)})[_0x343c[5]](function(_0x434ax6){return _0x434ax5(_0x434ax6)})};exports[_0x343c[10]]=function(_0x434ax3,_0x434ax4,_0x434ax5){Thing[_0x343c[14]](_0x434ax3[_0x343c[13]][_0x343c[12]])[_0x343c[8]](function(_0x434ax8){if(!_0x434ax8){return _0x434ax4[_0x343c[11]](404)};return _0x434ax4[_0x343c[6]](_0x434ax8);})[_0x343c[5]](function(_0x434ax6){return _0x434ax5(_0x434ax6)})};exports[_0x343c[15]]=function(_0x434ax3,_0x434ax4,_0x434ax5){Thing[_0x343c[15]](_0x434ax3[_0x343c[16]])[_0x343c[8]](function(_0x434ax8){return _0x434ax4[_0x343c[7]](201)[_0x343c[6]](_0x434ax8)})[_0x343c[5]](function(_0x434ax6){return _0x434ax5(_0x434ax6)})};exports[_0x343c[17]]=function(_0x434ax3,_0x434ax4,_0x434ax5){if(_0x434ax3[_0x343c[16]][_0x343c[12]]){delete _0x434ax3[_0x343c[16]][_0x343c[12]]};Thing[_0x343c[14]](_0x434ax3[_0x343c[13]][_0x343c[12]])[_0x343c[8]](function(_0x434ax8){if(!_0x434ax8){return _0x434ax4[_0x343c[11]](404)};var _0x434ax9=_[_0x343c[18]](_0x434ax8,_0x434ax3[_0x343c[16]]);_0x434ax9[_0x343c[19]]()[_0x343c[8]](function(){return _0x434ax4[_0x343c[7]](200)[_0x343c[6]](_0x434ax8)})[_0x343c[5]](function(_0x434ax6){return _0x434ax5(_0x434ax6)});})[_0x343c[5]](function(_0x434ax6){return _0x434ax5(_0x434ax6)});};exports[_0x343c[20]]=function(_0x434ax3,_0x434ax4,_0x434ax5){Thing[_0x343c[14]](_0x434ax3[_0x343c[13]][_0x343c[12]])[_0x343c[8]](function(_0x434ax8){if(!_0x434ax8){return _0x434ax4[_0x343c[11]](404)};_0x434ax8[_0x343c[20]]()[_0x343c[8]](function(){return _0x434ax4[_0x343c[11]](204)})[_0x343c[5]](function(_0x434ax6){return _0x434ax5(_0x434ax6)});})[_0x343c[5]](function(_0x434ax6){return _0x434ax5(_0x434ax6)})}; \ No newline at end of file diff --git a/server/api/thing/thing.socket.js b/server/api/thing/thing.socket.js index 55b9c5a..64fb289 100644 --- a/server/api/thing/thing.socket.js +++ b/server/api/thing/thing.socket.js @@ -1,27 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -//var thing = require('./thing.model'); -var thing = require('../../models').Thing; - -exports.register = function (socket) { - - thing.afterCreate(function (doc) { - onSave(socket, doc); - }); - - thing.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('thing:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('thing:remove', doc); -} +var _0xf61b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x54\x68\x69\x6E\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x74\x68\x69\x6E\x67\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x74\x68\x69\x6E\x67\x3A\x72\x65\x6D\x6F\x76\x65"];_0xf61b[0];var thing=require(_0xf61b[2])[_0xf61b[1]];exports[_0xf61b[3]]=function(_0xff11x2){thing[_0xf61b[4]](function(_0xff11x3){onSave(_0xff11x2,_0xff11x3)});thing[_0xf61b[5]](function(_0xff11x3){onRemove(_0xff11x2,_0xff11x3)});};function onSave(_0xff11x2,_0xff11x3,_0xff11x5){_0xff11x2[_0xf61b[7]](_0xf61b[6],_0xff11x3)}function onRemove(_0xff11x2,_0xff11x3,_0xff11x5){_0xff11x2[_0xf61b[7]](_0xf61b[8],_0xff11x3)} \ No newline at end of file diff --git a/server/api/thing/thing.spec.js b/server/api/thing/thing.spec.js index 17c8c6c..c9a6a6d 100644 --- a/server/api/thing/thing.spec.js +++ b/server/api/thing/thing.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/things', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/things') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x9bdf=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x74\x68\x69\x6E\x67\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x74\x68\x69\x6E\x67\x73","\x67\x65\x74"];_0x9bdf[0];var should=require(_0x9bdf[1]);var app=require(_0x9bdf[2]);var request=require(_0x9bdf[3]);describe(_0x9bdf[4],function(){it(_0x9bdf[5],function(_0xb095x4){request(app)[_0x9bdf[13]](_0x9bdf[12])[_0x9bdf[11]](200)[_0x9bdf[11]](_0x9bdf[10],/json/)[_0x9bdf[9]](function(_0xb095x5,_0xb095x6){if(_0xb095x5){return _0xb095x4(_0xb095x5)};_0xb095x6[_0x9bdf[8]][_0x9bdf[1]][_0x9bdf[7]][_0x9bdf[6]](Array);_0xb095x4();})})}); \ No newline at end of file diff --git a/server/api/trigger/index.js b/server/api/trigger/index.js index e2c0971..9f86ea0 100644 --- a/server/api/trigger/index.js +++ b/server/api/trigger/index.js @@ -1,17 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./trigger.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); - -module.exports = router; +var _0xeab1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x74\x72\x69\x67\x67\x65\x72\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0xeab1[0];var express=require(_0xeab1[1]);var controller=require(_0xeab1[2]);var auth=require(_0xeab1[3]);var router=express.Router();router[_0xeab1[7]](_0xeab1[4],auth[_0xeab1[5]](),controller[_0xeab1[6]]);router[_0xeab1[7]](_0xeab1[8],auth[_0xeab1[5]](),controller[_0xeab1[9]]);router[_0xeab1[11]](_0xeab1[4],auth[_0xeab1[5]](),controller[_0xeab1[10]]);router[_0xeab1[13]](_0xeab1[8],auth[_0xeab1[5]](),controller[_0xeab1[12]]);router[_0xeab1[14]](_0xeab1[8],auth[_0xeab1[5]](),controller[_0xeab1[12]]);router[_0xeab1[16]](_0xeab1[8],auth[_0xeab1[5]](),controller[_0xeab1[15]]);router[_0xeab1[16]](_0xeab1[4],auth[_0xeab1[5]](),controller[_0xeab1[17]]);module[_0xeab1[18]]=router; \ No newline at end of file diff --git a/server/api/trigger/trigger.controller.js b/server/api/trigger/trigger.controller.js index 87dccb3..f1c89e5 100644 --- a/server/api/trigger/trigger.controller.js +++ b/server/api/trigger/trigger.controller.js @@ -1,168 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var Trigger = require('../../models').Trigger; - -// Get list of agents -exports.index = function(req, res, next) { - - var attributes = ['fullname', 'name', 'email']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Trigger - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single Trigger -exports.show = function(req, res) { - Trigger - .findById(req.params.id) - .then(function(Trigger) { - if (!Trigger) { - return res.sendStatus(404); - } - return res.send(Trigger); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new Trigger in the DB. -exports.create = function(req, res) { - Trigger - .create(req.body) - .then(function() { - return res.sendStatus(201); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing Trigger in the DB. -exports.update = function(req, res, next) { - if (req.body.id) { - delete req.body.id; - } - Trigger - .findById(req.params.id) - .then(function(Trigger) { - if (!Trigger) { - return res.sendStatus(404); - } - var updated = _.merge(Trigger, req.body); - updated - .save() - .then(function() { - return res.status(200).send(Trigger); - }) - .catch(function(err) { - // return handleError(res, err); - return next(err); - - }); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Deletes a Trigger from the DB. -exports.destroy = function(req, res) { - Trigger - .findById(req.params.id) - .then(function(Trigger) { - if (!Trigger) { - return res.sendStatus(404); - } - Trigger.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDestroy = function(req, res) { - Trigger - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x1935=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x54\x72\x69\x67\x67\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x1935[0];var _=require(_0x1935[1]);var util=require(_0x1935[2]);var Trigger=require(_0x1935[4])[_0x1935[3]];exports[_0x1935[5]]=function(_0xc394x4,_0xc394x5,_0xc394x6){var _0xc394x7=[_0x1935[6],_0x1935[7],_0x1935[8]];var _0xc394x8=_0xc394x4[_0x1935[10]][_0x1935[9]]?parseInt(_0xc394x4[_0x1935[10]][_0x1935[9]],10):100;var _0xc394x9=_0xc394x4[_0x1935[10]][_0x1935[11]]?parseInt(_0xc394x4[_0x1935[10]][_0x1935[11]],10):0;var _0xc394xa={where:{},limit:_0xc394x8,offset:_0xc394x9*_0xc394x8};_[_0x1935[25]](_0xc394x4[_0x1935[10]],function(_0xc394xb,_0xc394xc){switch(_0xc394xc){case _0x1935[9]:;case _0x1935[11]:break ;;case _0x1935[14]:_0xc394xa[_0x1935[12]]=util[_0x1935[17]](_0x1935[13],_0xc394x4[_0x1935[10]][_0x1935[14]],_0xc394x4[_0x1935[10]][_0x1935[15]]||_0x1935[16])||null;break ;;case _0x1935[15]:break ;;case _0x1935[23]:_0xc394xa[_0x1935[19]][_0x1935[18]]=[];_0xc394x7[_0x1935[22]](function(_0xc394xd){var _0xc394xe={};_0xc394xe[_0xc394xd]={$like:_0x1935[20]+_0xc394xb+_0x1935[20]};_0xc394xa[_0x1935[19]][_0x1935[18]][_0x1935[21]](_0xc394xe);});break ;;default:_0xc394xa[_0x1935[19]][_0xc394xc]={$like:{}};_0xc394xa[_0x1935[19]][_0xc394xc][_0x1935[24]]=_0x1935[20]+_0xc394xb+_0x1935[20];;}});Trigger[_0x1935[40]](_0xc394xa)[_0x1935[39]](function(_0xc394x10){var _0xc394x11=Math[_0x1935[31]](_0xc394x10[_0x1935[30]]/_0xc394x8);var _0xc394x12=_0xc394x11>(_0xc394xa[_0x1935[32]]+1)?util[_0x1935[17]](_0x1935[33],_0xc394x4[_0x1935[34]],_0xc394x4[_0x1935[36]][_0x1935[35]],_0xc394x4[_0x1935[37]],_0xc394x9+1):null;var _0xc394x13=_0xc394x9>0?util[_0x1935[17]](_0x1935[33],_0xc394x4[_0x1935[34]],_0xc394x4[_0x1935[36]][_0x1935[35]],_0xc394x4[_0x1935[37]],_0xc394x9-1):null;_0xc394x5[_0x1935[28]](200)[_0x1935[27]]({count:_0xc394x10[_0x1935[30]],rows:_0xc394x10[_0x1935[38]],next_page:_0xc394x12,previous_page:_0xc394x13,total_pages:_0xc394x11});})[_0x1935[29]](function(_0xc394xf){_0xc394x5[_0x1935[28]](500)[_0x1935[27]]({error:_0x1935[26]})});};exports[_0x1935[41]]=function(_0xc394x4,_0xc394x5){Trigger[_0x1935[45]](_0xc394x4[_0x1935[44]][_0x1935[43]])[_0x1935[39]](function(Trigger){if(!Trigger){return _0xc394x5[_0x1935[42]](404)};return _0xc394x5[_0x1935[27]](Trigger);})[_0x1935[29]](function(_0xc394xf){return handleError(_0xc394x5,_0xc394xf)})};exports[_0x1935[46]]=function(_0xc394x4,_0xc394x5){Trigger[_0x1935[46]](_0xc394x4[_0x1935[47]])[_0x1935[39]](function(){return _0xc394x5[_0x1935[42]](201)})[_0x1935[29]](function(_0xc394xf){return handleError(_0xc394x5,_0xc394xf)})};exports[_0x1935[48]]=function(_0xc394x4,_0xc394x5,_0xc394x6){if(_0xc394x4[_0x1935[47]][_0x1935[43]]){delete _0xc394x4[_0x1935[47]][_0x1935[43]]};Trigger[_0x1935[45]](_0xc394x4[_0x1935[44]][_0x1935[43]])[_0x1935[39]](function(Trigger){if(!Trigger){return _0xc394x5[_0x1935[42]](404)};var _0xc394x14=_[_0x1935[49]](Trigger,_0xc394x4[_0x1935[47]]);_0xc394x14[_0x1935[50]]()[_0x1935[39]](function(){return _0xc394x5[_0x1935[28]](200)[_0x1935[27]](Trigger)})[_0x1935[29]](function(_0xc394xf){return _0xc394x6(_0xc394xf)});})[_0x1935[29]](function(_0xc394xf){return _0xc394x6(_0xc394xf)});};exports[_0x1935[51]]=function(_0xc394x4,_0xc394x5){Trigger[_0x1935[45]](_0xc394x4[_0x1935[44]][_0x1935[43]])[_0x1935[39]](function(Trigger){if(!Trigger){return _0xc394x5[_0x1935[42]](404)};Trigger[_0x1935[51]]()[_0x1935[39]](function(){return _0xc394x5[_0x1935[42]](204)})[_0x1935[29]](function(_0xc394xf){return handleError(_0xc394x5,_0xc394xf)});})[_0x1935[29]](function(_0xc394xf){return handleError(_0xc394x5,_0xc394xf)})};exports[_0x1935[52]]=function(_0xc394x4,_0xc394x5){Trigger[_0x1935[51]]({where:{id:_0xc394x4[_0x1935[10]][_0x1935[43]]},individualHooks:true})[_0x1935[39]](function(){return _0xc394x5[_0x1935[42]](204)})[_0x1935[29]](function(_0xc394xf){return handleError(_0xc394x5,_0xc394xf)})};function handleError(_0xc394x5,_0xc394xf){return _0xc394x5[_0x1935[28]](500)[_0x1935[27]](_0xc394xf)} \ No newline at end of file diff --git a/server/api/trigger/trigger.socket.js b/server/api/trigger/trigger.socket.js index 7fe5fa2..89134b0 100644 --- a/server/api/trigger/trigger.socket.js +++ b/server/api/trigger/trigger.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Trigger = require('../../models').Trigger; - -exports.register = function(socket) { - Trigger.afterCreate(function(doc) { - onSave(socket, doc); - }); - Trigger.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('trigger:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('trigger:remove', doc); -} +var _0xfc57=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x54\x72\x69\x67\x67\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x74\x72\x69\x67\x67\x65\x72\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x74\x72\x69\x67\x67\x65\x72\x3A\x72\x65\x6D\x6F\x76\x65"];_0xfc57[0];var Trigger=require(_0xfc57[2])[_0xfc57[1]];exports[_0xfc57[3]]=function(_0x93adx2){Trigger[_0xfc57[4]](function(_0x93adx3){onSave(_0x93adx2,_0x93adx3)});Trigger[_0xfc57[5]](function(_0x93adx3){onRemove(_0x93adx2,_0x93adx3)});};function onSave(_0x93adx2,_0x93adx3,_0x93adx5){_0x93adx2[_0xfc57[7]](_0xfc57[6],_0x93adx3)}function onRemove(_0x93adx2,_0x93adx3,_0x93adx5){_0x93adx2[_0xfc57[7]](_0xfc57[8],_0x93adx3)} \ No newline at end of file diff --git a/server/api/trigger/trigger.spec.js b/server/api/trigger/trigger.spec.js index c88586d..addb881 100644 --- a/server/api/trigger/trigger.spec.js +++ b/server/api/trigger/trigger.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/triggers', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/triggers') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0xbb06=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x74\x72\x69\x67\x67\x65\x72\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x74\x72\x69\x67\x67\x65\x72\x73","\x67\x65\x74"];_0xbb06[0];var should=require(_0xbb06[1]);var app=require(_0xbb06[2]);var request=require(_0xbb06[3]);describe(_0xbb06[4],function(){it(_0xbb06[5],function(_0x64dbx4){request(app)[_0xbb06[13]](_0xbb06[12])[_0xbb06[11]](200)[_0xbb06[11]](_0xbb06[10],/json/)[_0xbb06[9]](function(_0x64dbx5,_0x64dbx6){if(_0x64dbx5){return _0x64dbx4(_0x64dbx5)};_0x64dbx6[_0xbb06[8]][_0xbb06[1]][_0xbb06[7]][_0xbb06[6]](Array);_0x64dbx4();})})}); \ No newline at end of file diff --git a/server/api/trunk/index.js b/server/api/trunk/index.js index ea72fdd..4ae6e85 100644 --- a/server/api/trunk/index.js +++ b/server/api/trunk/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./trunk.controller'); -var config = require('../../config/environment'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.trunkValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x2f5b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x74\x72\x75\x6E\x6B\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x74\x72\x75\x6E\x6B\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x2f5b[0];var express=require(_0x2f5b[1]);var controller=require(_0x2f5b[2]);var config=require(_0x2f5b[3]);var auth=require(_0x2f5b[4]);var router=express.Router();router[_0x2f5b[8]](_0x2f5b[5],auth[_0x2f5b[6]](),controller[_0x2f5b[7]]);router[_0x2f5b[8]](_0x2f5b[9],auth[_0x2f5b[6]](),controller[_0x2f5b[10]]);router[_0x2f5b[12]](_0x2f5b[5],auth[_0x2f5b[6]](),controller[_0x2f5b[11]]);router[_0x2f5b[12]](_0x2f5b[13],auth[_0x2f5b[6]](),controller[_0x2f5b[14]]);router[_0x2f5b[16]](_0x2f5b[9],auth[_0x2f5b[6]](),controller[_0x2f5b[15]]);router[_0x2f5b[18]](_0x2f5b[5],auth[_0x2f5b[6]](),controller[_0x2f5b[17]]);router[_0x2f5b[18]](_0x2f5b[9],auth[_0x2f5b[6]](),controller[_0x2f5b[19]]);module[_0x2f5b[20]]=router; \ No newline at end of file diff --git a/server/api/trunk/trunk.ami.js b/server/api/trunk/trunk.ami.js index 32b4a66..a64df42 100644 --- a/server/api/trunk/trunk.ami.js +++ b/server/api/trunk/trunk.ami.js @@ -1,90 +1 @@ -'use strict'; - -var fs = require('fs'); -var util = require('util'); -var path = require('path'); -var config = require('../../config/environment'); -var Trunk = require('../../models').Trunk; -var VoiceExtension = require('../../models').VoiceExtension; -var _ = require('lodash'); - -exports.register = function(ami) { - Trunk.afterCreate(function(doc) { - console.log('create trunk hook'); - trunksRewrite(doc, ami, false); - }) - Trunk.afterUpdate(function(doc) { - console.log('update trunk hook'); - trunksRewrite(doc, ami, false); - }) - Trunk.afterDelete(function(doc) { - console.log('delete trunk hook'); - trunksRewrite(doc, ami, true); - }) -} - -function trunksRewrite(doc, ami, deleteTrunk) { - var trunksFile = ''; - if (!deleteTrunk) { - var newTrunk = _.clone(doc.dataValues); - delete newTrunk.id; - delete newTrunk.createdAt; - delete newTrunk.updatedAt; - trunksFile += util.format('[%s]\n', newTrunk.name); - if (newTrunk.otherFields) { - trunksFile += util.format('%s\n', newTrunk.otherFields); - delete newTrunk.otherFields; - } - for (var key in newTrunk) { - if (newTrunk[key]) { - trunksFile += util.format('%s=%s\n', key, newTrunk[key]); - } - } - } - Trunk - .findAll({ - where: { - id: { - $ne: doc.id - } - } - }) - .then(function(trunks) { - var oldTrunks = _.pluck(trunks, 'dataValues'); - oldTrunks.forEach(function(element) { - delete element.id; - delete element.createdAt; - delete element.updatedAt; - trunksFile += util.format('[%s]\n', element.name); - if (element.otherFields) { - trunksFile += util.format('%s\n', element.otherFields); - delete element.otherFields; - } - for (var key in element) { - if (element[key]) { - trunksFile += util.format('%s=%s\n', key, element[key]); - } - } - }); - fs.writeFile(path.join(config.root, 'server/files/asterisk/sip_xcally_trunks.conf'), trunksFile, { - flags: 'w', - mode: parseInt('0777', 8) - }, function(err) { - if (err) throw err; - console.log("Trunks file saved!"); - ami.action({ - Action: 'Reload', - Module: 'chan_sip' - }, function(err, res) { - if (err) { - console.error(err); - } else { - console.log(res); - } - }); - }); - }) - .catch(function(err) { - console.log(err); - }); -} +var _0x3186=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x66\x73","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x54\x72\x75\x6E\x6B","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x6C\x6F\x64\x61\x73\x68","\x72\x65\x67\x69\x73\x74\x65\x72","\x63\x72\x65\x61\x74\x65\x20\x74\x72\x75\x6E\x6B\x20\x68\x6F\x6F\x6B","\x6C\x6F\x67","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65\x20\x74\x72\x75\x6E\x6B\x20\x68\x6F\x6F\x6B","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x64\x65\x6C\x65\x74\x65\x20\x74\x72\x75\x6E\x6B\x20\x68\x6F\x6F\x6B","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x63\x6C\x6F\x6E\x65","\x69\x64","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x75\x70\x64\x61\x74\x65\x64\x41\x74","\x5B\x25\x73\x5D\x0A","\x6E\x61\x6D\x65","\x66\x6F\x72\x6D\x61\x74","\x6F\x74\x68\x65\x72\x46\x69\x65\x6C\x64\x73","\x25\x73\x0A","\x25\x73\x3D\x25\x73\x0A","\x63\x61\x74\x63\x68","\x70\x6C\x75\x63\x6B","\x66\x6F\x72\x45\x61\x63\x68","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x61\x73\x74\x65\x72\x69\x73\x6B\x2F\x73\x69\x70\x5F\x78\x63\x61\x6C\x6C\x79\x5F\x74\x72\x75\x6E\x6B\x73\x2E\x63\x6F\x6E\x66","\x6A\x6F\x69\x6E","\x77","\x30\x37\x37\x37","\x54\x72\x75\x6E\x6B\x73\x20\x66\x69\x6C\x65\x20\x73\x61\x76\x65\x64\x21","\x52\x65\x6C\x6F\x61\x64","\x63\x68\x61\x6E\x5F\x73\x69\x70","\x65\x72\x72\x6F\x72","\x61\x63\x74\x69\x6F\x6E","\x77\x72\x69\x74\x65\x46\x69\x6C\x65","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C"];_0x3186[0];var fs=require(_0x3186[1]);var util=require(_0x3186[2]);var path=require(_0x3186[3]);var config=require(_0x3186[4]);var Trunk=require(_0x3186[6])[_0x3186[5]];var VoiceExtension=require(_0x3186[6])[_0x3186[7]];var _=require(_0x3186[8]);exports[_0x3186[9]]=function(_0x2b98x8){Trunk[_0x3186[12]](function(_0x2b98x9){console[_0x3186[11]](_0x3186[10]);trunksRewrite(_0x2b98x9,_0x2b98x8,false);});Trunk[_0x3186[14]](function(_0x2b98x9){console[_0x3186[11]](_0x3186[13]);trunksRewrite(_0x2b98x9,_0x2b98x8,false);});Trunk[_0x3186[16]](function(_0x2b98x9){console[_0x3186[11]](_0x3186[15]);trunksRewrite(_0x2b98x9,_0x2b98x8,true);});};function trunksRewrite(_0x2b98x9,_0x2b98x8,_0x2b98xb){var _0x2b98xc=_0x3186[17];if(!_0x2b98xb){var _0x2b98xd=_[_0x3186[19]](_0x2b98x9[_0x3186[18]]);delete _0x2b98xd[_0x3186[20]];delete _0x2b98xd[_0x3186[21]];delete _0x2b98xd[_0x3186[22]];_0x2b98xc+=util[_0x3186[25]](_0x3186[23],_0x2b98xd[_0x3186[24]]);if(_0x2b98xd[_0x3186[26]]){_0x2b98xc+=util[_0x3186[25]](_0x3186[27],_0x2b98xd[_0x3186[26]]);delete _0x2b98xd[_0x3186[26]];};for(var _0x2b98xe in _0x2b98xd){if(_0x2b98xd[_0x2b98xe]){_0x2b98xc+=util[_0x3186[25]](_0x3186[28],_0x2b98xe,_0x2b98xd[_0x2b98xe])}};};Trunk[_0x3186[44]]({where:{id:{$ne:_0x2b98x9[_0x3186[20]]}}})[_0x3186[43]](function(_0x2b98x10){var _0x2b98x11=_[_0x3186[30]](_0x2b98x10,_0x3186[18]);_0x2b98x11[_0x3186[31]](function(_0x2b98x12){delete _0x2b98x12[_0x3186[20]];delete _0x2b98x12[_0x3186[21]];delete _0x2b98x12[_0x3186[22]];_0x2b98xc+=util[_0x3186[25]](_0x3186[23],_0x2b98x12[_0x3186[24]]);if(_0x2b98x12[_0x3186[26]]){_0x2b98xc+=util[_0x3186[25]](_0x3186[27],_0x2b98x12[_0x3186[26]]);delete _0x2b98x12[_0x3186[26]];};for(var _0x2b98xe in _0x2b98x12){if(_0x2b98x12[_0x2b98xe]){_0x2b98xc+=util[_0x3186[25]](_0x3186[28],_0x2b98xe,_0x2b98x12[_0x2b98xe])}};});fs[_0x3186[42]](path[_0x3186[34]](config[_0x3186[32]],_0x3186[33]),_0x2b98xc,{flags:_0x3186[35],mode:parseInt(_0x3186[36],8)},function(_0x2b98xf){if(_0x2b98xf){throw _0x2b98xf};console[_0x3186[11]](_0x3186[37]);_0x2b98x8[_0x3186[41]]({Action:_0x3186[38],Module:_0x3186[39]},function(_0x2b98xf,_0x2b98x13){if(_0x2b98xf){console[_0x3186[40]](_0x2b98xf)}else {console[_0x3186[11]](_0x2b98x13)}});});})[_0x3186[29]](function(_0x2b98xf){console[_0x3186[11]](_0x2b98xf)});} \ No newline at end of file diff --git a/server/api/trunk/trunk.controller.js b/server/api/trunk/trunk.controller.js index 2ccdd9a..a5835a7 100644 --- a/server/api/trunk/trunk.controller.js +++ b/server/api/trunk/trunk.controller.js @@ -1,298 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Trunk = require('../../models').Trunk; -var VoiceExtension = require('../../models').VoiceExtension; -var sequelize = require('../../models').sequelize; -var util = require('util'); - -// Get list of trunks -exports.index = function(req, res, next) { - - var attributes = ['name', 'host', 'context', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - case 'role': - query.where.role = { - $or: value.split(/[\s,]+/) - }; - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Trunk - .findAndCountAll(query) - .then(function(result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; -// Get a single trunk -exports.show = function(req, res) { - Trunk - .findById(req.params.id) - .then(function(trunk) { - if (!trunk) { - return res.sendStatus(404); - } - return res.send(trunk); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Validate the existence of a trunk -exports.trunkValidation = function(req, res) { - console.log(req.body); - Trunk - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(trunks) { - if (!trunks) { - return res.sendStatus(404); - } - return res.send(trunks); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new trunk in the DB. -exports.create = function(req, res) { - Trunk - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(existingTrunks) { - console.log(existingTrunks); - console.log('Finding app row.....'); - if (!existingTrunks) { - return res.sendStatus(404); - } - if (existingTrunks.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_TRUNK' - }); - } - Trunk - .create(req.body) - .then(function(trunk) { - return res.status(201).send(trunk); - }) - .catch(function(err) { - console.log('trunks create', err); - return handleError(res, err); - }); - }) - .catch(function(err) { - console.log('trunks findall', err); - return handleError(res, err); - }); -}; - -// Updates an existing trunk in the DB. -exports.update = function(req, res, next) { - Trunk - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(existingTrunks) { - console.log(existingTrunks); - console.log('Finding app row.....'); - if (!existingTrunks) { - return res.sendStatus(404); - } - if (existingTrunks.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_TRUNK' - }); - } - if (req.body.id) { - delete req.body.id; - } - Trunk - .findById(req.params.id) - .then(function(trunk) { - if (!trunk) { - return res.sendStatus(404); - } - var updated = _.merge(trunk, req.body); - return sequelize.transaction(function(t) { - return updated.save({ - transaction: t - }) - .then(function(trunk) { - return VoiceExtension - .update({ - trunk: trunk.name, - cutdigits: sequelize.literal('cutdigits') - }, { - where: { - TrunkId: trunk.id - } - }, { - transaction: t - }) - .then(function() { - return res.status(200).send(trunk); - }) - }) - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return next(err); - }); - }) - .catch(function(err) { - return next(err); - }); -}; - -// Deletes a trunk from the DB. -exports.destroy = function(req, res) { - Trunk - .findById(req.params.id) - .then(function(trunk) { - if (!trunk) { - return res.sendStatus(404); - } - trunk.getVoiceExtensions({ - where: { - isApp: true - } - }) - .then(function(outbound_dials) { - console.log(outbound_dials.length); - if (outbound_dials.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_TRUNK_OUTBOUND_ASSOCIATED' - }); - } - trunk.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes multiple trunk from the DB. -exports.bulkDestroy = function(req, res) { - var associatedTrunks = false; - Trunk - .findAll({ - where: { - id: req.query.id - }, - include: [{ - all: true - }] - }) - .then(function(trunks) { - if (!trunks) { - return res.sendStatus(404); - } - trunks.forEach(function(element) { - if (element.VoiceExtensions.length > 0) { - associatedTrunks = true; - } - }); - if (associatedTrunks) { - return res.status(500).send({ - message: 'MESSAGE_TRUNK_OUTBOUND_ASSOCIATED' - }); - } - Trunk - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xd398=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x54\x72\x75\x6E\x6B","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x68\x6F\x73\x74","\x63\x6F\x6E\x74\x65\x78\x74","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x72\x6F\x6C\x65","\x73\x70\x6C\x69\x74","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x74\x72\x75\x6E\x6B\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x74\x72\x75\x6E\x6B\x73\x20\x66\x69\x6E\x64\x61\x6C\x6C","\x46\x69\x6E\x64\x69\x6E\x67\x20\x61\x70\x70\x20\x72\x6F\x77\x2E\x2E\x2E\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x54\x52\x55\x4E\x4B","\x74\x72\x75\x6E\x6B\x73\x20\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x63\x75\x74\x64\x69\x67\x69\x74\x73","\x6C\x69\x74\x65\x72\x61\x6C","\x73\x61\x76\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x64\x65\x73\x74\x72\x6F\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x54\x52\x55\x4E\x4B\x5F\x4F\x55\x54\x42\x4F\x55\x4E\x44\x5F\x41\x53\x53\x4F\x43\x49\x41\x54\x45\x44","\x67\x65\x74\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73"];_0xd398[0];var _=require(_0xd398[1]);var Trunk=require(_0xd398[3])[_0xd398[2]];var VoiceExtension=require(_0xd398[3])[_0xd398[4]];var sequelize=require(_0xd398[3])[_0xd398[5]];var util=require(_0xd398[6]);exports[_0xd398[7]]=function(_0xd436x6,_0xd436x7,_0xd436x8){var _0xd436x9=[_0xd398[8],_0xd398[9],_0xd398[10],_0xd398[11]];var _0xd436xa=_0xd436x6[_0xd398[13]][_0xd398[12]]?parseInt(_0xd436x6[_0xd398[13]][_0xd398[12]],10):100;var _0xd436xb=_0xd436x6[_0xd398[13]][_0xd398[14]]?parseInt(_0xd436x6[_0xd398[13]][_0xd398[14]],10):0;var _0xd436xc={where:{},limit:_0xd436xa,offset:_0xd436xb*_0xd436xa};_[_0xd398[30]](_0xd436x6[_0xd398[13]],function(_0xd436xd,_0xd436xe){switch(_0xd436xe){case _0xd398[12]:;case _0xd398[14]:break ;;case _0xd398[17]:_0xd436xc[_0xd398[15]]=util[_0xd398[20]](_0xd398[16],_0xd436x6[_0xd398[13]][_0xd398[17]],_0xd436x6[_0xd398[13]][_0xd398[18]]||_0xd398[19])||null;break ;;case _0xd398[18]:break ;;case _0xd398[26]:_0xd436xc[_0xd398[22]][_0xd398[21]]=[];_0xd436x9[_0xd398[25]](function(_0xd436xf){var _0xd436x10={};_0xd436x10[_0xd436xf]={$like:_0xd398[23]+_0xd436xd+_0xd398[23]};_0xd436xc[_0xd398[22]][_0xd398[21]][_0xd398[24]](_0xd436x10);});break ;;case _0xd398[27]:_0xd436xc[_0xd398[22]][_0xd398[27]]={$or:_0xd436xd[_0xd398[28]](/[\s,]+/)};break ;;default:_0xd436xc[_0xd398[22]][_0xd436xe]={$like:{}};_0xd436xc[_0xd398[22]][_0xd436xe][_0xd398[29]]=_0xd398[23]+_0xd436xd+_0xd398[23];;}});Trunk[_0xd398[44]](_0xd436xc)[_0xd398[43]](function(_0xd436x12){var _0xd436x13=Math[_0xd398[36]](_0xd436x12[_0xd398[35]]/_0xd436xa);var _0xd436x14=_0xd436x13>(_0xd436xc[_0xd398[37]]+1)?util[_0xd398[20]](_0xd398[38],_0xd436x6[_0xd398[39]],_0xd436x6[_0xd398[40]][_0xd398[9]],_0xd436x6[_0xd398[41]],_0xd436xb+1):null;var _0xd436x15=_0xd436xb>0?util[_0xd398[20]](_0xd398[38],_0xd436x6[_0xd398[39]],_0xd436x6[_0xd398[40]][_0xd398[9]],_0xd436x6[_0xd398[41]],_0xd436xb-1):null;_0xd436x7[_0xd398[33]](200)[_0xd398[32]]({count:_0xd436x12[_0xd398[35]],rows:_0xd436x12[_0xd398[42]],next_page:_0xd436x14,previous_page:_0xd436x15,total_pages:_0xd436x13});})[_0xd398[34]](function(_0xd436x11){_0xd436x7[_0xd398[33]](500)[_0xd398[32]]({error:_0xd398[31]})});};exports[_0xd398[45]]=function(_0xd436x6,_0xd436x7){Trunk[_0xd398[49]](_0xd436x6[_0xd398[48]][_0xd398[47]])[_0xd398[43]](function(_0xd436x16){if(!_0xd436x16){return _0xd436x7[_0xd398[46]](404)};return _0xd436x7[_0xd398[32]](_0xd436x16);})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)})};exports[_0xd398[50]]=function(_0xd436x6,_0xd436x7){console[_0xd398[52]](_0xd436x6[_0xd398[51]]);Trunk[_0xd398[53]]({where:{name:_0xd436x6[_0xd398[51]][_0xd398[8]]}})[_0xd398[43]](function(_0xd436x17){if(!_0xd436x17){return _0xd436x7[_0xd398[46]](404)};return _0xd436x7[_0xd398[32]](_0xd436x17);})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)});};exports[_0xd398[54]]=function(_0xd436x6,_0xd436x7){Trunk[_0xd398[53]]({where:{name:_0xd436x6[_0xd398[51]][_0xd398[8]]}})[_0xd398[43]](function(_0xd436x18){console[_0xd398[52]](_0xd436x18);console[_0xd398[52]](_0xd398[56]);if(!_0xd436x18){return _0xd436x7[_0xd398[46]](404)};if(_0xd436x18[_0xd398[57]]>0){return _0xd436x7[_0xd398[33]](500)[_0xd398[32]]({message:_0xd398[58]})};Trunk[_0xd398[54]](_0xd436x6[_0xd398[51]])[_0xd398[43]](function(_0xd436x16){return _0xd436x7[_0xd398[33]](201)[_0xd398[32]](_0xd436x16)})[_0xd398[34]](function(_0xd436x11){console[_0xd398[52]](_0xd398[59],_0xd436x11);return handleError(_0xd436x7,_0xd436x11);});})[_0xd398[34]](function(_0xd436x11){console[_0xd398[52]](_0xd398[55],_0xd436x11);return handleError(_0xd436x7,_0xd436x11);})};exports[_0xd398[60]]=function(_0xd436x6,_0xd436x7,_0xd436x8){Trunk[_0xd398[53]]({where:{name:_0xd436x6[_0xd398[51]][_0xd398[8]],id:{$ne:_0xd436x6[_0xd398[51]][_0xd398[47]]}}})[_0xd398[43]](function(_0xd436x18){console[_0xd398[52]](_0xd436x18);console[_0xd398[52]](_0xd398[56]);if(!_0xd436x18){return _0xd436x7[_0xd398[46]](404)};if(_0xd436x18[_0xd398[57]]>0){return _0xd436x7[_0xd398[33]](500)[_0xd398[32]]({message:_0xd398[58]})};if(_0xd436x6[_0xd398[51]][_0xd398[47]]){delete _0xd436x6[_0xd398[51]][_0xd398[47]]};Trunk[_0xd398[49]](_0xd436x6[_0xd398[48]][_0xd398[47]])[_0xd398[43]](function(_0xd436x16){if(!_0xd436x16){return _0xd436x7[_0xd398[46]](404)};var _0xd436x19=_[_0xd398[61]](_0xd436x16,_0xd436x6[_0xd398[51]]);return sequelize[_0xd398[65]](function(_0xd436x1a){return _0xd436x19[_0xd398[64]]({transaction:_0xd436x1a})[_0xd398[43]](function(_0xd436x16){return VoiceExtension[_0xd398[60]]({trunk:_0xd436x16[_0xd398[8]],cutdigits:sequelize[_0xd398[63]](_0xd398[62])},{where:{TrunkId:_0xd436x16[_0xd398[47]]}},{transaction:_0xd436x1a})[_0xd398[43]](function(){return _0xd436x7[_0xd398[33]](200)[_0xd398[32]](_0xd436x16)})})})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)});})[_0xd398[34]](function(_0xd436x11){return _0xd436x8(_0xd436x11)});})[_0xd398[34]](function(_0xd436x11){return _0xd436x8(_0xd436x11)})};exports[_0xd398[66]]=function(_0xd436x6,_0xd436x7){Trunk[_0xd398[49]](_0xd436x6[_0xd398[48]][_0xd398[47]])[_0xd398[43]](function(_0xd436x16){if(!_0xd436x16){return _0xd436x7[_0xd398[46]](404)};_0xd436x16[_0xd398[68]]({where:{isApp:true}})[_0xd398[43]](function(_0xd436x1b){console[_0xd398[52]](_0xd436x1b[_0xd398[57]]);if(_0xd436x1b[_0xd398[57]]>0){return _0xd436x7[_0xd398[33]](500)[_0xd398[32]]({message:_0xd398[67]})};_0xd436x16[_0xd398[66]]()[_0xd398[43]](function(){return _0xd436x7[_0xd398[46]](204)})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)});})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)});})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)})};exports[_0xd398[69]]=function(_0xd436x6,_0xd436x7){var _0xd436x1c=false;Trunk[_0xd398[53]]({where:{id:_0xd436x6[_0xd398[13]][_0xd398[47]]},include:[{all:true}]})[_0xd398[43]](function(_0xd436x17){if(!_0xd436x17){return _0xd436x7[_0xd398[46]](404)};_0xd436x17[_0xd398[25]](function(_0xd436x1d){if(_0xd436x1d[_0xd398[70]][_0xd398[57]]>0){_0xd436x1c=true}});if(_0xd436x1c){return _0xd436x7[_0xd398[33]](500)[_0xd398[32]]({message:_0xd398[67]})};Trunk[_0xd398[66]]({where:{id:_0xd436x6[_0xd398[13]][_0xd398[47]]},individualHooks:true})[_0xd398[43]](function(){return _0xd436x7[_0xd398[46]](204)})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)});})[_0xd398[34]](function(_0xd436x11){return handleError(_0xd436x7,_0xd436x11)});};function handleError(_0xd436x7,_0xd436x11){return _0xd436x7[_0xd398[33]](500)[_0xd398[32]](_0xd436x11)} \ No newline at end of file diff --git a/server/api/trunk/trunk.socket.js b/server/api/trunk/trunk.socket.js index d4f7e36..608bf0f 100644 --- a/server/api/trunk/trunk.socket.js +++ b/server/api/trunk/trunk.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Trunk = require('../../models').User; - -exports.register = function(socket) { - Trunk.afterCreate(function(doc) { - onSave(socket, doc); - }); - Trunk.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('trunk:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('trunk:remove', doc); -} +var _0x15fa=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x74\x72\x75\x6E\x6B\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x74\x72\x75\x6E\x6B\x3A\x72\x65\x6D\x6F\x76\x65"];_0x15fa[0];var Trunk=require(_0x15fa[2])[_0x15fa[1]];exports[_0x15fa[3]]=function(_0xdd78x2){Trunk[_0x15fa[4]](function(_0xdd78x3){onSave(_0xdd78x2,_0xdd78x3)});Trunk[_0x15fa[5]](function(_0xdd78x3){onRemove(_0xdd78x2,_0xdd78x3)});};function onSave(_0xdd78x2,_0xdd78x3,_0xdd78x5){_0xdd78x2[_0x15fa[7]](_0x15fa[6],_0xdd78x3)}function onRemove(_0xdd78x2,_0xdd78x3,_0xdd78x5){_0xdd78x2[_0x15fa[7]](_0x15fa[8],_0xdd78x3)} \ No newline at end of file diff --git a/server/api/trunk/trunk.spec.js b/server/api/trunk/trunk.spec.js index 48ad76c..89570d6 100644 --- a/server/api/trunk/trunk.spec.js +++ b/server/api/trunk/trunk.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/trunks', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/trunks') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x7ad8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x74\x72\x75\x6E\x6B\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x74\x72\x75\x6E\x6B\x73","\x67\x65\x74"];_0x7ad8[0];var should=require(_0x7ad8[1]);var app=require(_0x7ad8[2]);var request=require(_0x7ad8[3]);describe(_0x7ad8[4],function(){it(_0x7ad8[5],function(_0xef5dx4){request(app)[_0x7ad8[13]](_0x7ad8[12])[_0x7ad8[11]](200)[_0x7ad8[11]](_0x7ad8[10],/json/)[_0x7ad8[9]](function(_0xef5dx5,_0xef5dx6){if(_0xef5dx5){return _0xef5dx4(_0xef5dx5)};_0xef5dx6[_0x7ad8[8]][_0x7ad8[1]][_0x7ad8[7]][_0x7ad8[6]](Array);_0xef5dx4();})})}); \ No newline at end of file diff --git a/server/api/update/index.js b/server/api/update/index.js index d57b32c..80a4216 100644 --- a/server/api/update/index.js +++ b/server/api/update/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./update.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), auth.hasRole('admin'), controller.index); -router.get('/pull', auth.isAuthenticated(), auth.hasRole('admin'), controller.pull); -// router.get('/checkout/:hash', controller.checkout); -// router.get('/:id', controller.show); -// router.post('/', controller.create); -// router.put('/:id', controller.update); -// router.patch('/:id', controller.update); -// router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x486a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x70\x64\x61\x74\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x61\x64\x6D\x69\x6E","\x68\x61\x73\x52\x6F\x6C\x65","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x70\x75\x6C\x6C","\x70\x75\x6C\x6C","\x65\x78\x70\x6F\x72\x74\x73"];_0x486a[0];var express=require(_0x486a[1]);var controller=require(_0x486a[2]);var auth=require(_0x486a[3]);var router=express.Router();router[_0x486a[9]](_0x486a[4],auth[_0x486a[5]](),auth[_0x486a[7]](_0x486a[6]),controller[_0x486a[8]]);router[_0x486a[9]](_0x486a[10],auth[_0x486a[5]](),auth[_0x486a[7]](_0x486a[6]),controller[_0x486a[11]]);module[_0x486a[12]]=router; \ No newline at end of file diff --git a/server/api/update/update.controller.js b/server/api/update/update.controller.js index 6637294..4fc9449 100644 --- a/server/api/update/update.controller.js +++ b/server/api/update/update.controller.js @@ -1,127 +1 @@ -'use strict'; - -var _ = require('lodash'); -var path = require("path"); -var config = require('../../config/environment'); - -var Git = require('simple-git')(path.join(config.root)); - -var Update = require('../../models').Update; - -// Get list of updates -exports.index = function(req, res) { - Git - .log(function(err, logs) { - if (err) { - return handleError(res, err); - } - - var versions = []; - logs.all.forEach(function(log) { - log.version = log.message.split('|')[1] || 'unknown'; - log.message = log.message.split('|')[0]; - versions.push(log); - }); - //logs.all = _.take(logs.all, 10); - console.log("Latest available tag: %s", logs.latest); - return res.status(200).send(versions); - }); -}; - -// Get a single update -exports.show = function(req, res) { - -}; - -// Get a single update -exports.pull = function(req, res) { - Git - .pull(function(err, update) { - if (err) { - return handleError(res, err); - } - return res.status(201).send(update); - }); -}; - -// Get a single update -exports.checkout = function(req, res) { - console.log('req.params.hash', req.params.hash); - Git - .checkout(req.params.hash, function(err, update) { - if (err) { - return handleError(res, err); - } - return res.status(201).send(update); - }); -}; - -// Creates a new update in the DB. -exports.create = function(req, res) { - Update - .create(req.body) - .then(function(update) { - return res.status(201).send(update); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing update in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Update - .find({ - where: { - id: req.params.id - } - }) - .then(function(update) { - if (!update) { - return res.sendStatus(404); - } - var updated = _.merge(update, req.body); - updated.save() - .then(function() { - return res.status(200).send(update); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a update from the DB. -exports.destroy = function(req, res) { - Update - .find({ - where: { - id: req.params.id - } - }) - .then(function(update) { - if (!update) { - return res.sendStatus(404); - } - update.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xd1d5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x72\x6F\x6F\x74","\x6A\x6F\x69\x6E","\x73\x69\x6D\x70\x6C\x65\x2D\x67\x69\x74","\x55\x70\x64\x61\x74\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x76\x65\x72\x73\x69\x6F\x6E","\x7C","\x73\x70\x6C\x69\x74","\x6D\x65\x73\x73\x61\x67\x65","\x75\x6E\x6B\x6E\x6F\x77\x6E","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x61\x6C\x6C","\x4C\x61\x74\x65\x73\x74\x20\x61\x76\x61\x69\x6C\x61\x62\x6C\x65\x20\x74\x61\x67\x3A\x20\x25\x73","\x6C\x61\x74\x65\x73\x74","\x6C\x6F\x67","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x73\x68\x6F\x77","\x70\x75\x6C\x6C","\x63\x68\x65\x63\x6B\x6F\x75\x74","\x72\x65\x71\x2E\x70\x61\x72\x61\x6D\x73\x2E\x68\x61\x73\x68","\x68\x61\x73\x68","\x70\x61\x72\x61\x6D\x73","\x63\x72\x65\x61\x74\x65","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x69\x64","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0xd1d5[0];var _=require(_0xd1d5[1]);var path=require(_0xd1d5[2]);var config=require(_0xd1d5[3]);var Git=require(_0xd1d5[6])(path[_0xd1d5[5]](config[_0xd1d5[4]]));var Update=require(_0xd1d5[8])[_0xd1d5[7]];exports[_0xd1d5[9]]=function(_0x1335x6,_0x1335x7){Git[_0xd1d5[20]](function(_0x1335x8,_0x1335x9){if(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)};var _0x1335xa=[];_0x1335x9[_0xd1d5[17]][_0xd1d5[16]](function(_0x1335xb){_0x1335xb[_0xd1d5[10]]=_0x1335xb[_0xd1d5[13]][_0xd1d5[12]](_0xd1d5[11])[1]||_0xd1d5[14];_0x1335xb[_0xd1d5[13]]=_0x1335xb[_0xd1d5[13]][_0xd1d5[12]](_0xd1d5[11])[0];_0x1335xa[_0xd1d5[15]](_0x1335xb);});console[_0xd1d5[20]](_0xd1d5[18],_0x1335x9[_0xd1d5[19]]);return _0x1335x7[_0xd1d5[22]](200)[_0xd1d5[21]](_0x1335xa);})};exports[_0xd1d5[23]]=function(_0x1335x6,_0x1335x7){};exports[_0xd1d5[24]]=function(_0x1335x6,_0x1335x7){Git[_0xd1d5[24]](function(_0x1335x8,_0x1335xc){if(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)};return _0x1335x7[_0xd1d5[22]](201)[_0xd1d5[21]](_0x1335xc);})};exports[_0xd1d5[25]]=function(_0x1335x6,_0x1335x7){console[_0xd1d5[20]](_0xd1d5[26],_0x1335x6[_0xd1d5[28]][_0xd1d5[27]]);Git[_0xd1d5[25]](_0x1335x6[_0xd1d5[28]][_0xd1d5[27]],function(_0x1335x8,_0x1335xc){if(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)};return _0x1335x7[_0xd1d5[22]](201)[_0xd1d5[21]](_0x1335xc);});};exports[_0xd1d5[29]]=function(_0x1335x6,_0x1335x7){Update[_0xd1d5[29]](_0x1335x6[_0xd1d5[32]])[_0xd1d5[31]](function(_0x1335xc){return _0x1335x7[_0xd1d5[22]](201)[_0xd1d5[21]](_0x1335xc)})[_0xd1d5[30]](function(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)})};exports[_0xd1d5[33]]=function(_0x1335x6,_0x1335x7){if(_0x1335x6[_0xd1d5[32]][_0xd1d5[34]]){delete _0x1335x6[_0xd1d5[32]][_0xd1d5[34]]};Update[_0xd1d5[38]]({where:{id:_0x1335x6[_0xd1d5[28]][_0xd1d5[34]]}})[_0xd1d5[31]](function(_0x1335xc){if(!_0x1335xc){return _0x1335x7[_0xd1d5[35]](404)};var _0x1335xd=_[_0xd1d5[36]](_0x1335xc,_0x1335x6[_0xd1d5[32]]);_0x1335xd[_0xd1d5[37]]()[_0xd1d5[31]](function(){return _0x1335x7[_0xd1d5[22]](200)[_0xd1d5[21]](_0x1335xc)})[_0xd1d5[30]](function(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)});})[_0xd1d5[30]](function(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)});};exports[_0xd1d5[39]]=function(_0x1335x6,_0x1335x7){Update[_0xd1d5[38]]({where:{id:_0x1335x6[_0xd1d5[28]][_0xd1d5[34]]}})[_0xd1d5[31]](function(_0x1335xc){if(!_0x1335xc){return _0x1335x7[_0xd1d5[35]](404)};_0x1335xc[_0xd1d5[39]]()[_0xd1d5[31]](function(){return _0x1335x7[_0xd1d5[35]](204)})[_0xd1d5[30]](function(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)});})[_0xd1d5[30]](function(_0x1335x8){return handleError(_0x1335x7,_0x1335x8)})};function handleError(_0x1335x7,_0x1335x8){return _0x1335x7[_0xd1d5[22]](500)[_0xd1d5[21]](_0x1335x8)} \ No newline at end of file diff --git a/server/api/update/update.js b/server/api/update/update.js index 6333030..b9cca71 100644 --- a/server/api/update/update.js +++ b/server/api/update/update.js @@ -1,11 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Update = sequelize.define('Update', { - name: DataTypes.STRING, - description: DataTypes.STRING - }); - - return Update; -}; +var _0x97f1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x55\x70\x64\x61\x74\x65","\x53\x54\x52\x49\x4E\x47","\x64\x65\x66\x69\x6E\x65"];_0x97f1[0];module[_0x97f1[1]]=function(_0xf2b5x1,_0xf2b5x2){var _0xf2b5x3=_0xf2b5x1[_0x97f1[4]](_0x97f1[2],{name:_0xf2b5x2[_0x97f1[3]],description:_0xf2b5x2[_0x97f1[3]]});return _0xf2b5x3;}; \ No newline at end of file diff --git a/server/api/update/update.socket.js b/server/api/update/update.socket.js index 149d026..7d16934 100644 --- a/server/api/update/update.socket.js +++ b/server/api/update/update.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Update = require('../../models').Update; - -exports.register = function(socket) { - Update.afterCreate(function (doc) { - onSave(socket, doc); - }); - Update.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('update:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('update:remove', doc); -} +var _0x6af8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x70\x64\x61\x74\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x75\x70\x64\x61\x74\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x75\x70\x64\x61\x74\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x6af8[0];var Update=require(_0x6af8[2])[_0x6af8[1]];exports[_0x6af8[3]]=function(_0xb996x2){Update[_0x6af8[4]](function(_0xb996x3){onSave(_0xb996x2,_0xb996x3)});Update[_0x6af8[5]](function(_0xb996x3){onRemove(_0xb996x2,_0xb996x3)});};function onSave(_0xb996x2,_0xb996x3,_0xb996x5){_0xb996x2[_0x6af8[7]](_0x6af8[6],_0xb996x3)}function onRemove(_0xb996x2,_0xb996x3,_0xb996x5){_0xb996x2[_0x6af8[7]](_0x6af8[8],_0xb996x3)} \ No newline at end of file diff --git a/server/api/update/update.spec.js b/server/api/update/update.spec.js index 21276e3..4402c79 100644 --- a/server/api/update/update.spec.js +++ b/server/api/update/update.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/updates', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/updates') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xee62=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x75\x70\x64\x61\x74\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x75\x70\x64\x61\x74\x65\x73","\x67\x65\x74"];_0xee62[0];var should=require(_0xee62[1]);var app=require(_0xee62[2]);var request=require(_0xee62[3]);describe(_0xee62[4],function(){it(_0xee62[5],function(_0x8e0cx4){request(app)[_0xee62[13]](_0xee62[12])[_0xee62[11]](200)[_0xee62[11]](_0xee62[10],/json/)[_0xee62[9]](function(_0x8e0cx5,_0x8e0cx6){if(_0x8e0cx5){return _0x8e0cx4(_0x8e0cx5)};_0x8e0cx6[_0xee62[8]][_0xee62[1]][_0xee62[7]][_0xee62[6]](Array);_0x8e0cx4();})})}); \ No newline at end of file diff --git a/server/api/upload/index.js b/server/api/upload/index.js index 3b2eded..528965f 100644 --- a/server/api/upload/index.js +++ b/server/api/upload/index.js @@ -1,17 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./upload.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.download); -router.get('/stream/:id', auth.isAuthenticated(), controller.stream); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x6d45=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x70\x6C\x6F\x61\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x2F\x73\x74\x72\x65\x61\x6D\x2F\x3A\x69\x64","\x73\x74\x72\x65\x61\x6D","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x6d45[0];var express=require(_0x6d45[1]);var controller=require(_0x6d45[2]);var auth=require(_0x6d45[3]);var router=express.Router();router[_0x6d45[7]](_0x6d45[4],auth[_0x6d45[5]](),controller[_0x6d45[6]]);router[_0x6d45[7]](_0x6d45[8],auth[_0x6d45[5]](),controller[_0x6d45[9]]);router[_0x6d45[7]](_0x6d45[10],auth[_0x6d45[5]](),controller[_0x6d45[11]]);router[_0x6d45[13]](_0x6d45[4],auth[_0x6d45[5]](),controller[_0x6d45[12]]);router[_0x6d45[15]](_0x6d45[8],auth[_0x6d45[5]](),controller[_0x6d45[14]]);router[_0x6d45[16]](_0x6d45[8],auth[_0x6d45[5]](),controller[_0x6d45[14]]);router[_0x6d45[18]](_0x6d45[8],auth[_0x6d45[5]](),controller[_0x6d45[17]]);module[_0x6d45[19]]=router; \ No newline at end of file diff --git a/server/api/upload/upload.controller.js b/server/api/upload/upload.controller.js index 710b3a0..94f4268 100644 --- a/server/api/upload/upload.controller.js +++ b/server/api/upload/upload.controller.js @@ -1,269 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Upload = require('../../models').Upload; -var uploadFile = require('upload-file'); -var sr = require('simple-random'); -var sox = require('sox'); -var path = require('path'); -var config = require('../../config/environment'); -var fs = require('fs'); -var sequelize = require('../../models').sequelize; -var base64 = require('file-base64'); - -// Get list of uploads -exports.index = function(req, res) { - Upload - .findAll() - .then(function(uploads) { - return res.status(200).send(uploads); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single upload -exports.show = function(req, res) { - Upload - .findById(req.params.id) - .then(function(upload) { - if (!upload) { - return res.sendStatus(404); - } - return res.send(upload); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new upload in the DB. -exports.create = function(req, res) { - var upload = new uploadFile({ - dest: path.join(config.root, 'server/files/sounds/original'), - maxFileSize: 15 * 1000000, - maxNumberOfFiles: 10, - minNumberOfFiles: 0, - acceptFileTypes: /(\.|\/)(wav|mp3|gsm|ogg)$/i, - rename: function(name, file) { - return sr() + path.extname(file.filename); - }, - messages: { - maxNumberOfFiles: "Max number of files upload exceeded", - acceptFileTypes: "Only wav,mp3,gsm, and ogg format accepted", - maxFileSize: "The maximum file size is 15 Mb", - invalidRequest: "Invalid request" - } - }); - - upload.on('end', function(fields, files) { - var job_details = {}; - job_details.description = ""; - job_details.name = job_details.display_name = path.basename(files.file.path, path.extname(files.file.filename)); - job_details.save_name = path.basename(files.file.filename, path.extname(files.file.filename)); - job_details.original_path = path.join(config.root, 'server/files/sounds/original'); - job_details.converted_path = path.join(config.root, 'server/files/sounds/converted'); - - if (!files.file.filename) { - return res.status(500).send(upload); - } - - var filepath = path.join(job_details.original_path, job_details.save_name + path.extname(files.file.filename)); - var destination = path.join(job_details.converted_path, job_details.save_name + '.wav'); - // - - fs.chmodSync(filepath, parseInt('0777', 8)); - sox.identify(filepath, function(err, result) { - console.log('************** Result: ', result); - }); - - var job = sox.transcode(filepath, destination, { - sampleRate: 8000, - format: 'wav', - channelCount: 1, - bitRate: 192 * 1024, - compressionQuality: 5, - }); - - - - job.on('error', function(err) { - console.error('********** Conversion Error: ', err); - fs.unlink(filepath, function(err) { - if (err) - return handleError(res, err); - }); - return handleError(res, err); - }); - - job.on('progress', function(amountDone, amountTotal) { - // console.log("*********** Progress", amountDone, amountTotal); - }); - - job.on('src', function(info) { - // console.log('********** src: ', info); - /* info looks like: - { - format: 'wav', - duration: 1.5, - sampleCount: 66150, - channelCount: 1, - bitRate: 722944, - sampleRate: 44100, - } - */ - job_details.original_format = info.format; - job_details.original_duration = info.duration * 1000; - job_details.original_sampleCount = info.sampleCount; - job_details.original_channelCount = info.channelCount; - job_details.original_bitRate = info.bitRate; - job_details.original_sampleRate = info.sampleRate; - }); - - job.on('dest', function(info) { - // console.log('********** dest: ', info); - /* info looks like: - { - sampleRate: 44100, - format: 'mp3', - channelCount: 2, - sampleCount: 67958, - duration: 1.540998, - bitRate: 196608, - } - */ - job_details.converted_format = info.format; - job_details.converted_duration = info.duration * 1000; - job_details.converted_sampleCount = info.sampleCount; - job_details.converted_channelCount = info.channelCount; - job_details.converted_bitRate = info.bitRate; - job_details.converted_sampleRate = info.sampleRate; - }); - - job.on('end', function() { - console.log("Conversion completed"); - fs.chmodSync(destination, parseInt('0777', 8)); - Upload - .create(job_details) - .then(function(upload) { - return res.status(201).send(upload); - }) - .catch(function(err) { - return handleError(res, err); - }); - }); - - job.start(); - - }); - - upload.on('error', function(err) { - console.log('********** Upload error :', err) - return handleError(res, err); - }); - - upload.parse(req); -}; - -// Updates an existing upload in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - Upload - .findById(req.params.id) - .then(function(upload) { - if (!upload) { - return res.sendStatus(404); - } - var updated = _.merge(upload, req.body); - updated.save() - .then(function() { - return res.status(200).send(upload); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a upload from the DB. -exports.destroy = function(req, res) { - Upload - .findById(req.params.id) - .then(function(upload) { - if (!upload) { - return res.status(404).send(upload); - } - var original_filepath = path.join(upload.original_path, upload.save_name + '.' + upload.original_format); - var converted_filepath = path.join(upload.converted_path, upload.save_name + '.' + upload.converted_format); - return sequelize.transaction(function(t) { - return upload.destroy({ - transaction: t - }) - .then(function() { - fs.unlink(original_filepath, function(err) { - if (err) - return handleError(res, err); - }); - fs.unlink(converted_filepath, function(err) { - if (err) - return handleError(res, err); - }); - return res.status(200).send(upload); - }) - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -//Download an uploaded file -exports.download = function(req, res) { - Upload - .findById(req.params.id) - .then(function(upload) { - if (!upload) { - return res.status(404).send(upload); - } - var original_filepath = path.join(upload.original_path, upload.save_name + '.' + upload.original_format); - res.status(200).download(original_filepath, upload.display_name + '.' + upload.original_format, function(err) { - if (err) { - return handleError(res, err); - } else { - console.log("Sent file under :", original_filepath); - } - }); - }) -}; - -//Stream an uploaded file -exports.stream = function(req, res) { - Upload - .findById(req.params.id) - .then(function(upload) { - if (!upload) { - return res.status(404).send(upload); - } - var original_filepath = path.join(upload.converted_path, upload.save_name + '.' + upload.original_format); - base64.encode(original_filepath, function(err, base64String) { - if (err) { - console.log(err); - return handleError(res, err); - } else { - return res.status(200).send(base64String); - } - }); - }) -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x7469=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x70\x6C\x6F\x61\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x70\x6C\x6F\x61\x64\x2D\x66\x69\x6C\x65","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x73\x6F\x78","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x66\x73","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x66\x69\x6C\x65\x2D\x62\x61\x73\x65\x36\x34","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x73\x6F\x75\x6E\x64\x73\x2F\x6F\x72\x69\x67\x69\x6E\x61\x6C","\x6A\x6F\x69\x6E","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x65\x78\x74\x6E\x61\x6D\x65","\x4D\x61\x78\x20\x6E\x75\x6D\x62\x65\x72\x20\x6F\x66\x20\x66\x69\x6C\x65\x73\x20\x75\x70\x6C\x6F\x61\x64\x20\x65\x78\x63\x65\x65\x64\x65\x64","\x4F\x6E\x6C\x79\x20\x77\x61\x76\x2C\x6D\x70\x33\x2C\x67\x73\x6D\x2C\x20\x61\x6E\x64\x20\x6F\x67\x67\x20\x66\x6F\x72\x6D\x61\x74\x20\x61\x63\x63\x65\x70\x74\x65\x64","\x54\x68\x65\x20\x6D\x61\x78\x69\x6D\x75\x6D\x20\x66\x69\x6C\x65\x20\x73\x69\x7A\x65\x20\x69\x73\x20\x31\x35\x20\x4D\x62","\x49\x6E\x76\x61\x6C\x69\x64\x20\x72\x65\x71\x75\x65\x73\x74","\x65\x6E\x64","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","","\x6E\x61\x6D\x65","\x64\x69\x73\x70\x6C\x61\x79\x5F\x6E\x61\x6D\x65","\x66\x69\x6C\x65","\x62\x61\x73\x65\x6E\x61\x6D\x65","\x73\x61\x76\x65\x5F\x6E\x61\x6D\x65","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x70\x61\x74\x68","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x70\x61\x74\x68","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x73\x6F\x75\x6E\x64\x73\x2F\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x2E\x77\x61\x76","\x30\x37\x37\x37","\x63\x68\x6D\x6F\x64\x53\x79\x6E\x63","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x52\x65\x73\x75\x6C\x74\x3A\x20","\x6C\x6F\x67","\x69\x64\x65\x6E\x74\x69\x66\x79","\x77\x61\x76","\x74\x72\x61\x6E\x73\x63\x6F\x64\x65","\x65\x72\x72\x6F\x72","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x20\x45\x72\x72\x6F\x72\x3A\x20","\x75\x6E\x6C\x69\x6E\x6B","\x6F\x6E","\x70\x72\x6F\x67\x72\x65\x73\x73","\x73\x72\x63","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x66\x6F\x72\x6D\x61\x74","\x66\x6F\x72\x6D\x61\x74","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x64\x75\x72\x61\x74\x69\x6F\x6E","\x64\x75\x72\x61\x74\x69\x6F\x6E","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x62\x69\x74\x52\x61\x74\x65","\x62\x69\x74\x52\x61\x74\x65","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x64\x65\x73\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x66\x6F\x72\x6D\x61\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x64\x75\x72\x61\x74\x69\x6F\x6E","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x62\x69\x74\x52\x61\x74\x65","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x20\x63\x6F\x6D\x70\x6C\x65\x74\x65\x64","\x73\x74\x61\x72\x74","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x55\x70\x6C\x6F\x61\x64\x20\x65\x72\x72\x6F\x72\x20\x3A","\x70\x61\x72\x73\x65","\x75\x70\x64\x61\x74\x65","\x62\x6F\x64\x79","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x2E","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x53\x65\x6E\x74\x20\x66\x69\x6C\x65\x20\x75\x6E\x64\x65\x72\x20\x3A","\x73\x74\x72\x65\x61\x6D","\x65\x6E\x63\x6F\x64\x65"];_0x7469[0];var _=require(_0x7469[1]);var Upload=require(_0x7469[3])[_0x7469[2]];var uploadFile=require(_0x7469[4]);var sr=require(_0x7469[5]);var sox=require(_0x7469[6]);var path=require(_0x7469[7]);var config=require(_0x7469[8]);var fs=require(_0x7469[9]);var sequelize=require(_0x7469[3])[_0x7469[10]];var base64=require(_0x7469[11]);exports[_0x7469[12]]=function(_0x58d3xb,_0x58d3xc){Upload[_0x7469[17]]()[_0x7469[16]](function(_0x58d3xe){return _0x58d3xc[_0x7469[15]](200)[_0x7469[14]](_0x58d3xe)})[_0x7469[13]](function(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)})};exports[_0x7469[18]]=function(_0x58d3xb,_0x58d3xc){Upload[_0x7469[22]](_0x58d3xb[_0x7469[21]][_0x7469[20]])[_0x7469[16]](function(_0x58d3xf){if(!_0x58d3xf){return _0x58d3xc[_0x7469[19]](404)};return _0x58d3xc[_0x7469[14]](_0x58d3xf);})[_0x7469[13]](function(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)})};exports[_0x7469[23]]=function(_0x58d3xb,_0x58d3xc){var _0x58d3xf= new uploadFile({dest:path[_0x7469[26]](config[_0x7469[24]],_0x7469[25]),maxFileSize:15*1000000,maxNumberOfFiles:10,minNumberOfFiles:0,acceptFileTypes:/(\.|\/)(wav|mp3|gsm|ogg)$/i,rename:function(_0x58d3x10,_0x58d3x11){return sr()+path[_0x7469[28]](_0x58d3x11[_0x7469[27]])},messages:{maxNumberOfFiles:_0x7469[29],acceptFileTypes:_0x7469[30],maxFileSize:_0x7469[31],invalidRequest:_0x7469[32]}});_0x58d3xf[_0x7469[55]](_0x7469[33],function(_0x58d3x12,_0x58d3x13){var _0x58d3x14={};_0x58d3x14[_0x7469[34]]=_0x7469[35];_0x58d3x14[_0x7469[36]]=_0x58d3x14[_0x7469[37]]=path[_0x7469[39]](_0x58d3x13[_0x7469[38]][_0x7469[7]],path[_0x7469[28]](_0x58d3x13[_0x7469[38]][_0x7469[27]]));_0x58d3x14[_0x7469[40]]=path[_0x7469[39]](_0x58d3x13[_0x7469[38]][_0x7469[27]],path[_0x7469[28]](_0x58d3x13[_0x7469[38]][_0x7469[27]]));_0x58d3x14[_0x7469[41]]=path[_0x7469[26]](config[_0x7469[24]],_0x7469[25]);_0x58d3x14[_0x7469[42]]=path[_0x7469[26]](config[_0x7469[24]],_0x7469[43]);if(!_0x58d3x13[_0x7469[38]][_0x7469[27]]){return _0x58d3xc[_0x7469[15]](500)[_0x7469[14]](_0x58d3xf)};var _0x58d3x15=path[_0x7469[26]](_0x58d3x14[_0x7469[41]],_0x58d3x14[_0x7469[40]]+path[_0x7469[28]](_0x58d3x13[_0x7469[38]][_0x7469[27]]));var _0x58d3x16=path[_0x7469[26]](_0x58d3x14[_0x7469[42]],_0x58d3x14[_0x7469[40]]+_0x7469[44]);fs[_0x7469[46]](_0x58d3x15,parseInt(_0x7469[45],8));sox[_0x7469[49]](_0x58d3x15,function(_0x58d3xd,_0x58d3x17){console[_0x7469[48]](_0x7469[47],_0x58d3x17)});var _0x58d3x18=sox[_0x7469[51]](_0x58d3x15,_0x58d3x16,{sampleRate:8000,format:_0x7469[50],channelCount:1,bitRate:192*1024,compressionQuality:5});_0x58d3x18[_0x7469[55]](_0x7469[52],function(_0x58d3xd){console[_0x7469[52]](_0x7469[53],_0x58d3xd);fs[_0x7469[54]](_0x58d3x15,function(_0x58d3xd){if(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)}});return handleError(_0x58d3xc,_0x58d3xd);});_0x58d3x18[_0x7469[55]](_0x7469[56],function(_0x58d3x19,_0x58d3x1a){});_0x58d3x18[_0x7469[55]](_0x7469[57],function(_0x58d3x1b){_0x58d3x14[_0x7469[58]]=_0x58d3x1b[_0x7469[59]];_0x58d3x14[_0x7469[60]]=_0x58d3x1b[_0x7469[61]]*1000;_0x58d3x14[_0x7469[62]]=_0x58d3x1b[_0x7469[63]];_0x58d3x14[_0x7469[64]]=_0x58d3x1b[_0x7469[65]];_0x58d3x14[_0x7469[66]]=_0x58d3x1b[_0x7469[67]];_0x58d3x14[_0x7469[68]]=_0x58d3x1b[_0x7469[69]];});_0x58d3x18[_0x7469[55]](_0x7469[70],function(_0x58d3x1b){_0x58d3x14[_0x7469[71]]=_0x58d3x1b[_0x7469[59]];_0x58d3x14[_0x7469[72]]=_0x58d3x1b[_0x7469[61]]*1000;_0x58d3x14[_0x7469[73]]=_0x58d3x1b[_0x7469[63]];_0x58d3x14[_0x7469[74]]=_0x58d3x1b[_0x7469[65]];_0x58d3x14[_0x7469[75]]=_0x58d3x1b[_0x7469[67]];_0x58d3x14[_0x7469[76]]=_0x58d3x1b[_0x7469[69]];});_0x58d3x18[_0x7469[55]](_0x7469[33],function(){console[_0x7469[48]](_0x7469[77]);fs[_0x7469[46]](_0x58d3x16,parseInt(_0x7469[45],8));Upload[_0x7469[23]](_0x58d3x14)[_0x7469[16]](function(_0x58d3xf){return _0x58d3xc[_0x7469[15]](201)[_0x7469[14]](_0x58d3xf)})[_0x7469[13]](function(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)});});_0x58d3x18[_0x7469[78]]();});_0x58d3xf[_0x7469[55]](_0x7469[52],function(_0x58d3xd){console[_0x7469[48]](_0x7469[79],_0x58d3xd);return handleError(_0x58d3xc,_0x58d3xd);});_0x58d3xf[_0x7469[80]](_0x58d3xb);};exports[_0x7469[81]]=function(_0x58d3xb,_0x58d3xc){if(_0x58d3xb[_0x7469[82]][_0x7469[20]]){delete _0x58d3xb[_0x7469[82]][_0x7469[20]]};Upload[_0x7469[22]](_0x58d3xb[_0x7469[21]][_0x7469[20]])[_0x7469[16]](function(_0x58d3xf){if(!_0x58d3xf){return _0x58d3xc[_0x7469[19]](404)};var _0x58d3x1c=_[_0x7469[83]](_0x58d3xf,_0x58d3xb[_0x7469[82]]);_0x58d3x1c[_0x7469[84]]()[_0x7469[16]](function(){return _0x58d3xc[_0x7469[15]](200)[_0x7469[14]](_0x58d3xf)})[_0x7469[13]](function(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)});})[_0x7469[13]](function(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)});};exports[_0x7469[85]]=function(_0x58d3xb,_0x58d3xc){Upload[_0x7469[22]](_0x58d3xb[_0x7469[21]][_0x7469[20]])[_0x7469[16]](function(_0x58d3xf){if(!_0x58d3xf){return _0x58d3xc[_0x7469[15]](404)[_0x7469[14]](_0x58d3xf)};var _0x58d3x1d=path[_0x7469[26]](_0x58d3xf[_0x7469[41]],_0x58d3xf[_0x7469[40]]+_0x7469[86]+_0x58d3xf[_0x7469[58]]);var _0x58d3x1e=path[_0x7469[26]](_0x58d3xf[_0x7469[42]],_0x58d3xf[_0x7469[40]]+_0x7469[86]+_0x58d3xf[_0x7469[71]]);return sequelize[_0x7469[87]](function(_0x58d3x1f){return _0x58d3xf[_0x7469[85]]({transaction:_0x58d3x1f})[_0x7469[16]](function(){fs[_0x7469[54]](_0x58d3x1d,function(_0x58d3xd){if(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)}});fs[_0x7469[54]](_0x58d3x1e,function(_0x58d3xd){if(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)}});return _0x58d3xc[_0x7469[15]](200)[_0x7469[14]](_0x58d3xf);})})[_0x7469[13]](function(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)});})[_0x7469[13]](function(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)})};exports[_0x7469[88]]=function(_0x58d3xb,_0x58d3xc){Upload[_0x7469[22]](_0x58d3xb[_0x7469[21]][_0x7469[20]])[_0x7469[16]](function(_0x58d3xf){if(!_0x58d3xf){return _0x58d3xc[_0x7469[15]](404)[_0x7469[14]](_0x58d3xf)};var _0x58d3x1d=path[_0x7469[26]](_0x58d3xf[_0x7469[41]],_0x58d3xf[_0x7469[40]]+_0x7469[86]+_0x58d3xf[_0x7469[58]]);_0x58d3xc[_0x7469[15]](200)[_0x7469[88]](_0x58d3x1d,_0x58d3xf[_0x7469[37]]+_0x7469[86]+_0x58d3xf[_0x7469[58]],function(_0x58d3xd){if(_0x58d3xd){return handleError(_0x58d3xc,_0x58d3xd)}else {console[_0x7469[48]](_0x7469[89],_0x58d3x1d)}});})};exports[_0x7469[90]]=function(_0x58d3xb,_0x58d3xc){Upload[_0x7469[22]](_0x58d3xb[_0x7469[21]][_0x7469[20]])[_0x7469[16]](function(_0x58d3xf){if(!_0x58d3xf){return _0x58d3xc[_0x7469[15]](404)[_0x7469[14]](_0x58d3xf)};var _0x58d3x1d=path[_0x7469[26]](_0x58d3xf[_0x7469[42]],_0x58d3xf[_0x7469[40]]+_0x7469[86]+_0x58d3xf[_0x7469[58]]);base64[_0x7469[91]](_0x58d3x1d,function(_0x58d3xd,_0x58d3x20){if(_0x58d3xd){console[_0x7469[48]](_0x58d3xd);return handleError(_0x58d3xc,_0x58d3xd);}else {return _0x58d3xc[_0x7469[15]](200)[_0x7469[14]](_0x58d3x20)}});})};function handleError(_0x58d3xc,_0x58d3xd){return _0x58d3xc[_0x7469[15]](500)[_0x7469[14]](_0x58d3xd)} \ No newline at end of file diff --git a/server/api/upload/upload.socket.js b/server/api/upload/upload.socket.js index 938d94b..c59872c 100644 --- a/server/api/upload/upload.socket.js +++ b/server/api/upload/upload.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var upload = require('../../models').Upload; - -exports.register = function(socket) { - upload.afterCreate(function (doc) { - onSave(socket, doc); - }); - upload.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('upload:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('upload:remove', doc); -} +var _0x5a59=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x70\x6C\x6F\x61\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x75\x70\x6C\x6F\x61\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x75\x70\x6C\x6F\x61\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0x5a59[0];var upload=require(_0x5a59[2])[_0x5a59[1]];exports[_0x5a59[3]]=function(_0x9a2bx2){upload[_0x5a59[4]](function(_0x9a2bx3){onSave(_0x9a2bx2,_0x9a2bx3)});upload[_0x5a59[5]](function(_0x9a2bx3){onRemove(_0x9a2bx2,_0x9a2bx3)});};function onSave(_0x9a2bx2,_0x9a2bx3,_0x9a2bx5){_0x9a2bx2[_0x5a59[7]](_0x5a59[6],_0x9a2bx3)}function onRemove(_0x9a2bx2,_0x9a2bx3,_0x9a2bx5){_0x9a2bx2[_0x5a59[7]](_0x5a59[8],_0x9a2bx3)} \ No newline at end of file diff --git a/server/api/upload/upload.spec.js b/server/api/upload/upload.spec.js index bde9f38..e426559 100644 --- a/server/api/upload/upload.spec.js +++ b/server/api/upload/upload.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/uploads', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/uploads') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x26c1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x75\x70\x6C\x6F\x61\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x75\x70\x6C\x6F\x61\x64\x73","\x67\x65\x74"];_0x26c1[0];var should=require(_0x26c1[1]);var app=require(_0x26c1[2]);var request=require(_0x26c1[3]);describe(_0x26c1[4],function(){it(_0x26c1[5],function(_0x4d6ex4){request(app)[_0x26c1[13]](_0x26c1[12])[_0x26c1[11]](200)[_0x26c1[11]](_0x26c1[10],/json/)[_0x26c1[9]](function(_0x4d6ex5,_0x4d6ex6){if(_0x4d6ex5){return _0x4d6ex4(_0x4d6ex5)};_0x4d6ex6[_0x26c1[8]][_0x26c1[1]][_0x26c1[7]][_0x26c1[6]](Array);_0x4d6ex4();})})}); \ No newline at end of file diff --git a/server/api/user/index.js b/server/api/user/index.js index ba13b49..f981b0e 100644 --- a/server/api/user/index.js +++ b/server/api/user/index.js @@ -1,25 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./user.controller'); -var config = require('../../config/environment'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/me', auth.isAuthenticated(), controller.me); -router.get('/all', auth.isAuthenticated(), controller.getUsers); -router.get('/avatar/:filename', controller.getAvatar); -router.get('/:id/avatar', controller.getAvatarById); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/validate/:field', auth.isAuthenticated(), controller.userValidation); -router.put('/password', auth.isAuthenticated(), controller.changePassword); -router.put('/password/:id/reset', auth.isAuthenticated(), auth.hasRole('admin'), controller.resetPassword); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/:id/avatar', auth.isAuthenticated(), controller.changeAvatar); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x7d95=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x73\x65\x72\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x6D\x65","\x6D\x65","\x2F\x61\x6C\x6C","\x67\x65\x74\x55\x73\x65\x72\x73","\x2F\x61\x76\x61\x74\x61\x72\x2F\x3A\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x67\x65\x74\x41\x76\x61\x74\x61\x72","\x2F\x3A\x69\x64\x2F\x61\x76\x61\x74\x61\x72","\x67\x65\x74\x41\x76\x61\x74\x61\x72\x42\x79\x49\x64","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65\x2F\x3A\x66\x69\x65\x6C\x64","\x75\x73\x65\x72\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x2F\x70\x61\x73\x73\x77\x6F\x72\x64","\x63\x68\x61\x6E\x67\x65\x50\x61\x73\x73\x77\x6F\x72\x64","\x70\x75\x74","\x2F\x70\x61\x73\x73\x77\x6F\x72\x64\x2F\x3A\x69\x64\x2F\x72\x65\x73\x65\x74","\x61\x64\x6D\x69\x6E","\x68\x61\x73\x52\x6F\x6C\x65","\x72\x65\x73\x65\x74\x50\x61\x73\x73\x77\x6F\x72\x64","\x75\x70\x64\x61\x74\x65","\x63\x72\x65\x61\x74\x65","\x63\x68\x61\x6E\x67\x65\x41\x76\x61\x74\x61\x72","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x7d95[0];var express=require(_0x7d95[1]);var controller=require(_0x7d95[2]);var config=require(_0x7d95[3]);var auth=require(_0x7d95[4]);var router=express.Router();router[_0x7d95[8]](_0x7d95[5],auth[_0x7d95[6]](),controller[_0x7d95[7]]);router[_0x7d95[8]](_0x7d95[9],auth[_0x7d95[6]](),controller[_0x7d95[10]]);router[_0x7d95[8]](_0x7d95[11],auth[_0x7d95[6]](),controller[_0x7d95[12]]);router[_0x7d95[8]](_0x7d95[13],controller[_0x7d95[14]]);router[_0x7d95[8]](_0x7d95[15],controller[_0x7d95[16]]);router[_0x7d95[8]](_0x7d95[17],auth[_0x7d95[6]](),controller[_0x7d95[18]]);router[_0x7d95[21]](_0x7d95[19],auth[_0x7d95[6]](),controller[_0x7d95[20]]);router[_0x7d95[24]](_0x7d95[22],auth[_0x7d95[6]](),controller[_0x7d95[23]]);router[_0x7d95[24]](_0x7d95[25],auth[_0x7d95[6]](),auth[_0x7d95[27]](_0x7d95[26]),controller[_0x7d95[28]]);router[_0x7d95[24]](_0x7d95[17],auth[_0x7d95[6]](),controller[_0x7d95[29]]);router[_0x7d95[21]](_0x7d95[5],auth[_0x7d95[6]](),controller[_0x7d95[30]]);router[_0x7d95[21]](_0x7d95[15],auth[_0x7d95[6]](),controller[_0x7d95[31]]);router[_0x7d95[33]](_0x7d95[5],auth[_0x7d95[6]](),controller[_0x7d95[32]]);router[_0x7d95[33]](_0x7d95[17],auth[_0x7d95[6]](),controller[_0x7d95[34]]);module[_0x7d95[35]]=router; \ No newline at end of file diff --git a/server/api/user/user.ami.js b/server/api/user/user.ami.js index d26deb4..a805161 100644 --- a/server/api/user/user.ami.js +++ b/server/api/user/user.ami.js @@ -1,75 +1 @@ -'use strict'; - -var fs = require('fs'); -var util = require('util'); -var path = require('path'); -var config = require('../../config/environment'); -var User = require('../../models').User; -var VoiceExtension = require('../../models').VoiceExtension; - -exports.register = function (ami) { - User.afterCreate(function (doc) { - createCallerID(doc); - createExtension(doc); - }) - User.afterUpdate(function (doc) { - updateExtension(doc); - createCallerID(doc); - }) -} - - -function createCallerID(doc) { - if (doc.name && doc.internal) { - doc.callerid = util.format('"%s" <%s>', doc.name, doc.internal); - doc.save(); - } - - return; -} - -function updateExtension(doc) { - if (doc.changed('name')) { - doc - .getUserExtensions() - .then(function (userExtensions) { - userExtensions.forEach(function (elem) { - elem.exten = (elem.exten === doc._previousDataValues.internal) ? doc.internal : doc.name; - elem.appdata = 'SIP/' + doc.name; - elem.save(); - }) - }) - .catch(function (err) { - console.log(err); - }); - } -} - - -function createExtension(doc) { - if (doc.internal) { - var userDials = [{ - context: 'from-sip', - exten: doc.internal, - priority: 1, - app: 'Dial', - appdata: 'SIP/' + doc.name, - UserId: doc.id, - type: 'internal' - }, { - context: 'from-sip', - exten: doc.name, - priority: 1, - app: 'Dial', - appdata: 'SIP/' + doc.name, - UserId: doc.id, - type: 'internal' - }]; - - return VoiceExtension - .bulkCreate(userDials) - .catch(function (err) { - console.log(err); - }); - } -} +var _0x5b09=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x66\x73","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x6E\x61\x6D\x65","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x63\x61\x6C\x6C\x65\x72\x69\x64","\x22\x25\x73\x22\x20\x3C\x25\x73\x3E","\x66\x6F\x72\x6D\x61\x74","\x73\x61\x76\x65","\x63\x68\x61\x6E\x67\x65\x64","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x65\x78\x74\x65\x6E","\x5F\x70\x72\x65\x76\x69\x6F\x75\x73\x44\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x61\x70\x70\x64\x61\x74\x61","\x53\x49\x50\x2F","\x66\x6F\x72\x45\x61\x63\x68","\x74\x68\x65\x6E","\x67\x65\x74\x55\x73\x65\x72\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x66\x72\x6F\x6D\x2D\x73\x69\x70","\x44\x69\x61\x6C","\x69\x64","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65"];_0x5b09[0];var fs=require(_0x5b09[1]);var util=require(_0x5b09[2]);var path=require(_0x5b09[3]);var config=require(_0x5b09[4]);var User=require(_0x5b09[6])[_0x5b09[5]];var VoiceExtension=require(_0x5b09[6])[_0x5b09[7]];exports[_0x5b09[8]]=function(_0xb4fcx7){User[_0x5b09[9]](function(_0xb4fcx8){createCallerID(_0xb4fcx8);createExtension(_0xb4fcx8);});User[_0x5b09[10]](function(_0xb4fcx8){updateExtension(_0xb4fcx8);createCallerID(_0xb4fcx8);});};function createCallerID(_0xb4fcx8){if(_0xb4fcx8[_0x5b09[11]]&&_0xb4fcx8[_0x5b09[12]]){_0xb4fcx8[_0x5b09[13]]=util[_0x5b09[15]](_0x5b09[14],_0xb4fcx8[_0x5b09[11]],_0xb4fcx8[_0x5b09[12]]);_0xb4fcx8[_0x5b09[16]]();};return ;}function updateExtension(_0xb4fcx8){if(_0xb4fcx8[_0x5b09[17]](_0x5b09[11])){_0xb4fcx8[_0x5b09[26]]()[_0x5b09[25]](function(_0xb4fcxc){_0xb4fcxc[_0x5b09[24]](function(_0xb4fcxd){_0xb4fcxd[_0x5b09[20]]=(_0xb4fcxd[_0x5b09[20]]===_0xb4fcx8[_0x5b09[21]][_0x5b09[12]])?_0xb4fcx8[_0x5b09[12]]:_0xb4fcx8[_0x5b09[11]];_0xb4fcxd[_0x5b09[22]]=_0x5b09[23]+_0xb4fcx8[_0x5b09[11]];_0xb4fcxd[_0x5b09[16]]();})})[_0x5b09[19]](function(_0xb4fcxb){console[_0x5b09[18]](_0xb4fcxb)})}}function createExtension(_0xb4fcx8){if(_0xb4fcx8[_0x5b09[12]]){var _0xb4fcxf=[{context:_0x5b09[27],exten:_0xb4fcx8[_0x5b09[12]],priority:1,app:_0x5b09[28],appdata:_0x5b09[23]+_0xb4fcx8[_0x5b09[11]],UserId:_0xb4fcx8[_0x5b09[29]],type:_0x5b09[12]},{context:_0x5b09[27],exten:_0xb4fcx8[_0x5b09[11]],priority:1,app:_0x5b09[28],appdata:_0x5b09[23]+_0xb4fcx8[_0x5b09[11]],UserId:_0xb4fcx8[_0x5b09[29]],type:_0x5b09[12]}];return VoiceExtension[_0x5b09[30]](_0xb4fcxf)[_0x5b09[19]](function(_0xb4fcxb){console[_0x5b09[18]](_0xb4fcxb)});}} \ No newline at end of file diff --git a/server/api/user/user.controller.js b/server/api/user/user.controller.js index 3e2e864..63c4d23 100644 --- a/server/api/user/user.controller.js +++ b/server/api/user/user.controller.js @@ -1,447 +1 @@ -'use strict'; - -var User = require('../../models').User; -var Module = require('../../models').Module; -var config = require('../../config/environment'); - -var passport = require('passport'); -var moment = require('moment'); -var jwt = require('jsonwebtoken'); -var uploadFile = require('upload-file'); -var path = require('path'); -var fs = require('fs'); -var _ = require('lodash'); -var util = require('util'); -var sr = require('simple-random'); - -/** - * Get list of admin/user - */ -exports.index = function(req, res, next) { - - var attributes = ['fullname', 'name', 'email', 'role']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: { - role: ['admin', 'user'] - }, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - User - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - return res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return res.status(500).send({ - error: 'Something blew up!' - }); - }); - -}; - -/** - * Get list of admin/user/agent - */ -exports.getUsers = function(req, res, next) { - User - .findAll({ - where: { - role: { - $in: ['admin', 'user', 'agent'] - } - } - }) - .then(function(users) { - return res.status(200).send(users); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -/** - * Creates a new user - */ -exports.create = function(req, res, next) { - - var body = req.body; - _(body).keys().sort().each(function(key) { - var value = body[key]; - }); - - var newUser = User.build(req.body); - newUser.provider = 'local'; - newUser - .save() - .then(function(user) { - var token = jwt.sign({ - id: user.id - }, config.session.secret, { - expiresIn: "5h" - }); - return res.status(201).send({ - token: token - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -/** - * Get a single user - */ -exports.show = function(req, res, next) { - - User - .findById(req.params.id) - .then(function(user) { - if (user) { - return res.status(200).send(user); - } else { - return res.sendStatus(404); - } - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -/** - * Deletes a user - */ -exports.destroy = function(req, res, next) { - var userId = req.params.id; - // console.log(req.params); - // console.log(req.body); - - User - .findById(userId) - .then(function(user) { - if (user) { - user - .destroy() - .then(function(user) { - console.log(user); - return res.status(200).send(user); - }) - .catch(function(err) { - return handleError(res, err); - }); - } else { - return res.sendStatus(404); - } - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -/** - * Change a user password - */ -exports.changePassword = function(req, res, next) { - var userId = req.user.id; - var oldPass = String(req.body.oldPassword); - var newPass = String(req.body.newPassword); - User - .findById(userId) - .then(function(user) { - if (user.authenticate(oldPass)) { - user.password = newPass; - user.save() - .then(function() { - return res.status(200).send(user); - }) - .catch(function(err) { - return handleError(res, err); - }); - } else { - return res.sendStatus(403); - } - }); -}; - -/** - * Change a user password by admin - */ -exports.resetPassword = function(req, res, next) { - var newPass = String(req.body.newPassword); - User - .findById(req.params.id) - .then(function(user) { - user.password = newPass; - user.save() - .then(function() { - return res.status(200).send(user); - }) - .catch(function(err) { - return handleError(res, err); - }); - }); -}; - -/** - * Change the avatar of the user - */ -exports.changeAvatar = function(req, res, next) { - - var upload = new uploadFile({ - dest: path.join(config.root, 'server', 'files', 'images'), - maxNumberOfFiles: 1, - minNumberOfFiles: 0, - acceptFileTypes: /(\.|\/)(jpeg|png)$/i, - rename: function(name, file) { - return sr() + path.extname(file.filename); - // return 'avatar' + req.params.id + path.extname(file.filename); - }, - messages: { - maxNumberOfFiles: "Max number of files upload exceeded", - acceptFileTypes: "Only jpeg and png format accepted", - // maxFileSize: "The maximum file size is 5 Mb", - invalidRequest: "Invalid request" - } - }); - - upload.on('end', function(fields, files) { - if (!files.file.filename) { - return res.status(500).send(upload); - } else { - User - .findById(req.params.id) - .then(function(user) { - if (user) { - user.updateAttributes({ - userpic: files.file.filename - }) - .then(function() { - return res.status(200).send(user); - }) - .catch(function(err) { - return handleError(res, err); - }); - } else { - return res.sendStatus(404); - } - }) - .catch(function(err) { - return handleError(res, err); - }); - } - }); - - upload.on('error', function(err) { - console.log('********** Upload error :', err) - return handleError(res, err); - }); - - upload.parse(req); -}; - - -/** - * Get my info - */ -exports.me = function(req, res, next) { - var userId = req.user.id; - - User - .findOne({ - where: { - id: userId - }, - attributes: ['id', 'fullname', 'name', 'email', 'role', 'userpic'], - include: [Module] - }) - .then(function(user) { - if (!user) { - return res.sendStatus(401); - } - return res.status(200).send(user); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -/** - * Update my user - */ -exports.update = function(req, res, next) { - var userId = req.user.id; - - User - .findById(req.params.id) - .then(function(user) { - if (user) { - user - .updateAttributes(req.body) - .then(function(user) { - return res.status(200).send(user); - }) - .catch(function(err) { - return handleError(res, err); - }); - } else { - return res.sendStatus(500); - } - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -/** - * Get my avatar - */ -exports.getAvatar = function(req, res, next) { - // var userId = req.params.id; - - var imgPath = path.join(config.root, 'server', 'files', 'images', req.params.filename); - - fs.exists(imgPath, function(exists) { - if (!exists) { - imgPath = path.join(config.root, 'server', 'files', 'images', 'userpic.png'); - } - - return res.sendFile(imgPath); - }); -}; - -/** - * Get my avatar by id - */ -exports.getAvatarById = function(req, res, next) { - - // console.log('getAvatarById'); - // console.log(req.params); - - if (req.params.id === 'visitor') { - var imgPath = path.join(config.root, 'server', 'files', 'images', 'customer.png'); - - fs.exists(imgPath, function(exists) { - return res.sendFile(imgPath); - }); - - } else { - User - .findById(req.params.id) - .then(function(user) { - if (user) { - var imgPath = path.join(config.root, 'server', 'files', 'images', user.userpic ? user.userpic : 'userpic.png'); - - fs.exists(imgPath, function(exists) { - if (!exists) { - imgPath = path.join(config.root, 'server', 'files', 'images', 'userpic.png'); - } - - return res.sendFile(imgPath); - }); - } else { - return res.sendStatus(500); - } - }) - .catch(function(err) { - return handleError(res, err); - }); - } -}; - -// Deletes a agent from the DB. -exports.bulkDestroy = function(req, res) { - User - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.userValidation = function(req, res) { - var where = {}; - where[req.params.field] = req.body.value; - User - .findAndCountAll({ - where: where - }) - .then(function(result) { - if (result.count) { - return res.status(200).send({ - isValid: false, - value: req.body.value - }); - } - return res.status(200).send({ - isValid: true, - value: req.body.value - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - -}; - -/** - * Authentication callback - */ -exports.authCallback = function(req, res, next) { - res.redirect('/'); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xcaa9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x6F\x64\x75\x6C\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x70\x61\x73\x73\x70\x6F\x72\x74","\x6D\x6F\x6D\x65\x6E\x74","\x6A\x73\x6F\x6E\x77\x65\x62\x74\x6F\x6B\x65\x6E","\x75\x70\x6C\x6F\x61\x64\x2D\x66\x69\x6C\x65","\x70\x61\x74\x68","\x66\x73","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x69\x6E\x64\x65\x78","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x72\x6F\x6C\x65","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x61\x64\x6D\x69\x6E","\x75\x73\x65\x72","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x67\x65\x74\x55\x73\x65\x72\x73","\x61\x67\x65\x6E\x74","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x65\x61\x63\x68","\x73\x6F\x72\x74","\x6B\x65\x79\x73","\x62\x75\x69\x6C\x64","\x70\x72\x6F\x76\x69\x64\x65\x72","\x6C\x6F\x63\x61\x6C","\x69\x64","\x73\x65\x63\x72\x65\x74","\x73\x65\x73\x73\x69\x6F\x6E","\x35\x68","\x73\x69\x67\x6E","\x73\x61\x76\x65","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x64\x65\x73\x74\x72\x6F\x79","\x6C\x6F\x67","\x63\x68\x61\x6E\x67\x65\x50\x61\x73\x73\x77\x6F\x72\x64","\x6F\x6C\x64\x50\x61\x73\x73\x77\x6F\x72\x64","\x6E\x65\x77\x50\x61\x73\x73\x77\x6F\x72\x64","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x72\x65\x73\x65\x74\x50\x61\x73\x73\x77\x6F\x72\x64","\x63\x68\x61\x6E\x67\x65\x41\x76\x61\x74\x61\x72","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x69\x6D\x61\x67\x65\x73","\x6A\x6F\x69\x6E","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x65\x78\x74\x6E\x61\x6D\x65","\x4D\x61\x78\x20\x6E\x75\x6D\x62\x65\x72\x20\x6F\x66\x20\x66\x69\x6C\x65\x73\x20\x75\x70\x6C\x6F\x61\x64\x20\x65\x78\x63\x65\x65\x64\x65\x64","\x4F\x6E\x6C\x79\x20\x6A\x70\x65\x67\x20\x61\x6E\x64\x20\x70\x6E\x67\x20\x66\x6F\x72\x6D\x61\x74\x20\x61\x63\x63\x65\x70\x74\x65\x64","\x49\x6E\x76\x61\x6C\x69\x64\x20\x72\x65\x71\x75\x65\x73\x74","\x65\x6E\x64","\x66\x69\x6C\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x6F\x6E","\x65\x72\x72\x6F\x72","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x55\x70\x6C\x6F\x61\x64\x20\x65\x72\x72\x6F\x72\x20\x3A","\x70\x61\x72\x73\x65","\x6D\x65","\x75\x73\x65\x72\x70\x69\x63","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65","\x67\x65\x74\x41\x76\x61\x74\x61\x72","\x75\x73\x65\x72\x70\x69\x63\x2E\x70\x6E\x67","\x73\x65\x6E\x64\x46\x69\x6C\x65","\x65\x78\x69\x73\x74\x73","\x67\x65\x74\x41\x76\x61\x74\x61\x72\x42\x79\x49\x64","\x76\x69\x73\x69\x74\x6F\x72","\x63\x75\x73\x74\x6F\x6D\x65\x72\x2E\x70\x6E\x67","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x75\x73\x65\x72\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x61\x75\x74\x68\x43\x61\x6C\x6C\x62\x61\x63\x6B","\x2F","\x72\x65\x64\x69\x72\x65\x63\x74"];_0xcaa9[0];var User=require(_0xcaa9[2])[_0xcaa9[1]];var Module=require(_0xcaa9[2])[_0xcaa9[3]];var config=require(_0xcaa9[4]);var passport=require(_0xcaa9[5]);var moment=require(_0xcaa9[6]);var jwt=require(_0xcaa9[7]);var uploadFile=require(_0xcaa9[8]);var path=require(_0xcaa9[9]);var fs=require(_0xcaa9[10]);var _=require(_0xcaa9[11]);var util=require(_0xcaa9[12]);var sr=require(_0xcaa9[13]);exports[_0xcaa9[14]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx10=[_0xcaa9[15],_0xcaa9[16],_0xcaa9[17],_0xcaa9[18]];var _0x392fx11=_0x392fxd[_0xcaa9[20]][_0xcaa9[19]]?parseInt(_0x392fxd[_0xcaa9[20]][_0xcaa9[19]],10):100;var _0x392fx12=_0x392fxd[_0xcaa9[20]][_0xcaa9[21]]?parseInt(_0x392fxd[_0xcaa9[20]][_0xcaa9[21]],10):0;var _0x392fx13={where:{role:[_0xcaa9[22],_0xcaa9[23]]},limit:_0x392fx11,offset:_0x392fx12*_0x392fx11};_[_0xcaa9[37]](_0x392fxd[_0xcaa9[20]],function(_0x392fx14,_0x392fx15){switch(_0x392fx15){case _0xcaa9[19]:;case _0xcaa9[21]:break ;;case _0xcaa9[26]:_0x392fx13[_0xcaa9[24]]=util[_0xcaa9[29]](_0xcaa9[25],_0x392fxd[_0xcaa9[20]][_0xcaa9[26]],_0x392fxd[_0xcaa9[20]][_0xcaa9[27]]||_0xcaa9[28])||null;break ;;case _0xcaa9[27]:break ;;case _0xcaa9[35]:_0x392fx13[_0xcaa9[31]][_0xcaa9[30]]=[];_0x392fx10[_0xcaa9[34]](function(_0x392fx16){var _0x392fx17={};_0x392fx17[_0x392fx16]={$like:_0xcaa9[32]+_0x392fx14+_0xcaa9[32]};_0x392fx13[_0xcaa9[31]][_0xcaa9[30]][_0xcaa9[33]](_0x392fx17);});break ;;default:_0x392fx13[_0xcaa9[31]][_0x392fx15]={$like:{}};_0x392fx13[_0xcaa9[31]][_0x392fx15][_0xcaa9[36]]=_0xcaa9[32]+_0x392fx14+_0xcaa9[32];;}});User[_0xcaa9[52]](_0x392fx13)[_0xcaa9[51]](function(_0x392fx19){var _0x392fx1a=Math[_0xcaa9[43]](_0x392fx19[_0xcaa9[42]]/_0x392fx11);var _0x392fx1b=_0x392fx1a>(_0x392fx13[_0xcaa9[44]]+1)?util[_0xcaa9[29]](_0xcaa9[45],_0x392fxd[_0xcaa9[46]],_0x392fxd[_0xcaa9[48]][_0xcaa9[47]],_0x392fxd[_0xcaa9[49]],_0x392fx12+1):null;var _0x392fx1c=_0x392fx12>0?util[_0xcaa9[29]](_0xcaa9[45],_0x392fxd[_0xcaa9[46]],_0x392fxd[_0xcaa9[48]][_0xcaa9[47]],_0x392fxd[_0xcaa9[49]],_0x392fx12-1):null;return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]]({count:_0x392fx19[_0xcaa9[42]],rows:_0x392fx19[_0xcaa9[50]],next_page:_0x392fx1b,previous_page:_0x392fx1c,total_pages:_0x392fx1a});})[_0xcaa9[41]](function(_0x392fx18){return _0x392fxe[_0xcaa9[40]](500)[_0xcaa9[39]]({error:_0xcaa9[38]})});};exports[_0xcaa9[53]]=function(_0x392fxd,_0x392fxe,_0x392fxf){User[_0xcaa9[55]]({where:{role:{$in:[_0xcaa9[22],_0xcaa9[23],_0xcaa9[54]]}}})[_0xcaa9[51]](function(_0x392fx1d){return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx1d)})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})};exports[_0xcaa9[56]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx1e=_0x392fxd[_0xcaa9[57]];_(_0x392fx1e)[_0xcaa9[60]]()[_0xcaa9[59]]()[_0xcaa9[58]](function(_0x392fx15){var _0x392fx14=_0x392fx1e[_0x392fx15]});var _0x392fx1f=User[_0xcaa9[61]](_0x392fxd[_0xcaa9[57]]);_0x392fx1f[_0xcaa9[62]]=_0xcaa9[63];_0x392fx1f[_0xcaa9[69]]()[_0xcaa9[51]](function(_0x392fx20){var _0x392fx21=jwt[_0xcaa9[68]]({id:_0x392fx20[_0xcaa9[64]]},config[_0xcaa9[66]][_0xcaa9[65]],{expiresIn:_0xcaa9[67]});return _0x392fxe[_0xcaa9[40]](201)[_0xcaa9[39]]({token:_0x392fx21});})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)});};exports[_0xcaa9[70]]=function(_0x392fxd,_0x392fxe,_0x392fxf){User[_0xcaa9[73]](_0x392fxd[_0xcaa9[72]][_0xcaa9[64]])[_0xcaa9[51]](function(_0x392fx20){if(_0x392fx20){return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx20)}else {return _0x392fxe[_0xcaa9[71]](404)}})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})};exports[_0xcaa9[74]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx22=_0x392fxd[_0xcaa9[72]][_0xcaa9[64]];User[_0xcaa9[73]](_0x392fx22)[_0xcaa9[51]](function(_0x392fx20){if(_0x392fx20){_0x392fx20[_0xcaa9[74]]()[_0xcaa9[51]](function(_0x392fx20){console[_0xcaa9[75]](_0x392fx20);return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx20);})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})}else {return _0x392fxe[_0xcaa9[71]](404)}})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)});};exports[_0xcaa9[76]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx22=_0x392fxd[_0xcaa9[23]][_0xcaa9[64]];var _0x392fx23=String(_0x392fxd[_0xcaa9[57]][_0xcaa9[77]]);var _0x392fx24=String(_0x392fxd[_0xcaa9[57]][_0xcaa9[78]]);User[_0xcaa9[73]](_0x392fx22)[_0xcaa9[51]](function(_0x392fx20){if(_0x392fx20[_0xcaa9[79]](_0x392fx23)){_0x392fx20[_0xcaa9[80]]=_0x392fx24;_0x392fx20[_0xcaa9[69]]()[_0xcaa9[51]](function(){return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx20)})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)});}else {return _0x392fxe[_0xcaa9[71]](403)}});};exports[_0xcaa9[81]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx24=String(_0x392fxd[_0xcaa9[57]][_0xcaa9[78]]);User[_0xcaa9[73]](_0x392fxd[_0xcaa9[72]][_0xcaa9[64]])[_0xcaa9[51]](function(_0x392fx20){_0x392fx20[_0xcaa9[80]]=_0x392fx24;_0x392fx20[_0xcaa9[69]]()[_0xcaa9[51]](function(){return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx20)})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)});});};exports[_0xcaa9[82]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx25= new uploadFile({dest:path[_0xcaa9[87]](config[_0xcaa9[83]],_0xcaa9[84],_0xcaa9[85],_0xcaa9[86]),maxNumberOfFiles:1,minNumberOfFiles:0,acceptFileTypes:/(\.|\/)(jpeg|png)$/i,rename:function(_0x392fx26,_0x392fx27){return sr()+path[_0xcaa9[89]](_0x392fx27[_0xcaa9[88]])},messages:{maxNumberOfFiles:_0xcaa9[90],acceptFileTypes:_0xcaa9[91],invalidRequest:_0xcaa9[92]}});_0x392fx25[_0xcaa9[96]](_0xcaa9[93],function(_0x392fx28,_0x392fx29){if(!_0x392fx29[_0xcaa9[94]][_0xcaa9[88]]){return _0x392fxe[_0xcaa9[40]](500)[_0xcaa9[39]](_0x392fx25)}else {User[_0xcaa9[73]](_0x392fxd[_0xcaa9[72]][_0xcaa9[64]])[_0xcaa9[51]](function(_0x392fx20){if(_0x392fx20){_0x392fx20[_0xcaa9[95]]({userpic:_0x392fx29[_0xcaa9[94]][_0xcaa9[88]]})[_0xcaa9[51]](function(){return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx20)})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})}else {return _0x392fxe[_0xcaa9[71]](404)}})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})}});_0x392fx25[_0xcaa9[96]](_0xcaa9[97],function(_0x392fx18){console[_0xcaa9[75]](_0xcaa9[98],_0x392fx18);return handleError(_0x392fxe,_0x392fx18);});_0x392fx25[_0xcaa9[99]](_0x392fxd);};exports[_0xcaa9[100]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx22=_0x392fxd[_0xcaa9[23]][_0xcaa9[64]];User[_0xcaa9[102]]({where:{id:_0x392fx22},attributes:[_0xcaa9[64],_0xcaa9[15],_0xcaa9[16],_0xcaa9[17],_0xcaa9[18],_0xcaa9[101]],include:[Module]})[_0xcaa9[51]](function(_0x392fx20){if(!_0x392fx20){return _0x392fxe[_0xcaa9[71]](401)};return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx20);})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)});};exports[_0xcaa9[103]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx22=_0x392fxd[_0xcaa9[23]][_0xcaa9[64]];User[_0xcaa9[73]](_0x392fxd[_0xcaa9[72]][_0xcaa9[64]])[_0xcaa9[51]](function(_0x392fx20){if(_0x392fx20){_0x392fx20[_0xcaa9[95]](_0x392fxd[_0xcaa9[57]])[_0xcaa9[51]](function(_0x392fx20){return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]](_0x392fx20)})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})}else {return _0x392fxe[_0xcaa9[71]](500)}})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)});};exports[_0xcaa9[104]]=function(_0x392fxd,_0x392fxe,_0x392fxf){var _0x392fx2a=path[_0xcaa9[87]](config[_0xcaa9[83]],_0xcaa9[84],_0xcaa9[85],_0xcaa9[86],_0x392fxd[_0xcaa9[72]][_0xcaa9[88]]);fs[_0xcaa9[107]](_0x392fx2a,function(_0x392fx2b){if(!_0x392fx2b){_0x392fx2a=path[_0xcaa9[87]](config[_0xcaa9[83]],_0xcaa9[84],_0xcaa9[85],_0xcaa9[86],_0xcaa9[105])};return _0x392fxe[_0xcaa9[106]](_0x392fx2a);});};exports[_0xcaa9[108]]=function(_0x392fxd,_0x392fxe,_0x392fxf){if(_0x392fxd[_0xcaa9[72]][_0xcaa9[64]]===_0xcaa9[109]){var _0x392fx2a=path[_0xcaa9[87]](config[_0xcaa9[83]],_0xcaa9[84],_0xcaa9[85],_0xcaa9[86],_0xcaa9[110]);fs[_0xcaa9[107]](_0x392fx2a,function(_0x392fx2b){return _0x392fxe[_0xcaa9[106]](_0x392fx2a)});}else {User[_0xcaa9[73]](_0x392fxd[_0xcaa9[72]][_0xcaa9[64]])[_0xcaa9[51]](function(_0x392fx20){if(_0x392fx20){var _0x392fx2a=path[_0xcaa9[87]](config[_0xcaa9[83]],_0xcaa9[84],_0xcaa9[85],_0xcaa9[86],_0x392fx20[_0xcaa9[101]]?_0x392fx20[_0xcaa9[101]]:_0xcaa9[105]);fs[_0xcaa9[107]](_0x392fx2a,function(_0x392fx2b){if(!_0x392fx2b){_0x392fx2a=path[_0xcaa9[87]](config[_0xcaa9[83]],_0xcaa9[84],_0xcaa9[85],_0xcaa9[86],_0xcaa9[105])};return _0x392fxe[_0xcaa9[106]](_0x392fx2a);});}else {return _0x392fxe[_0xcaa9[71]](500)}})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})}};exports[_0xcaa9[111]]=function(_0x392fxd,_0x392fxe){User[_0xcaa9[74]]({where:{id:_0x392fxd[_0xcaa9[20]][_0xcaa9[64]]},individualHooks:true})[_0xcaa9[51]](function(){return _0x392fxe[_0xcaa9[71]](204)})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)})};exports[_0xcaa9[112]]=function(_0x392fxd,_0x392fxe){var _0x392fx2c={};_0x392fx2c[_0x392fxd[_0xcaa9[72]][_0xcaa9[113]]]=_0x392fxd[_0xcaa9[57]][_0xcaa9[114]];User[_0xcaa9[52]]({where:_0x392fx2c})[_0xcaa9[51]](function(_0x392fx19){if(_0x392fx19[_0xcaa9[42]]){return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]]({isValid:false,value:_0x392fxd[_0xcaa9[57]][_0xcaa9[114]]})};return _0x392fxe[_0xcaa9[40]](200)[_0xcaa9[39]]({isValid:true,value:_0x392fxd[_0xcaa9[57]][_0xcaa9[114]]});})[_0xcaa9[41]](function(_0x392fx18){return handleError(_0x392fxe,_0x392fx18)});};exports[_0xcaa9[115]]=function(_0x392fxd,_0x392fxe,_0x392fxf){_0x392fxe[_0xcaa9[117]](_0xcaa9[116])};function handleError(_0x392fxe,_0x392fx18){return _0x392fxe[_0xcaa9[40]](500)[_0xcaa9[39]](_0x392fx18)} \ No newline at end of file diff --git a/server/api/user/user.socket.js b/server/api/user/user.socket.js index e1071aa..db81dd7 100644 --- a/server/api/user/user.socket.js +++ b/server/api/user/user.socket.js @@ -1,31 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var user = require('../../models').User; - -exports.register = function(socket) { - user.afterCreate(function(doc) { - onSave(socket, doc); - }); - user.afterUpdate(function(doc) { - onSave(socket, doc); - }); - user.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - if (doc.role === 'admin') { - socket.emit('user:save', doc); - } -} - -function onRemove(socket, doc, cb) { - if (doc.role === 'admin') { - socket.emit('user:remove', doc); - } -} +var _0x50a1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x72\x6F\x6C\x65","\x61\x64\x6D\x69\x6E","\x75\x73\x65\x72\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x75\x73\x65\x72\x3A\x72\x65\x6D\x6F\x76\x65"];_0x50a1[0];var user=require(_0x50a1[2])[_0x50a1[1]];exports[_0x50a1[3]]=function(_0xdef2x2){user[_0x50a1[4]](function(_0xdef2x3){onSave(_0xdef2x2,_0xdef2x3)});user[_0x50a1[5]](function(_0xdef2x3){onSave(_0xdef2x2,_0xdef2x3)});user[_0x50a1[6]](function(_0xdef2x3){onRemove(_0xdef2x2,_0xdef2x3)});};function onSave(_0xdef2x2,_0xdef2x3,_0xdef2x5){if(_0xdef2x3[_0x50a1[7]]===_0x50a1[8]){_0xdef2x2[_0x50a1[10]](_0x50a1[9],_0xdef2x3)}}function onRemove(_0xdef2x2,_0xdef2x3,_0xdef2x5){if(_0xdef2x3[_0x50a1[7]]===_0x50a1[8]){_0xdef2x2[_0x50a1[10]](_0x50a1[11],_0xdef2x3)}} \ No newline at end of file diff --git a/server/api/user/user.spec.js b/server/api/user/user.spec.js index 485dee1..47de0aa 100644 --- a/server/api/user/user.spec.js +++ b/server/api/user/user.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/users', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/users') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x13f4=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x73","\x67\x65\x74"];_0x13f4[0];var should=require(_0x13f4[1]);var app=require(_0x13f4[2]);var request=require(_0x13f4[3]);describe(_0x13f4[4],function(){it(_0x13f4[5],function(_0xa456x4){request(app)[_0x13f4[13]](_0x13f4[12])[_0x13f4[11]](200)[_0x13f4[11]](_0x13f4[10],/json/)[_0x13f4[9]](function(_0xa456x5,_0xa456x6){if(_0xa456x5){return _0xa456x4(_0xa456x5)};_0xa456x6[_0x13f4[8]][_0x13f4[1]][_0x13f4[7]][_0x13f4[6]](Array);_0xa456x4();})})}); \ No newline at end of file diff --git a/server/api/user_has_chat_queue/index.js b/server/api/user_has_chat_queue/index.js index bce94e7..ed71915 100644 --- a/server/api/user_has_chat_queue/index.js +++ b/server/api/user_has_chat_queue/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./user_has_chat_queue.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xa02b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xa02b[0];var express=require(_0xa02b[1]);var controller=require(_0xa02b[2]);var router=express.Router();router[_0xa02b[5]](_0xa02b[3],controller[_0xa02b[4]]);router[_0xa02b[5]](_0xa02b[6],controller[_0xa02b[7]]);router[_0xa02b[9]](_0xa02b[3],controller[_0xa02b[8]]);router[_0xa02b[11]](_0xa02b[6],controller[_0xa02b[10]]);router[_0xa02b[12]](_0xa02b[6],controller[_0xa02b[10]]);router[_0xa02b[14]](_0xa02b[6],controller[_0xa02b[13]]);module[_0xa02b[15]]=router; \ No newline at end of file diff --git a/server/api/user_has_chat_queue/user_has_chat_queue.controller.js b/server/api/user_has_chat_queue/user_has_chat_queue.controller.js index b399892..f7c88d6 100644 --- a/server/api/user_has_chat_queue/user_has_chat_queue.controller.js +++ b/server/api/user_has_chat_queue/user_has_chat_queue.controller.js @@ -1,103 +1 @@ -'use strict'; - -var _ = require('lodash'); -var UserHasChatQueue = require('../../models').UserHasChatQueue; - -// Get list of userHasChatQueues -exports.index = function(req, res) { - UserHasChatQueue - .findAll(req.query ? { - where: req.query - } : {}) - .then(function(userHasChatQueues) { - return res.status(200).send(userHasChatQueues); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single userHasChatQueue -exports.show = function(req, res) { - UserHasChatQueue - .findById(req.params.id) - .then(function(userHasChatQueue) { - if (!userHasChatQueue) { - return res.sendStatus(404); - } - return res.send(userHasChatQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new userHasChatQueue in the DB. -exports.create = function(req, res) { - UserHasChatQueue - .create(req.body) - .then(function(userHasChatQueue) { - return res.status(201).send(userHasChatQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing userHasChatQueue in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - UserHasChatQueue - .find({ - where: { - id: req.params.id - } - }) - .then(function(userHasChatQueue) { - if (!userHasChatQueue) { - return res.sendStatus(404); - } - var updated = _.merge(userHasChatQueue, req.body); - updated.save() - .then(function() { - return res.status(200).send(userHasChatQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a userHasChatQueue from the DB. -exports.destroy = function(req, res) { - UserHasChatQueue - .find({ - where: { - id: req.params.id - } - }) - .then(function(userHasChatQueue) { - if (!userHasChatQueue) { - return res.sendStatus(404); - } - userHasChatQueue.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x377a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x377a[0];var _=require(_0x377a[1]);var UserHasChatQueue=require(_0x377a[3])[_0x377a[2]];exports[_0x377a[4]]=function(_0x4d93x3,_0x4d93x4){UserHasChatQueue[_0x377a[10]](_0x4d93x3[_0x377a[9]]?{where:_0x4d93x3[_0x377a[9]]}:{})[_0x377a[8]](function(_0x4d93x6){return _0x4d93x4[_0x377a[7]](200)[_0x377a[6]](_0x4d93x6)})[_0x377a[5]](function(_0x4d93x5){return handleError(_0x4d93x4,_0x4d93x5)})};exports[_0x377a[11]]=function(_0x4d93x3,_0x4d93x4){UserHasChatQueue[_0x377a[15]](_0x4d93x3[_0x377a[14]][_0x377a[13]])[_0x377a[8]](function(_0x4d93x7){if(!_0x4d93x7){return _0x4d93x4[_0x377a[12]](404)};return _0x4d93x4[_0x377a[6]](_0x4d93x7);})[_0x377a[5]](function(_0x4d93x5){return handleError(_0x4d93x4,_0x4d93x5)})};exports[_0x377a[16]]=function(_0x4d93x3,_0x4d93x4){UserHasChatQueue[_0x377a[16]](_0x4d93x3[_0x377a[17]])[_0x377a[8]](function(_0x4d93x7){return _0x4d93x4[_0x377a[7]](201)[_0x377a[6]](_0x4d93x7)})[_0x377a[5]](function(_0x4d93x5){return handleError(_0x4d93x4,_0x4d93x5)})};exports[_0x377a[18]]=function(_0x4d93x3,_0x4d93x4){if(_0x4d93x3[_0x377a[17]][_0x377a[13]]){delete _0x4d93x3[_0x377a[17]][_0x377a[13]]};UserHasChatQueue[_0x377a[21]]({where:{id:_0x4d93x3[_0x377a[14]][_0x377a[13]]}})[_0x377a[8]](function(_0x4d93x7){if(!_0x4d93x7){return _0x4d93x4[_0x377a[12]](404)};var _0x4d93x8=_[_0x377a[19]](_0x4d93x7,_0x4d93x3[_0x377a[17]]);_0x4d93x8[_0x377a[20]]()[_0x377a[8]](function(){return _0x4d93x4[_0x377a[7]](200)[_0x377a[6]](_0x4d93x7)})[_0x377a[5]](function(_0x4d93x5){return handleError(_0x4d93x4,_0x4d93x5)});})[_0x377a[5]](function(_0x4d93x5){return handleError(_0x4d93x4,_0x4d93x5)});};exports[_0x377a[22]]=function(_0x4d93x3,_0x4d93x4){UserHasChatQueue[_0x377a[21]]({where:{id:_0x4d93x3[_0x377a[14]][_0x377a[13]]}})[_0x377a[8]](function(_0x4d93x7){if(!_0x4d93x7){return _0x4d93x4[_0x377a[12]](404)};_0x4d93x7[_0x377a[22]]()[_0x377a[8]](function(){return _0x4d93x4[_0x377a[12]](204)})[_0x377a[5]](function(_0x4d93x5){return handleError(_0x4d93x4,_0x4d93x5)});})[_0x377a[5]](function(_0x4d93x5){return handleError(_0x4d93x4,_0x4d93x5)})};function handleError(_0x4d93x4,_0x4d93x5){return _0x4d93x4[_0x377a[7]](500)[_0x377a[6]](_0x4d93x5)} \ No newline at end of file diff --git a/server/api/user_has_chat_queue/user_has_chat_queue.socket.js b/server/api/user_has_chat_queue/user_has_chat_queue.socket.js index d760d5e..062ddb9 100644 --- a/server/api/user_has_chat_queue/user_has_chat_queue.socket.js +++ b/server/api/user_has_chat_queue/user_has_chat_queue.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var UserHasChatQueue = require('../../models').UserHasChatQueue; - -exports.register = function(socket) { - UserHasChatQueue.afterCreate(function (doc) { - onSave(socket, doc); - }); - UserHasChatQueue.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('user_has_chat_queue:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('user_has_chat_queue:remove', doc); -} +var _0x7430=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x7430[0];var UserHasChatQueue=require(_0x7430[2])[_0x7430[1]];exports[_0x7430[3]]=function(_0x6726x2){UserHasChatQueue[_0x7430[4]](function(_0x6726x3){onSave(_0x6726x2,_0x6726x3)});UserHasChatQueue[_0x7430[5]](function(_0x6726x3){onRemove(_0x6726x2,_0x6726x3)});};function onSave(_0x6726x2,_0x6726x3,_0x6726x5){_0x6726x2[_0x7430[7]](_0x7430[6],_0x6726x3)}function onRemove(_0x6726x2,_0x6726x3,_0x6726x5){_0x6726x2[_0x7430[7]](_0x7430[8],_0x6726x3)} \ No newline at end of file diff --git a/server/api/user_has_chat_queue/user_has_chat_queue.spec.js b/server/api/user_has_chat_queue/user_has_chat_queue.spec.js index 539163a..051c996 100644 --- a/server/api/user_has_chat_queue/user_has_chat_queue.spec.js +++ b/server/api/user_has_chat_queue/user_has_chat_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/user_has_queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/user_has_queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xf937=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0xf937[0];var should=require(_0xf937[1]);var app=require(_0xf937[2]);var request=require(_0xf937[3]);describe(_0xf937[4],function(){it(_0xf937[5],function(_0x1cc7x4){request(app)[_0xf937[13]](_0xf937[12])[_0xf937[11]](200)[_0xf937[11]](_0xf937[10],/json/)[_0xf937[9]](function(_0x1cc7x5,_0x1cc7x6){if(_0x1cc7x5){return _0x1cc7x4(_0x1cc7x5)};_0x1cc7x6[_0xf937[8]][_0xf937[1]][_0xf937[7]][_0xf937[6]](Array);_0x1cc7x4();})})}); \ No newline at end of file diff --git a/server/api/user_has_chat_room/index.js b/server/api/user_has_chat_room/index.js index 381448d..336789e 100644 --- a/server/api/user_has_chat_room/index.js +++ b/server/api/user_has_chat_room/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./user_has_chat_room.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -// router.get('/', controller.index); -// router.get('/:id', controller.show); -// router.post('/', controller.create); -router.put('/:userId/:chatRoomId', controller.update); -// router.patch('/:id', controller.update); -// router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x6d44=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F\x3A\x75\x73\x65\x72\x49\x64\x2F\x3A\x63\x68\x61\x74\x52\x6F\x6F\x6D\x49\x64","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x65\x78\x70\x6F\x72\x74\x73"];_0x6d44[0];var express=require(_0x6d44[1]);var controller=require(_0x6d44[2]);var auth=require(_0x6d44[3]);var router=express.Router();router[_0x6d44[6]](_0x6d44[4],controller[_0x6d44[5]]);module[_0x6d44[7]]=router; \ No newline at end of file diff --git a/server/api/user_has_chat_room/user_has_chat_room.controller.js b/server/api/user_has_chat_room/user_has_chat_room.controller.js index d747380..fdf190d 100644 --- a/server/api/user_has_chat_room/user_has_chat_room.controller.js +++ b/server/api/user_has_chat_room/user_has_chat_room.controller.js @@ -1,96 +1 @@ -'use strict'; - -var _ = require('lodash'); -var UserHasChatRoom = require('../../models').UserHasChatRoom; - -// Get list of user_has_chat_rooms -exports.index = function(req, res) { - UserHasChatRoom - .findAll() - .then(function (user_has_chat_rooms) { - return res.status(200).send(user_has_chat_rooms); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single user_has_chat_room -exports.show = function(req, res) { - UserHasChatRoom - .findById(req.params.id) - .then(function (user_has_chat_room) { - if(!user_has_chat_room) { return res.sendStatus(404); } - return res.send(user_has_chat_room); - }) - .catch(function(err){ - return handleError(res, err); - }); -}; - -// Creates a new user_has_chat_room in the DB. -exports.create = function(req, res) { - - UserHasChatRoom - .create(req.body) - .then(function(user_has_chat_room) { - return res.status(201).send(user_has_chat_room); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing user_has_chat_room in the DB. -exports.update = function(req, res) { - - UserHasChatRoom - .findOne({ - where: { - UserId: req.params.userId, - ChatRoomId: req.params.chatRoomId - }, - limit: 1 - }) - .then(function (user_has_chat_room) { - if (!user_has_chat_room) { - return res.sendStatus(404); - } - - user_has_chat_room - .updateAttributes(req.body) - .then(function () { - return res.status(200).send(user_has_chat_room); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a user_has_chat_room from the DB. -exports.destroy = function(req, res) { - - UserHasChatRoom - .findById(req.params.id) - .then(function (user_has_chat_room) { - if(!user_has_chat_room) { return res.sendStatus(404); } - user_has_chat_room.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x5784=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x75\x73\x65\x72\x49\x64","\x63\x68\x61\x74\x52\x6F\x6F\x6D\x49\x64","\x66\x69\x6E\x64\x4F\x6E\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x5784[0];var _=require(_0x5784[1]);var UserHasChatRoom=require(_0x5784[3])[_0x5784[2]];exports[_0x5784[4]]=function(_0x29ddx3,_0x29ddx4){UserHasChatRoom[_0x5784[9]]()[_0x5784[8]](function(_0x29ddx6){return _0x29ddx4[_0x5784[7]](200)[_0x5784[6]](_0x29ddx6)})[_0x5784[5]](function(_0x29ddx5){return handleError(_0x29ddx4,_0x29ddx5)})};exports[_0x5784[10]]=function(_0x29ddx3,_0x29ddx4){UserHasChatRoom[_0x5784[14]](_0x29ddx3[_0x5784[13]][_0x5784[12]])[_0x5784[8]](function(_0x29ddx7){if(!_0x29ddx7){return _0x29ddx4[_0x5784[11]](404)};return _0x29ddx4[_0x5784[6]](_0x29ddx7);})[_0x5784[5]](function(_0x29ddx5){return handleError(_0x29ddx4,_0x29ddx5)})};exports[_0x5784[15]]=function(_0x29ddx3,_0x29ddx4){UserHasChatRoom[_0x5784[15]](_0x29ddx3[_0x5784[16]])[_0x5784[8]](function(_0x29ddx7){return _0x29ddx4[_0x5784[7]](201)[_0x5784[6]](_0x29ddx7)})[_0x5784[5]](function(_0x29ddx5){return handleError(_0x29ddx4,_0x29ddx5)})};exports[_0x5784[17]]=function(_0x29ddx3,_0x29ddx4){UserHasChatRoom[_0x5784[21]]({where:{UserId:_0x29ddx3[_0x5784[13]][_0x5784[19]],ChatRoomId:_0x29ddx3[_0x5784[13]][_0x5784[20]]},limit:1})[_0x5784[8]](function(_0x29ddx7){if(!_0x29ddx7){return _0x29ddx4[_0x5784[11]](404)};_0x29ddx7[_0x5784[18]](_0x29ddx3[_0x5784[16]])[_0x5784[8]](function(){return _0x29ddx4[_0x5784[7]](200)[_0x5784[6]](_0x29ddx7)})[_0x5784[5]](function(_0x29ddx5){return handleError(_0x29ddx4,_0x29ddx5)});})[_0x5784[5]](function(_0x29ddx5){return handleError(_0x29ddx4,_0x29ddx5)})};exports[_0x5784[22]]=function(_0x29ddx3,_0x29ddx4){UserHasChatRoom[_0x5784[14]](_0x29ddx3[_0x5784[13]][_0x5784[12]])[_0x5784[8]](function(_0x29ddx7){if(!_0x29ddx7){return _0x29ddx4[_0x5784[11]](404)};_0x29ddx7[_0x5784[22]]()[_0x5784[8]](function(){return _0x29ddx4[_0x5784[11]](204)})[_0x5784[5]](function(_0x29ddx5){return handleError(_0x29ddx4,_0x29ddx5)});})[_0x5784[5]](function(_0x29ddx5){return handleError(_0x29ddx4,_0x29ddx5)})};function handleError(_0x29ddx4,_0x29ddx5){return _0x29ddx4[_0x5784[7]](500)[_0x5784[6]](_0x29ddx5)} \ No newline at end of file diff --git a/server/api/user_has_chat_room/user_has_chat_room.socket.js b/server/api/user_has_chat_room/user_has_chat_room.socket.js index c58a829..c7f7af6 100644 --- a/server/api/user_has_chat_room/user_has_chat_room.socket.js +++ b/server/api/user_has_chat_room/user_has_chat_room.socket.js @@ -1,58 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; -var _ = require('lodash'); -var User = require('../../models').User; -var ChatRoom = require('../../models').ChatRoom; -var ChatVisitor = require('../../models').ChatVisitor; -var UserHasChatRoom = require('../../models').UserHasChatRoom; - -exports.register = function (socket) { - UserHasChatRoom.afterCreate(function (doc) { - onSave(socket, doc); - }); - UserHasChatRoom.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc) { - - var _chatRoom; - - return ChatRoom - .findById(doc.ChatRoomId, { - include: [{ - model: ChatVisitor, - attributes: ['id', 'email', 'fullname'] - }, { - model: User, - attributes: ['id', 'email', 'name', 'fullname'] - }] - }) - .then(function (chatRoom) { - _chatRoom = chatRoom; - _chatRoom.dataValues.ChatMessages = []; - - console.log('_chatRoom', _chatRoom); - - var ids = _.pluck(_chatRoom.Users, 'id'); - - ids.forEach(function (id) { - if (socket.userId == id) { - socket.emit('user_has_chat_room:save', _chatRoom.dataValues) - } - }); - - return; - }) - .catch(function (err) { - console.error(err); - }); -} - -function onRemove(socket, doc) { - socket.emit('user_has_chat_room:remove', doc); -} +var _0x3185=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65\x73","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x5F\x63\x68\x61\x74\x52\x6F\x6F\x6D","\x6C\x6F\x67","\x69\x64","\x70\x6C\x75\x63\x6B","\x75\x73\x65\x72\x49\x64","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x66\x6F\x72\x45\x61\x63\x68","\x74\x68\x65\x6E","\x65\x6D\x61\x69\x6C","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x3A\x72\x65\x6D\x6F\x76\x65"];_0x3185[0];var _=require(_0x3185[1]);var User=require(_0x3185[3])[_0x3185[2]];var ChatRoom=require(_0x3185[3])[_0x3185[4]];var ChatVisitor=require(_0x3185[3])[_0x3185[5]];var UserHasChatRoom=require(_0x3185[3])[_0x3185[6]];exports[_0x3185[7]]=function(_0xadbcx6){UserHasChatRoom[_0x3185[8]](function(_0xadbcx7){onSave(_0xadbcx6,_0xadbcx7)});UserHasChatRoom[_0x3185[9]](function(_0xadbcx7){onRemove(_0xadbcx6,_0xadbcx7)});};function onSave(_0xadbcx6,_0xadbcx7){var _0xadbcx9;return ChatRoom[_0x3185[26]](_0xadbcx7.ChatRoomId,{include:[{model:ChatVisitor,attributes:[_0x3185[16],_0x3185[23],_0x3185[24]]},{model:User,attributes:[_0x3185[16],_0x3185[23],_0x3185[25],_0x3185[24]]}]})[_0x3185[22]](function(_0xadbcxb){_0xadbcx9=_0xadbcxb;_0xadbcx9[_0x3185[13]][_0x3185[12]]=[];console[_0x3185[15]](_0x3185[14],_0xadbcx9);var _0xadbcxc=_[_0x3185[17]](_0xadbcx9.Users,_0x3185[16]);_0xadbcxc[_0x3185[21]](function(_0xadbcxd){if(_0xadbcx6[_0x3185[18]]==_0xadbcxd){_0xadbcx6[_0x3185[20]](_0x3185[19],_0xadbcx9[_0x3185[13]])}});return ;})[_0x3185[11]](function(_0xadbcxa){console[_0x3185[10]](_0xadbcxa)});}function onRemove(_0xadbcx6,_0xadbcx7){_0xadbcx6[_0x3185[20]](_0x3185[27],_0xadbcx7)} \ No newline at end of file diff --git a/server/api/user_has_chat_room/user_has_chat_room.spec.js b/server/api/user_has_chat_room/user_has_chat_room.spec.js index b33382a..a45ca65 100644 --- a/server/api/user_has_chat_room/user_has_chat_room.spec.js +++ b/server/api/user_has_chat_room/user_has_chat_room.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/chat/user_has_rooms', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/chat/user_has_rooms') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x5996=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x72\x6F\x6F\x6D\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x72\x6F\x6F\x6D\x73","\x67\x65\x74"];_0x5996[0];var should=require(_0x5996[1]);var app=require(_0x5996[2]);var request=require(_0x5996[3]);describe(_0x5996[4],function(){it(_0x5996[5],function(_0x9d40x4){request(app)[_0x5996[13]](_0x5996[12])[_0x5996[11]](200)[_0x5996[11]](_0x5996[10],/json/)[_0x5996[9]](function(_0x9d40x5,_0x9d40x6){if(_0x9d40x5){return _0x9d40x4(_0x9d40x5)};_0x9d40x6[_0x5996[8]][_0x5996[1]][_0x5996[7]][_0x5996[6]](Array);_0x9d40x4();})})}); \ No newline at end of file diff --git a/server/api/user_has_fax_queue/index.js b/server/api/user_has_fax_queue/index.js index 5805e3d..ef6e636 100644 --- a/server/api/user_has_fax_queue/index.js +++ b/server/api/user_has_fax_queue/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./user_has_fax_queue.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x5564=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x5564[0];var express=require(_0x5564[1]);var controller=require(_0x5564[2]);var router=express.Router();router[_0x5564[5]](_0x5564[3],controller[_0x5564[4]]);router[_0x5564[5]](_0x5564[6],controller[_0x5564[7]]);router[_0x5564[9]](_0x5564[3],controller[_0x5564[8]]);router[_0x5564[11]](_0x5564[6],controller[_0x5564[10]]);router[_0x5564[12]](_0x5564[6],controller[_0x5564[10]]);router[_0x5564[14]](_0x5564[6],controller[_0x5564[13]]);module[_0x5564[15]]=router; \ No newline at end of file diff --git a/server/api/user_has_fax_queue/user_has_fax_queue.controller.js b/server/api/user_has_fax_queue/user_has_fax_queue.controller.js index f92e570..3c02222 100644 --- a/server/api/user_has_fax_queue/user_has_fax_queue.controller.js +++ b/server/api/user_has_fax_queue/user_has_fax_queue.controller.js @@ -1,103 +1 @@ -'use strict'; - -var _ = require('lodash'); -var UserHasFaxQueue = require('../../models').UserHasFaxQueue; - -// Get list of user_has_fax_queues -exports.index = function(req, res) { - UserHasFaxQueue - .findAll(req.query ? { - where: req.query - } : {}) - .then(function(user_has_fax_queues) { - return res.status(200).send(user_has_fax_queues); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single user_has_fax_queue -exports.show = function(req, res) { - UserHasFaxQueue - .findById(req.params.id) - .then(function(user_has_fax_queue) { - if (!user_has_fax_queue) { - return res.sendStatus(404); - } - return res.send(user_has_fax_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new user_has_fax_queue in the DB. -exports.create = function(req, res) { - UserHasFaxQueue - .create(req.body) - .then(function(user_has_fax_queue) { - return res.status(201).send(user_has_fax_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing user_has_fax_queue in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - UserHasFaxQueue - .find({ - where: { - id: req.params.id - } - }) - .then(function(user_has_fax_queue) { - if (!user_has_fax_queue) { - return res.sendStatus(404); - } - var updated = _.merge(user_has_fax_queue, req.body); - updated.save() - .then(function() { - return res.status(200).send(user_has_fax_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a user_has_fax_queue from the DB. -exports.destroy = function(req, res) { - UserHasFaxQueue - .find({ - where: { - id: req.params.id - } - }) - .then(function(user_has_fax_queue) { - if (!user_has_fax_queue) { - return res.sendStatus(404); - } - user_has_fax_queue.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x99a9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x73\x65\x72\x48\x61\x73\x46\x61\x78\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0x99a9[0];var _=require(_0x99a9[1]);var UserHasFaxQueue=require(_0x99a9[3])[_0x99a9[2]];exports[_0x99a9[4]]=function(_0xdb0fx3,_0xdb0fx4){UserHasFaxQueue[_0x99a9[10]](_0xdb0fx3[_0x99a9[9]]?{where:_0xdb0fx3[_0x99a9[9]]}:{})[_0x99a9[8]](function(_0xdb0fx6){return _0xdb0fx4[_0x99a9[7]](200)[_0x99a9[6]](_0xdb0fx6)})[_0x99a9[5]](function(_0xdb0fx5){return handleError(_0xdb0fx4,_0xdb0fx5)})};exports[_0x99a9[11]]=function(_0xdb0fx3,_0xdb0fx4){UserHasFaxQueue[_0x99a9[15]](_0xdb0fx3[_0x99a9[14]][_0x99a9[13]])[_0x99a9[8]](function(_0xdb0fx7){if(!_0xdb0fx7){return _0xdb0fx4[_0x99a9[12]](404)};return _0xdb0fx4[_0x99a9[6]](_0xdb0fx7);})[_0x99a9[5]](function(_0xdb0fx5){return handleError(_0xdb0fx4,_0xdb0fx5)})};exports[_0x99a9[16]]=function(_0xdb0fx3,_0xdb0fx4){UserHasFaxQueue[_0x99a9[16]](_0xdb0fx3[_0x99a9[17]])[_0x99a9[8]](function(_0xdb0fx7){return _0xdb0fx4[_0x99a9[7]](201)[_0x99a9[6]](_0xdb0fx7)})[_0x99a9[5]](function(_0xdb0fx5){return handleError(_0xdb0fx4,_0xdb0fx5)})};exports[_0x99a9[18]]=function(_0xdb0fx3,_0xdb0fx4){if(_0xdb0fx3[_0x99a9[17]][_0x99a9[13]]){delete _0xdb0fx3[_0x99a9[17]][_0x99a9[13]]};UserHasFaxQueue[_0x99a9[21]]({where:{id:_0xdb0fx3[_0x99a9[14]][_0x99a9[13]]}})[_0x99a9[8]](function(_0xdb0fx7){if(!_0xdb0fx7){return _0xdb0fx4[_0x99a9[12]](404)};var _0xdb0fx8=_[_0x99a9[19]](_0xdb0fx7,_0xdb0fx3[_0x99a9[17]]);_0xdb0fx8[_0x99a9[20]]()[_0x99a9[8]](function(){return _0xdb0fx4[_0x99a9[7]](200)[_0x99a9[6]](_0xdb0fx7)})[_0x99a9[5]](function(_0xdb0fx5){return handleError(_0xdb0fx4,_0xdb0fx5)});})[_0x99a9[5]](function(_0xdb0fx5){return handleError(_0xdb0fx4,_0xdb0fx5)});};exports[_0x99a9[22]]=function(_0xdb0fx3,_0xdb0fx4){UserHasFaxQueue[_0x99a9[21]]({where:{id:_0xdb0fx3[_0x99a9[14]][_0x99a9[13]]}})[_0x99a9[8]](function(_0xdb0fx7){if(!_0xdb0fx7){return _0xdb0fx4[_0x99a9[12]](404)};_0xdb0fx7[_0x99a9[22]]()[_0x99a9[8]](function(){return _0xdb0fx4[_0x99a9[12]](204)})[_0x99a9[5]](function(_0xdb0fx5){return handleError(_0xdb0fx4,_0xdb0fx5)});})[_0x99a9[5]](function(_0xdb0fx5){return handleError(_0xdb0fx4,_0xdb0fx5)})};function handleError(_0xdb0fx4,_0xdb0fx5){return _0xdb0fx4[_0x99a9[7]](500)[_0x99a9[6]](_0xdb0fx5)} \ No newline at end of file diff --git a/server/api/user_has_fax_queue/user_has_fax_queue.socket.js b/server/api/user_has_fax_queue/user_has_fax_queue.socket.js index 4b0602a..a5222b7 100644 --- a/server/api/user_has_fax_queue/user_has_fax_queue.socket.js +++ b/server/api/user_has_fax_queue/user_has_fax_queue.socket.js @@ -1,30 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var UserHasFaxQueue = require('../../models').UserHasFaxQueue; - -exports.register = function(socket) { - UserHasFaxQueue.afterCreate(function(doc) { - onSave(socket, doc); - }); - UserHasFaxQueue.afterDestroy(function(doc) { - onRemove(socket, doc); - }); - UserHasFaxQueue.afterBulkCreate(function(doc) { - onSave(socket, doc); - }); - UserHasFaxQueue.afterBulkDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('user_has_fax_queue:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('user_has_fax_queue:remove', doc); -} +var _0xe51a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72\x48\x61\x73\x46\x61\x78\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x66\x74\x65\x72\x42\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x42\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0xe51a[0];var UserHasFaxQueue=require(_0xe51a[2])[_0xe51a[1]];exports[_0xe51a[3]]=function(_0xb378x2){UserHasFaxQueue[_0xe51a[4]](function(_0xb378x3){onSave(_0xb378x2,_0xb378x3)});UserHasFaxQueue[_0xe51a[5]](function(_0xb378x3){onRemove(_0xb378x2,_0xb378x3)});UserHasFaxQueue[_0xe51a[6]](function(_0xb378x3){onSave(_0xb378x2,_0xb378x3)});UserHasFaxQueue[_0xe51a[7]](function(_0xb378x3){onRemove(_0xb378x2,_0xb378x3)});};function onSave(_0xb378x2,_0xb378x3,_0xb378x5){_0xb378x2[_0xe51a[9]](_0xe51a[8],_0xb378x3)}function onRemove(_0xb378x2,_0xb378x3,_0xb378x5){_0xb378x2[_0xe51a[9]](_0xe51a[10],_0xb378x3)} \ No newline at end of file diff --git a/server/api/user_has_fax_queue/user_has_fax_queue.spec.js b/server/api/user_has_fax_queue/user_has_fax_queue.spec.js index 992672c..75ea7b2 100644 --- a/server/api/user_has_fax_queue/user_has_fax_queue.spec.js +++ b/server/api/user_has_fax_queue/user_has_fax_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/fax/user_has_queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/fax/user_has_queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x83f2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0x83f2[0];var should=require(_0x83f2[1]);var app=require(_0x83f2[2]);var request=require(_0x83f2[3]);describe(_0x83f2[4],function(){it(_0x83f2[5],function(_0xe29ex4){request(app)[_0x83f2[13]](_0x83f2[12])[_0x83f2[11]](200)[_0x83f2[11]](_0x83f2[10],/json/)[_0x83f2[9]](function(_0xe29ex5,_0xe29ex6){if(_0xe29ex5){return _0xe29ex4(_0xe29ex5)};_0xe29ex6[_0x83f2[8]][_0x83f2[1]][_0x83f2[7]][_0x83f2[6]](Array);_0xe29ex4();})})}); \ No newline at end of file diff --git a/server/api/user_has_mail_queue/index.js b/server/api/user_has_mail_queue/index.js index 50b083e..c2e1a29 100644 --- a/server/api/user_has_mail_queue/index.js +++ b/server/api/user_has_mail_queue/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./user_has_mail_queue.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xa741=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xa741[0];var express=require(_0xa741[1]);var controller=require(_0xa741[2]);var router=express.Router();router[_0xa741[5]](_0xa741[3],controller[_0xa741[4]]);router[_0xa741[5]](_0xa741[6],controller[_0xa741[7]]);router[_0xa741[9]](_0xa741[3],controller[_0xa741[8]]);router[_0xa741[11]](_0xa741[6],controller[_0xa741[10]]);router[_0xa741[12]](_0xa741[6],controller[_0xa741[10]]);router[_0xa741[14]](_0xa741[6],controller[_0xa741[13]]);module[_0xa741[15]]=router; \ No newline at end of file diff --git a/server/api/user_has_mail_queue/user_has_mail_queue.controller.js b/server/api/user_has_mail_queue/user_has_mail_queue.controller.js index c15bc9d..2606740 100644 --- a/server/api/user_has_mail_queue/user_has_mail_queue.controller.js +++ b/server/api/user_has_mail_queue/user_has_mail_queue.controller.js @@ -1,95 +1 @@ -'use strict'; - -var _ = require('lodash'); -var UserHasMailQueue = require('../../models').UserHasMailQueue; - -// Get list of user_has_mail_queues -exports.index = function(req, res) { - UserHasMailQueue - .findAll(req.query ? { - where: req.query - } : {}) - .then(function(user_has_mail_queues) { - return res.status(200).send(user_has_mail_queues); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single user_has_mail_queue -exports.show = function(req, res) { - UserHasMailQueue - .findById(req.params.id) - .then(function(user_has_mail_queue) { - if (!user_has_mail_queue) { - return res.sendStatus(404); - } - return res.send(user_has_mail_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new user_has_mail_queue in the DB. -exports.create = function(req, res) { - UserHasMailQueue - .create(req.body) - .then(function(user_has_mail_queue) { - return res.status(201).send(user_has_mail_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing user_has_mail_queue in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - UserHasMailQueue - .findById(req.params.id) - .then(function(user_has_mail_queue) { - if (!user_has_mail_queue) { - return res.sendStatus(404); - } - var updated = _.merge(user_has_mail_queue, req.body); - updated.save() - .then(function() { - return res.status(200).send(user_has_mail_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a user_has_mail_queue from the DB. -exports.destroy = function(req, res) { - UserHasMailQueue - .findById(req.params.id) - .then(function(user_has_mail_queue) { - if (!user_has_mail_queue) { - return res.sendStatus(404); - } - user_has_mail_queue.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x75e8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x73\x65\x72\x48\x61\x73\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x75e8[0];var _=require(_0x75e8[1]);var UserHasMailQueue=require(_0x75e8[3])[_0x75e8[2]];exports[_0x75e8[4]]=function(_0xde6dx3,_0xde6dx4){UserHasMailQueue[_0x75e8[10]](_0xde6dx3[_0x75e8[9]]?{where:_0xde6dx3[_0x75e8[9]]}:{})[_0x75e8[8]](function(_0xde6dx6){return _0xde6dx4[_0x75e8[7]](200)[_0x75e8[6]](_0xde6dx6)})[_0x75e8[5]](function(_0xde6dx5){return handleError(_0xde6dx4,_0xde6dx5)})};exports[_0x75e8[11]]=function(_0xde6dx3,_0xde6dx4){UserHasMailQueue[_0x75e8[15]](_0xde6dx3[_0x75e8[14]][_0x75e8[13]])[_0x75e8[8]](function(_0xde6dx7){if(!_0xde6dx7){return _0xde6dx4[_0x75e8[12]](404)};return _0xde6dx4[_0x75e8[6]](_0xde6dx7);})[_0x75e8[5]](function(_0xde6dx5){return handleError(_0xde6dx4,_0xde6dx5)})};exports[_0x75e8[16]]=function(_0xde6dx3,_0xde6dx4){UserHasMailQueue[_0x75e8[16]](_0xde6dx3[_0x75e8[17]])[_0x75e8[8]](function(_0xde6dx7){return _0xde6dx4[_0x75e8[7]](201)[_0x75e8[6]](_0xde6dx7)})[_0x75e8[5]](function(_0xde6dx5){return handleError(_0xde6dx4,_0xde6dx5)})};exports[_0x75e8[18]]=function(_0xde6dx3,_0xde6dx4){if(_0xde6dx3[_0x75e8[17]][_0x75e8[13]]){delete _0xde6dx3[_0x75e8[17]][_0x75e8[13]]};UserHasMailQueue[_0x75e8[15]](_0xde6dx3[_0x75e8[14]][_0x75e8[13]])[_0x75e8[8]](function(_0xde6dx7){if(!_0xde6dx7){return _0xde6dx4[_0x75e8[12]](404)};var _0xde6dx8=_[_0x75e8[19]](_0xde6dx7,_0xde6dx3[_0x75e8[17]]);_0xde6dx8[_0x75e8[20]]()[_0x75e8[8]](function(){return _0xde6dx4[_0x75e8[7]](200)[_0x75e8[6]](_0xde6dx7)})[_0x75e8[5]](function(_0xde6dx5){return handleError(_0xde6dx4,_0xde6dx5)});})[_0x75e8[5]](function(_0xde6dx5){return handleError(_0xde6dx4,_0xde6dx5)});};exports[_0x75e8[21]]=function(_0xde6dx3,_0xde6dx4){UserHasMailQueue[_0x75e8[15]](_0xde6dx3[_0x75e8[14]][_0x75e8[13]])[_0x75e8[8]](function(_0xde6dx7){if(!_0xde6dx7){return _0xde6dx4[_0x75e8[12]](404)};_0xde6dx7[_0x75e8[21]]()[_0x75e8[8]](function(){return _0xde6dx4[_0x75e8[12]](204)})[_0x75e8[5]](function(_0xde6dx5){return handleError(_0xde6dx4,_0xde6dx5)});})[_0x75e8[5]](function(_0xde6dx5){return handleError(_0xde6dx4,_0xde6dx5)})};function handleError(_0xde6dx4,_0xde6dx5){return _0xde6dx4[_0x75e8[7]](500)[_0x75e8[6]](_0xde6dx5)} \ No newline at end of file diff --git a/server/api/user_has_mail_queue/user_has_mail_queue.socket.js b/server/api/user_has_mail_queue/user_has_mail_queue.socket.js index bea513c..d95cb77 100644 --- a/server/api/user_has_mail_queue/user_has_mail_queue.socket.js +++ b/server/api/user_has_mail_queue/user_has_mail_queue.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var UserHasMailQueue = require('../../models').UserHasMailQueue; - -exports.register = function(socket) { - UserHasMailQueue.afterCreate(function(doc) { - onSave(socket, doc); - }); - UserHasMailQueue.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('user_has_mail_queue:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('user_has_mail_queue:remove', doc); -} +var _0x610a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72\x48\x61\x73\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x610a[0];var UserHasMailQueue=require(_0x610a[2])[_0x610a[1]];exports[_0x610a[3]]=function(_0x6935x2){UserHasMailQueue[_0x610a[4]](function(_0x6935x3){onSave(_0x6935x2,_0x6935x3)});UserHasMailQueue[_0x610a[5]](function(_0x6935x3){onRemove(_0x6935x2,_0x6935x3)});};function onSave(_0x6935x2,_0x6935x3,_0x6935x5){_0x6935x2[_0x610a[7]](_0x610a[6],_0x6935x3)}function onRemove(_0x6935x2,_0x6935x3,_0x6935x5){_0x6935x2[_0x610a[7]](_0x610a[8],_0x6935x3)} \ No newline at end of file diff --git a/server/api/user_has_mail_queue/user_has_mail_queue.spec.js b/server/api/user_has_mail_queue/user_has_mail_queue.spec.js index d516012..6a48f06 100644 --- a/server/api/user_has_mail_queue/user_has_mail_queue.spec.js +++ b/server/api/user_has_mail_queue/user_has_mail_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/mail/user_has_queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/mail/user_has_queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xb392=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0xb392[0];var should=require(_0xb392[1]);var app=require(_0xb392[2]);var request=require(_0xb392[3]);describe(_0xb392[4],function(){it(_0xb392[5],function(_0xf8b8x4){request(app)[_0xb392[13]](_0xb392[12])[_0xb392[11]](200)[_0xb392[11]](_0xb392[10],/json/)[_0xb392[9]](function(_0xf8b8x5,_0xf8b8x6){if(_0xf8b8x5){return _0xf8b8x4(_0xf8b8x5)};_0xf8b8x6[_0xb392[8]][_0xb392[1]][_0xb392[7]][_0xb392[6]](Array);_0xf8b8x4();})})}); \ No newline at end of file diff --git a/server/api/user_has_team/index.js b/server/api/user_has_team/index.js index 723bdc1..1d4d6ec 100644 --- a/server/api/user_has_team/index.js +++ b/server/api/user_has_team/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./user_has_team.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0x2026=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x2026[0];var express=require(_0x2026[1]);var controller=require(_0x2026[2]);var router=express.Router();router[_0x2026[5]](_0x2026[3],controller[_0x2026[4]]);router[_0x2026[5]](_0x2026[6],controller[_0x2026[7]]);router[_0x2026[9]](_0x2026[3],controller[_0x2026[8]]);router[_0x2026[11]](_0x2026[6],controller[_0x2026[10]]);router[_0x2026[12]](_0x2026[6],controller[_0x2026[10]]);router[_0x2026[14]](_0x2026[6],controller[_0x2026[13]]);module[_0x2026[15]]=router; \ No newline at end of file diff --git a/server/api/user_has_team/user_has_team.controller.js b/server/api/user_has_team/user_has_team.controller.js index 7f0f426..6d2be5f 100644 --- a/server/api/user_has_team/user_has_team.controller.js +++ b/server/api/user_has_team/user_has_team.controller.js @@ -1,96 +1 @@ -'use strict'; - -var _ = require('lodash'); -var UserHasTeam = require('../../models').UserHasTeam; - -// Get list of user_has_teams -exports.index = function(req, res) { - console.log(req.query); - UserHasTeam - .findAll({ - where: req.query - }) - .then(function(user_has_teams) { - return res.status(200).send(user_has_teams); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single user_has_team -exports.show = function(req, res) { - UserHasTeam - .findById(req.params.id) - .then(function(user_has_team) { - if (!user_has_team) { - return res.sendStatus(404); - } - return res.send(user_has_team); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new user_has_team in the DB. -exports.create = function(req, res) { - UserHasTeam - .create(req.body) - .then(function(user_has_team) { - return res.status(201).send(user_has_team); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing user_has_team in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - UserHasTeam - .findById(req.params.id) - .then(function(user_has_team) { - if (!user_has_team) { - return res.sendStatus(404); - } - var updated = _.merge(user_has_team, req.body); - updated.save() - .then(function() { - return res.status(200).send(user_has_team); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a user_has_team from the DB. -exports.destroy = function(req, res) { - UserHasTeam - .findById(req.params.id) - .then(function(user_has_team) { - if (!user_has_team) { - return res.sendStatus(404); - } - user_has_team.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x9a7b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x71\x75\x65\x72\x79","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x9a7b[0];var _=require(_0x9a7b[1]);var UserHasTeam=require(_0x9a7b[3])[_0x9a7b[2]];exports[_0x9a7b[4]]=function(_0x6d7bx3,_0x6d7bx4){console[_0x9a7b[6]](_0x6d7bx3[_0x9a7b[5]]);UserHasTeam[_0x9a7b[11]]({where:_0x6d7bx3[_0x9a7b[5]]})[_0x9a7b[10]](function(_0x6d7bx6){return _0x6d7bx4[_0x9a7b[9]](200)[_0x9a7b[8]](_0x6d7bx6)})[_0x9a7b[7]](function(_0x6d7bx5){return handleError(_0x6d7bx4,_0x6d7bx5)});};exports[_0x9a7b[12]]=function(_0x6d7bx3,_0x6d7bx4){UserHasTeam[_0x9a7b[16]](_0x6d7bx3[_0x9a7b[15]][_0x9a7b[14]])[_0x9a7b[10]](function(_0x6d7bx7){if(!_0x6d7bx7){return _0x6d7bx4[_0x9a7b[13]](404)};return _0x6d7bx4[_0x9a7b[8]](_0x6d7bx7);})[_0x9a7b[7]](function(_0x6d7bx5){return handleError(_0x6d7bx4,_0x6d7bx5)})};exports[_0x9a7b[17]]=function(_0x6d7bx3,_0x6d7bx4){UserHasTeam[_0x9a7b[17]](_0x6d7bx3[_0x9a7b[18]])[_0x9a7b[10]](function(_0x6d7bx7){return _0x6d7bx4[_0x9a7b[9]](201)[_0x9a7b[8]](_0x6d7bx7)})[_0x9a7b[7]](function(_0x6d7bx5){return handleError(_0x6d7bx4,_0x6d7bx5)})};exports[_0x9a7b[19]]=function(_0x6d7bx3,_0x6d7bx4){if(_0x6d7bx3[_0x9a7b[18]][_0x9a7b[14]]){delete _0x6d7bx3[_0x9a7b[18]][_0x9a7b[14]]};UserHasTeam[_0x9a7b[16]](_0x6d7bx3[_0x9a7b[15]][_0x9a7b[14]])[_0x9a7b[10]](function(_0x6d7bx7){if(!_0x6d7bx7){return _0x6d7bx4[_0x9a7b[13]](404)};var _0x6d7bx8=_[_0x9a7b[20]](_0x6d7bx7,_0x6d7bx3[_0x9a7b[18]]);_0x6d7bx8[_0x9a7b[21]]()[_0x9a7b[10]](function(){return _0x6d7bx4[_0x9a7b[9]](200)[_0x9a7b[8]](_0x6d7bx7)})[_0x9a7b[7]](function(_0x6d7bx5){return handleError(_0x6d7bx4,_0x6d7bx5)});})[_0x9a7b[7]](function(_0x6d7bx5){return handleError(_0x6d7bx4,_0x6d7bx5)});};exports[_0x9a7b[22]]=function(_0x6d7bx3,_0x6d7bx4){UserHasTeam[_0x9a7b[16]](_0x6d7bx3[_0x9a7b[15]][_0x9a7b[14]])[_0x9a7b[10]](function(_0x6d7bx7){if(!_0x6d7bx7){return _0x6d7bx4[_0x9a7b[13]](404)};_0x6d7bx7[_0x9a7b[22]]()[_0x9a7b[10]](function(){return _0x6d7bx4[_0x9a7b[13]](204)})[_0x9a7b[7]](function(_0x6d7bx5){return handleError(_0x6d7bx4,_0x6d7bx5)});})[_0x9a7b[7]](function(_0x6d7bx5){return handleError(_0x6d7bx4,_0x6d7bx5)})};function handleError(_0x6d7bx4,_0x6d7bx5){return _0x6d7bx4[_0x9a7b[9]](500)[_0x9a7b[8]](_0x6d7bx5)} \ No newline at end of file diff --git a/server/api/user_has_team/user_has_team.model.js b/server/api/user_has_team/user_has_team.model.js index 6d5861d..87afe73 100644 --- a/server/api/user_has_team/user_has_team.model.js +++ b/server/api/user_has_team/user_has_team.model.js @@ -1,13 +1 @@ -'use strict'; - -module.export = function(sequelize, DataTypes) { - - var UserHasTeam = sequelize.define('UserHasTeam', { - name: String, - info: String, - active: Boolean - }); - - return UserHasTeam; - -}; +var _0x2635=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x64\x65\x66\x69\x6E\x65"];_0x2635[0];module[_0x2635[1]]=function(_0xf339x1,_0xf339x2){var _0xf339x3=_0xf339x1[_0x2635[3]](_0x2635[2],{name:String,info:String,active:Boolean});return _0xf339x3;}; \ No newline at end of file diff --git a/server/api/user_has_team/user_has_team.socket.js b/server/api/user_has_team/user_has_team.socket.js index 879043c..6747225 100644 --- a/server/api/user_has_team/user_has_team.socket.js +++ b/server/api/user_has_team/user_has_team.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var user_has_team = require('../../models').UserHasTeam; - -exports.register = function(socket) { - user_has_team.afterCreate(function (doc) { - onSave(socket, doc); - }); - user_has_team.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('user_has_team:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('user_has_team:remove', doc); -} +var _0xb7cb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x3A\x72\x65\x6D\x6F\x76\x65"];_0xb7cb[0];var user_has_team=require(_0xb7cb[2])[_0xb7cb[1]];exports[_0xb7cb[3]]=function(_0xb95fx2){user_has_team[_0xb7cb[4]](function(_0xb95fx3){onSave(_0xb95fx2,_0xb95fx3)});user_has_team[_0xb7cb[5]](function(_0xb95fx3){onRemove(_0xb95fx2,_0xb95fx3)});};function onSave(_0xb95fx2,_0xb95fx3,_0xb95fx5){_0xb95fx2[_0xb7cb[7]](_0xb7cb[6],_0xb95fx3)}function onRemove(_0xb95fx2,_0xb95fx3,_0xb95fx5){_0xb95fx2[_0xb7cb[7]](_0xb7cb[8],_0xb95fx3)} \ No newline at end of file diff --git a/server/api/user_has_team/user_has_team.spec.js b/server/api/user_has_team/user_has_team.spec.js index 5cc5226..ce86646 100644 --- a/server/api/user_has_team/user_has_team.spec.js +++ b/server/api/user_has_team/user_has_team.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/user_has_teams', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/user_has_teams') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x6a34=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x73","\x67\x65\x74"];_0x6a34[0];var should=require(_0x6a34[1]);var app=require(_0x6a34[2]);var request=require(_0x6a34[3]);describe(_0x6a34[4],function(){it(_0x6a34[5],function(_0xd70ax4){request(app)[_0x6a34[13]](_0x6a34[12])[_0x6a34[11]](200)[_0x6a34[11]](_0x6a34[10],/json/)[_0x6a34[9]](function(_0xd70ax5,_0xd70ax6){if(_0xd70ax5){return _0xd70ax4(_0xd70ax5)};_0xd70ax6[_0x6a34[8]][_0x6a34[1]][_0x6a34[7]][_0x6a34[6]](Array);_0xd70ax4();})})}); \ No newline at end of file diff --git a/server/api/user_has_voice_queue/index.js b/server/api/user_has_voice_queue/index.js index 72551d5..e734269 100644 --- a/server/api/user_has_voice_queue/index.js +++ b/server/api/user_has_voice_queue/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./user_has_voice_queue.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; \ No newline at end of file +var _0xf285=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xf285[0];var express=require(_0xf285[1]);var controller=require(_0xf285[2]);var router=express.Router();router[_0xf285[5]](_0xf285[3],controller[_0xf285[4]]);router[_0xf285[5]](_0xf285[6],controller[_0xf285[7]]);router[_0xf285[9]](_0xf285[3],controller[_0xf285[8]]);router[_0xf285[11]](_0xf285[6],controller[_0xf285[10]]);router[_0xf285[12]](_0xf285[6],controller[_0xf285[10]]);router[_0xf285[14]](_0xf285[6],controller[_0xf285[13]]);module[_0xf285[15]]=router; \ No newline at end of file diff --git a/server/api/user_has_voice_queue/user_has_voice_queue.controller.js b/server/api/user_has_voice_queue/user_has_voice_queue.controller.js index f3e5d22..4ecb993 100644 --- a/server/api/user_has_voice_queue/user_has_voice_queue.controller.js +++ b/server/api/user_has_voice_queue/user_has_voice_queue.controller.js @@ -1,98 +1 @@ -'use strict'; - -var _ = require('lodash'); -var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue; - -// Get list of user_has_voice_queues -exports.index = function(req, res) { - UserHasVoiceQueue - .findAll(req.query ? { - where: req.query - } : {}) - .then(function(user_has_voice_queues) { - return res.status(200).send(user_has_voice_queues); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single userHasVoiceQueue -exports.show = function(req, res) { - UserHasVoiceQueue - .findById(req.params.id) - .then(function(userHasVoiceQueue) { - if (!userHasVoiceQueue) { - return res.sendStatus(404); - } - return res.send(userHasVoiceQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new userHasVoiceQueue in the DB. -exports.create = function(req, res, next) { - console.log(req.body); - UserHasVoiceQueue - .create(req.body) - .then(function(userHasVoiceQueue) { - return res.status(201).send(userHasVoiceQueue); - }) - .catch(function(err) { - console.error(err); - return next(err); - // return handleError(res, err); - }); -}; - -// Updates an existing userHasVoiceQueue in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - UserHasVoiceQueue - .findById(req.params.id) - .then(function(userHasVoiceQueue) { - if (!userHasVoiceQueue) { - return res.sendStatus(404); - } - var updated = _.merge(userHasVoiceQueue, req.body); - updated.save() - .then(function() { - return res.status(200).send(userHasVoiceQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a userHasVoiceQueue from the DB. -exports.destroy = function(req, res) { - UserHasVoiceQueue - .findById(req.params.id) - .then(function(userHasVoiceQueue) { - if (!userHasVoiceQueue) { - return res.sendStatus(404); - } - userHasVoiceQueue.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x58ad=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x6C\x6F\x67","\x65\x72\x72\x6F\x72","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x58ad[0];var _=require(_0x58ad[1]);var UserHasVoiceQueue=require(_0x58ad[3])[_0x58ad[2]];exports[_0x58ad[4]]=function(_0xa27cx3,_0xa27cx4){UserHasVoiceQueue[_0x58ad[10]](_0xa27cx3[_0x58ad[9]]?{where:_0xa27cx3[_0x58ad[9]]}:{})[_0x58ad[8]](function(_0xa27cx6){return _0xa27cx4[_0x58ad[7]](200)[_0x58ad[6]](_0xa27cx6)})[_0x58ad[5]](function(_0xa27cx5){return handleError(_0xa27cx4,_0xa27cx5)})};exports[_0x58ad[11]]=function(_0xa27cx3,_0xa27cx4){UserHasVoiceQueue[_0x58ad[15]](_0xa27cx3[_0x58ad[14]][_0x58ad[13]])[_0x58ad[8]](function(_0xa27cx7){if(!_0xa27cx7){return _0xa27cx4[_0x58ad[12]](404)};return _0xa27cx4[_0x58ad[6]](_0xa27cx7);})[_0x58ad[5]](function(_0xa27cx5){return handleError(_0xa27cx4,_0xa27cx5)})};exports[_0x58ad[16]]=function(_0xa27cx3,_0xa27cx4,_0xa27cx8){console[_0x58ad[18]](_0xa27cx3[_0x58ad[17]]);UserHasVoiceQueue[_0x58ad[16]](_0xa27cx3[_0x58ad[17]])[_0x58ad[8]](function(_0xa27cx7){return _0xa27cx4[_0x58ad[7]](201)[_0x58ad[6]](_0xa27cx7)})[_0x58ad[5]](function(_0xa27cx5){console[_0x58ad[19]](_0xa27cx5);return _0xa27cx8(_0xa27cx5);});};exports[_0x58ad[20]]=function(_0xa27cx3,_0xa27cx4){if(_0xa27cx3[_0x58ad[17]][_0x58ad[13]]){delete _0xa27cx3[_0x58ad[17]][_0x58ad[13]]};UserHasVoiceQueue[_0x58ad[15]](_0xa27cx3[_0x58ad[14]][_0x58ad[13]])[_0x58ad[8]](function(_0xa27cx7){if(!_0xa27cx7){return _0xa27cx4[_0x58ad[12]](404)};var _0xa27cx9=_[_0x58ad[21]](_0xa27cx7,_0xa27cx3[_0x58ad[17]]);_0xa27cx9[_0x58ad[22]]()[_0x58ad[8]](function(){return _0xa27cx4[_0x58ad[7]](200)[_0x58ad[6]](_0xa27cx7)})[_0x58ad[5]](function(_0xa27cx5){return handleError(_0xa27cx4,_0xa27cx5)});})[_0x58ad[5]](function(_0xa27cx5){return handleError(_0xa27cx4,_0xa27cx5)});};exports[_0x58ad[23]]=function(_0xa27cx3,_0xa27cx4){UserHasVoiceQueue[_0x58ad[15]](_0xa27cx3[_0x58ad[14]][_0x58ad[13]])[_0x58ad[8]](function(_0xa27cx7){if(!_0xa27cx7){return _0xa27cx4[_0x58ad[12]](404)};_0xa27cx7[_0x58ad[23]]()[_0x58ad[8]](function(){return _0xa27cx4[_0x58ad[12]](204)})[_0x58ad[5]](function(_0xa27cx5){return handleError(_0xa27cx4,_0xa27cx5)});})[_0x58ad[5]](function(_0xa27cx5){return handleError(_0xa27cx4,_0xa27cx5)})};function handleError(_0xa27cx4,_0xa27cx5){return _0xa27cx4[_0x58ad[7]](500)[_0x58ad[6]](_0xa27cx5)} \ No newline at end of file diff --git a/server/api/user_has_voice_queue/user_has_voice_queue.socket.js b/server/api/user_has_voice_queue/user_has_voice_queue.socket.js index 73e229c..1cfa1df 100644 --- a/server/api/user_has_voice_queue/user_has_voice_queue.socket.js +++ b/server/api/user_has_voice_queue/user_has_voice_queue.socket.js @@ -1,41 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue; - -exports.register = function(socket) { - UserHasVoiceQueue.afterCreate(function(doc) { - onSave(socket, doc); - }); - UserHasVoiceQueue.afterUpdate(function(doc) { - onSave(socket, doc); - }); - UserHasVoiceQueue.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('user_has_voice_queue:save', { - logged: doc.logged, - loggedAt: doc.loggedAt, - queue: doc.queue, - membername: doc.membername, - interface: doc.interface, - callstaken: doc.callstaken, - lastcall: doc.lastcall, - status: doc.status, - statusdesc: doc.statusdesc, - statusAt: doc.statusAt, - paused: doc.paused, - pausedAt: doc.pausedAt, - reason: doc.reason - }); -} - -function onRemove(socket, doc, cb) { - socket.emit('user_has_voice_queue:remove', doc); -} +var _0x11db=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x6C\x6F\x67\x67\x65\x64","\x6C\x6F\x67\x67\x65\x64\x41\x74","\x71\x75\x65\x75\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x69\x6E\x74\x65\x72\x66\x61\x63\x65","\x63\x61\x6C\x6C\x73\x74\x61\x6B\x65\x6E","\x6C\x61\x73\x74\x63\x61\x6C\x6C","\x73\x74\x61\x74\x75\x73","\x73\x74\x61\x74\x75\x73\x64\x65\x73\x63","\x73\x74\x61\x74\x75\x73\x41\x74","\x70\x61\x75\x73\x65\x64","\x70\x61\x75\x73\x65\x64\x41\x74","\x72\x65\x61\x73\x6F\x6E","\x65\x6D\x69\x74","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x11db[0];var UserHasVoiceQueue=require(_0x11db[2])[_0x11db[1]];exports[_0x11db[3]]=function(_0xaa0dx2){UserHasVoiceQueue[_0x11db[4]](function(_0xaa0dx3){onSave(_0xaa0dx2,_0xaa0dx3)});UserHasVoiceQueue[_0x11db[5]](function(_0xaa0dx3){onSave(_0xaa0dx2,_0xaa0dx3)});UserHasVoiceQueue[_0x11db[6]](function(_0xaa0dx3){onRemove(_0xaa0dx2,_0xaa0dx3)});};function onSave(_0xaa0dx2,_0xaa0dx3,_0xaa0dx5){_0xaa0dx2[_0x11db[21]](_0x11db[7],{logged:_0xaa0dx3[_0x11db[8]],loggedAt:_0xaa0dx3[_0x11db[9]],queue:_0xaa0dx3[_0x11db[10]],membername:_0xaa0dx3[_0x11db[11]],interface:_0xaa0dx3[_0x11db[12]],callstaken:_0xaa0dx3[_0x11db[13]],lastcall:_0xaa0dx3[_0x11db[14]],status:_0xaa0dx3[_0x11db[15]],statusdesc:_0xaa0dx3[_0x11db[16]],statusAt:_0xaa0dx3[_0x11db[17]],paused:_0xaa0dx3[_0x11db[18]],pausedAt:_0xaa0dx3[_0x11db[19]],reason:_0xaa0dx3[_0x11db[20]]})}function onRemove(_0xaa0dx2,_0xaa0dx3,_0xaa0dx5){_0xaa0dx2[_0x11db[21]](_0x11db[22],_0xaa0dx3)} \ No newline at end of file diff --git a/server/api/user_has_voice_queue/user_has_voice_queue.spec.js b/server/api/user_has_voice_queue/user_has_voice_queue.spec.js index 0ac501f..0ee1487 100644 --- a/server/api/user_has_voice_queue/user_has_voice_queue.spec.js +++ b/server/api/user_has_voice_queue/user_has_voice_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/voice/user_has_queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/voice/user_has_queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0xad90=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0xad90[0];var should=require(_0xad90[1]);var app=require(_0xad90[2]);var request=require(_0xad90[3]);describe(_0xad90[4],function(){it(_0xad90[5],function(_0x450bx4){request(app)[_0xad90[13]](_0xad90[12])[_0xad90[11]](200)[_0xad90[11]](_0xad90[10],/json/)[_0xad90[9]](function(_0x450bx5,_0x450bx6){if(_0x450bx5){return _0x450bx4(_0x450bx5)};_0x450bx6[_0xad90[8]][_0xad90[1]][_0xad90[7]][_0xad90[6]](Array);_0x450bx4();})})}); \ No newline at end of file diff --git a/server/api/variable/index.js b/server/api/variable/index.js index c2fafbf..57b5f15 100644 --- a/server/api/variable/index.js +++ b/server/api/variable/index.js @@ -1,18 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./variable.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.variableValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x3b8a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x76\x61\x72\x69\x61\x62\x6C\x65\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x3b8a[0];var express=require(_0x3b8a[1]);var controller=require(_0x3b8a[2]);var auth=require(_0x3b8a[3]);var router=express.Router();router[_0x3b8a[7]](_0x3b8a[4],auth[_0x3b8a[5]](),controller[_0x3b8a[6]]);router[_0x3b8a[7]](_0x3b8a[8],auth[_0x3b8a[5]](),controller[_0x3b8a[9]]);router[_0x3b8a[11]](_0x3b8a[4],auth[_0x3b8a[5]](),controller[_0x3b8a[10]]);router[_0x3b8a[11]](_0x3b8a[12],auth[_0x3b8a[5]](),controller[_0x3b8a[13]]);router[_0x3b8a[15]](_0x3b8a[8],auth[_0x3b8a[5]](),controller[_0x3b8a[14]]);router[_0x3b8a[16]](_0x3b8a[8],auth[_0x3b8a[5]](),controller[_0x3b8a[14]]);router[_0x3b8a[18]](_0x3b8a[4],auth[_0x3b8a[5]](),controller[_0x3b8a[17]]);router[_0x3b8a[18]](_0x3b8a[8],auth[_0x3b8a[5]](),controller[_0x3b8a[19]]);module[_0x3b8a[20]]=router; \ No newline at end of file diff --git a/server/api/variable/variable.controller.js b/server/api/variable/variable.controller.js index 5cd10db..67f1f9a 100644 --- a/server/api/variable/variable.controller.js +++ b/server/api/variable/variable.controller.js @@ -1,220 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Variable = require('../../models').Variable; -var util = require('util'); - -// Get list of variables -exports.index = function(req, res) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - Variable - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -exports.variableValidation = function(req, res) { - console.log(req.body); - Variable - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(variables) { - if (!variables) { - return res.sendStatus(404); - } - return res.send(variables); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single variable -exports.show = function(req, res) { - Variable - .findById(req.params.id) - .then(function(variable) { - if (!variable) { - return res.sendStatus(404); - } - return res.send(variable); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new variable in the DB. -exports.create = function(req, res) { - Variable - .create(req.body) - .then(function(variable) { - return res.status(201).send(variable); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing variable in the DB. -exports.update = function(req, res) { - Variable - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(variables) { - if (!variables) { - return res.sendStatus(404); - } - if (variables.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_VARIABLE' - }) - } - if (req.body.id) { - delete req.body.id; - } - Variable - .find({ - where: { - id: req.params.id - } - }) - .then(function(variable) { - if (!variable) { - return res.sendStatus(404); - } - var updated = _.merge(variable, req.body); - updated.save() - .then(function() { - return res.status(200).send(variable); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a variable from the DB. -exports.destroy = function(req, res) { - Variable - .findById(req.params.id) - .then(function(variable) { - if (!variable) { - return res.sendStatus(404); - } - variable.getZendeskTexts() - .then(function(texts) { - if (texts.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_VARIABLE_CONFIGURATION_ASSOCIATED' - }); - } - variable.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDestroy = function(req, res) { - Variable - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xf7a6=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x56\x61\x72\x69\x61\x62\x6C\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x76\x61\x72\x69\x61\x62\x6C\x65\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x56\x41\x52\x49\x41\x42\x4C\x45","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x56\x41\x52\x49\x41\x42\x4C\x45\x5F\x43\x4F\x4E\x46\x49\x47\x55\x52\x41\x54\x49\x4F\x4E\x5F\x41\x53\x53\x4F\x43\x49\x41\x54\x45\x44","\x67\x65\x74\x5A\x65\x6E\x64\x65\x73\x6B\x54\x65\x78\x74\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0xf7a6[0];var _=require(_0xf7a6[1]);var Variable=require(_0xf7a6[3])[_0xf7a6[2]];var util=require(_0xf7a6[4]);exports[_0xf7a6[5]]=function(_0xf2d5x4,_0xf2d5x5){var _0xf2d5x6=[_0xf7a6[6],_0xf7a6[7]];var _0xf2d5x7=_0xf2d5x4[_0xf7a6[9]][_0xf7a6[8]]?parseInt(_0xf2d5x4[_0xf7a6[9]][_0xf7a6[8]],10):100;var _0xf2d5x8=_0xf2d5x4[_0xf7a6[9]][_0xf7a6[10]]?parseInt(_0xf2d5x4[_0xf7a6[9]][_0xf7a6[10]],10):0;var _0xf2d5x9={where:{},limit:_0xf2d5x7,offset:_0xf2d5x8*_0xf2d5x7};_[_0xf7a6[24]](_0xf2d5x4[_0xf7a6[9]],function(_0xf2d5xa,_0xf2d5xb){switch(_0xf2d5xb){case _0xf7a6[8]:;case _0xf7a6[10]:break ;;case _0xf7a6[13]:_0xf2d5x9[_0xf7a6[11]]=util[_0xf7a6[16]](_0xf7a6[12],_0xf2d5x4[_0xf7a6[9]][_0xf7a6[13]],_0xf2d5x4[_0xf7a6[9]][_0xf7a6[14]]||_0xf7a6[15])||null;break ;;case _0xf7a6[14]:break ;;case _0xf7a6[22]:_0xf2d5x9[_0xf7a6[18]][_0xf7a6[17]]=[];_0xf2d5x6[_0xf7a6[21]](function(_0xf2d5xc){var _0xf2d5xd={};_0xf2d5xd[_0xf2d5xc]={$like:_0xf7a6[19]+_0xf2d5xa+_0xf7a6[19]};_0xf2d5x9[_0xf7a6[18]][_0xf7a6[17]][_0xf7a6[20]](_0xf2d5xd);});break ;;default:_0xf2d5x9[_0xf7a6[18]][_0xf2d5xb]={$like:{}};_0xf2d5x9[_0xf7a6[18]][_0xf2d5xb][_0xf7a6[23]]=_0xf7a6[19]+_0xf2d5xa+_0xf7a6[19];;}});Variable[_0xf7a6[39]](_0xf2d5x9)[_0xf7a6[38]](function(_0xf2d5xf){var _0xf2d5x10=Math[_0xf7a6[30]](_0xf2d5xf[_0xf7a6[29]]/_0xf2d5x7);var _0xf2d5x11=_0xf2d5x10>(_0xf2d5x9[_0xf7a6[31]]+1)?util[_0xf7a6[16]](_0xf7a6[32],_0xf2d5x4[_0xf7a6[33]],_0xf2d5x4[_0xf7a6[35]][_0xf7a6[34]],_0xf2d5x4[_0xf7a6[36]],_0xf2d5x8+1):null;var _0xf2d5x12=_0xf2d5x8>0?util[_0xf7a6[16]](_0xf7a6[32],_0xf2d5x4[_0xf7a6[33]],_0xf2d5x4[_0xf7a6[35]][_0xf7a6[34]],_0xf2d5x4[_0xf7a6[36]],_0xf2d5x8-1):null;_0xf2d5x5[_0xf7a6[27]](200)[_0xf7a6[26]]({count:_0xf2d5xf[_0xf7a6[29]],rows:_0xf2d5xf[_0xf7a6[37]],next_page:_0xf2d5x11,previous_page:_0xf2d5x12,total_pages:_0xf2d5x10});})[_0xf7a6[28]](function(_0xf2d5xe){_0xf2d5x5[_0xf7a6[27]](500)[_0xf7a6[26]]({error:_0xf7a6[25]})});};exports[_0xf7a6[40]]=function(_0xf2d5x4,_0xf2d5x5){console[_0xf7a6[42]](_0xf2d5x4[_0xf7a6[41]]);Variable[_0xf7a6[44]]({where:{name:_0xf2d5x4[_0xf7a6[41]][_0xf7a6[6]]}})[_0xf7a6[38]](function(_0xf2d5x13){if(!_0xf2d5x13){return _0xf2d5x5[_0xf7a6[43]](404)};return _0xf2d5x5[_0xf7a6[26]](_0xf2d5x13);})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)});};exports[_0xf7a6[45]]=function(_0xf2d5x4,_0xf2d5x5){Variable[_0xf7a6[48]](_0xf2d5x4[_0xf7a6[47]][_0xf7a6[46]])[_0xf7a6[38]](function(_0xf2d5x14){if(!_0xf2d5x14){return _0xf2d5x5[_0xf7a6[43]](404)};return _0xf2d5x5[_0xf7a6[26]](_0xf2d5x14);})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)})};exports[_0xf7a6[49]]=function(_0xf2d5x4,_0xf2d5x5){Variable[_0xf7a6[49]](_0xf2d5x4[_0xf7a6[41]])[_0xf7a6[38]](function(_0xf2d5x14){return _0xf2d5x5[_0xf7a6[27]](201)[_0xf7a6[26]](_0xf2d5x14)})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)})};exports[_0xf7a6[50]]=function(_0xf2d5x4,_0xf2d5x5){Variable[_0xf7a6[44]]({where:{name:_0xf2d5x4[_0xf7a6[41]][_0xf7a6[6]],id:{$ne:_0xf2d5x4[_0xf7a6[41]][_0xf7a6[46]]}}})[_0xf7a6[38]](function(_0xf2d5x13){if(!_0xf2d5x13){return _0xf2d5x5[_0xf7a6[43]](404)};if(_0xf2d5x13[_0xf7a6[51]]>0){return _0xf2d5x5[_0xf7a6[27]](500)[_0xf7a6[26]]({message:_0xf7a6[52]})};if(_0xf2d5x4[_0xf7a6[41]][_0xf7a6[46]]){delete _0xf2d5x4[_0xf7a6[41]][_0xf7a6[46]]};Variable[_0xf7a6[55]]({where:{id:_0xf2d5x4[_0xf7a6[47]][_0xf7a6[46]]}})[_0xf7a6[38]](function(_0xf2d5x14){if(!_0xf2d5x14){return _0xf2d5x5[_0xf7a6[43]](404)};var _0xf2d5x15=_[_0xf7a6[53]](_0xf2d5x14,_0xf2d5x4[_0xf7a6[41]]);_0xf2d5x15[_0xf7a6[54]]()[_0xf7a6[38]](function(){return _0xf2d5x5[_0xf7a6[27]](200)[_0xf7a6[26]](_0xf2d5x14)})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)});})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)});})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)})};exports[_0xf7a6[56]]=function(_0xf2d5x4,_0xf2d5x5){Variable[_0xf7a6[48]](_0xf2d5x4[_0xf7a6[47]][_0xf7a6[46]])[_0xf7a6[38]](function(_0xf2d5x14){if(!_0xf2d5x14){return _0xf2d5x5[_0xf7a6[43]](404)};_0xf2d5x14[_0xf7a6[58]]()[_0xf7a6[38]](function(_0xf2d5x16){if(_0xf2d5x16[_0xf7a6[51]]>0){return _0xf2d5x5[_0xf7a6[27]](500)[_0xf7a6[26]]({message:_0xf7a6[57]})};_0xf2d5x14[_0xf7a6[56]]()[_0xf7a6[38]](function(){return _0xf2d5x5[_0xf7a6[43]](204)})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)});})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)});})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)})};exports[_0xf7a6[59]]=function(_0xf2d5x4,_0xf2d5x5){Variable[_0xf7a6[56]]({where:{id:_0xf2d5x4[_0xf7a6[9]][_0xf7a6[46]]},individualHooks:true})[_0xf7a6[38]](function(){return _0xf2d5x5[_0xf7a6[43]](204)})[_0xf7a6[28]](function(_0xf2d5xe){return handleError(_0xf2d5x5,_0xf2d5xe)})};function handleError(_0xf2d5x5,_0xf2d5xe){return _0xf2d5x5[_0xf7a6[27]](500)[_0xf7a6[26]](_0xf2d5xe)} \ No newline at end of file diff --git a/server/api/variable/variable.socket.js b/server/api/variable/variable.socket.js index 739f11c..209fae8 100644 --- a/server/api/variable/variable.socket.js +++ b/server/api/variable/variable.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var Variable = require('../../models').Variable; - -exports.register = function(socket) { - Variable.afterCreate(function(doc) { - onSave(socket, doc); - }); - Variable.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('variable:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('variable:remove', doc); -} +var _0x9505=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x61\x72\x69\x61\x62\x6C\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x76\x61\x72\x69\x61\x62\x6C\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x76\x61\x72\x69\x61\x62\x6C\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x9505[0];var Variable=require(_0x9505[2])[_0x9505[1]];exports[_0x9505[3]]=function(_0x8a63x2){Variable[_0x9505[4]](function(_0x8a63x3){onSave(_0x8a63x2,_0x8a63x3)});Variable[_0x9505[5]](function(_0x8a63x3){onRemove(_0x8a63x2,_0x8a63x3)});};function onSave(_0x8a63x2,_0x8a63x3,_0x8a63x5){_0x8a63x2[_0x9505[7]](_0x9505[6],_0x8a63x3)}function onRemove(_0x8a63x2,_0x8a63x3,_0x8a63x5){_0x8a63x2[_0x9505[7]](_0x9505[8],_0x8a63x3)} \ No newline at end of file diff --git a/server/api/variable/variable.spec.js b/server/api/variable/variable.spec.js index 0a463f7..eb1ca0b 100644 --- a/server/api/variable/variable.spec.js +++ b/server/api/variable/variable.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/variables', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/variables') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0xe58d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x67\x65\x74"];_0xe58d[0];var should=require(_0xe58d[1]);var app=require(_0xe58d[2]);var request=require(_0xe58d[3]);describe(_0xe58d[4],function(){it(_0xe58d[5],function(_0x5f74x4){request(app)[_0xe58d[13]](_0xe58d[12])[_0xe58d[11]](200)[_0xe58d[11]](_0xe58d[10],/json/)[_0xe58d[9]](function(_0x5f74x5,_0x5f74x6){if(_0x5f74x5){return _0x5f74x4(_0x5f74x5)};_0x5f74x6[_0xe58d[8]][_0xe58d[1]][_0xe58d[7]][_0xe58d[6]](Array);_0x5f74x4();})})}); \ No newline at end of file diff --git a/server/api/voice_context/index.js b/server/api/voice_context/index.js index 1b436c8..02f3ea2 100644 --- a/server/api/voice_context/index.js +++ b/server/api/voice_context/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./voice_context.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.contextValidation); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); -module.exports = router; +var _0x2117=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x63\x6F\x6E\x74\x65\x78\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x2117[0];var express=require(_0x2117[1]);var controller=require(_0x2117[2]);var auth=require(_0x2117[3]);var router=express.Router();router[_0x2117[7]](_0x2117[4],auth[_0x2117[5]](),controller[_0x2117[6]]);router[_0x2117[7]](_0x2117[8],auth[_0x2117[5]](),controller[_0x2117[9]]);router[_0x2117[11]](_0x2117[4],auth[_0x2117[5]](),controller[_0x2117[10]]);router[_0x2117[11]](_0x2117[12],auth[_0x2117[5]](),controller[_0x2117[13]]);router[_0x2117[15]](_0x2117[8],auth[_0x2117[5]](),controller[_0x2117[14]]);router[_0x2117[17]](_0x2117[4],auth[_0x2117[5]](),controller[_0x2117[16]]);router[_0x2117[17]](_0x2117[8],auth[_0x2117[5]](),controller[_0x2117[18]]);module[_0x2117[19]]=router; \ No newline at end of file diff --git a/server/api/voice_context/voice_context.ami.js b/server/api/voice_context/voice_context.ami.js index a8737f4..f18e3d3 100644 --- a/server/api/voice_context/voice_context.ami.js +++ b/server/api/voice_context/voice_context.ami.js @@ -1,71 +1 @@ -'use strict'; - -var VoiceContext = require('../../models').VoiceContext; -var fs = require('fs'); -var util = require('util'); -var path = require('path'); -var config = require('../../config/environment'); - -exports.register = function(ami) { - VoiceContext.beforeUpdate(function(updatedContext) { - if (updatedContext.changed('name')) { - throw new Error("You can't modify a context name"); - } - if (updatedContext.defaultEntry) { - throw new Error("You can't modify a default context"); - } - }); - - VoiceContext.beforeDelete(function(context) { - if (context.defaultEntry) { - throw new Error("You can't delete a default context"); - } - }); - - VoiceContext.afterCreate(function(doc) { - rewriteContexts(doc, ami, false); - }) - - VoiceContext.afterDelete(function(doc) { - rewriteContexts(doc, ami, true); - }) -} - -function rewriteContexts(doc, ami, deleteContext) { - var contextValues = ''; - if (!deleteContext) { - contextValues = util.format('[%s]\nswitch => Realtime\n', doc.name); - } - VoiceContext - .findAll({ - where: { - id: { - $ne: doc.id - } - } - }) - .then(function(contexts) { - contexts.forEach(function(element) { - contextValues += util.format('[%s]\nswitch => Realtime\n', element.name); - }); - fs.writeFile(path.join(config.root, 'server/files/asterisk/sip_xcally_contexts.conf'), contextValues, { - flags: 'w', - mode: parseInt('0777', 8) - }, function(err) { - if (err) throw err; - console.log("Contexts file saved!"); - ami.action({ - Action: 'Reload', - }, function(err, res) { - if (err) { - console.error(err); - } else { - console.log(res); - } - }); - }); - }) - .catch(function(err) { - console.log(err); - }); -} +var _0xd0b8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x6F\x69\x63\x65\x43\x6F\x6E\x74\x65\x78\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x66\x73","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x72\x65\x67\x69\x73\x74\x65\x72","\x6E\x61\x6D\x65","\x63\x68\x61\x6E\x67\x65\x64","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x6D\x6F\x64\x69\x66\x79\x20\x61\x20\x63\x6F\x6E\x74\x65\x78\x74\x20\x6E\x61\x6D\x65","\x64\x65\x66\x61\x75\x6C\x74\x45\x6E\x74\x72\x79","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x6D\x6F\x64\x69\x66\x79\x20\x61\x20\x64\x65\x66\x61\x75\x6C\x74\x20\x63\x6F\x6E\x74\x65\x78\x74","\x62\x65\x66\x6F\x72\x65\x55\x70\x64\x61\x74\x65","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x64\x65\x6C\x65\x74\x65\x20\x61\x20\x64\x65\x66\x61\x75\x6C\x74\x20\x63\x6F\x6E\x74\x65\x78\x74","\x62\x65\x66\x6F\x72\x65\x44\x65\x6C\x65\x74\x65","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","","\x5B\x25\x73\x5D\x0A\x73\x77\x69\x74\x63\x68\x20\x3D\x3E\x20\x52\x65\x61\x6C\x74\x69\x6D\x65\x0A","\x66\x6F\x72\x6D\x61\x74","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x66\x6F\x72\x45\x61\x63\x68","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x61\x73\x74\x65\x72\x69\x73\x6B\x2F\x73\x69\x70\x5F\x78\x63\x61\x6C\x6C\x79\x5F\x63\x6F\x6E\x74\x65\x78\x74\x73\x2E\x63\x6F\x6E\x66","\x6A\x6F\x69\x6E","\x77","\x30\x37\x37\x37","\x43\x6F\x6E\x74\x65\x78\x74\x73\x20\x66\x69\x6C\x65\x20\x73\x61\x76\x65\x64\x21","\x52\x65\x6C\x6F\x61\x64","\x65\x72\x72\x6F\x72","\x61\x63\x74\x69\x6F\x6E","\x77\x72\x69\x74\x65\x46\x69\x6C\x65","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x41\x6C\x6C"];_0xd0b8[0];var VoiceContext=require(_0xd0b8[2])[_0xd0b8[1]];var fs=require(_0xd0b8[3]);var util=require(_0xd0b8[4]);var path=require(_0xd0b8[5]);var config=require(_0xd0b8[6]);exports[_0xd0b8[7]]=function(_0xf32cx6){VoiceContext[_0xd0b8[13]](function(_0xf32cx7){if(_0xf32cx7[_0xd0b8[9]](_0xd0b8[8])){throw new Error(_0xd0b8[10])};if(_0xf32cx7[_0xd0b8[11]]){throw new Error(_0xd0b8[12])};});VoiceContext[_0xd0b8[15]](function(_0xf32cx8){if(_0xf32cx8[_0xd0b8[11]]){throw new Error(_0xd0b8[14])}});VoiceContext[_0xd0b8[16]](function(_0xf32cx9){rewriteContexts(_0xf32cx9,_0xf32cx6,false)});VoiceContext[_0xd0b8[17]](function(_0xf32cx9){rewriteContexts(_0xf32cx9,_0xf32cx6,true)});};function rewriteContexts(_0xf32cx9,_0xf32cx6,_0xf32cxb){var _0xf32cxc=_0xd0b8[18];if(!_0xf32cxb){_0xf32cxc=util[_0xd0b8[20]](_0xd0b8[19],_0xf32cx9[_0xd0b8[8]])};VoiceContext[_0xd0b8[36]]({where:{id:{$ne:_0xf32cx9[_0xd0b8[35]]}}})[_0xd0b8[34]](function(_0xf32cxe){_0xf32cxe[_0xd0b8[23]](function(_0xf32cxf){_0xf32cxc+=util[_0xd0b8[20]](_0xd0b8[19],_0xf32cxf[_0xd0b8[8]])});fs[_0xd0b8[33]](path[_0xd0b8[26]](config[_0xd0b8[24]],_0xd0b8[25]),_0xf32cxc,{flags:_0xd0b8[27],mode:parseInt(_0xd0b8[28],8)},function(_0xf32cxd){if(_0xf32cxd){throw _0xf32cxd};console[_0xd0b8[21]](_0xd0b8[29]);_0xf32cx6[_0xd0b8[32]]({Action:_0xd0b8[30]},function(_0xf32cxd,_0xf32cx10){if(_0xf32cxd){console[_0xd0b8[31]](_0xf32cxd)}else {console[_0xd0b8[21]](_0xf32cx10)}});});})[_0xd0b8[22]](function(_0xf32cxd){console[_0xd0b8[21]](_0xf32cxd)});} \ No newline at end of file diff --git a/server/api/voice_context/voice_context.controller.js b/server/api/voice_context/voice_context.controller.js index 662a803..06bb6dc 100644 --- a/server/api/voice_context/voice_context.controller.js +++ b/server/api/voice_context/voice_context.controller.js @@ -1,282 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var sequelize = require('../../models').sequelize; - -var VoiceContext = require('../../models').VoiceContext; -var VoiceExtension = require('../../models').VoiceExtension; - -// Get list of agents -exports.index = function(req, res, next) { - - var attributes = ['name', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - VoiceContext - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single voice_context -exports.show = function(req, res) { - VoiceContext - .findById(req.params.id) - .then(function(voice_context) { - if (!voice_context) { - return res.sendStatus(404); - } - return res.send(voice_context); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Validate the existence of a context -exports.contextValidation = function(req, res) { - console.log(req.body); - VoiceContext - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(voice_contexts) { - if (!voice_contexts) { - return res.sendStatus(404); - } - return res.send(voice_contexts); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new voice_context in the DB. -exports.create = function(req, res) { - VoiceContext - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(existingContexts) { - console.log(existingContexts); - console.log('Finding app row.....'); - if (!existingContexts) { - return res.sendStatus(404); - } - if (existingContexts.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_ROUTE' - }); - } - VoiceContext - .create(req.body) - .then(function(voice_context) { - return res.status(201).send(voice_context); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - -}; - -// Updates an existing voice_context in the DB. -exports.update = function(req, res) { - VoiceContext - .findAll({ - where: { - name: req.body.name, - id: { - $ne: req.body.id - } - } - }) - .then(function(existingContexts) { - console.log(existingContexts); - console.log('Finding app row.....'); - if (!existingContexts) { - return res.sendStatus(404); - } - if (existingContexts.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_ROUTE' - }); - } - if (req.body.id) { - delete req.body.id; - } - VoiceContext - .findById(req.params.id) - .then(function(voice_context) { - if (!voice_context) { - return res.sendStatus(404); - } - var updated = _.merge(voice_context, req.body); - updated.save() - .then(function() { - return res.status(200).send(voice_context); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - -}; - -// Deletes a voice_context from the DB. -exports.destroy = function(req, res) { - VoiceContext - .findById(req.params.id) - .then(function(voice_context) { - if (!voice_context) { - return res.sendStatus(404); - } - VoiceExtension - .findAll({ - where: { - context: voice_context.name - } - }) - .then(function(contextExtensions) { - if (contextExtensions.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_CONTEXT_ROUTE_ASSOCIATED' - }); - } - voice_context.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a context from the DB. -exports.bulkDestroy = function(req, res) { - VoiceContext - .findAll({ - where: { - id: req.query.id - } - }) - .then(function(voice_contexts) { - if (!voice_contexts) { - return res.sendStatus(404); - } - var destroyContextsNames = _.pluck(_.pluck(voice_contexts, 'dataValues'), 'name'); - VoiceExtension - .findAll({ - where: { - context: destroyContextsNames - } - }) - .then(function(contextExtensions) { - if (contextExtensions.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_CONTEXT_ROUTE_ASSOCIATED' - }); - } - VoiceContext - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x874f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x43\x6F\x6E\x74\x65\x78\x74","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x6F\x6E\x74\x65\x78\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x46\x69\x6E\x64\x69\x6E\x67\x20\x61\x70\x70\x20\x72\x6F\x77\x2E\x2E\x2E\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x52\x4F\x55\x54\x45","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x43\x4F\x4E\x54\x45\x58\x54\x5F\x52\x4F\x55\x54\x45\x5F\x41\x53\x53\x4F\x43\x49\x41\x54\x45\x44","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x6C\x75\x63\x6B"];_0x874f[0];var _=require(_0x874f[1]);var util=require(_0x874f[2]);var sequelize=require(_0x874f[4])[_0x874f[3]];var VoiceContext=require(_0x874f[4])[_0x874f[5]];var VoiceExtension=require(_0x874f[4])[_0x874f[6]];exports[_0x874f[7]]=function(_0xa31cx6,_0xa31cx7,_0xa31cx8){var _0xa31cx9=[_0x874f[8],_0x874f[9]];var _0xa31cxa=_0xa31cx6[_0x874f[11]][_0x874f[10]]?parseInt(_0xa31cx6[_0x874f[11]][_0x874f[10]],10):100;var _0xa31cxb=_0xa31cx6[_0x874f[11]][_0x874f[12]]?parseInt(_0xa31cx6[_0x874f[11]][_0x874f[12]],10):0;var _0xa31cxc={where:{},limit:_0xa31cxa,offset:_0xa31cxb*_0xa31cxa};_[_0x874f[26]](_0xa31cx6[_0x874f[11]],function(_0xa31cxd,_0xa31cxe){switch(_0xa31cxe){case _0x874f[10]:;case _0x874f[12]:break ;;case _0x874f[15]:_0xa31cxc[_0x874f[13]]=util[_0x874f[18]](_0x874f[14],_0xa31cx6[_0x874f[11]][_0x874f[15]],_0xa31cx6[_0x874f[11]][_0x874f[16]]||_0x874f[17])||null;break ;;case _0x874f[16]:break ;;case _0x874f[24]:_0xa31cxc[_0x874f[20]][_0x874f[19]]=[];_0xa31cx9[_0x874f[23]](function(_0xa31cxf){var _0xa31cx10={};_0xa31cx10[_0xa31cxf]={$like:_0x874f[21]+_0xa31cxd+_0x874f[21]};_0xa31cxc[_0x874f[20]][_0x874f[19]][_0x874f[22]](_0xa31cx10);});break ;;default:_0xa31cxc[_0x874f[20]][_0xa31cxe]={$like:{}};_0xa31cxc[_0x874f[20]][_0xa31cxe][_0x874f[25]]=_0x874f[21]+_0xa31cxd+_0x874f[21];;}});VoiceContext[_0x874f[41]](_0xa31cxc)[_0x874f[40]](function(_0xa31cx12){var _0xa31cx13=Math[_0x874f[32]](_0xa31cx12[_0x874f[31]]/_0xa31cxa);var _0xa31cx14=_0xa31cx13>(_0xa31cxc[_0x874f[33]]+1)?util[_0x874f[18]](_0x874f[34],_0xa31cx6[_0x874f[35]],_0xa31cx6[_0x874f[37]][_0x874f[36]],_0xa31cx6[_0x874f[38]],_0xa31cxb+1):null;var _0xa31cx15=_0xa31cxb>0?util[_0x874f[18]](_0x874f[34],_0xa31cx6[_0x874f[35]],_0xa31cx6[_0x874f[37]][_0x874f[36]],_0xa31cx6[_0x874f[38]],_0xa31cxb-1):null;_0xa31cx7[_0x874f[29]](200)[_0x874f[28]]({count:_0xa31cx12[_0x874f[31]],rows:_0xa31cx12[_0x874f[39]],next_page:_0xa31cx14,previous_page:_0xa31cx15,total_pages:_0xa31cx13});})[_0x874f[30]](function(_0xa31cx11){_0xa31cx7[_0x874f[29]](500)[_0x874f[28]]({error:_0x874f[27]})});};exports[_0x874f[42]]=function(_0xa31cx6,_0xa31cx7){VoiceContext[_0x874f[46]](_0xa31cx6[_0x874f[45]][_0x874f[44]])[_0x874f[40]](function(_0xa31cx16){if(!_0xa31cx16){return _0xa31cx7[_0x874f[43]](404)};return _0xa31cx7[_0x874f[28]](_0xa31cx16);})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)})};exports[_0x874f[47]]=function(_0xa31cx6,_0xa31cx7){console[_0x874f[49]](_0xa31cx6[_0x874f[48]]);VoiceContext[_0x874f[50]]({where:{name:_0xa31cx6[_0x874f[48]][_0x874f[8]]}})[_0x874f[40]](function(_0xa31cx17){if(!_0xa31cx17){return _0xa31cx7[_0x874f[43]](404)};return _0xa31cx7[_0x874f[28]](_0xa31cx17);})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});};exports[_0x874f[51]]=function(_0xa31cx6,_0xa31cx7){VoiceContext[_0x874f[50]]({where:{name:_0xa31cx6[_0x874f[48]][_0x874f[8]]}})[_0x874f[40]](function(_0xa31cx18){console[_0x874f[49]](_0xa31cx18);console[_0x874f[49]](_0x874f[52]);if(!_0xa31cx18){return _0xa31cx7[_0x874f[43]](404)};if(_0xa31cx18[_0x874f[53]]>0){return _0xa31cx7[_0x874f[29]](500)[_0x874f[28]]({message:_0x874f[54]})};VoiceContext[_0x874f[51]](_0xa31cx6[_0x874f[48]])[_0x874f[40]](function(_0xa31cx16){return _0xa31cx7[_0x874f[29]](201)[_0x874f[28]](_0xa31cx16)})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)})};exports[_0x874f[55]]=function(_0xa31cx6,_0xa31cx7){VoiceContext[_0x874f[50]]({where:{name:_0xa31cx6[_0x874f[48]][_0x874f[8]],id:{$ne:_0xa31cx6[_0x874f[48]][_0x874f[44]]}}})[_0x874f[40]](function(_0xa31cx18){console[_0x874f[49]](_0xa31cx18);console[_0x874f[49]](_0x874f[52]);if(!_0xa31cx18){return _0xa31cx7[_0x874f[43]](404)};if(_0xa31cx18[_0x874f[53]]>0){return _0xa31cx7[_0x874f[29]](500)[_0x874f[28]]({message:_0x874f[54]})};if(_0xa31cx6[_0x874f[48]][_0x874f[44]]){delete _0xa31cx6[_0x874f[48]][_0x874f[44]]};VoiceContext[_0x874f[46]](_0xa31cx6[_0x874f[45]][_0x874f[44]])[_0x874f[40]](function(_0xa31cx16){if(!_0xa31cx16){return _0xa31cx7[_0x874f[43]](404)};var _0xa31cx19=_[_0x874f[56]](_0xa31cx16,_0xa31cx6[_0x874f[48]]);_0xa31cx19[_0x874f[57]]()[_0x874f[40]](function(){return _0xa31cx7[_0x874f[29]](200)[_0x874f[28]](_0xa31cx16)})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)})};exports[_0x874f[58]]=function(_0xa31cx6,_0xa31cx7){VoiceContext[_0x874f[46]](_0xa31cx6[_0x874f[45]][_0x874f[44]])[_0x874f[40]](function(_0xa31cx16){if(!_0xa31cx16){return _0xa31cx7[_0x874f[43]](404)};VoiceExtension[_0x874f[50]]({where:{context:_0xa31cx16[_0x874f[8]]}})[_0x874f[40]](function(_0xa31cx1a){if(_0xa31cx1a[_0x874f[53]]>0){return _0xa31cx7[_0x874f[29]](500)[_0x874f[28]]({message:_0x874f[59]})};_0xa31cx16[_0x874f[58]]()[_0x874f[40]](function(){return _0xa31cx7[_0x874f[43]](204)})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)})};exports[_0x874f[60]]=function(_0xa31cx6,_0xa31cx7){VoiceContext[_0x874f[50]]({where:{id:_0xa31cx6[_0x874f[11]][_0x874f[44]]}})[_0x874f[40]](function(_0xa31cx17){if(!_0xa31cx17){return _0xa31cx7[_0x874f[43]](404)};var _0xa31cx1b=_[_0x874f[62]](_[_0x874f[62]](_0xa31cx17,_0x874f[61]),_0x874f[8]);VoiceExtension[_0x874f[50]]({where:{context:_0xa31cx1b}})[_0x874f[40]](function(_0xa31cx1a){if(_0xa31cx1a[_0x874f[53]]>0){return _0xa31cx7[_0x874f[29]](500)[_0x874f[28]]({message:_0x874f[59]})};VoiceContext[_0x874f[58]]({where:{id:_0xa31cx6[_0x874f[11]][_0x874f[44]]},individualHooks:true})[_0x874f[40]](function(){return _0xa31cx7[_0x874f[43]](204)})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)});})[_0x874f[30]](function(_0xa31cx11){return handleError(_0xa31cx7,_0xa31cx11)})};function handleError(_0xa31cx7,_0xa31cx11){return _0xa31cx7[_0x874f[29]](500)[_0x874f[28]](_0xa31cx11)} \ No newline at end of file diff --git a/server/api/voice_context/voice_context.socket.js b/server/api/voice_context/voice_context.socket.js index c3841ec..f0be6b1 100644 --- a/server/api/voice_context/voice_context.socket.js +++ b/server/api/voice_context/voice_context.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var VoiceContext = require('../../models').VoiceContext; - -exports.register = function(socket) { - VoiceContext.afterCreate(function(doc) { - onSave(socket, doc); - }); - VoiceContext.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('voice_context:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('voice_context:remove', doc); -} +var _0x8b00=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x6F\x69\x63\x65\x43\x6F\x6E\x74\x65\x78\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0x8b00[0];var VoiceContext=require(_0x8b00[2])[_0x8b00[1]];exports[_0x8b00[3]]=function(_0x8334x2){VoiceContext[_0x8b00[4]](function(_0x8334x3){onSave(_0x8334x2,_0x8334x3)});VoiceContext[_0x8b00[5]](function(_0x8334x3){onRemove(_0x8334x2,_0x8334x3)});};function onSave(_0x8334x2,_0x8334x3,_0x8334x5){_0x8334x2[_0x8b00[7]](_0x8b00[6],_0x8334x3)}function onRemove(_0x8334x2,_0x8334x3,_0x8334x5){_0x8334x2[_0x8b00[7]](_0x8b00[8],_0x8334x3)} \ No newline at end of file diff --git a/server/api/voice_context/voice_context.spec.js b/server/api/voice_context/voice_context.spec.js index 1a60777..4ae7f0b 100644 --- a/server/api/voice_context/voice_context.spec.js +++ b/server/api/voice_context/voice_context.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/voice/contexts', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/voice/contexts') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x2a0a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x63\x6F\x6E\x74\x65\x78\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x63\x6F\x6E\x74\x65\x78\x74\x73","\x67\x65\x74"];_0x2a0a[0];var should=require(_0x2a0a[1]);var app=require(_0x2a0a[2]);var request=require(_0x2a0a[3]);describe(_0x2a0a[4],function(){it(_0x2a0a[5],function(_0x2aa1x4){request(app)[_0x2a0a[13]](_0x2a0a[12])[_0x2a0a[11]](200)[_0x2a0a[11]](_0x2a0a[10],/json/)[_0x2a0a[9]](function(_0x2aa1x5,_0x2aa1x6){if(_0x2aa1x5){return _0x2aa1x4(_0x2aa1x5)};_0x2aa1x6[_0x2a0a[8]][_0x2a0a[1]][_0x2a0a[7]][_0x2a0a[6]](Array);_0x2aa1x4();})})}); \ No newline at end of file diff --git a/server/api/voice_extension/index.js b/server/api/voice_extension/index.js index cf428d7..18f9dbb 100644 --- a/server/api/voice_extension/index.js +++ b/server/api/voice_extension/index.js @@ -1,22 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./voice_extension.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/route/:route', auth.isAuthenticated(), controller.showByRoute); -router.get('/applications/:id', auth.isAuthenticated(), controller.show); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/applications', auth.isAuthenticated(), controller.showAppsByRoute); -router.post('/validate', auth.isAuthenticated(), controller.routeValidation); -router.post('/:id/applications', auth.isAuthenticated(), controller.sortAppsByRoute); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.put('/applications/:id', auth.isAuthenticated(), controller.updateApplication); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x7051=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x72\x6F\x75\x74\x65\x2F\x3A\x72\x6F\x75\x74\x65","\x73\x68\x6F\x77\x42\x79\x52\x6F\x75\x74\x65","\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64","\x2F\x3A\x69\x64\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x77\x41\x70\x70\x73\x42\x79\x52\x6F\x75\x74\x65","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x72\x6F\x75\x74\x65\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x73\x6F\x72\x74\x41\x70\x70\x73\x42\x79\x52\x6F\x75\x74\x65","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x75\x70\x64\x61\x74\x65\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x7051[0];var express=require(_0x7051[1]);var controller=require(_0x7051[2]);var auth=require(_0x7051[3]);var router=express.Router();router[_0x7051[7]](_0x7051[4],auth[_0x7051[5]](),controller[_0x7051[6]]);router[_0x7051[7]](_0x7051[8],auth[_0x7051[5]](),controller[_0x7051[9]]);router[_0x7051[7]](_0x7051[10],auth[_0x7051[5]](),controller[_0x7051[11]]);router[_0x7051[7]](_0x7051[12],auth[_0x7051[5]](),controller[_0x7051[11]]);router[_0x7051[7]](_0x7051[13],auth[_0x7051[5]](),controller[_0x7051[14]]);router[_0x7051[17]](_0x7051[15],auth[_0x7051[5]](),controller[_0x7051[16]]);router[_0x7051[17]](_0x7051[13],auth[_0x7051[5]](),controller[_0x7051[18]]);router[_0x7051[17]](_0x7051[4],auth[_0x7051[5]](),controller[_0x7051[19]]);router[_0x7051[21]](_0x7051[12],auth[_0x7051[5]](),controller[_0x7051[20]]);router[_0x7051[21]](_0x7051[10],auth[_0x7051[5]](),controller[_0x7051[22]]);router[_0x7051[24]](_0x7051[4],auth[_0x7051[5]](),controller[_0x7051[23]]);router[_0x7051[24]](_0x7051[12],auth[_0x7051[5]](),controller[_0x7051[25]]);module[_0x7051[26]]=router; \ No newline at end of file diff --git a/server/api/voice_extension/voice_extension.controller.js b/server/api/voice_extension/voice_extension.controller.js index 9701d40..053f1ba 100644 --- a/server/api/voice_extension/voice_extension.controller.js +++ b/server/api/voice_extension/voice_extension.controller.js @@ -1,1348 +1 @@ -'use strict'; - -var _ = require('lodash'); -var VoiceExtension = require('../../models').VoiceExtension; -var Interval = require('../../models').Interval; -var sequelize = require('../../models').sequelize; -var Sequelize = require('../../models').Sequelize; -var util = require('util'); -var async = require('async'); - -var Applications = { - Dial: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Set', - appdata: 'CALLERID(all)=%s' - }, { - app: 'Dial', - appdata: '%s,%s,%s,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Dial Application End' - }], - Queue: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Answer', - appdata: '' - }, { - app: 'Queue', - appdata: '%s,%s,%s,%s,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Queue Application End' - }], - Playback: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Playback', - appdata: '%s,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Playback Application End' - }], - AGI: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'AGI', - appdata: 'agi://127.0.0.1/square,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'AGI Application End' - }], - Goto: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Goto', - appdata: '%s,%s,%d', - isApp: true - }, { - app: 'NoOp', - appdata: 'Goto Application End' - }], - Hangup: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Hangup', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Hangup Application End' - }], - Set: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Set', - appdata: '%s=%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Set Application End' - }], - custom: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }], - Voicemail: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Voicemail', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Voicemail Application End' - }] -}; - -// Get list of voice_extensions -exports.index = function (req, res) { - VoiceExtension - .findAll() - .then(function (voice_extensions) { - return res.status(200).send(voice_extensions); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get list of agents -exports.showByRoute = function (req, res, next) { - - var attributes = ['context', 'exten', 'app', 'appdata']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: { - type: req.params.route, - VoiceExtensionId: null, - app: 'NoOp' - }, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function (value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function (attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - VoiceExtension - .findAndCountAll(query) - .then(function (result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function (err) { - res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - - -// Get list of voice_extensions by route -exports.showAppsByRoute = function (req, res) { - VoiceExtension - .findAll({ - where: { - VoiceExtensionId: req.params.id, - isApp: true - } - }) - .then(function (voice_extensions) { - return res.status(200).send(voice_extensions); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Get a single voice_extension or application -exports.show = function (req, res) { - VoiceExtension - .findById(req.params.id) - .then(function (voice_extension) { - if (!voice_extension) { - return res.sendStatus(404); - } - return res.send(voice_extension); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Validate the existence of a route -exports.routeValidation = function (req, res) { - VoiceExtension - .findAll({ - where: { - exten: req.body.exten, - context: req.body.context, - type: req.body.type - } - }) - .then(function (voice_extension) { - if (!voice_extension) { - return res.sendStatus(404); - } - return res.send(voice_extension); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// exports.sortAppsByRoute = function(req, res, next) { -// return sequelize -// .transaction() -// .then(function(t) { -// async.waterfall([ -// function(callback) { -// VoiceExtension -// .findAll({ -// where: { -// appGroup: req.body.applications -// } -// }) -// .then(function(voiceApplications) { -// callback(null, voiceApplications); -// }) -// .catch(function(err) { -// callback(err); -// }); -// }, -// function(voiceApplications, callback) { -// console.log('found ad saved applications'); -// console.log('destroying old applications from db'); -// return VoiceExtension.destroy({ -// where: { -// appGroup: req.body.applications -// } -// }, { -// transaction: t -// }) -// .then(function() { -// callback(null, voiceApplications); -// }) -// .catch(function(err) { -// callback(err); -// }); -// }, -// function(voiceApplications, callback) { -// console.log('destroyed old applications from db'); -// var priority = 2; -// console.log('iterating sorted applications ids'); -// req.body.applications.forEach(function(sortedElem) { -// var tmpElem = _.find(voiceApplications, function(elem) { -// return (elem.appGroup == sortedElem && elem.isApp === true); -// }); -// var application = _.cloneDeep(Applications[tmpElem.app]); -// if (!application || tmpElem.customApp) { -// application = [{ -// app: 'GotoIfTime', -// appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', -// }, { -// app: 'custom', -// appdata: '%s', -// isApp: true -// }, { -// app: 'NoOp', -// appdata: 'Custom Application End' -// }]; -// } -// //console.log('PRIORITY'); -// //console.log(priority); -// var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority); -// tmpElem.interval = tmpElem.interval || '*,*,*,*'; -// var tmpIntervals = _.filter(voiceApplications, function(elem) { -// return (elem.appGroup == sortedElem && elem.isInterval === true); -// }); -// if (tmpIntervals && tmpIntervals.length > 0) { -// console.log('found custom interval, adding to app'); -// application.splice(0, 1); -// tmpIntervals.forEach(function(elem, index) { -// -// application.unshift({ -// app: 'GotoIfTimeFromArray', -// appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s', -// IntervalId: elem.IntervalId ? elem.IntervalId : null, -// isInterval: true, -// interval: elem.interval, -// }); -// }) -// } -// priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority); -// //console.log('returned priority'); -// //console.log(priority); -// console.log('creating group of extensions'); -// return VoiceExtension -// .bulkCreate(application, { -// transaction: t -// }) -// }); -// callback(); -// } -// ], -// function(err, result) { -// if (err) { -// console.log(err); -// t.rollback(); -// } else { -// console.log('commit'); -// t.commit(); -// console.log('finished creating, now searching the sorted and saved apps'); -// VoiceExtension -// .findAll({ -// where: { -// VoiceExtensionId: req.params.id, -// isApp: true -// } -// }) -// .then(function(voiceExtensions) { -// console.log('found sorted applications, returning'); -// //console.log(_.pluck(voiceExtensions, 'dataValues')); -// return res.status(201).send(voiceExtensions); -// }) -// } -// }); -// }); -// } - -exports.sortAppsByRoute = function (req, res, next) { - // console.log('finding and saving old applications'); - VoiceExtension - .findAll({ - where: { - appGroup: req.body.applications - } - }) - .then(function (voiceApplications) { - // console.log('found ad saved applications'); - return sequelize.transaction(function (t) { - // console.log('destroying old applications from db'); - return VoiceExtension.destroy({ - where: { - appGroup: req.body.applications - } - }, { - transaction: t - }) - .then(function () { - var priority = 2; - req.body.applications.forEach(function (sortedElem) { - var tmpElem = _.find(voiceApplications, function (elem) { - return (elem.appGroup == sortedElem && elem.isApp === true); - }); - var application = _.cloneDeep(Applications[tmpElem.app]); - if (!application || tmpElem.customApp) { - application = [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }]; - } - var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority); - tmpElem.interval = tmpElem.interval || '*,*,*,*'; - var tmpIntervals = _.filter(voiceApplications, function (elem) { - return (elem.appGroup == sortedElem && elem.isInterval === true); - }); - if (tmpIntervals && tmpIntervals.length > 0) { - // console.log('found custom interval, adding to app'); - application.splice(0, 1); - tmpIntervals.forEach(function (elem, index) { - - application.unshift({ - app: 'GotoIfTimeFromArray', - appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s', - IntervalId: elem.IntervalId ? elem.IntervalId : null, - isInterval: true, - interval: elem.interval, - }); - }) - } - priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority); - //console.log('returned priority'); - //console.log(priority); - // console.log('creating group of extensions'); - return VoiceExtension - .bulkCreate(application, { - transaction: t - }) - }); - }) - }) - .then(function () { - // console.log('finished creating, now searching the sorted and saved apps'); - // VoiceExtension - // .findAll({ - // where: { - // VoiceExtensionId: req.params.id, - // isApp: true - // } - // }) - // .then(function(voiceExtensions) { - // console.log('found sorted applications, returning'); - // //console.log(_.pluck(voiceExtensions, 'dataValues')); - // return res.status(201).send(voiceExtensions); - // }) - return res.sendStatus(201); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return next(err); - }); -}; - -// // Creates a new voice_extension in the DB. -// exports.create = function(req, res) { -// VoiceExtension -// .create(req.body) -// .then(function(voice_extension) { -// return res.status(201).send(voice_extension); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }; - -// Creates a new voiceApplication in the DB. -exports.create = function (req, res, next) { - // //console.log(req.body); - var application; - var appGroup; - var interval; - VoiceExtension - .max('priority', { - where: { - VoiceExtensionId: req.body.VoiceExtensionId - } - }).then(function (max) { - // SET PRIORITY - if (req.body.VoiceExtensionId) { - req.body.priority = max ? ++max : 2; - application = _.cloneDeep(Applications[req.body.app]); - if (!application || req.body.customApp) { - application = [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }]; - } - appGroup = util.format('%s%s%s', req.body.context, req.body.exten, req.body.priority); - // interval = createInterval(req.body); - - - req.body.interval = req.body.interval || '*,*,*,*'; - Interval - .findAll({ - where: { - IntervalId: (req.body.IntervalId !== null) ? req.body.IntervalId : 0 - } - }) - .then(function (Intervals) { - var intervals = []; - var gotoInterval; - if (Intervals && Intervals.length > 0) { - application.splice(0, 1); - intervals = _.pluck(Intervals, 'dataValues'); - intervals.forEach(function (elem, index) { - // gotoInterval = createInterval(elem); - application.unshift({ - app: 'GotoIfTimeFromArray', - appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s', - IntervalId: elem.id, - interval: gotoInterval, - isInterval: true - }); - }) - } - appCreate(application, req.body, appGroup, intervals); - VoiceExtension - .bulkCreate(application) - .then(function (voiceExtensions) { - return res.status(201).send(voiceExtensions); - }) - }) - } else { - VoiceExtension - .findAll({ - where: { - exten: req.body.exten, - context: req.body.context, - type: req.body.type, - } - }) - .then(function (existingExtensions) { - //console.log(existingExtensions); - //console.log('Finding app row.....'); - if (!existingExtensions) { - return res.sendStatus(404); - } - if (existingExtensions.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_ROUTE' - }); - } - req.body.priority = 1; - VoiceExtension - .create(req.body) - .then(function (voiceExtensions) { - return res.status(201).send(voiceExtensions); - }) - .catch(function (err) { - return res.handleError(err); - }) - }) - .catch(function (err) { - return res.handleError(err); - }); - } - // //console.log(application); - - }) - .catch(function (err) { - next(err); - }); -}; - -// function createInterval(element) { -// var interval = []; -// if (element.t_from && element.t_from !== '') { -// interval[0] = element.t_from; -// if (element.t_to && element.t_to !== '') { -// interval[0] += '-' + element.t_to; -// } -// } else { -// interval[0] = '*'; -// } -// -// if (element.wd_from && element.wd_from !== '') { -// interval[1] = element.wd_from; -// if (element.wd_to && element.wd_to !== '') { -// interval[1] += '-' + element.wd_to; -// } -// } else { -// interval[1] = '*'; -// } -// -// if (element.md_from && element.md_from !== '') { -// interval[2] = element.md_from; -// if (element.md_to && element.md_to !== '') { -// interval[2] += '-' + element.md_to; -// } -// } else { -// interval[2] = '*'; -// } -// -// if (element.m_from && element.m_from !== '') { -// interval[3] = element.m_from; -// if (element.m_to && element.m_to !== '') { -// interval[3] += '-' + element.m_to; -// } -// } else { -// interval[3] = '*'; -// } -// -// return interval.join(','); -// } - -function appCreate(application, element, appGroup, intervals, priority) { - var intLength = intervals.length; - if (element.customApp) { - element.app = 'custom'; //in questo modo posso rimuovere il default dello switch, ma lo lascio per completezza - } - switch (element.app) { - case 'Dial': - if (!element.callerID) { - _.remove(application, { - app: 'Set' - }); - } - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Dial': - if (element.type === 'outbound') { - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.trunk = element.trunk; - elem.TrunkId = element.TrunkId; - elem.cutdigits = element.cutdigits || 0; - elem.callerID = element.callerID || null; - // elem.appdata = util.format('SIP/${EXTEN:%d}@%s', elem.cutdigits, elem.trunk); - } else { - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.interface = element.interface; - elem.app_options = element.app_options || ''; - elem.timeout = element.timeout || ''; - elem.url = element.url || ''; - elem.appdata = util.format(elem.appdata, element.interface, elem.timeout, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url); - } - break; - case 'Set': - elem.appdata = util.format(elem.appdata, element.callerID); - break; - case 'NoOp': - if (element.type === 'outbound') { - elem.appdata = 'Outbound Dial Application End'; - } - break; - default: - - } - }); - break; - case 'Queue': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Queue': - elem.IntervalId = element.IntervalId; - elem.app_options = element.app_options || ''; - elem.audiofile = element.audiofile || ''; - elem.queue = element.queue; - elem.interval = element.interval; - elem.interface = element.interface; - elem.app_options = element.app_options; - elem.timeout = element.timeout || ''; - elem.url = element.url || ''; - elem.appdata = util.format(elem.appdata, elem.queue, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url, elem.audiofile, elem.timeout); - break; - default: - - } - }); - break; - case 'Playback': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Playback': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.audiofile = element.audiofile || ''; - elem.app_options = element.app_options || ''; - elem.appdata = util.format(elem.appdata, elem.audiofile, elem.app_options ? elem.app_options.replace(',', '') : ''); - break; - default: - - } - }); - break; - case 'AGI': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'AGI': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.project = element.project; - elem.appdata = util.format(elem.appdata, elem.project); - break; - default: - - } - }); - break; - case 'Goto': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Goto': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.alt_priority = element.alt_priority; - elem.alt_extension = element.alt_extension; - elem.alt_context = element.alt_context; - elem.appdata = util.format(elem.appdata, elem.alt_context, elem.alt_extension, elem.alt_priority); - break; - default: - - } - }); - break; - case 'Hangup': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Hangup': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.causecode = element.causecode; - elem.appdata = util.format(elem.appdata, elem.causecode); - break; - default: - - } - }); - break; - case 'Set': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Set': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.variable = element.variable; - elem.value = element.value; - elem.appdata = util.format(elem.appdata, elem.variable, elem.value); - break; - default: - - } - }); - break; - case 'custom': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'custom': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.app = elem.customApp = element.customApp; - elem.appdata = util.format(elem.appdata, element.appdata); - break; - default: - - } - }); - break; - case 'Voicemail': - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Voicemail': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.mailbox = element.mailbox; - elem.appdata = util.format(elem.appdata, elem.mailbox); - break; - default: - - } - }); - break; - default: - application.forEach(function (elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'custom': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.app = elem.customApp = element.customApp; - elem.appdata = util.format(elem.appdata, element.appdata); - break; - default: - - } - }); - - } - if (priority) { - return priority; - } -} - -// Updates an existing voice_extension in the DB. -exports.update = function (req, res) { - VoiceExtension - .findAll({ - where: { - exten: req.body.exten, - context: req.body.context, - type: req.body.type, - VoiceExtensionId: null, - id: { - $ne: req.body.id - } - } - }) - .then(function (existingExtensions) { - //console.log(existingExtensions); - //console.log('Finding app row.....'); - if (!existingExtensions) { - return res.sendStatus(404); - } - if (existingExtensions.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_ROUTE' - }) - } - if (req.body.id) { - delete req.body.id; - } - VoiceExtension - .find({ - where: { - id: req.params.id - } - }) - .then(function (voice_extension) { - if (!voice_extension) { - return res.sendStatus(404); - } - var updated = _.merge(voice_extension, req.body); - return sequelize.transaction(function (t) { - return updated.save({ - transaction: t - }) - .then(function (updatedRoute) { - VoiceExtension - .findAll({ - where: { - VoiceExtensionId: updatedRoute.id, - isApp: true - } - }) - .then(function (voiceExtensions) { - return VoiceExtension.destroy({ - where: { - VoiceExtensionId: updatedRoute.id - } - }, { - transaction: t - }) - .then(function () { - voiceExtensions = _.pluck(voiceExtensions, 'dataValues'); - var intervalIds = _.filter(_.pluck(voiceExtensions, 'IntervalId'), function (elem) { - return elem !== null; - }); - Interval - .findAll({ - where: { - IntervalId: intervalIds - } - }) - .then(function (intervals) { - var priority = 2; - var interval; - voiceExtensions.forEach(function (tmpElem) { - var application = _.cloneDeep(Applications[tmpElem.app]); - if (!application || tmpElem.customApp) { - application = [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }]; - } - tmpElem.context = updatedRoute.context; - tmpElem.exten = updatedRoute.exten; - var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority); - tmpElem.interval = tmpElem.interval || '*,*,*,*'; - var tmpIntervals = _.filter(intervals, function (elem) { - return (elem.IntervalId == tmpElem.IntervalId); - }); - if (tmpIntervals && tmpIntervals.length > 0) { - application.splice(0, 1); - tmpIntervals.forEach(function (elem, index) { - application.unshift({ - app: 'GotoIfTimeFromArray', - appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s', - IntervalId: elem.id, - isInterval: true, - interval: elem.interval - }); - }) - } - priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority); - VoiceExtension - .bulkCreate(application) - }); - return res.sendStatus(200); - }) - }) - }) - }) - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -// Updates an existing voice_extension in the DB. -exports.updateApplication = function (req, res, next) { - var interval; - if (req.body.appdata) { - delete req.body.appdata; - } - - //console.log('Finding app row.....'); - VoiceExtension - .findById(req.body.id) - .then(function (voiceExtension) { - if (!voiceExtension) { - return res.sendStatus(404); - } - delete req.body.id; - var updated = _.merge(voiceExtension, req.body); - //console.log('Updating app row.....'); - return sequelize.transaction(function (t) { - return updated.save({ - transaction: t - }) - .then(function () { - //console.log('Finding extension apps..'); - VoiceExtension - .findAll({ - where: { - VoiceExtensionId: req.body.VoiceExtensionId, - isApp: true - } - }) - .then(function (voiceExtensions) { - //console.log('Extensions found'); - //console.log('Destroying extension rows...'); - return VoiceExtension.destroy({ - where: { - VoiceExtensionId: req.body.VoiceExtensionId - } - }, { - transaction: t - }) - .then(function () { - voiceExtensions = _.pluck(voiceExtensions, 'dataValues'); - var intervalIds = _.filter(_.pluck(voiceExtensions, 'IntervalId'), function (elem) { - return elem !== null; - }); - return Interval - .findAll({ - where: { - IntervalId: intervalIds - } - }) - .then(function (intervals) { - //console.log('Creating extension rows...'); - var priority = 2; - var interval; - voiceExtensions.forEach(function (tmpElem) { - //console.log('Creating app..'); - var application = _.cloneDeep(Applications[tmpElem.app]); - if (!application || tmpElem.customApp) { - application = [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }]; - } - //console.log('PRIORITY'); - //console.log(priority); - var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority); - tmpElem.interval = tmpElem.interval || '*,*,*,*'; - var tmpIntervals = _.filter(intervals, function (elem) { - return (elem.IntervalId == tmpElem.IntervalId); - }); - if (tmpIntervals && tmpIntervals.length > 0) { - application.splice(0, 1); - tmpIntervals.forEach(function (elem, index) { - // interval = createInterval(elem); - application.unshift({ - app: 'GotoIfTimeFromArray', - appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s', - IntervalId: elem.id, - isInterval: true, - interval: elem.interval - }); - }) - } - priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority); - //console.log('returned priority'); - //console.log(priority); - VoiceExtension - .bulkCreate(application) - }); - //console.log('THE END'); - }) - }) - }) - }) - }) - .then(function (result) { - return res.status(201).send(result); - }) - .catch(function (err) { - return handleError(res, err); - }); - }) - .catch(function (err) { - return handleError(res, err); - }); - -}; - -// Deletes a voice_extension from the DB. -exports.destroy = function (req, res, next) { - VoiceExtension - .findById(req.params.id) - .then(function (voice_extension) { - if (!voice_extension) { - return res.sendStatus(404); - } - if (!voice_extension.VoiceExtensionId) { - voice_extension.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); - } else { - //console.log('isApplication'); - VoiceExtension - .findAll({ - where: { - appGroup: voice_extension.appGroup - } - }) - .then(function (voice_extensions) { - //console.log('found extensions'); - if (!voice_extensions) { - return res.sendStatus(404); - } - return sequelize.transaction(function (t) { - //console.log('trying to delete'); - return VoiceExtension.destroy({ - where: { - appGroup: voice_extension.appGroup - } - }, { - transaction: t - }) - .then(function (deleted_rows) { - //console.log('the length of the group is', deleted_rows); - // //console.log(voice_extensions); - return VoiceExtension - .findAll({ - where: { - VoiceExtensionId: voice_extension.VoiceExtensionId, - priority: { - $gt: voice_extensions[deleted_rows - 1].priority - } - } - }) - .then(function (voiceApplications) { - return VoiceExtension - .destroy({ - where: { - VoiceExtensionId: voice_extension.VoiceExtensionId, - priority: { - $gt: voice_extensions[deleted_rows - 1].priority - } - } - }, { - transaction: t - }) - .then(function () { - var appGroups = _.pluck(_.filter(_.pluck(voiceApplications, 'dataValues'), function (elem) { - return elem.isApp === true; - }), 'appGroup'); - var priority = voice_extensions[0].priority; - appGroups.forEach(function (sortedElem) { - var tmpElem = _.find(voiceApplications, function (elem) { - return (elem.appGroup == sortedElem && elem.isApp === true); - }); - var application = _.cloneDeep(Applications[tmpElem.app]); - if (!application || tmpElem.customApp) { - application = [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }]; - } - //console.log('PRIORITY'); - //console.log(priority); - var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority); - tmpElem.interval = tmpElem.interval || '*,*,*,*'; - var tmpIntervals = _.filter(voiceApplications, function (elem) { - return (elem.appGroup == sortedElem && elem.isInterval === true); - }); - if (tmpIntervals && tmpIntervals.length > 0) { - application.splice(0, 1); - tmpIntervals.forEach(function (elem, index) { - - application.unshift({ - app: 'GotoIfTimeFromArray', - appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s', - IntervalId: elem.IntervalId ? elem.IntervalId : null, - isInterval: true, - interval: elem.interval, - }); - }) - } - priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority); - //console.log('returned priority'); - //console.log(priority); - VoiceExtension - .bulkCreate(application) - }); - }) - }) - }) - }) - .then(function (result) { - // VoiceExtension - // .findAll({ - // where: { - // VoiceExtensionId: voice_extension.VoiceExtensionId, - // isApp: true - // } - // }) - // .then(function(voiceExtensions) { - // // //console.log(_.pluck(voiceExtensions, 'dataValues')); - // return res.status(201).send(voiceExtensions); - // }) - res.sendStatus(201); - }) - .catch(function (err) { - return next(err); - }); - }) - } - }) - .catch(function (err) { - return next(err); - }); -}; - - -// Deletes a agent from the DB. -exports.bulkDestroy = function (req, res) { - VoiceExtension - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x6f17=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x53\x65\x71\x75\x65\x6C\x69\x7A\x65","\x75\x74\x69\x6C","\x61\x73\x79\x6E\x63","\x47\x6F\x74\x6F\x49\x66\x54\x69\x6D\x65","\x25\x73\x3F\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73\x3A\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73","\x53\x65\x74","\x43\x41\x4C\x4C\x45\x52\x49\x44\x28\x61\x6C\x6C\x29\x3D\x25\x73","\x44\x69\x61\x6C","\x25\x73\x2C\x25\x73\x2C\x25\x73\x2C\x25\x73","\x4E\x6F\x4F\x70","\x44\x69\x61\x6C\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x41\x6E\x73\x77\x65\x72","","\x51\x75\x65\x75\x65","\x25\x73\x2C\x25\x73\x2C\x25\x73\x2C\x25\x73\x2C\x25\x73","\x51\x75\x65\x75\x65\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x50\x6C\x61\x79\x62\x61\x63\x6B","\x25\x73\x2C\x25\x73","\x50\x6C\x61\x79\x62\x61\x63\x6B\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x41\x47\x49","\x61\x67\x69\x3A\x2F\x2F\x31\x32\x37\x2E\x30\x2E\x30\x2E\x31\x2F\x73\x71\x75\x61\x72\x65\x2C\x25\x73","\x41\x47\x49\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x47\x6F\x74\x6F","\x25\x73\x2C\x25\x73\x2C\x25\x64","\x47\x6F\x74\x6F\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x48\x61\x6E\x67\x75\x70","\x25\x73","\x48\x61\x6E\x67\x75\x70\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x25\x73\x3D\x25\x73","\x53\x65\x74\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x63\x75\x73\x74\x6F\x6D","\x43\x75\x73\x74\x6F\x6D\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77\x42\x79\x52\x6F\x75\x74\x65","\x63\x6F\x6E\x74\x65\x78\x74","\x65\x78\x74\x65\x6E","\x61\x70\x70","\x61\x70\x70\x64\x61\x74\x61","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x72\x6F\x75\x74\x65","\x70\x61\x72\x61\x6D\x73","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77\x41\x70\x70\x73\x42\x79\x52\x6F\x75\x74\x65","\x69\x64","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x72\x6F\x75\x74\x65\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x74\x79\x70\x65","\x73\x6F\x72\x74\x41\x70\x70\x73\x42\x79\x52\x6F\x75\x74\x65","\x61\x70\x70\x47\x72\x6F\x75\x70","\x69\x73\x41\x70\x70","\x66\x69\x6E\x64","\x63\x6C\x6F\x6E\x65\x44\x65\x65\x70","\x63\x75\x73\x74\x6F\x6D\x41\x70\x70","\x25\x73\x25\x73\x25\x73","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x2A\x2C\x2A\x2C\x2A\x2C\x2A","\x69\x73\x49\x6E\x74\x65\x72\x76\x61\x6C","\x66\x69\x6C\x74\x65\x72","\x6C\x65\x6E\x67\x74\x68","\x73\x70\x6C\x69\x63\x65","\x47\x6F\x74\x6F\x49\x66\x54\x69\x6D\x65\x46\x72\x6F\x6D\x41\x72\x72\x61\x79","\x3F\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73\x3A\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73","\x49\x6E\x74\x65\x72\x76\x61\x6C\x49\x64","\x75\x6E\x73\x68\x69\x66\x74","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x64\x65\x73\x74\x72\x6F\x79","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x63\x72\x65\x61\x74\x65","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x49\x64","\x70\x72\x69\x6F\x72\x69\x74\x79","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x6C\x75\x63\x6B","\x68\x61\x6E\x64\x6C\x65\x45\x72\x72\x6F\x72","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x52\x4F\x55\x54\x45","\x6D\x61\x78","\x63\x61\x6C\x6C\x65\x72\x49\x44","\x72\x65\x6D\x6F\x76\x65","\x6F\x75\x74\x62\x6F\x75\x6E\x64","\x74\x72\x75\x6E\x6B","\x54\x72\x75\x6E\x6B\x49\x64","\x63\x75\x74\x64\x69\x67\x69\x74\x73","\x69\x6E\x74\x65\x72\x66\x61\x63\x65","\x61\x70\x70\x5F\x6F\x70\x74\x69\x6F\x6E\x73","\x74\x69\x6D\x65\x6F\x75\x74","\x75\x72\x6C","\x2C","\x72\x65\x70\x6C\x61\x63\x65","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x20\x44\x69\x61\x6C\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x61\x75\x64\x69\x6F\x66\x69\x6C\x65","\x71\x75\x65\x75\x65","\x70\x72\x6F\x6A\x65\x63\x74","\x61\x6C\x74\x5F\x70\x72\x69\x6F\x72\x69\x74\x79","\x61\x6C\x74\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x61\x6C\x74\x5F\x63\x6F\x6E\x74\x65\x78\x74","\x63\x61\x75\x73\x65\x63\x6F\x64\x65","\x76\x61\x72\x69\x61\x62\x6C\x65","\x76\x61\x6C\x75\x65","\x6D\x61\x69\x6C\x62\x6F\x78","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x75\x70\x64\x61\x74\x65\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x6f17[0];var _=require(_0x6f17[1]);var VoiceExtension=require(_0x6f17[3])[_0x6f17[2]];var Interval=require(_0x6f17[3])[_0x6f17[4]];var sequelize=require(_0x6f17[3])[_0x6f17[5]];var Sequelize=require(_0x6f17[3])[_0x6f17[6]];var util=require(_0x6f17[7]);var async=require(_0x6f17[8]);var Applications={Dial:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[11],appdata:_0x6f17[12]},{app:_0x6f17[13],appdata:_0x6f17[14],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[16]}],Queue:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[17],appdata:_0x6f17[18]},{app:_0x6f17[19],appdata:_0x6f17[20],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[21]}],Playback:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[22],appdata:_0x6f17[23],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[24]}],AGI:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[25],appdata:_0x6f17[26],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[27]}],Goto:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[28],appdata:_0x6f17[29],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[30]}],Hangup:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[31],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[33]}],Set:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[11],appdata:_0x6f17[34],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[35]}],custom:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[36],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[37]}],Voicemail:[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[38],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[39]}]};exports[_0x6f17[40]]=function(_0x23f7x9,_0x23f7xa){VoiceExtension[_0x6f17[45]]()[_0x6f17[44]](function(_0x23f7xc){return _0x23f7xa[_0x6f17[43]](200)[_0x6f17[42]](_0x23f7xc)})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})};exports[_0x6f17[46]]=function(_0x23f7x9,_0x23f7xa,_0x23f7xd){var _0x23f7xe=[_0x6f17[47],_0x6f17[48],_0x6f17[49],_0x6f17[50]];var _0x23f7xf=_0x23f7x9[_0x6f17[52]][_0x6f17[51]]?parseInt(_0x23f7x9[_0x6f17[52]][_0x6f17[51]],10):100;var _0x23f7x10=_0x23f7x9[_0x6f17[52]][_0x6f17[53]]?parseInt(_0x23f7x9[_0x6f17[52]][_0x6f17[53]],10):0;var _0x23f7x11={where:{type:_0x23f7x9[_0x6f17[55]][_0x6f17[54]],VoiceExtensionId:null,app:_0x6f17[15]},limit:_0x23f7xf,offset:_0x23f7x10*_0x23f7xf};_[_0x6f17[69]](_0x23f7x9[_0x6f17[52]],function(_0x23f7x12,_0x23f7x13){switch(_0x23f7x13){case _0x6f17[51]:;case _0x6f17[53]:break ;;case _0x6f17[58]:_0x23f7x11[_0x6f17[56]]=util[_0x6f17[61]](_0x6f17[57],_0x23f7x9[_0x6f17[52]][_0x6f17[58]],_0x23f7x9[_0x6f17[52]][_0x6f17[59]]||_0x6f17[60])||null;break ;;case _0x6f17[59]:break ;;case _0x6f17[67]:_0x23f7x11[_0x6f17[63]][_0x6f17[62]]=[];_0x23f7xe[_0x6f17[66]](function(_0x23f7x14){var _0x23f7x15={};_0x23f7x15[_0x23f7x14]={$like:_0x6f17[64]+_0x23f7x12+_0x6f17[64]};_0x23f7x11[_0x6f17[63]][_0x6f17[62]][_0x6f17[65]](_0x23f7x15);});break ;;default:_0x23f7x11[_0x6f17[63]][_0x23f7x13]={$like:{}};_0x23f7x11[_0x6f17[63]][_0x23f7x13][_0x6f17[68]]=_0x6f17[64]+_0x23f7x12+_0x6f17[64];;}});VoiceExtension[_0x6f17[80]](_0x23f7x11)[_0x6f17[44]](function(_0x23f7x16){var _0x23f7x17=Math[_0x6f17[72]](_0x23f7x16[_0x6f17[71]]/_0x23f7xf);var _0x23f7x18=_0x23f7x17>(_0x23f7x11[_0x6f17[73]]+1)?util[_0x6f17[61]](_0x6f17[74],_0x23f7x9[_0x6f17[75]],_0x23f7x9[_0x6f17[77]][_0x6f17[76]],_0x23f7x9[_0x6f17[78]],_0x23f7x10+1):null;var _0x23f7x19=_0x23f7x10>0?util[_0x6f17[61]](_0x6f17[74],_0x23f7x9[_0x6f17[75]],_0x23f7x9[_0x6f17[77]][_0x6f17[76]],_0x23f7x9[_0x6f17[78]],_0x23f7x10-1):null;_0x23f7xa[_0x6f17[43]](200)[_0x6f17[42]]({count:_0x23f7x16[_0x6f17[71]],rows:_0x23f7x16[_0x6f17[79]],next_page:_0x23f7x18,previous_page:_0x23f7x19,total_pages:_0x23f7x17});})[_0x6f17[41]](function(_0x23f7xb){_0x23f7xa[_0x6f17[43]](500)[_0x6f17[42]]({error:_0x6f17[70]})});};exports[_0x6f17[81]]=function(_0x23f7x9,_0x23f7xa){VoiceExtension[_0x6f17[45]]({where:{VoiceExtensionId:_0x23f7x9[_0x6f17[55]][_0x6f17[82]],isApp:true}})[_0x6f17[44]](function(_0x23f7xc){return _0x23f7xa[_0x6f17[43]](200)[_0x6f17[42]](_0x23f7xc)})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})};exports[_0x6f17[83]]=function(_0x23f7x9,_0x23f7xa){VoiceExtension[_0x6f17[85]](_0x23f7x9[_0x6f17[55]][_0x6f17[82]])[_0x6f17[44]](function(_0x23f7x1a){if(!_0x23f7x1a){return _0x23f7xa[_0x6f17[84]](404)};return _0x23f7xa[_0x6f17[42]](_0x23f7x1a);})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})};exports[_0x6f17[86]]=function(_0x23f7x9,_0x23f7xa){VoiceExtension[_0x6f17[45]]({where:{exten:_0x23f7x9[_0x6f17[87]][_0x6f17[48]],context:_0x23f7x9[_0x6f17[87]][_0x6f17[47]],type:_0x23f7x9[_0x6f17[87]][_0x6f17[88]]}})[_0x6f17[44]](function(_0x23f7x1a){if(!_0x23f7x1a){return _0x23f7xa[_0x6f17[84]](404)};return _0x23f7xa[_0x6f17[42]](_0x23f7x1a);})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})};exports[_0x6f17[89]]=function(_0x23f7x9,_0x23f7xa,_0x23f7xd){VoiceExtension[_0x6f17[45]]({where:{appGroup:_0x23f7x9[_0x6f17[87]][_0x6f17[107]]}})[_0x6f17[44]](function(_0x23f7x1b){return sequelize[_0x6f17[109]](function(_0x23f7x1c){return VoiceExtension[_0x6f17[108]]({where:{appGroup:_0x23f7x9[_0x6f17[87]][_0x6f17[107]]}},{transaction:_0x23f7x1c})[_0x6f17[44]](function(){var _0x23f7x1d=2;_0x23f7x9[_0x6f17[87]][_0x6f17[107]][_0x6f17[66]](function(_0x23f7x1e){var _0x23f7x1f=_[_0x6f17[92]](_0x23f7x1b,function(_0x23f7x20){return (_0x23f7x20[_0x6f17[90]]==_0x23f7x1e&&_0x23f7x20[_0x6f17[91]]===true)});var _0x23f7x21=_[_0x6f17[93]](Applications[_0x23f7x1f[_0x6f17[49]]]);if(!_0x23f7x21||_0x23f7x1f[_0x6f17[94]]){_0x23f7x21=[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[36],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[37]}]};var _0x23f7x22=util[_0x6f17[61]](_0x6f17[95],_0x23f7x1f[_0x6f17[47]],_0x23f7x1f[_0x6f17[48]],_0x23f7x1d);_0x23f7x1f[_0x6f17[96]]=_0x23f7x1f[_0x6f17[96]]||_0x6f17[97];var _0x23f7x23=_[_0x6f17[99]](_0x23f7x1b,function(_0x23f7x20){return (_0x23f7x20[_0x6f17[90]]==_0x23f7x1e&&_0x23f7x20[_0x6f17[98]]===true)});if(_0x23f7x23&&_0x23f7x23[_0x6f17[100]]>0){_0x23f7x21[_0x6f17[101]](0,1);_0x23f7x23[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x21[_0x6f17[105]]({app:_0x6f17[102],appdata:_0x23f7x20[_0x6f17[96]]+_0x6f17[103],IntervalId:_0x23f7x20[_0x6f17[104]]?_0x23f7x20[_0x6f17[104]]:null,isInterval:true,interval:_0x23f7x20[_0x6f17[96]]})});};_0x23f7x1d=appCreate(_0x23f7x21,_0x23f7x1f,_0x23f7x22,_0x23f7x23||[],_0x23f7x1d);return VoiceExtension[_0x6f17[106]](_0x23f7x21,{transaction:_0x23f7x1c});});})})[_0x6f17[44]](function(){return _0x23f7xa[_0x6f17[84]](201)})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})})[_0x6f17[41]](function(_0x23f7xb){return _0x23f7xd(_0x23f7xb)})};exports[_0x6f17[110]]=function(_0x23f7x9,_0x23f7xa,_0x23f7xd){var _0x23f7x21;var _0x23f7x22;var _0x23f7x25;VoiceExtension[_0x6f17[117]](_0x6f17[112],{where:{VoiceExtensionId:_0x23f7x9[_0x6f17[87]][_0x6f17[111]]}})[_0x6f17[44]](function(_0x23f7x26){if(_0x23f7x9[_0x6f17[87]][_0x6f17[111]]){_0x23f7x9[_0x6f17[87]][_0x6f17[112]]=_0x23f7x26?++_0x23f7x26:2;_0x23f7x21=_[_0x6f17[93]](Applications[_0x23f7x9[_0x6f17[87]][_0x6f17[49]]]);if(!_0x23f7x21||_0x23f7x9[_0x6f17[87]][_0x6f17[94]]){_0x23f7x21=[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[36],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[37]}]};_0x23f7x22=util[_0x6f17[61]](_0x6f17[95],_0x23f7x9[_0x6f17[87]][_0x6f17[47]],_0x23f7x9[_0x6f17[87]][_0x6f17[48]],_0x23f7x9[_0x6f17[87]][_0x6f17[112]]);_0x23f7x9[_0x6f17[87]][_0x6f17[96]]=_0x23f7x9[_0x6f17[87]][_0x6f17[96]]||_0x6f17[97];Interval[_0x6f17[45]]({where:{IntervalId:(_0x23f7x9[_0x6f17[87]][_0x6f17[104]]!==null)?_0x23f7x9[_0x6f17[87]][_0x6f17[104]]:0}})[_0x6f17[44]](function(_0x23f7x27){var _0x23f7x28=[];var _0x23f7x29;if(_0x23f7x27&&_0x23f7x27[_0x6f17[100]]>0){_0x23f7x21[_0x6f17[101]](0,1);_0x23f7x28=_[_0x6f17[114]](_0x23f7x27,_0x6f17[113]);_0x23f7x28[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x21[_0x6f17[105]]({app:_0x6f17[102],appdata:_0x23f7x20[_0x6f17[96]]+_0x6f17[103],IntervalId:_0x23f7x20[_0x6f17[82]],interval:_0x23f7x29,isInterval:true})});};appCreate(_0x23f7x21,_0x23f7x9[_0x6f17[87]],_0x23f7x22,_0x23f7x28);VoiceExtension[_0x6f17[106]](_0x23f7x21)[_0x6f17[44]](function(_0x23f7x2a){return _0x23f7xa[_0x6f17[43]](201)[_0x6f17[42]](_0x23f7x2a)});});}else {VoiceExtension[_0x6f17[45]]({where:{exten:_0x23f7x9[_0x6f17[87]][_0x6f17[48]],context:_0x23f7x9[_0x6f17[87]][_0x6f17[47]],type:_0x23f7x9[_0x6f17[87]][_0x6f17[88]]}})[_0x6f17[44]](function(_0x23f7x2b){if(!_0x23f7x2b){return _0x23f7xa[_0x6f17[84]](404)};if(_0x23f7x2b[_0x6f17[100]]>0){return _0x23f7xa[_0x6f17[43]](500)[_0x6f17[42]]({message:_0x6f17[116]})};_0x23f7x9[_0x6f17[87]][_0x6f17[112]]=1;VoiceExtension[_0x6f17[110]](_0x23f7x9[_0x6f17[87]])[_0x6f17[44]](function(_0x23f7x2a){return _0x23f7xa[_0x6f17[43]](201)[_0x6f17[42]](_0x23f7x2a)})[_0x6f17[41]](function(_0x23f7xb){return _0x23f7xa[_0x6f17[115]](_0x23f7xb)});})[_0x6f17[41]](function(_0x23f7xb){return _0x23f7xa[_0x6f17[115]](_0x23f7xb)})}})[_0x6f17[41]](function(_0x23f7xb){_0x23f7xd(_0x23f7xb)});};function appCreate(_0x23f7x21,_0x23f7x2d,_0x23f7x22,_0x23f7x28,_0x23f7x1d){var _0x23f7x2e=_0x23f7x28[_0x6f17[100]];if(_0x23f7x2d[_0x6f17[94]]){_0x23f7x2d[_0x6f17[49]]=_0x6f17[36]};switch(_0x23f7x2d[_0x6f17[49]]){case _0x6f17[13]:if(!_0x23f7x2d[_0x6f17[118]]){_[_0x6f17[119]](_0x23f7x21,{app:_0x6f17[11]})};_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[13]:if(_0x23f7x2d[_0x6f17[88]]===_0x6f17[120]){_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[121]]=_0x23f7x2d[_0x6f17[121]];_0x23f7x20[_0x6f17[122]]=_0x23f7x2d[_0x6f17[122]];_0x23f7x20[_0x6f17[123]]=_0x23f7x2d[_0x6f17[123]]||0;_0x23f7x20[_0x6f17[118]]=_0x23f7x2d[_0x6f17[118]]||null;}else {_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[124]]=_0x23f7x2d[_0x6f17[124]];_0x23f7x20[_0x6f17[125]]=_0x23f7x2d[_0x6f17[125]]||_0x6f17[18];_0x23f7x20[_0x6f17[126]]=_0x23f7x2d[_0x6f17[126]]||_0x6f17[18];_0x23f7x20[_0x6f17[127]]=_0x23f7x2d[_0x6f17[127]]||_0x6f17[18];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[124]],_0x23f7x20[_0x6f17[126]],_0x23f7x20[_0x6f17[125]]?_0x23f7x20[_0x6f17[125]][_0x6f17[129]](_0x6f17[128],_0x6f17[18]):_0x6f17[18],_0x23f7x20[_0x6f17[127]]);};break ;;case _0x6f17[11]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[118]]);break ;;case _0x6f17[15]:if(_0x23f7x2d[_0x6f17[88]]===_0x6f17[120]){_0x23f7x20[_0x6f17[50]]=_0x6f17[130]};break ;;default:;};});break ;;case _0x6f17[19]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[19]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[125]]=_0x23f7x2d[_0x6f17[125]]||_0x6f17[18];_0x23f7x20[_0x6f17[131]]=_0x23f7x2d[_0x6f17[131]]||_0x6f17[18];_0x23f7x20[_0x6f17[132]]=_0x23f7x2d[_0x6f17[132]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[124]]=_0x23f7x2d[_0x6f17[124]];_0x23f7x20[_0x6f17[125]]=_0x23f7x2d[_0x6f17[125]];_0x23f7x20[_0x6f17[126]]=_0x23f7x2d[_0x6f17[126]]||_0x6f17[18];_0x23f7x20[_0x6f17[127]]=_0x23f7x2d[_0x6f17[127]]||_0x6f17[18];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[132]],_0x23f7x20[_0x6f17[125]]?_0x23f7x20[_0x6f17[125]][_0x6f17[129]](_0x6f17[128],_0x6f17[18]):_0x6f17[18],_0x23f7x20[_0x6f17[127]],_0x23f7x20[_0x6f17[131]],_0x23f7x20[_0x6f17[126]]);break ;;default:;};});break ;;case _0x6f17[22]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[22]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[131]]=_0x23f7x2d[_0x6f17[131]]||_0x6f17[18];_0x23f7x20[_0x6f17[125]]=_0x23f7x2d[_0x6f17[125]]||_0x6f17[18];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[131]],_0x23f7x20[_0x6f17[125]]?_0x23f7x20[_0x6f17[125]][_0x6f17[129]](_0x6f17[128],_0x6f17[18]):_0x6f17[18]);break ;;default:;};});break ;;case _0x6f17[25]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[25]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[133]]=_0x23f7x2d[_0x6f17[133]];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[133]]);break ;;default:;};});break ;;case _0x6f17[28]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[28]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[134]]=_0x23f7x2d[_0x6f17[134]];_0x23f7x20[_0x6f17[135]]=_0x23f7x2d[_0x6f17[135]];_0x23f7x20[_0x6f17[136]]=_0x23f7x2d[_0x6f17[136]];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[136]],_0x23f7x20[_0x6f17[135]],_0x23f7x20[_0x6f17[134]]);break ;;default:;};});break ;;case _0x6f17[31]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[31]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[137]]=_0x23f7x2d[_0x6f17[137]];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[137]]);break ;;default:;};});break ;;case _0x6f17[11]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[11]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[138]]=_0x23f7x2d[_0x6f17[138]];_0x23f7x20[_0x6f17[139]]=_0x23f7x2d[_0x6f17[139]];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[138]],_0x23f7x20[_0x6f17[139]]);break ;;default:;};});break ;;case _0x6f17[36]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[36]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[49]]=_0x23f7x20[_0x6f17[94]]=_0x23f7x2d[_0x6f17[94]];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[50]]);break ;;default:;};});break ;;case _0x6f17[38]:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[38]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[140]]=_0x23f7x2d[_0x6f17[140]];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[140]]);break ;;default:;};});break ;;default:_0x23f7x21[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x20[_0x6f17[48]]=_0x23f7x2d[_0x6f17[48]];_0x23f7x20[_0x6f17[88]]=_0x23f7x2d[_0x6f17[88]];_0x23f7x20[_0x6f17[47]]=_0x23f7x2d[_0x6f17[47]];_0x23f7x20[_0x6f17[111]]=_0x23f7x2d[_0x6f17[111]];_0x23f7x20[_0x6f17[112]]=_0x23f7x1d?_0x23f7x1d++:_0x23f7x2d[_0x6f17[112]]++;_0x23f7x20[_0x6f17[90]]=_0x23f7x22;switch(_0x23f7x20[_0x6f17[49]]){case _0x6f17[9]:_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[104]]?_0x6f17[97]:_0x23f7x2d[_0x6f17[96]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+1,_0x23f7x20[_0x6f17[47]],(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[102]:_0x23f7x20[_0x6f17[49]]=_0x6f17[9];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x20[_0x6f17[47]],_0x23f7x20[_0x6f17[112]]+_0x23f7x2e-_0x23f7x24,_0x23f7x20[_0x6f17[47]],(_0x23f7x24+1)<_0x23f7x2e?(_0x23f7x20[_0x6f17[112]]+1):(_0x23f7x20[_0x6f17[112]]+2));break ;;case _0x6f17[36]:_0x23f7x20[_0x6f17[104]]=_0x23f7x2d[_0x6f17[104]];_0x23f7x20[_0x6f17[96]]=_0x23f7x2d[_0x6f17[96]];_0x23f7x20[_0x6f17[49]]=_0x23f7x20[_0x6f17[94]]=_0x23f7x2d[_0x6f17[94]];_0x23f7x20[_0x6f17[50]]=util[_0x6f17[61]](_0x23f7x20[_0x6f17[50]],_0x23f7x2d[_0x6f17[50]]);break ;;default:;};});;};if(_0x23f7x1d){return _0x23f7x1d};}exports[_0x6f17[141]]=function(_0x23f7x9,_0x23f7xa){VoiceExtension[_0x6f17[45]]({where:{exten:_0x23f7x9[_0x6f17[87]][_0x6f17[48]],context:_0x23f7x9[_0x6f17[87]][_0x6f17[47]],type:_0x23f7x9[_0x6f17[87]][_0x6f17[88]],VoiceExtensionId:null,id:{$ne:_0x23f7x9[_0x6f17[87]][_0x6f17[82]]}}})[_0x6f17[44]](function(_0x23f7x2b){if(!_0x23f7x2b){return _0x23f7xa[_0x6f17[84]](404)};if(_0x23f7x2b[_0x6f17[100]]>0){return _0x23f7xa[_0x6f17[43]](500)[_0x6f17[42]]({message:_0x6f17[116]})};if(_0x23f7x9[_0x6f17[87]][_0x6f17[82]]){delete _0x23f7x9[_0x6f17[87]][_0x6f17[82]]};VoiceExtension[_0x6f17[92]]({where:{id:_0x23f7x9[_0x6f17[55]][_0x6f17[82]]}})[_0x6f17[44]](function(_0x23f7x1a){if(!_0x23f7x1a){return _0x23f7xa[_0x6f17[84]](404)};var _0x23f7x2f=_[_0x6f17[142]](_0x23f7x1a,_0x23f7x9[_0x6f17[87]]);return sequelize[_0x6f17[109]](function(_0x23f7x1c){return _0x23f7x2f[_0x6f17[143]]({transaction:_0x23f7x1c})[_0x6f17[44]](function(_0x23f7x30){VoiceExtension[_0x6f17[45]]({where:{VoiceExtensionId:_0x23f7x30[_0x6f17[82]],isApp:true}})[_0x6f17[44]](function(_0x23f7x2a){return VoiceExtension[_0x6f17[108]]({where:{VoiceExtensionId:_0x23f7x30[_0x6f17[82]]}},{transaction:_0x23f7x1c})[_0x6f17[44]](function(){_0x23f7x2a=_[_0x6f17[114]](_0x23f7x2a,_0x6f17[113]);var _0x23f7x31=_[_0x6f17[99]](_[_0x6f17[114]](_0x23f7x2a,_0x6f17[104]),function(_0x23f7x20){return _0x23f7x20!==null});Interval[_0x6f17[45]]({where:{IntervalId:_0x23f7x31}})[_0x6f17[44]](function(_0x23f7x28){var _0x23f7x1d=2;var _0x23f7x25;_0x23f7x2a[_0x6f17[66]](function(_0x23f7x1f){var _0x23f7x21=_[_0x6f17[93]](Applications[_0x23f7x1f[_0x6f17[49]]]);if(!_0x23f7x21||_0x23f7x1f[_0x6f17[94]]){_0x23f7x21=[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[36],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[37]}]};_0x23f7x1f[_0x6f17[47]]=_0x23f7x30[_0x6f17[47]];_0x23f7x1f[_0x6f17[48]]=_0x23f7x30[_0x6f17[48]];var _0x23f7x22=util[_0x6f17[61]](_0x6f17[95],_0x23f7x1f[_0x6f17[47]],_0x23f7x1f[_0x6f17[48]],_0x23f7x1d);_0x23f7x1f[_0x6f17[96]]=_0x23f7x1f[_0x6f17[96]]||_0x6f17[97];var _0x23f7x23=_[_0x6f17[99]](_0x23f7x28,function(_0x23f7x20){return (_0x23f7x20[_0x6f17[104]]==_0x23f7x1f[_0x6f17[104]])});if(_0x23f7x23&&_0x23f7x23[_0x6f17[100]]>0){_0x23f7x21[_0x6f17[101]](0,1);_0x23f7x23[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x21[_0x6f17[105]]({app:_0x6f17[102],appdata:_0x23f7x20[_0x6f17[96]]+_0x6f17[103],IntervalId:_0x23f7x20[_0x6f17[82]],isInterval:true,interval:_0x23f7x20[_0x6f17[96]]})});};_0x23f7x1d=appCreate(_0x23f7x21,_0x23f7x1f,_0x23f7x22,_0x23f7x23||[],_0x23f7x1d);VoiceExtension[_0x6f17[106]](_0x23f7x21);});return _0x23f7xa[_0x6f17[84]](200);});})})})})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)});})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)});})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})};exports[_0x6f17[144]]=function(_0x23f7x9,_0x23f7xa,_0x23f7xd){var _0x23f7x25;if(_0x23f7x9[_0x6f17[87]][_0x6f17[50]]){delete _0x23f7x9[_0x6f17[87]][_0x6f17[50]]};VoiceExtension[_0x6f17[85]](_0x23f7x9[_0x6f17[87]][_0x6f17[82]])[_0x6f17[44]](function(_0x23f7x32){if(!_0x23f7x32){return _0x23f7xa[_0x6f17[84]](404)};delete _0x23f7x9[_0x6f17[87]][_0x6f17[82]];var _0x23f7x2f=_[_0x6f17[142]](_0x23f7x32,_0x23f7x9[_0x6f17[87]]);return sequelize[_0x6f17[109]](function(_0x23f7x1c){return _0x23f7x2f[_0x6f17[143]]({transaction:_0x23f7x1c})[_0x6f17[44]](function(){VoiceExtension[_0x6f17[45]]({where:{VoiceExtensionId:_0x23f7x9[_0x6f17[87]][_0x6f17[111]],isApp:true}})[_0x6f17[44]](function(_0x23f7x2a){return VoiceExtension[_0x6f17[108]]({where:{VoiceExtensionId:_0x23f7x9[_0x6f17[87]][_0x6f17[111]]}},{transaction:_0x23f7x1c})[_0x6f17[44]](function(){_0x23f7x2a=_[_0x6f17[114]](_0x23f7x2a,_0x6f17[113]);var _0x23f7x31=_[_0x6f17[99]](_[_0x6f17[114]](_0x23f7x2a,_0x6f17[104]),function(_0x23f7x20){return _0x23f7x20!==null});return Interval[_0x6f17[45]]({where:{IntervalId:_0x23f7x31}})[_0x6f17[44]](function(_0x23f7x28){var _0x23f7x1d=2;var _0x23f7x25;_0x23f7x2a[_0x6f17[66]](function(_0x23f7x1f){var _0x23f7x21=_[_0x6f17[93]](Applications[_0x23f7x1f[_0x6f17[49]]]);if(!_0x23f7x21||_0x23f7x1f[_0x6f17[94]]){_0x23f7x21=[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[36],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[37]}]};var _0x23f7x22=util[_0x6f17[61]](_0x6f17[95],_0x23f7x1f[_0x6f17[47]],_0x23f7x1f[_0x6f17[48]],_0x23f7x1d);_0x23f7x1f[_0x6f17[96]]=_0x23f7x1f[_0x6f17[96]]||_0x6f17[97];var _0x23f7x23=_[_0x6f17[99]](_0x23f7x28,function(_0x23f7x20){return (_0x23f7x20[_0x6f17[104]]==_0x23f7x1f[_0x6f17[104]])});if(_0x23f7x23&&_0x23f7x23[_0x6f17[100]]>0){_0x23f7x21[_0x6f17[101]](0,1);_0x23f7x23[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x21[_0x6f17[105]]({app:_0x6f17[102],appdata:_0x23f7x20[_0x6f17[96]]+_0x6f17[103],IntervalId:_0x23f7x20[_0x6f17[82]],isInterval:true,interval:_0x23f7x20[_0x6f17[96]]})});};_0x23f7x1d=appCreate(_0x23f7x21,_0x23f7x1f,_0x23f7x22,_0x23f7x23||[],_0x23f7x1d);VoiceExtension[_0x6f17[106]](_0x23f7x21);});});})})})})[_0x6f17[44]](function(_0x23f7x16){return _0x23f7xa[_0x6f17[43]](201)[_0x6f17[42]](_0x23f7x16)})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)});})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)});};exports[_0x6f17[108]]=function(_0x23f7x9,_0x23f7xa,_0x23f7xd){VoiceExtension[_0x6f17[85]](_0x23f7x9[_0x6f17[55]][_0x6f17[82]])[_0x6f17[44]](function(_0x23f7x1a){if(!_0x23f7x1a){return _0x23f7xa[_0x6f17[84]](404)};if(!_0x23f7x1a[_0x6f17[111]]){_0x23f7x1a[_0x6f17[108]]()[_0x6f17[44]](function(){return _0x23f7xa[_0x6f17[84]](204)})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})}else {VoiceExtension[_0x6f17[45]]({where:{appGroup:_0x23f7x1a[_0x6f17[90]]}})[_0x6f17[44]](function(_0x23f7xc){if(!_0x23f7xc){return _0x23f7xa[_0x6f17[84]](404)};return sequelize[_0x6f17[109]](function(_0x23f7x1c){return VoiceExtension[_0x6f17[108]]({where:{appGroup:_0x23f7x1a[_0x6f17[90]]}},{transaction:_0x23f7x1c})[_0x6f17[44]](function(_0x23f7x33){return VoiceExtension[_0x6f17[45]]({where:{VoiceExtensionId:_0x23f7x1a[_0x6f17[111]],priority:{$gt:_0x23f7xc[_0x23f7x33-1][_0x6f17[112]]}}})[_0x6f17[44]](function(_0x23f7x1b){return VoiceExtension[_0x6f17[108]]({where:{VoiceExtensionId:_0x23f7x1a[_0x6f17[111]],priority:{$gt:_0x23f7xc[_0x23f7x33-1][_0x6f17[112]]}}},{transaction:_0x23f7x1c})[_0x6f17[44]](function(){var _0x23f7x34=_[_0x6f17[114]](_[_0x6f17[99]](_[_0x6f17[114]](_0x23f7x1b,_0x6f17[113]),function(_0x23f7x20){return _0x23f7x20[_0x6f17[91]]===true}),_0x6f17[90]);var _0x23f7x1d=_0x23f7xc[0][_0x6f17[112]];_0x23f7x34[_0x6f17[66]](function(_0x23f7x1e){var _0x23f7x1f=_[_0x6f17[92]](_0x23f7x1b,function(_0x23f7x20){return (_0x23f7x20[_0x6f17[90]]==_0x23f7x1e&&_0x23f7x20[_0x6f17[91]]===true)});var _0x23f7x21=_[_0x6f17[93]](Applications[_0x23f7x1f[_0x6f17[49]]]);if(!_0x23f7x21||_0x23f7x1f[_0x6f17[94]]){_0x23f7x21=[{app:_0x6f17[9],appdata:_0x6f17[10]},{app:_0x6f17[36],appdata:_0x6f17[32],isApp:true},{app:_0x6f17[15],appdata:_0x6f17[37]}]};var _0x23f7x22=util[_0x6f17[61]](_0x6f17[95],_0x23f7x1f[_0x6f17[47]],_0x23f7x1f[_0x6f17[48]],_0x23f7x1d);_0x23f7x1f[_0x6f17[96]]=_0x23f7x1f[_0x6f17[96]]||_0x6f17[97];var _0x23f7x23=_[_0x6f17[99]](_0x23f7x1b,function(_0x23f7x20){return (_0x23f7x20[_0x6f17[90]]==_0x23f7x1e&&_0x23f7x20[_0x6f17[98]]===true)});if(_0x23f7x23&&_0x23f7x23[_0x6f17[100]]>0){_0x23f7x21[_0x6f17[101]](0,1);_0x23f7x23[_0x6f17[66]](function(_0x23f7x20,_0x23f7x24){_0x23f7x21[_0x6f17[105]]({app:_0x6f17[102],appdata:_0x23f7x20[_0x6f17[96]]+_0x6f17[103],IntervalId:_0x23f7x20[_0x6f17[104]]?_0x23f7x20[_0x6f17[104]]:null,isInterval:true,interval:_0x23f7x20[_0x6f17[96]]})});};_0x23f7x1d=appCreate(_0x23f7x21,_0x23f7x1f,_0x23f7x22,_0x23f7x23||[],_0x23f7x1d);VoiceExtension[_0x6f17[106]](_0x23f7x21);});})})})})[_0x6f17[44]](function(_0x23f7x16){_0x23f7xa[_0x6f17[84]](201)})[_0x6f17[41]](function(_0x23f7xb){return _0x23f7xd(_0x23f7xb)});})};})[_0x6f17[41]](function(_0x23f7xb){return _0x23f7xd(_0x23f7xb)})};exports[_0x6f17[145]]=function(_0x23f7x9,_0x23f7xa){VoiceExtension[_0x6f17[108]]({where:{id:_0x23f7x9[_0x6f17[52]][_0x6f17[82]]},individualHooks:true})[_0x6f17[44]](function(){return _0x23f7xa[_0x6f17[84]](204)})[_0x6f17[41]](function(_0x23f7xb){return handleError(_0x23f7xa,_0x23f7xb)})};function handleError(_0x23f7xa,_0x23f7xb){return _0x23f7xa[_0x6f17[43]](500)[_0x6f17[42]](_0x23f7xb)} \ No newline at end of file diff --git a/server/api/voice_extension/voice_extension.socket.js b/server/api/voice_extension/voice_extension.socket.js index da477d1..3ab3b4b 100644 --- a/server/api/voice_extension/voice_extension.socket.js +++ b/server/api/voice_extension/voice_extension.socket.js @@ -1,34 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var VoiceExtension = require('../../models').VoiceExtension; - -exports.register = function(socket) { - VoiceExtension.afterCreate(function(doc) { - onSave(socket, doc); - }); - VoiceExtension.afterDestroy(function(doc) { - onRemove(socket, doc); - }); - VoiceExtension.afterBulkDestroy(function(doc) { - onRemove(socket, doc); - }); - VoiceExtension.afterUpdate(function(doc) { - onUpdate(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('voice_extension:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('voice_extension:remove', doc); -} - -function onUpdate(socket, doc, cb) { - socket.emit('voice_extension:update', doc); -} +var _0x55e3=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x66\x74\x65\x72\x42\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65","\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x3A\x75\x70\x64\x61\x74\x65"];_0x55e3[0];var VoiceExtension=require(_0x55e3[2])[_0x55e3[1]];exports[_0x55e3[3]]=function(_0x4f2dx2){VoiceExtension[_0x55e3[4]](function(_0x4f2dx3){onSave(_0x4f2dx2,_0x4f2dx3)});VoiceExtension[_0x55e3[5]](function(_0x4f2dx3){onRemove(_0x4f2dx2,_0x4f2dx3)});VoiceExtension[_0x55e3[6]](function(_0x4f2dx3){onRemove(_0x4f2dx2,_0x4f2dx3)});VoiceExtension[_0x55e3[7]](function(_0x4f2dx3){onUpdate(_0x4f2dx2,_0x4f2dx3)});};function onSave(_0x4f2dx2,_0x4f2dx3,_0x4f2dx5){_0x4f2dx2[_0x55e3[9]](_0x55e3[8],_0x4f2dx3)}function onRemove(_0x4f2dx2,_0x4f2dx3,_0x4f2dx5){_0x4f2dx2[_0x55e3[9]](_0x55e3[10],_0x4f2dx3)}function onUpdate(_0x4f2dx2,_0x4f2dx3,_0x4f2dx5){_0x4f2dx2[_0x55e3[9]](_0x55e3[11],_0x4f2dx3)} \ No newline at end of file diff --git a/server/api/voice_extension/voice_extension.spec.js b/server/api/voice_extension/voice_extension.spec.js index 0971536..d57323f 100644 --- a/server/api/voice_extension/voice_extension.spec.js +++ b/server/api/voice_extension/voice_extension.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/voice/extensions', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/voice/extensions') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xc47e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x67\x65\x74"];_0xc47e[0];var should=require(_0xc47e[1]);var app=require(_0xc47e[2]);var request=require(_0xc47e[3]);describe(_0xc47e[4],function(){it(_0xc47e[5],function(_0x56fax4){request(app)[_0xc47e[13]](_0xc47e[12])[_0xc47e[11]](200)[_0xc47e[11]](_0xc47e[10],/json/)[_0xc47e[9]](function(_0x56fax5,_0x56fax6){if(_0x56fax5){return _0x56fax4(_0x56fax5)};_0x56fax6[_0xc47e[8]][_0xc47e[1]][_0xc47e[7]][_0xc47e[6]](Array);_0x56fax4();})})}); \ No newline at end of file diff --git a/server/api/voice_musiconhold/index.js b/server/api/voice_musiconhold/index.js index 59cc818..b292740 100644 --- a/server/api/voice_musiconhold/index.js +++ b/server/api/voice_musiconhold/index.js @@ -1,21 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./voice_musiconhold.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/stream', auth.isAuthenticated(), controller.stream); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/files', auth.isAuthenticated(), controller.showAudioFiles); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.mohValidation); -router.post('/:id/files', auth.isAuthenticated(), controller.addFiles); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); -router.delete('/:id/files', auth.isAuthenticated(), controller.deleteAudioFiles); - -module.exports = router; +var _0x8c86=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x76\x6F\x69\x63\x65\x5F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x73\x74\x72\x65\x61\x6D","\x73\x74\x72\x65\x61\x6D","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x66\x69\x6C\x65\x73","\x73\x68\x6F\x77\x41\x75\x64\x69\x6F\x46\x69\x6C\x65\x73","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x6D\x6F\x68\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x61\x64\x64\x46\x69\x6C\x65\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65\x41\x75\x64\x69\x6F\x46\x69\x6C\x65\x73","\x65\x78\x70\x6F\x72\x74\x73"];_0x8c86[0];var express=require(_0x8c86[1]);var controller=require(_0x8c86[2]);var auth=require(_0x8c86[3]);var router=express.Router();router[_0x8c86[7]](_0x8c86[4],auth[_0x8c86[5]](),controller[_0x8c86[6]]);router[_0x8c86[7]](_0x8c86[8],auth[_0x8c86[5]](),controller[_0x8c86[9]]);router[_0x8c86[7]](_0x8c86[10],auth[_0x8c86[5]](),controller[_0x8c86[11]]);router[_0x8c86[7]](_0x8c86[12],auth[_0x8c86[5]](),controller[_0x8c86[13]]);router[_0x8c86[15]](_0x8c86[4],auth[_0x8c86[5]](),controller[_0x8c86[14]]);router[_0x8c86[15]](_0x8c86[16],auth[_0x8c86[5]](),controller[_0x8c86[17]]);router[_0x8c86[15]](_0x8c86[12],auth[_0x8c86[5]](),controller[_0x8c86[18]]);router[_0x8c86[20]](_0x8c86[10],auth[_0x8c86[5]](),controller[_0x8c86[19]]);router[_0x8c86[22]](_0x8c86[4],auth[_0x8c86[5]](),controller[_0x8c86[21]]);router[_0x8c86[22]](_0x8c86[10],auth[_0x8c86[5]](),controller[_0x8c86[23]]);router[_0x8c86[22]](_0x8c86[12],auth[_0x8c86[5]](),controller[_0x8c86[24]]);module[_0x8c86[25]]=router; \ No newline at end of file diff --git a/server/api/voice_musiconhold/voice_musiconhold.controller.js b/server/api/voice_musiconhold/voice_musiconhold.controller.js index 72f8b70..f453bb9 100644 --- a/server/api/voice_musiconhold/voice_musiconhold.controller.js +++ b/server/api/voice_musiconhold/voice_musiconhold.controller.js @@ -1,357 +1 @@ -'use strict'; - -var _ = require('lodash'); -var VoiceMusicOnHold = require('../../models').VoiceMusicOnHold; -var fs = require('fs'); -var remove = require('remove'); -var Upload = require('../../models').Upload; -var fse = require('fs-extra'); -var path = require('path'); -var config = require('../../config/environment'); -var sequelize = require('../../models').sequelize; -var util = require('util'); -var base64 = require('file-base64'); - -// Get list of voice_musiconholds -exports.index = function(req, res) { - - var attributes = ['name', 'directory', 'sort', 'description']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - - VoiceMusicOnHold - .findAndCountAll(query) - .then(function(result) { - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single voice_musiconhold -exports.show = function(req, res) { - VoiceMusicOnHold - .findById(req.params.id) - .then(function(voice_musiconhold) { - if (!voice_musiconhold) { - return res.sendStatus(404); - } - return res.send(voice_musiconhold); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Add files to moh class -exports.addFiles = function(req, res) { - VoiceMusicOnHold - .findById(req.params.id) - .then(function(voice_musiconhold) { - if (!voice_musiconhold) { - return res.sendStatus(404); - } - Upload - .findAll({ - where: { - id: req.body.sounds - } - }) - .then(function(soundFiles) { - var origin = path.join(config.root, 'server/files/sounds/converted'); - var dest; - soundFiles.forEach(function(elem) { - dest = path.join(voice_musiconhold.directory, elem.display_name + '.wav'); - fse.copySync(path.join(origin, elem.save_name + '.wav'), dest); - }); - fs.chmodSync(dest, parseInt('0777', 8)); - res.sendStatus(200); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.showAudioFiles = function(req, res) { - var fileObject = {}; - VoiceMusicOnHold - .findById(req.params.id) - .then(function(voice_musiconhold) { - if (!voice_musiconhold) { - return res.sendStatus(404); - } - fileObject.path = voice_musiconhold.directory; - fs.readdir(voice_musiconhold.directory, function(err, files) { - if (!err) { - fileObject.files = files; - return res.send(fileObject); - } else { - throw err; - } - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.deleteAudioFiles = function(req, res) { - VoiceMusicOnHold - .findById(req.params.id) - .then(function(voice_musiconhold) { - if (!voice_musiconhold) { - return res.sendStatus(404); - } - var deletePath = voice_musiconhold.directory + '/' + req.query.filename; - fs.unlink(deletePath, function(err) { - if (err) { - return handleError(res, err); - } else { - return res.sendStatus(204); - } - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Validate the existence of a route -exports.mohValidation = function(req, res) { - console.log(req.body); - VoiceMusicOnHold - .findAll({ - where: { - name: req.body.name, - } - }) - .then(function(voice_mohs) { - if (!voice_mohs) { - return res.sendStatus(404); - } - return res.send(voice_mohs); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new voice_musiconhold in the DB. -exports.create = function(req, res) { - VoiceMusicOnHold - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(existingMohs) { - console.log(existingMohs); - console.log('Finding app row.....'); - if (!existingMohs) { - console.log('error1'); - return res.sendStatus(404); - } - if (existingMohs.length > 0) { - console.log('error2'); - return res.status(500).send({ - message: 'MESSAGE_EXIST_MOH' - }); - } - return sequelize.transaction().then(function(t) { - req.body.directory = path.join(config.root, 'server/files/moh', req.body.name); - return VoiceMusicOnHold - .create(req.body, { - transaction: t - }) - .then(function(voice_musiconhold) { - fs.mkdir(voice_musiconhold.directory, parseInt('0777', 8), function(err) { - if (err) { - console.log('file error'); - t.rollback(); - return res.status(500).send({ - message: 'MESSAGE_FILE_CREATION_ERROR' - }); - } - t.commit(); - console.log('file created'); - return res.status(201).send(voice_musiconhold); - }); - }) - .catch(function(err) { - t.rollback(); - }); - }) - }) - .catch(function(err) { - console.log('thaterror'); - return handleError(res, err); - }); -}; - -// Updates an existing voice_musiconhold in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - VoiceMusicOnHold - .find({ - where: { - id: req.params.id - } - }) - .then(function(voice_musiconhold) { - if (!voice_musiconhold) { - return res.sendStatus(404); - } - var updated = _.merge(voice_musiconhold, req.body); - updated.save() - .then(function() { - return res.status(200).send(voice_musiconhold); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a voice_musiconhold from the DB. -exports.destroy = function(req, res) { - VoiceMusicOnHold - .findById(req.params.id) - .then(function(voice_musiconhold) { - if (!voice_musiconhold) { - return res.sendStatus(404); - } - return sequelize.transaction(function(t) { - return voice_musiconhold.destroy({ - transaction: t - }) - .then(function() { - remove(voice_musiconhold.directory, function(err) { - if (err) { - console.log(err); - } - return res.sendStatus(204); - }); - }) - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes multiple voice_musiconholds from the DB. -exports.bulkDestroy = function(req, res) { - VoiceMusicOnHold - .findAll({ - where: { - id: req.query.id - } - }) - .then(function(voice_musiconholds) { - if (!voice_musiconholds) { - return res.sendStatus(404); - } - return sequelize.transaction(function(t) { - voice_musiconholds.forEach(function(element) { - return element.destroy({ - transaction: t - }) - .then(function() { - remove(element.directory, function(err) { - if (err) { - console.log(err); - throw err - } - }); - }) - }) - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - console.log(err); - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// stream a moh file -exports.stream = function(req, res) { - var filepath = decodeURI(req.query.path); - base64.encode(filepath, function(err, base64String) { - if (err) { - return handleError(res, err); - } else { - return res.status(200).send(base64String); - } - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x4218=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x56\x6F\x69\x63\x65\x4D\x75\x73\x69\x63\x4F\x6E\x48\x6F\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x66\x73","\x72\x65\x6D\x6F\x76\x65","\x55\x70\x6C\x6F\x61\x64","\x66\x73\x2D\x65\x78\x74\x72\x61","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x75\x74\x69\x6C","\x66\x69\x6C\x65\x2D\x62\x61\x73\x65\x36\x34","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x69\x72\x65\x63\x74\x6F\x72\x79","\x73\x6F\x72\x74","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x64\x64\x46\x69\x6C\x65\x73","\x6C\x6F\x67","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x73\x6F\x75\x6E\x64\x73\x2F\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x6A\x6F\x69\x6E","\x64\x69\x73\x70\x6C\x61\x79\x5F\x6E\x61\x6D\x65","\x2E\x77\x61\x76","\x73\x61\x76\x65\x5F\x6E\x61\x6D\x65","\x63\x6F\x70\x79\x53\x79\x6E\x63","\x30\x37\x37\x37","\x63\x68\x6D\x6F\x64\x53\x79\x6E\x63","\x73\x6F\x75\x6E\x64\x73","\x62\x6F\x64\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77\x41\x75\x64\x69\x6F\x46\x69\x6C\x65\x73","\x66\x69\x6C\x65\x73","\x72\x65\x61\x64\x64\x69\x72","\x64\x65\x6C\x65\x74\x65\x41\x75\x64\x69\x6F\x46\x69\x6C\x65\x73","\x2F","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x75\x6E\x6C\x69\x6E\x6B","\x6D\x6F\x68\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x63\x72\x65\x61\x74\x65","\x74\x68\x61\x74\x65\x72\x72\x6F\x72","\x46\x69\x6E\x64\x69\x6E\x67\x20\x61\x70\x70\x20\x72\x6F\x77\x2E\x2E\x2E\x2E\x2E","\x65\x72\x72\x6F\x72\x31","\x6C\x65\x6E\x67\x74\x68","\x65\x72\x72\x6F\x72\x32","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x4D\x4F\x48","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x6D\x6F\x68","\x72\x6F\x6C\x6C\x62\x61\x63\x6B","\x66\x69\x6C\x65\x20\x65\x72\x72\x6F\x72","\x4D\x45\x53\x53\x41\x47\x45\x5F\x46\x49\x4C\x45\x5F\x43\x52\x45\x41\x54\x49\x4F\x4E\x5F\x45\x52\x52\x4F\x52","\x63\x6F\x6D\x6D\x69\x74","\x66\x69\x6C\x65\x20\x63\x72\x65\x61\x74\x65\x64","\x6D\x6B\x64\x69\x72","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x73\x74\x72\x65\x61\x6D","\x65\x6E\x63\x6F\x64\x65"];_0x4218[0];var _=require(_0x4218[1]);var VoiceMusicOnHold=require(_0x4218[3])[_0x4218[2]];var fs=require(_0x4218[4]);var remove=require(_0x4218[5]);var Upload=require(_0x4218[3])[_0x4218[6]];var fse=require(_0x4218[7]);var path=require(_0x4218[8]);var config=require(_0x4218[9]);var sequelize=require(_0x4218[3])[_0x4218[10]];var util=require(_0x4218[11]);var base64=require(_0x4218[12]);exports[_0x4218[13]]=function(_0x8d59xc,_0x8d59xd){var _0x8d59xe=[_0x4218[14],_0x4218[15],_0x4218[16],_0x4218[17]];var _0x8d59xf=_0x8d59xc[_0x4218[19]][_0x4218[18]]?parseInt(_0x8d59xc[_0x4218[19]][_0x4218[18]],10):100;var _0x8d59x10=_0x8d59xc[_0x4218[19]][_0x4218[20]]?parseInt(_0x8d59xc[_0x4218[19]][_0x4218[20]],10):0;var _0x8d59x11={where:{},limit:_0x8d59xf,offset:_0x8d59x10*_0x8d59xf};_[_0x4218[34]](_0x8d59xc[_0x4218[19]],function(_0x8d59x12,_0x8d59x13){switch(_0x8d59x13){case _0x4218[18]:;case _0x4218[20]:break ;;case _0x4218[23]:_0x8d59x11[_0x4218[21]]=util[_0x4218[26]](_0x4218[22],_0x8d59xc[_0x4218[19]][_0x4218[23]],_0x8d59xc[_0x4218[19]][_0x4218[24]]||_0x4218[25])||null;break ;;case _0x4218[24]:break ;;case _0x4218[32]:_0x8d59x11[_0x4218[28]][_0x4218[27]]=[];_0x8d59xe[_0x4218[31]](function(_0x8d59x14){var _0x8d59x15={};_0x8d59x15[_0x8d59x14]={$like:_0x4218[29]+_0x8d59x12+_0x4218[29]};_0x8d59x11[_0x4218[28]][_0x4218[27]][_0x4218[30]](_0x8d59x15);});break ;;default:_0x8d59x11[_0x4218[28]][_0x8d59x13]={$like:{}};_0x8d59x11[_0x4218[28]][_0x8d59x13][_0x4218[33]]=_0x4218[29]+_0x8d59x12+_0x4218[29];;}});VoiceMusicOnHold[_0x4218[48]](_0x8d59x11)[_0x4218[47]](function(_0x8d59x17){var _0x8d59x18=Math[_0x4218[37]](_0x8d59x17[_0x4218[36]]/_0x8d59xf);var _0x8d59x19=_0x8d59x18>(_0x8d59x11[_0x4218[38]]+1)?util[_0x4218[26]](_0x4218[39],_0x8d59xc[_0x4218[40]],_0x8d59xc[_0x4218[42]][_0x4218[41]],_0x8d59xc[_0x4218[43]],_0x8d59x10+1):null;var _0x8d59x1a=_0x8d59x10>0?util[_0x4218[26]](_0x4218[39],_0x8d59xc[_0x4218[40]],_0x8d59xc[_0x4218[42]][_0x4218[41]],_0x8d59xc[_0x4218[43]],_0x8d59x10-1):null;_0x8d59xd[_0x4218[46]](200)[_0x4218[45]]({count:_0x8d59x17[_0x4218[36]],rows:_0x8d59x17[_0x4218[44]],next_page:_0x8d59x19,previous_page:_0x8d59x1a,total_pages:_0x8d59x18});})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)});};exports[_0x4218[49]]=function(_0x8d59xc,_0x8d59xd){VoiceMusicOnHold[_0x4218[53]](_0x8d59xc[_0x4218[52]][_0x4218[51]])[_0x4218[47]](function(_0x8d59x1b){if(!_0x8d59x1b){return _0x8d59xd[_0x4218[50]](404)};return _0x8d59xd[_0x4218[45]](_0x8d59x1b);})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)})};exports[_0x4218[54]]=function(_0x8d59xc,_0x8d59xd){VoiceMusicOnHold[_0x4218[53]](_0x8d59xc[_0x4218[52]][_0x4218[51]])[_0x4218[47]](function(_0x8d59x1b){if(!_0x8d59x1b){return _0x8d59xd[_0x4218[50]](404)};Upload[_0x4218[67]]({where:{id:_0x8d59xc[_0x4218[66]][_0x4218[65]]}})[_0x4218[47]](function(_0x8d59x1c){var _0x8d59x1d=path[_0x4218[58]](config[_0x4218[56]],_0x4218[57]);var _0x8d59x1e;_0x8d59x1c[_0x4218[31]](function(_0x8d59x1f){_0x8d59x1e=path[_0x4218[58]](_0x8d59x1b[_0x4218[15]],_0x8d59x1f[_0x4218[59]]+_0x4218[60]);fse[_0x4218[62]](path[_0x4218[58]](_0x8d59x1d,_0x8d59x1f[_0x4218[61]]+_0x4218[60]),_0x8d59x1e);});fs[_0x4218[64]](_0x8d59x1e,parseInt(_0x4218[63],8));_0x8d59xd[_0x4218[50]](200);})[_0x4218[35]](function(_0x8d59x16){console[_0x4218[55]](_0x8d59x16);return handleError(_0x8d59xd,_0x8d59x16);});})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)})};exports[_0x4218[68]]=function(_0x8d59xc,_0x8d59xd){var _0x8d59x20={};VoiceMusicOnHold[_0x4218[53]](_0x8d59xc[_0x4218[52]][_0x4218[51]])[_0x4218[47]](function(_0x8d59x1b){if(!_0x8d59x1b){return _0x8d59xd[_0x4218[50]](404)};_0x8d59x20[_0x4218[8]]=_0x8d59x1b[_0x4218[15]];fs[_0x4218[70]](_0x8d59x1b[_0x4218[15]],function(_0x8d59x16,_0x8d59x21){if(!_0x8d59x16){_0x8d59x20[_0x4218[69]]=_0x8d59x21;return _0x8d59xd[_0x4218[45]](_0x8d59x20);}else {throw _0x8d59x16}});})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)});};exports[_0x4218[71]]=function(_0x8d59xc,_0x8d59xd){VoiceMusicOnHold[_0x4218[53]](_0x8d59xc[_0x4218[52]][_0x4218[51]])[_0x4218[47]](function(_0x8d59x1b){if(!_0x8d59x1b){return _0x8d59xd[_0x4218[50]](404)};var _0x8d59x22=_0x8d59x1b[_0x4218[15]]+_0x4218[72]+_0x8d59xc[_0x4218[19]][_0x4218[73]];fs[_0x4218[74]](_0x8d59x22,function(_0x8d59x16){if(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)}else {return _0x8d59xd[_0x4218[50]](204)}});})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)})};exports[_0x4218[75]]=function(_0x8d59xc,_0x8d59xd){console[_0x4218[55]](_0x8d59xc[_0x4218[66]]);VoiceMusicOnHold[_0x4218[67]]({where:{name:_0x8d59xc[_0x4218[66]][_0x4218[14]]}})[_0x4218[47]](function(_0x8d59x23){if(!_0x8d59x23){return _0x8d59xd[_0x4218[50]](404)};return _0x8d59xd[_0x4218[45]](_0x8d59x23);})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)});};exports[_0x4218[76]]=function(_0x8d59xc,_0x8d59xd){VoiceMusicOnHold[_0x4218[67]]({where:{name:_0x8d59xc[_0x4218[66]][_0x4218[14]]}})[_0x4218[47]](function(_0x8d59x24){console[_0x4218[55]](_0x8d59x24);console[_0x4218[55]](_0x4218[78]);if(!_0x8d59x24){console[_0x4218[55]](_0x4218[79]);return _0x8d59xd[_0x4218[50]](404);};if(_0x8d59x24[_0x4218[80]]>0){console[_0x4218[55]](_0x4218[81]);return _0x8d59xd[_0x4218[46]](500)[_0x4218[45]]({message:_0x4218[82]});};return sequelize[_0x4218[90]]()[_0x4218[47]](function(_0x8d59x25){_0x8d59xc[_0x4218[66]][_0x4218[15]]=path[_0x4218[58]](config[_0x4218[56]],_0x4218[83],_0x8d59xc[_0x4218[66]][_0x4218[14]]);return VoiceMusicOnHold[_0x4218[76]](_0x8d59xc[_0x4218[66]],{transaction:_0x8d59x25})[_0x4218[47]](function(_0x8d59x1b){fs[_0x4218[89]](_0x8d59x1b[_0x4218[15]],parseInt(_0x4218[63],8),function(_0x8d59x16){if(_0x8d59x16){console[_0x4218[55]](_0x4218[85]);_0x8d59x25[_0x4218[84]]();return _0x8d59xd[_0x4218[46]](500)[_0x4218[45]]({message:_0x4218[86]});};_0x8d59x25[_0x4218[87]]();console[_0x4218[55]](_0x4218[88]);return _0x8d59xd[_0x4218[46]](201)[_0x4218[45]](_0x8d59x1b);})})[_0x4218[35]](function(_0x8d59x16){_0x8d59x25[_0x4218[84]]()});});})[_0x4218[35]](function(_0x8d59x16){console[_0x4218[55]](_0x4218[77]);return handleError(_0x8d59xd,_0x8d59x16);})};exports[_0x4218[91]]=function(_0x8d59xc,_0x8d59xd){if(_0x8d59xc[_0x4218[66]][_0x4218[51]]){delete _0x8d59xc[_0x4218[66]][_0x4218[51]]};VoiceMusicOnHold[_0x4218[94]]({where:{id:_0x8d59xc[_0x4218[52]][_0x4218[51]]}})[_0x4218[47]](function(_0x8d59x1b){if(!_0x8d59x1b){return _0x8d59xd[_0x4218[50]](404)};var _0x8d59x26=_[_0x4218[92]](_0x8d59x1b,_0x8d59xc[_0x4218[66]]);_0x8d59x26[_0x4218[93]]()[_0x4218[47]](function(){return _0x8d59xd[_0x4218[46]](200)[_0x4218[45]](_0x8d59x1b)})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)});})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)});};exports[_0x4218[95]]=function(_0x8d59xc,_0x8d59xd){VoiceMusicOnHold[_0x4218[53]](_0x8d59xc[_0x4218[52]][_0x4218[51]])[_0x4218[47]](function(_0x8d59x1b){if(!_0x8d59x1b){return _0x8d59xd[_0x4218[50]](404)};return sequelize[_0x4218[90]](function(_0x8d59x25){return _0x8d59x1b[_0x4218[95]]({transaction:_0x8d59x25})[_0x4218[47]](function(){remove(_0x8d59x1b[_0x4218[15]],function(_0x8d59x16){if(_0x8d59x16){console[_0x4218[55]](_0x8d59x16)};return _0x8d59xd[_0x4218[50]](204);})})})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)});})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)})};exports[_0x4218[96]]=function(_0x8d59xc,_0x8d59xd){VoiceMusicOnHold[_0x4218[67]]({where:{id:_0x8d59xc[_0x4218[19]][_0x4218[51]]}})[_0x4218[47]](function(_0x8d59x27){if(!_0x8d59x27){return _0x8d59xd[_0x4218[50]](404)};return sequelize[_0x4218[90]](function(_0x8d59x25){_0x8d59x27[_0x4218[31]](function(_0x8d59x28){return _0x8d59x28[_0x4218[95]]({transaction:_0x8d59x25})[_0x4218[47]](function(){remove(_0x8d59x28[_0x4218[15]],function(_0x8d59x16){if(_0x8d59x16){console[_0x4218[55]](_0x8d59x16);throw _0x8d59x16;}})})})})[_0x4218[47]](function(){return _0x8d59xd[_0x4218[50]](204)})[_0x4218[35]](function(_0x8d59x16){console[_0x4218[55]](_0x8d59x16);return handleError(_0x8d59xd,_0x8d59x16);});})[_0x4218[35]](function(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)})};exports[_0x4218[97]]=function(_0x8d59xc,_0x8d59xd){var _0x8d59x29=decodeURI(_0x8d59xc[_0x4218[19]][_0x4218[8]]);base64[_0x4218[98]](_0x8d59x29,function(_0x8d59x16,_0x8d59x2a){if(_0x8d59x16){return handleError(_0x8d59xd,_0x8d59x16)}else {return _0x8d59xd[_0x4218[46]](200)[_0x4218[45]](_0x8d59x2a)}});};function handleError(_0x8d59xd,_0x8d59x16){return _0x8d59xd[_0x4218[46]](500)[_0x4218[45]](_0x8d59x16)} \ No newline at end of file diff --git a/server/api/voice_musiconhold/voice_musiconhold.socket.js b/server/api/voice_musiconhold/voice_musiconhold.socket.js index efa073f..dcb9080 100644 --- a/server/api/voice_musiconhold/voice_musiconhold.socket.js +++ b/server/api/voice_musiconhold/voice_musiconhold.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var VoiceMusicOnHold = require('../../models').VoiceMusicOnHold; - -exports.register = function(socket) { - VoiceMusicOnHold.afterCreate(function(doc) { - onSave(socket, doc); - }); - VoiceMusicOnHold.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('voice_musiconhold:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('voice_musiconhold:remove', doc); -} +var _0x215d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x6F\x69\x63\x65\x4D\x75\x73\x69\x63\x4F\x6E\x48\x6F\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x76\x6F\x69\x63\x65\x5F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x76\x6F\x69\x63\x65\x5F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0x215d[0];var VoiceMusicOnHold=require(_0x215d[2])[_0x215d[1]];exports[_0x215d[3]]=function(_0xf691x2){VoiceMusicOnHold[_0x215d[4]](function(_0xf691x3){onSave(_0xf691x2,_0xf691x3)});VoiceMusicOnHold[_0x215d[5]](function(_0xf691x3){onRemove(_0xf691x2,_0xf691x3)});};function onSave(_0xf691x2,_0xf691x3,_0xf691x5){_0xf691x2[_0x215d[7]](_0x215d[6],_0xf691x3)}function onRemove(_0xf691x2,_0xf691x3,_0xf691x5){_0xf691x2[_0x215d[7]](_0x215d[8],_0xf691x3)} \ No newline at end of file diff --git a/server/api/voice_musiconhold/voice_musiconhold.spec.js b/server/api/voice_musiconhold/voice_musiconhold.spec.js index e992daf..06cd99b 100644 --- a/server/api/voice_musiconhold/voice_musiconhold.spec.js +++ b/server/api/voice_musiconhold/voice_musiconhold.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/voice/musiconhold', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/voice/musiconhold') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xff29=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64","\x67\x65\x74"];_0xff29[0];var should=require(_0xff29[1]);var app=require(_0xff29[2]);var request=require(_0xff29[3]);describe(_0xff29[4],function(){it(_0xff29[5],function(_0x4ebfx4){request(app)[_0xff29[13]](_0xff29[12])[_0xff29[11]](200)[_0xff29[11]](_0xff29[10],/json/)[_0xff29[9]](function(_0x4ebfx5,_0x4ebfx6){if(_0x4ebfx5){return _0x4ebfx4(_0x4ebfx5)};_0x4ebfx6[_0xff29[8]][_0xff29[1]][_0xff29[7]][_0xff29[6]](Array);_0x4ebfx4();})})}); \ No newline at end of file diff --git a/server/api/voice_queue/index.js b/server/api/voice_queue/index.js index a11cd5b..5027fd0 100644 --- a/server/api/voice_queue/index.js +++ b/server/api/voice_queue/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./voice_queue.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.queueValidation); -router.post('/:id/agents', auth.isAuthenticated(), controller.addAgents); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.put('/:id/agents', auth.isAuthenticated(), controller.removeAgents); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:name', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x5ef1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x71\x75\x65\x75\x65\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x2F\x3A\x69\x64\x2F\x61\x67\x65\x6E\x74\x73","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x2F\x3A\x6E\x61\x6D\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x5ef1[0];var express=require(_0x5ef1[1]);var controller=require(_0x5ef1[2]);var auth=require(_0x5ef1[3]);var router=express.Router();router[_0x5ef1[7]](_0x5ef1[4],auth[_0x5ef1[5]](),controller[_0x5ef1[6]]);router[_0x5ef1[7]](_0x5ef1[8],auth[_0x5ef1[5]](),controller[_0x5ef1[9]]);router[_0x5ef1[11]](_0x5ef1[4],auth[_0x5ef1[5]](),controller[_0x5ef1[10]]);router[_0x5ef1[11]](_0x5ef1[12],auth[_0x5ef1[5]](),controller[_0x5ef1[13]]);router[_0x5ef1[11]](_0x5ef1[14],auth[_0x5ef1[5]](),controller[_0x5ef1[15]]);router[_0x5ef1[17]](_0x5ef1[8],auth[_0x5ef1[5]](),controller[_0x5ef1[16]]);router[_0x5ef1[17]](_0x5ef1[14],auth[_0x5ef1[5]](),controller[_0x5ef1[18]]);router[_0x5ef1[20]](_0x5ef1[4],auth[_0x5ef1[5]](),controller[_0x5ef1[19]]);router[_0x5ef1[20]](_0x5ef1[21],auth[_0x5ef1[5]](),controller[_0x5ef1[22]]);module[_0x5ef1[23]]=router; \ No newline at end of file diff --git a/server/api/voice_queue/voice_queue.controller.js b/server/api/voice_queue/voice_queue.controller.js index 209bdeb..9051570 100644 --- a/server/api/voice_queue/voice_queue.controller.js +++ b/server/api/voice_queue/voice_queue.controller.js @@ -1,339 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); - -var User = require('../../models').User; -var VoiceQueue = require('../../models').VoiceQueue; -var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue; -var VoiceExtension = require('../../models').VoiceExtension; - -// Get list of voice_queues -exports.index = function(req, res) { - // console.log(req.query.page); - var attributes = ['name', 'description', 'strategy', 'context']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - VoiceQueue - .findAndCountAll(query) - .then(function(result) { - console.log(result.count); - var total_pages = Math.ceil(result.count / per_page); - console.log(total_pages); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single voice_queue -exports.show = function(req, res) { - VoiceQueue - .findById(req.params.id) - .then(function(voice_queue) { - if (!voice_queue) { - return res.sendStatus(404); - } - return res.send(voice_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Validate the existence of a queue -exports.queueValidation = function(req, res) { - console.log(req.body); - VoiceQueue - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(voice_queue) { - if (!voice_queue) { - return res.sendStatus(404); - } - return res.send(voice_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new voice_queue in the DB. -exports.create = function(req, res) { - VoiceQueue - .findAll({ - where: { - name: req.body.name - } - }) - .then(function(existingQueues) { - console.log(existingQueues); - console.log('Finding app row.....'); - if (!existingQueues) { - return res.sendStatus(404); - } - if (existingQueues.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_QUEUE' - }); - } - VoiceQueue - .create(req.body) - .then(function(voice_queue) { - return res.status(201).send(voice_queue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing voice_queue in the DB. -exports.update = function(req, res) { - VoiceQueue - .find({ - where: { - name: req.params.id - } - }) - .then(function(voiceQueue) { - if (!voiceQueue) { - return res.sendStatus(404); - } - if (req.body.id) { - delete req.body.id; - } - var updated = _.merge(voiceQueue, req.body); - updated.save() - .then(function() { - return res.status(200).send(voiceQueue); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - - -// Updates an existing user_has_voiceQueue in the DB. -exports.addAgents = function(req, res, next) { - - console.log('addAgents'); - console.log(req.params); - console.log(req.body); - User - .findAll({ - where: { - id: { - $in: req.body.agents - } - } - }) - .then(function(users) { - // console.log(users); - var userHasVoiceQueues = _.map(users, function(user) { - return { - queue: req.params.id, - location: util.format('SIP/%s', user.name), - membername: user.name, - VoiceQueueName: req.params.id, - UserId: user.id - }; - }); - - UserHasVoiceQueue - .bulkCreate(userHasVoiceQueues, { - individualHooks: true - }) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return next(err); - }); - }) - .catch(function(err) { - return next(err); - }); -}; - -exports.removeAgents = function(req, res, next) { - VoiceQueue - .find({ - where: { - name: req.params.id - } - }) - .then(function(voiceQueue) { - if (voiceQueue) { - // QUEUE FOUND - // REMOVE AGENTS - voiceQueue - .removeUsers(req.body.agents, { - individualHooks: true - }) - .then(function() { - return res.sendStatus(200); - }) - .catch(function(err) { - return next(err); - }); - } else { - return next(new Error('no mail queue found')); - } - }) - .catch(function(err) { - return next(err); - }); -}; - -// Deletes a voice_queue from the DB. -exports.destroy = function(req, res) { - VoiceQueue - .find({ - where: { - name: req.params.name - } - }) - .then(function(voice_queue) { - if (!voice_queue) { - return res.sendStatus(404); - } - VoiceExtension - .findAll({ - where: { - queue: voice_queue.name - } - }) - .then(function(contextExtensions) { - if (contextExtensions.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_QUEUE_ROUTE_ASSOCIATED' - }); - } - voice_queue.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes multiple voice_queues from the DB. -exports.bulkDestroy = function(req, res) { - VoiceQueue - .findAll({ - where: { - name: req.query.name - } - }) - .then(function(voice_queues) { - if (!voice_queues) { - return res.sendStatus(404); - } - var destroyQueuesNames = _.pluck(_.pluck(voice_queues, 'dataValues'), 'name'); - console.log(destroyQueuesNames); - VoiceExtension - .findAll({ - where: { - queue: destroyQueuesNames - } - }) - .then(function(contextExtensions) { - if (contextExtensions.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_QUEUE_ROUTE_ASSOCIATED' - }); - } - VoiceQueue - .destroy({ - where: { - name: req.query.name - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x4359=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x73\x74\x72\x61\x74\x65\x67\x79","\x63\x6F\x6E\x74\x65\x78\x74","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x6C\x6F\x67","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x71\x75\x65\x75\x65\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x46\x69\x6E\x64\x69\x6E\x67\x20\x61\x70\x70\x20\x72\x6F\x77\x2E\x2E\x2E\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x51\x55\x45\x55\x45","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x53\x49\x50\x2F\x25\x73","\x6D\x61\x70","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x61\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x55\x73\x65\x72\x73","\x6E\x6F\x20\x6D\x61\x69\x6C\x20\x71\x75\x65\x75\x65\x20\x66\x6F\x75\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x51\x55\x45\x55\x45\x5F\x52\x4F\x55\x54\x45\x5F\x41\x53\x53\x4F\x43\x49\x41\x54\x45\x44","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x6C\x75\x63\x6B"];_0x4359[0];var _=require(_0x4359[1]);var util=require(_0x4359[2]);var User=require(_0x4359[4])[_0x4359[3]];var VoiceQueue=require(_0x4359[4])[_0x4359[5]];var UserHasVoiceQueue=require(_0x4359[4])[_0x4359[6]];var VoiceExtension=require(_0x4359[4])[_0x4359[7]];exports[_0x4359[8]]=function(_0x61d1x7,_0x61d1x8){var _0x61d1x9=[_0x4359[9],_0x4359[10],_0x4359[11],_0x4359[12]];var _0x61d1xa=_0x61d1x7[_0x4359[14]][_0x4359[13]]?parseInt(_0x61d1x7[_0x4359[14]][_0x4359[13]],10):100;var _0x61d1xb=_0x61d1x7[_0x4359[14]][_0x4359[15]]?parseInt(_0x61d1x7[_0x4359[14]][_0x4359[15]],10):0;var _0x61d1xc={where:{},limit:_0x61d1xa,offset:_0x61d1xb*_0x61d1xa};_[_0x4359[29]](_0x61d1x7[_0x4359[14]],function(_0x61d1xd,_0x61d1xe){switch(_0x61d1xe){case _0x4359[13]:;case _0x4359[15]:break ;;case _0x4359[18]:_0x61d1xc[_0x4359[16]]=util[_0x4359[21]](_0x4359[17],_0x61d1x7[_0x4359[14]][_0x4359[18]],_0x61d1x7[_0x4359[14]][_0x4359[19]]||_0x4359[20])||null;break ;;case _0x4359[19]:break ;;case _0x4359[27]:_0x61d1xc[_0x4359[23]][_0x4359[22]]=[];_0x61d1x9[_0x4359[26]](function(_0x61d1xf){var _0x61d1x10={};_0x61d1x10[_0x61d1xf]={$like:_0x4359[24]+_0x61d1xd+_0x4359[24]};_0x61d1xc[_0x4359[23]][_0x4359[22]][_0x4359[25]](_0x61d1x10);});break ;;default:_0x61d1xc[_0x4359[23]][_0x61d1xe]={$like:{}};_0x61d1xc[_0x4359[23]][_0x61d1xe][_0x4359[28]]=_0x4359[24]+_0x61d1xd+_0x4359[24];;}});VoiceQueue[_0x4359[44]](_0x61d1xc)[_0x4359[43]](function(_0x61d1x12){console[_0x4359[32]](_0x61d1x12[_0x4359[31]]);var _0x61d1x13=Math[_0x4359[33]](_0x61d1x12[_0x4359[31]]/_0x61d1xa);console[_0x4359[32]](_0x61d1x13);var _0x61d1x14=_0x61d1x13>(_0x61d1xc[_0x4359[34]]+1)?util[_0x4359[21]](_0x4359[35],_0x61d1x7[_0x4359[36]],_0x61d1x7[_0x4359[38]][_0x4359[37]],_0x61d1x7[_0x4359[39]],_0x61d1xb+1):null;var _0x61d1x15=_0x61d1xb>0?util[_0x4359[21]](_0x4359[35],_0x61d1x7[_0x4359[36]],_0x61d1x7[_0x4359[38]][_0x4359[37]],_0x61d1x7[_0x4359[39]],_0x61d1xb-1):null;_0x61d1x8[_0x4359[42]](200)[_0x4359[41]]({count:_0x61d1x12[_0x4359[31]],rows:_0x61d1x12[_0x4359[40]],next_page:_0x61d1x14,previous_page:_0x61d1x15,total_pages:_0x61d1x13});})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});};exports[_0x4359[45]]=function(_0x61d1x7,_0x61d1x8){VoiceQueue[_0x4359[49]](_0x61d1x7[_0x4359[48]][_0x4359[47]])[_0x4359[43]](function(_0x61d1x16){if(!_0x61d1x16){return _0x61d1x8[_0x4359[46]](404)};return _0x61d1x8[_0x4359[41]](_0x61d1x16);})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)})};exports[_0x4359[50]]=function(_0x61d1x7,_0x61d1x8){console[_0x4359[32]](_0x61d1x7[_0x4359[51]]);VoiceQueue[_0x4359[52]]({where:{name:_0x61d1x7[_0x4359[51]][_0x4359[9]]}})[_0x4359[43]](function(_0x61d1x16){if(!_0x61d1x16){return _0x61d1x8[_0x4359[46]](404)};return _0x61d1x8[_0x4359[41]](_0x61d1x16);})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});};exports[_0x4359[53]]=function(_0x61d1x7,_0x61d1x8){VoiceQueue[_0x4359[52]]({where:{name:_0x61d1x7[_0x4359[51]][_0x4359[9]]}})[_0x4359[43]](function(_0x61d1x17){console[_0x4359[32]](_0x61d1x17);console[_0x4359[32]](_0x4359[54]);if(!_0x61d1x17){return _0x61d1x8[_0x4359[46]](404)};if(_0x61d1x17[_0x4359[55]]>0){return _0x61d1x8[_0x4359[42]](500)[_0x4359[41]]({message:_0x4359[56]})};VoiceQueue[_0x4359[53]](_0x61d1x7[_0x4359[51]])[_0x4359[43]](function(_0x61d1x16){return _0x61d1x8[_0x4359[42]](201)[_0x4359[41]](_0x61d1x16)})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)})};exports[_0x4359[57]]=function(_0x61d1x7,_0x61d1x8){VoiceQueue[_0x4359[60]]({where:{name:_0x61d1x7[_0x4359[48]][_0x4359[47]]}})[_0x4359[43]](function(_0x61d1x18){if(!_0x61d1x18){return _0x61d1x8[_0x4359[46]](404)};if(_0x61d1x7[_0x4359[51]][_0x4359[47]]){delete _0x61d1x7[_0x4359[51]][_0x4359[47]]};var _0x61d1x19=_[_0x4359[58]](_0x61d1x18,_0x61d1x7[_0x4359[51]]);_0x61d1x19[_0x4359[59]]()[_0x4359[43]](function(){return _0x61d1x8[_0x4359[42]](200)[_0x4359[41]](_0x61d1x18)})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)})};exports[_0x4359[61]]=function(_0x61d1x7,_0x61d1x8,_0x61d1x1a){console[_0x4359[32]](_0x4359[61]);console[_0x4359[32]](_0x61d1x7[_0x4359[48]]);console[_0x4359[32]](_0x61d1x7[_0x4359[51]]);User[_0x4359[52]]({where:{id:{$in:_0x61d1x7[_0x4359[51]][_0x4359[65]]}}})[_0x4359[43]](function(_0x61d1x1b){var _0x61d1x1c=_[_0x4359[63]](_0x61d1x1b,function(_0x61d1x1d){return {queue:_0x61d1x7[_0x4359[48]][_0x4359[47]],location:util[_0x4359[21]](_0x4359[62],_0x61d1x1d[_0x4359[9]]),membername:_0x61d1x1d[_0x4359[9]],VoiceQueueName:_0x61d1x7[_0x4359[48]][_0x4359[47]],UserId:_0x61d1x1d[_0x4359[47]]}});UserHasVoiceQueue[_0x4359[64]](_0x61d1x1c,{individualHooks:true})[_0x4359[43]](function(){return _0x61d1x8[_0x4359[46]](200)})[_0x4359[30]](function(_0x61d1x11){return _0x61d1x1a(_0x61d1x11)});})[_0x4359[30]](function(_0x61d1x11){return _0x61d1x1a(_0x61d1x11)});};exports[_0x4359[66]]=function(_0x61d1x7,_0x61d1x8,_0x61d1x1a){VoiceQueue[_0x4359[60]]({where:{name:_0x61d1x7[_0x4359[48]][_0x4359[47]]}})[_0x4359[43]](function(_0x61d1x18){if(_0x61d1x18){_0x61d1x18[_0x4359[67]](_0x61d1x7[_0x4359[51]][_0x4359[65]],{individualHooks:true})[_0x4359[43]](function(){return _0x61d1x8[_0x4359[46]](200)})[_0x4359[30]](function(_0x61d1x11){return _0x61d1x1a(_0x61d1x11)})}else {return _0x61d1x1a( new Error(_0x4359[68]))}})[_0x4359[30]](function(_0x61d1x11){return _0x61d1x1a(_0x61d1x11)})};exports[_0x4359[69]]=function(_0x61d1x7,_0x61d1x8){VoiceQueue[_0x4359[60]]({where:{name:_0x61d1x7[_0x4359[48]][_0x4359[9]]}})[_0x4359[43]](function(_0x61d1x16){if(!_0x61d1x16){return _0x61d1x8[_0x4359[46]](404)};VoiceExtension[_0x4359[52]]({where:{queue:_0x61d1x16[_0x4359[9]]}})[_0x4359[43]](function(_0x61d1x1e){if(_0x61d1x1e[_0x4359[55]]>0){return _0x61d1x8[_0x4359[42]](500)[_0x4359[41]]({message:_0x4359[70]})};_0x61d1x16[_0x4359[69]]()[_0x4359[43]](function(){return _0x61d1x8[_0x4359[46]](204)})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)})};exports[_0x4359[71]]=function(_0x61d1x7,_0x61d1x8){VoiceQueue[_0x4359[52]]({where:{name:_0x61d1x7[_0x4359[14]][_0x4359[9]]}})[_0x4359[43]](function(_0x61d1x1f){if(!_0x61d1x1f){return _0x61d1x8[_0x4359[46]](404)};var _0x61d1x20=_[_0x4359[73]](_[_0x4359[73]](_0x61d1x1f,_0x4359[72]),_0x4359[9]);console[_0x4359[32]](_0x61d1x20);VoiceExtension[_0x4359[52]]({where:{queue:_0x61d1x20}})[_0x4359[43]](function(_0x61d1x1e){if(_0x61d1x1e[_0x4359[55]]>0){return _0x61d1x8[_0x4359[42]](500)[_0x4359[41]]({message:_0x4359[70]})};VoiceQueue[_0x4359[69]]({where:{name:_0x61d1x7[_0x4359[14]][_0x4359[9]]},individualHooks:true})[_0x4359[43]](function(){return _0x61d1x8[_0x4359[46]](204)})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)});})[_0x4359[30]](function(_0x61d1x11){return handleError(_0x61d1x8,_0x61d1x11)})};function handleError(_0x61d1x8,_0x61d1x11){return _0x61d1x8[_0x4359[42]](500)[_0x4359[41]](_0x61d1x11)} \ No newline at end of file diff --git a/server/api/voice_queue/voice_queue.socket.js b/server/api/voice_queue/voice_queue.socket.js index 6cb2204..361c0fb 100644 --- a/server/api/voice_queue/voice_queue.socket.js +++ b/server/api/voice_queue/voice_queue.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var VoiceQueue = require('../../models').VoiceQueue; - -exports.register = function(socket) { - VoiceQueue.afterCreate(function (doc) { - onSave(socket, doc); - }); - VoiceQueue.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('voice_queue:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('voice_queue:remove', doc); -} +var _0x4293=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x3A\x72\x65\x6D\x6F\x76\x65"];_0x4293[0];var VoiceQueue=require(_0x4293[2])[_0x4293[1]];exports[_0x4293[3]]=function(_0xc47fx2){VoiceQueue[_0x4293[4]](function(_0xc47fx3){onSave(_0xc47fx2,_0xc47fx3)});VoiceQueue[_0x4293[5]](function(_0xc47fx3){onRemove(_0xc47fx2,_0xc47fx3)});};function onSave(_0xc47fx2,_0xc47fx3,_0xc47fx5){_0xc47fx2[_0x4293[7]](_0x4293[6],_0xc47fx3)}function onRemove(_0xc47fx2,_0xc47fx3,_0xc47fx5){_0xc47fx2[_0x4293[7]](_0x4293[8],_0xc47fx3)} \ No newline at end of file diff --git a/server/api/voice_queue/voice_queue.spec.js b/server/api/voice_queue/voice_queue.spec.js index fd49ebd..9b456f4 100644 --- a/server/api/voice_queue/voice_queue.spec.js +++ b/server/api/voice_queue/voice_queue.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/voice/queues', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/voice/queues') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x5a7a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x71\x75\x65\x75\x65\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x71\x75\x65\x75\x65\x73","\x67\x65\x74"];_0x5a7a[0];var should=require(_0x5a7a[1]);var app=require(_0x5a7a[2]);var request=require(_0x5a7a[3]);describe(_0x5a7a[4],function(){it(_0x5a7a[5],function(_0x2e8cx4){request(app)[_0x5a7a[13]](_0x5a7a[12])[_0x5a7a[11]](200)[_0x5a7a[11]](_0x5a7a[10],/json/)[_0x5a7a[9]](function(_0x2e8cx5,_0x2e8cx6){if(_0x2e8cx5){return _0x2e8cx4(_0x2e8cx5)};_0x2e8cx6[_0x5a7a[8]][_0x5a7a[1]][_0x5a7a[7]][_0x5a7a[6]](Array);_0x2e8cx4();})})}); \ No newline at end of file diff --git a/server/api/voice_voicemail/index.js b/server/api/voice_voicemail/index.js index 04c5ac8..ad0cf73 100644 --- a/server/api/voice_voicemail/index.js +++ b/server/api/voice_voicemail/index.js @@ -1,21 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./voice_voicemail.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:uniqueid', auth.isAuthenticated(), controller.show); -router.get('/:uniqueid/messages', auth.isAuthenticated(), controller.getMessages); -router.get('/messages/:id/download', auth.isAuthenticated(), controller.downloadMessage); -router.post('/', auth.isAuthenticated(), controller.create); -router.post('/validate', auth.isAuthenticated(), controller.mailboxValidation); -router.put('/:uniqueid', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:uniqueid', auth.isAuthenticated(), controller.destroy); -router.delete('/messages/:id/delete', auth.isAuthenticated(), controller.destroyMessage); - -module.exports = router; +var _0xc0d6=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x75\x6E\x69\x71\x75\x65\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x75\x6E\x69\x71\x75\x65\x69\x64\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x67\x65\x74\x4D\x65\x73\x73\x61\x67\x65\x73","\x2F\x6D\x65\x73\x73\x61\x67\x65\x73\x2F\x3A\x69\x64\x2F\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x64\x6F\x77\x6E\x6C\x6F\x61\x64\x4D\x65\x73\x73\x61\x67\x65","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65","\x6D\x61\x69\x6C\x62\x6F\x78\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x3A\x69\x64","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x2F\x6D\x65\x73\x73\x61\x67\x65\x73\x2F\x3A\x69\x64\x2F\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79\x4D\x65\x73\x73\x61\x67\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xc0d6[0];var express=require(_0xc0d6[1]);var controller=require(_0xc0d6[2]);var auth=require(_0xc0d6[3]);var router=express.Router();router[_0xc0d6[7]](_0xc0d6[4],auth[_0xc0d6[5]](),controller[_0xc0d6[6]]);router[_0xc0d6[7]](_0xc0d6[8],auth[_0xc0d6[5]](),controller[_0xc0d6[9]]);router[_0xc0d6[7]](_0xc0d6[10],auth[_0xc0d6[5]](),controller[_0xc0d6[11]]);router[_0xc0d6[7]](_0xc0d6[12],auth[_0xc0d6[5]](),controller[_0xc0d6[13]]);router[_0xc0d6[15]](_0xc0d6[4],auth[_0xc0d6[5]](),controller[_0xc0d6[14]]);router[_0xc0d6[15]](_0xc0d6[16],auth[_0xc0d6[5]](),controller[_0xc0d6[17]]);router[_0xc0d6[19]](_0xc0d6[8],auth[_0xc0d6[5]](),controller[_0xc0d6[18]]);router[_0xc0d6[21]](_0xc0d6[20],auth[_0xc0d6[5]](),controller[_0xc0d6[18]]);router[_0xc0d6[23]](_0xc0d6[4],auth[_0xc0d6[5]](),controller[_0xc0d6[22]]);router[_0xc0d6[23]](_0xc0d6[8],auth[_0xc0d6[5]](),controller[_0xc0d6[24]]);router[_0xc0d6[23]](_0xc0d6[25],auth[_0xc0d6[5]](),controller[_0xc0d6[26]]);module[_0xc0d6[27]]=router; \ No newline at end of file diff --git a/server/api/voice_voicemail/voice_voicemail.controller.js b/server/api/voice_voicemail/voice_voicemail.controller.js index eed06af..4f4556e 100644 --- a/server/api/voice_voicemail/voice_voicemail.controller.js +++ b/server/api/voice_voicemail/voice_voicemail.controller.js @@ -1,298 +1 @@ -'use strict'; - -var _ = require('lodash'); -var VoiceVoicemail = require('../../models').VoiceVoicemail; -var VoiceVoicemailMessages = require('../../models').VoiceVoicemailMessages; -var stream = require('stream'); - -// Get list of voice_voicemails -exports.index = function(req, res) { - - var attributes = ['mailbox', 'fullname', 'email']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - - VoiceVoicemail - .findAndCountAll(query) - .then(function(voice_voicemails) { - return res.status(200).send(voice_voicemails); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single voice_voicemail -exports.show = function(req, res) { - VoiceVoicemail - .find({ - where: { - uniqueid: req.params.uniqueid - } - }) - .then(function(voice_voicemail) { - if (!voice_voicemail) { - return res.sendStatus(404); - } - return res.send(voice_voicemail); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getMessages = function(req, res) { - VoiceVoicemail - .find({ - where: { - uniqueid: req.params.uniqueid - } - }) - .then(function(voice_voicemail) { - VoiceVoicemailMessages - .findAll({ - where: { - mailboxcontext: voice_voicemail.context, - mailboxuser: voice_voicemail.mailbox - } - }) - .then(function(voicemailMessages) { - return res.status(200).send(voicemailMessages); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// validate mailbox uniqueness -exports.mailboxValidation = function(req, res) { - console.log(req.body); - VoiceVoicemail - .findAll({ - where: { - mailbox: req.body.mailbox, - context: req.body.context - } - }) - .then(function(voicemails) { - if (!voicemails) { - return res.sendStatus(404); - } - return res.send(voicemails); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; -// Creates a new voice_voicemail in the DB. -exports.create = function(req, res) { - VoiceVoicemail - .findAll({ - where: { - mailbox: req.body.mailbox, - context: req.body.context - } - }) - .then(function(voicemails) { - if (!voicemails) { - return res.sendStatus(404); - } - if (voicemails.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_MAILBOX' - }) - } - VoiceVoicemail - .create(req.body) - .then(function(voice_voicemail) { - return res.status(201).send(voice_voicemail); - }) - .catch(function(err) { - return handleError(res, err); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) -}; - -// Updates an existing voice_voicemail in the DB. -exports.update = function(req, res) { - VoiceVoicemail - .findAll({ - where: { - mailbox: req.body.mailbox, - context: req.body.context, - uniqueid: { - $ne: req.body.uniqueid - } - } - }) - .then(function(voicemails) { - if (!voicemails) { - return res.sendStatus(404); - } - if (voicemails.length > 0) { - return res.status(500).send({ - message: 'MESSAGE_EXIST_MAILBOX' - }) - } - if (req.body.uniqueid) { - delete req.body.uniqueid; - } - VoiceVoicemail - .find({ - where: { - uniqueid: req.params.uniqueid - } - }) - .then(function(voice_voicemail) { - if (!voice_voicemail) { - return res.sendStatus(404); - } - var updated = _.merge(voice_voicemail, req.body); - updated.save() - .then(function() { - return res.status(200).send(voice_voicemail); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - -}; - -// Deletes a voice_voicemail from the DB. -exports.destroy = function(req, res) { - VoiceVoicemail - .find({ - where: { - uniqueid: req.params.uniqueid - } - }) - .then(function(voice_voicemail) { - if (!voice_voicemail) { - return res.sendStatus(404); - } - voice_voicemail.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a voice_voicemail from the DB. -exports.bulkDestroy = function(req, res) { - VoiceVoicemail - .destroy({ - where: { - uniqueid: req.query.uniqueid - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a voice_voicemail message from the DB. -exports.destroyMessage = function(req, res) { - VoiceVoicemailMessages - .findById(req.params.id) - .then(function(voicemailMessage) { - if (!voicemailMessage) { - return res.sendStatus(404); - } - voicemailMessage.recording = null; - voicemailMessage.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.downloadMessage = function(req, res) { - VoiceVoicemailMessages - .findById(req.params.id) - .then(function(message) { - if (!message) { - return res.sendStatus(404); - } - var filename = message.msg_id + '.wav'; - res.writeHead(200, "OK", { - "Content-Type": "audio/wav", - "Content-Disposition": "attachment; filename=" + filename, - "Content-Length": message.recording.length - }); - var bufferStream = new stream.PassThrough(); - bufferStream.end(new Buffer(message.recording)); - bufferStream.pipe(res) - }) -}; - - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x45f5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x56\x6F\x69\x63\x65\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65\x73","\x73\x74\x72\x65\x61\x6D","\x69\x6E\x64\x65\x78","\x6D\x61\x69\x6C\x62\x6F\x78","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x75\x6E\x69\x71\x75\x65\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64","\x67\x65\x74\x4D\x65\x73\x73\x61\x67\x65\x73","\x63\x6F\x6E\x74\x65\x78\x74","\x66\x69\x6E\x64\x41\x6C\x6C","\x6D\x61\x69\x6C\x62\x6F\x78\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x63\x72\x65\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x4D\x41\x49\x4C\x42\x4F\x58","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x73\x74\x72\x6F\x79\x4D\x65\x73\x73\x61\x67\x65","\x72\x65\x63\x6F\x72\x64\x69\x6E\x67","\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x64\x6F\x77\x6E\x6C\x6F\x61\x64\x4D\x65\x73\x73\x61\x67\x65","\x6D\x73\x67\x5F\x69\x64","\x2E\x77\x61\x76","\x4F\x4B","\x61\x75\x64\x69\x6F\x2F\x77\x61\x76","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x3B\x20\x66\x69\x6C\x65\x6E\x61\x6D\x65\x3D","\x77\x72\x69\x74\x65\x48\x65\x61\x64","\x65\x6E\x64","\x70\x69\x70\x65"];_0x45f5[0];var _=require(_0x45f5[1]);var VoiceVoicemail=require(_0x45f5[3])[_0x45f5[2]];var VoiceVoicemailMessages=require(_0x45f5[3])[_0x45f5[4]];var stream=require(_0x45f5[5]);exports[_0x45f5[6]]=function(_0x4e18x5,_0x4e18x6){var _0x4e18x7=[_0x45f5[7],_0x45f5[8],_0x45f5[9]];var _0x4e18x8=_0x4e18x5[_0x45f5[11]][_0x45f5[10]]?parseInt(_0x4e18x5[_0x45f5[11]][_0x45f5[10]],10):100;var _0x4e18x9=_0x4e18x5[_0x45f5[11]][_0x45f5[12]]?parseInt(_0x4e18x5[_0x45f5[11]][_0x45f5[12]],10):0;var _0x4e18xa={where:{},limit:_0x4e18x8,offset:_0x4e18x9*_0x4e18x8};_[_0x45f5[26]](_0x4e18x5[_0x45f5[11]],function(_0x4e18xb,_0x4e18xc){switch(_0x4e18xc){case _0x45f5[10]:;case _0x45f5[12]:break ;;case _0x45f5[15]:_0x4e18xa[_0x45f5[13]]=util[_0x45f5[18]](_0x45f5[14],_0x4e18x5[_0x45f5[11]][_0x45f5[15]],_0x4e18x5[_0x45f5[11]][_0x45f5[16]]||_0x45f5[17])||null;break ;;case _0x45f5[16]:break ;;case _0x45f5[24]:_0x4e18xa[_0x45f5[20]][_0x45f5[19]]=[];_0x4e18x7[_0x45f5[23]](function(_0x4e18xd){var _0x4e18xe={};_0x4e18xe[_0x4e18xd]={$like:_0x45f5[21]+_0x4e18xb+_0x45f5[21]};_0x4e18xa[_0x45f5[20]][_0x45f5[19]][_0x45f5[22]](_0x4e18xe);});break ;;default:_0x4e18xa[_0x45f5[20]][_0x4e18xc]={$like:{}};_0x4e18xa[_0x45f5[20]][_0x4e18xc][_0x45f5[25]]=_0x45f5[21]+_0x4e18xb+_0x45f5[21];;}});VoiceVoicemail[_0x45f5[31]](_0x4e18xa)[_0x45f5[30]](function(_0x4e18x10){return _0x4e18x6[_0x45f5[29]](200)[_0x45f5[28]](_0x4e18x10)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)});};exports[_0x45f5[32]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemail[_0x45f5[36]]({where:{uniqueid:_0x4e18x5[_0x45f5[35]][_0x45f5[34]]}})[_0x45f5[30]](function(_0x4e18x11){if(!_0x4e18x11){return _0x4e18x6[_0x45f5[33]](404)};return _0x4e18x6[_0x45f5[28]](_0x4e18x11);})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})};exports[_0x45f5[37]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemail[_0x45f5[36]]({where:{uniqueid:_0x4e18x5[_0x45f5[35]][_0x45f5[34]]}})[_0x45f5[30]](function(_0x4e18x11){VoiceVoicemailMessages[_0x45f5[39]]({where:{mailboxcontext:_0x4e18x11[_0x45f5[38]],mailboxuser:_0x4e18x11[_0x45f5[7]]}})[_0x45f5[30]](function(_0x4e18x12){return _0x4e18x6[_0x45f5[29]](200)[_0x45f5[28]](_0x4e18x12)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})};exports[_0x45f5[40]]=function(_0x4e18x5,_0x4e18x6){console[_0x45f5[42]](_0x4e18x5[_0x45f5[41]]);VoiceVoicemail[_0x45f5[39]]({where:{mailbox:_0x4e18x5[_0x45f5[41]][_0x45f5[7]],context:_0x4e18x5[_0x45f5[41]][_0x45f5[38]]}})[_0x45f5[30]](function(_0x4e18x13){if(!_0x4e18x13){return _0x4e18x6[_0x45f5[33]](404)};return _0x4e18x6[_0x45f5[28]](_0x4e18x13);})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)});};exports[_0x45f5[43]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemail[_0x45f5[39]]({where:{mailbox:_0x4e18x5[_0x45f5[41]][_0x45f5[7]],context:_0x4e18x5[_0x45f5[41]][_0x45f5[38]]}})[_0x45f5[30]](function(_0x4e18x13){if(!_0x4e18x13){return _0x4e18x6[_0x45f5[33]](404)};if(_0x4e18x13[_0x45f5[44]]>0){return _0x4e18x6[_0x45f5[29]](500)[_0x45f5[28]]({message:_0x45f5[45]})};VoiceVoicemail[_0x45f5[43]](_0x4e18x5[_0x45f5[41]])[_0x45f5[30]](function(_0x4e18x11){return _0x4e18x6[_0x45f5[29]](201)[_0x45f5[28]](_0x4e18x11)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)});})};exports[_0x45f5[46]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemail[_0x45f5[39]]({where:{mailbox:_0x4e18x5[_0x45f5[41]][_0x45f5[7]],context:_0x4e18x5[_0x45f5[41]][_0x45f5[38]],uniqueid:{$ne:_0x4e18x5[_0x45f5[41]][_0x45f5[34]]}}})[_0x45f5[30]](function(_0x4e18x13){if(!_0x4e18x13){return _0x4e18x6[_0x45f5[33]](404)};if(_0x4e18x13[_0x45f5[44]]>0){return _0x4e18x6[_0x45f5[29]](500)[_0x45f5[28]]({message:_0x45f5[45]})};if(_0x4e18x5[_0x45f5[41]][_0x45f5[34]]){delete _0x4e18x5[_0x45f5[41]][_0x45f5[34]]};VoiceVoicemail[_0x45f5[36]]({where:{uniqueid:_0x4e18x5[_0x45f5[35]][_0x45f5[34]]}})[_0x45f5[30]](function(_0x4e18x11){if(!_0x4e18x11){return _0x4e18x6[_0x45f5[33]](404)};var _0x4e18x14=_[_0x45f5[47]](_0x4e18x11,_0x4e18x5[_0x45f5[41]]);_0x4e18x14[_0x45f5[48]]()[_0x45f5[30]](function(){return _0x4e18x6[_0x45f5[29]](200)[_0x45f5[28]](_0x4e18x11)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)});})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)});})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})};exports[_0x45f5[49]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemail[_0x45f5[36]]({where:{uniqueid:_0x4e18x5[_0x45f5[35]][_0x45f5[34]]}})[_0x45f5[30]](function(_0x4e18x11){if(!_0x4e18x11){return _0x4e18x6[_0x45f5[33]](404)};_0x4e18x11[_0x45f5[49]]()[_0x45f5[30]](function(){return _0x4e18x6[_0x45f5[33]](204)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)});})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})};exports[_0x45f5[50]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemail[_0x45f5[49]]({where:{uniqueid:_0x4e18x5[_0x45f5[11]][_0x45f5[34]]},individualHooks:true})[_0x45f5[30]](function(){return _0x4e18x6[_0x45f5[33]](204)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})};exports[_0x45f5[51]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemailMessages[_0x45f5[54]](_0x4e18x5[_0x45f5[35]][_0x45f5[53]])[_0x45f5[30]](function(_0x4e18x15){if(!_0x4e18x15){return _0x4e18x6[_0x45f5[33]](404)};_0x4e18x15[_0x45f5[52]]=null;_0x4e18x15[_0x45f5[49]]()[_0x45f5[30]](function(){return _0x4e18x6[_0x45f5[33]](204)})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)});})[_0x45f5[27]](function(_0x4e18xf){return handleError(_0x4e18x6,_0x4e18xf)})};exports[_0x45f5[55]]=function(_0x4e18x5,_0x4e18x6){VoiceVoicemailMessages[_0x45f5[54]](_0x4e18x5[_0x45f5[35]][_0x45f5[53]])[_0x45f5[30]](function(_0x4e18x16){if(!_0x4e18x16){return _0x4e18x6[_0x45f5[33]](404)};var _0x4e18x17=_0x4e18x16[_0x45f5[56]]+_0x45f5[57];_0x4e18x6[_0x45f5[61]](200,_0x45f5[58],{"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65":_0x45f5[59],"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E":_0x45f5[60]+_0x4e18x17,"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x4C\x65\x6E\x67\x74\x68":_0x4e18x16[_0x45f5[52]][_0x45f5[44]]});var _0x4e18x18= new stream.PassThrough();_0x4e18x18[_0x45f5[62]]( new Buffer(_0x4e18x16[_0x45f5[52]]));_0x4e18x18[_0x45f5[63]](_0x4e18x6);})};function handleError(_0x4e18x6,_0x4e18xf){return _0x4e18x6[_0x45f5[29]](500)[_0x45f5[28]](_0x4e18xf)} \ No newline at end of file diff --git a/server/api/voice_voicemail/voice_voicemail.socket.js b/server/api/voice_voicemail/voice_voicemail.socket.js index 41e7a38..9785ed1 100644 --- a/server/api/voice_voicemail/voice_voicemail.socket.js +++ b/server/api/voice_voicemail/voice_voicemail.socket.js @@ -1,39 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var VoiceVoicemail = require('../../models').VoiceVoicemail; -var VoiceVoicemailMessages = require('../../models').VoiceVoicemailMessages; - -exports.register = function(socket) { - VoiceVoicemail.afterCreate(function(doc) { - onSave(socket, doc); - }); - VoiceVoicemail.afterDestroy(function(doc) { - onRemove(socket, doc); - }); - VoiceVoicemailMessages.afterCreate(function(doc) { - onMessageSave(socket, doc); - }); - VoiceVoicemailMessages.afterDestroy(function(doc) { - onMessageRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('voice_voicemail:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('voice_voicemail:remove', doc); -} - -function onMessageSave(socket, doc, cb) { - socket.emit('voice_voicemail_messages:save', doc); -} - -function onMessageRemove(socket, doc, cb) { - socket.emit('voice_voicemail_messages:remove', doc); -} +var _0xef2d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x6F\x69\x63\x65\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x3A\x72\x65\x6D\x6F\x76\x65","\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x73\x3A\x73\x61\x76\x65","\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x73\x3A\x72\x65\x6D\x6F\x76\x65"];_0xef2d[0];var VoiceVoicemail=require(_0xef2d[2])[_0xef2d[1]];var VoiceVoicemailMessages=require(_0xef2d[2])[_0xef2d[3]];exports[_0xef2d[4]]=function(_0xa32dx3){VoiceVoicemail[_0xef2d[5]](function(_0xa32dx4){onSave(_0xa32dx3,_0xa32dx4)});VoiceVoicemail[_0xef2d[6]](function(_0xa32dx4){onRemove(_0xa32dx3,_0xa32dx4)});VoiceVoicemailMessages[_0xef2d[5]](function(_0xa32dx4){onMessageSave(_0xa32dx3,_0xa32dx4)});VoiceVoicemailMessages[_0xef2d[6]](function(_0xa32dx4){onMessageRemove(_0xa32dx3,_0xa32dx4)});};function onSave(_0xa32dx3,_0xa32dx4,_0xa32dx6){_0xa32dx3[_0xef2d[8]](_0xef2d[7],_0xa32dx4)}function onRemove(_0xa32dx3,_0xa32dx4,_0xa32dx6){_0xa32dx3[_0xef2d[8]](_0xef2d[9],_0xa32dx4)}function onMessageSave(_0xa32dx3,_0xa32dx4,_0xa32dx6){_0xa32dx3[_0xef2d[8]](_0xef2d[10],_0xa32dx4)}function onMessageRemove(_0xa32dx3,_0xa32dx4,_0xa32dx6){_0xa32dx3[_0xef2d[8]](_0xef2d[11],_0xa32dx4)} \ No newline at end of file diff --git a/server/api/voice_voicemail/voice_voicemail.spec.js b/server/api/voice_voicemail/voice_voicemail.spec.js index 5785825..b59ba3c 100644 --- a/server/api/voice_voicemail/voice_voicemail.spec.js +++ b/server/api/voice_voicemail/voice_voicemail.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/voice/voicemails', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/voice/voicemails') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x9abe=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x73","\x67\x65\x74"];_0x9abe[0];var should=require(_0x9abe[1]);var app=require(_0x9abe[2]);var request=require(_0x9abe[3]);describe(_0x9abe[4],function(){it(_0x9abe[5],function(_0x3cf7x4){request(app)[_0x9abe[13]](_0x9abe[12])[_0x9abe[11]](200)[_0x9abe[11]](_0x9abe[10],/json/)[_0x9abe[9]](function(_0x3cf7x5,_0x3cf7x6){if(_0x3cf7x5){return _0x3cf7x4(_0x3cf7x5)};_0x3cf7x6[_0x9abe[8]][_0x9abe[1]][_0x9abe[7]][_0x9abe[6]](Array);_0x3cf7x4();})})}); \ No newline at end of file diff --git a/server/api/widget/index.js b/server/api/widget/index.js index 374e711..5d0eb59 100644 --- a/server/api/widget/index.js +++ b/server/api/widget/index.js @@ -1,19 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./widget.controller'); -var auth = require('../../auth/auth.service'); - -var router = express.Router(); - -// router.get('/', auth.isAuthenticated(), controller.index); -router.get('/counter', auth.isAuthenticated(), controller.counter); -router.get('/table', auth.isAuthenticated(), controller.table); -router.get('/piechart', auth.isAuthenticated(), controller.piechart); -// router.get('/:id', auth.isAuthenticated(), controller.show); -// router.post('/', auth.isAuthenticated(), controller.create); -// router.put('/:id', auth.isAuthenticated(), controller.update); -// router.patch('/:id', auth.isAuthenticated(), controller.update); -// router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0xb1b6=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x77\x69\x64\x67\x65\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F\x63\x6F\x75\x6E\x74\x65\x72","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x63\x6F\x75\x6E\x74\x65\x72","\x67\x65\x74","\x2F\x74\x61\x62\x6C\x65","\x74\x61\x62\x6C\x65","\x2F\x70\x69\x65\x63\x68\x61\x72\x74","\x70\x69\x65\x63\x68\x61\x72\x74","\x65\x78\x70\x6F\x72\x74\x73"];_0xb1b6[0];var express=require(_0xb1b6[1]);var controller=require(_0xb1b6[2]);var auth=require(_0xb1b6[3]);var router=express.Router();router[_0xb1b6[7]](_0xb1b6[4],auth[_0xb1b6[5]](),controller[_0xb1b6[6]]);router[_0xb1b6[7]](_0xb1b6[8],auth[_0xb1b6[5]](),controller[_0xb1b6[9]]);router[_0xb1b6[7]](_0xb1b6[10],auth[_0xb1b6[5]](),controller[_0xb1b6[11]]);module[_0xb1b6[12]]=router; \ No newline at end of file diff --git a/server/api/widget/widget.controller.js b/server/api/widget/widget.controller.js index f9bc793..d2930bf 100644 --- a/server/api/widget/widget.controller.js +++ b/server/api/widget/widget.controller.js @@ -1,181 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var sequelize = require('../../models').sequelize; - -// var ReportAgent = require('../../models').ReportAgent; -// var ReportCall = require('../../models').ReportCall; -// var ReportDial = require('../../models').ReportDial; -// var ReportMember = require('../../models').ReportMember; -// var ReportQueue = require('../../models').ReportQueue; - - - -exports.counter = function(req, res) { - var table = util.format('report_%s', req.query.table); - sequelize.query(util.format("SELECT COUNT(*) as count FROM %s WHERE %s", table, decodeURIComponent(req.query.condition)), { - type: sequelize.QueryTypes.SELECT - }) - .then(function(result) { - return res.status(200).send(result); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.table = function(req, res) { - var columns = []; - var elem; - if (req.query.fields) { - if (_.isArray(req.query.fields)) { - req.query.fields.forEach(function(element) { - elem = JSON.parse(element); - if (elem.column && elem.alias) { - columns.push(elem.column + ' AS "' + elem.alias + '"'); - } - }); - } else if (_.isString(req.query.fields)) { - elem = JSON.parse(req.query.fields); - if (elem.column && elem.alias) { - columns.push(elem.column + ' AS "' + elem.alias + '"'); - } - } - } - var select = columns.length ? columns.join(',') : '*'; - var table = util.format('report_%s', req.query.table); - sequelize.query(util.format("SELECT %s FROM %s WHERE %s", select, table, decodeURIComponent(req.query.condition)), { - type: sequelize.QueryTypes.SELECT - }) - .then(function(result) { - return res.status(200).send(result); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.piechart = function(req, res) { - var columns = []; - var elem; - if (req.query.fields) { - if (_.isArray(req.query.fields)) { - req.query.fields.forEach(function(element) { - elem = JSON.parse(element); - if (elem.column && elem.alias) { - columns.push(elem.column + ' AS "' + elem.alias + '"'); - } - }); - } else if (_.isString(req.query.fields)) { - elem = JSON.parse(req.query.fields); - if (elem.column && elem.alias) { - columns.push(elem.column + ' AS "' + elem.alias + '"'); - } - } - } - var select = columns.length ? columns.join(',') : '*'; - var table = util.format('report_%s', req.query.table); - var where = ''; - if (req.query.condition !== 'undefined') { - where = util.format(' WHERE %s', decodeURIComponent(req.query.condition)); - } - sequelize.query(util.format("SELECT %s FROM %s%s", select, table, where), { - type: sequelize.QueryTypes.SELECT - }) - .then(function(result) { - return res.status(200).send(result); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// // Get list of widgets -// exports.index = function(req, res) { -// Widget -// .findAll() -// .then(function (widgets) { -// return res.status(200).send(widgets); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }; -// -// // Get a single widget -// exports.show = function(req, res) { -// Widget -// .findById(req.params.id) -// .then(function (widget) { -// if(!widget) { return res.sendStatus(404); } -// return res.send(widget); -// }) -// .catch(function(err){ -// return handleError(res, err); -// }); -// }; -// -// // Creates a new widget in the DB. -// exports.create = function(req, res) { -// Widget -// .create(req.body) -// .then(function(widget) { -// return res.status(201).send(widget); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }; -// -// // Updates an existing widget in the DB. -// exports.update = function(req, res) { -// if(req.body.id) { delete req.body.id; } -// Widget -// .find({ -// where: { -// id: req.params.id -// } -// }) -// .then(function (widget) { -// if(!widget) { return res.sendStatus(404); } -// var updated = _.merge(widget, req.body); -// updated.save() -// .then(function () { -// return res.status(200).send(widget); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }; -// -// // Deletes a widget from the DB. -// exports.destroy = function(req, res) { -// Widget -// .find({ -// where: { -// id: req.params.id -// } -// }) -// .then(function (widget) { -// if(!widget) { return res.sendStatus(404); } -// widget.destroy() -// .then(function() { -// return res.sendStatus(204); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }) -// .catch(function(err) { -// return handleError(res, err); -// }); -// }; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x90fa=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x63\x6F\x75\x6E\x74\x65\x72","\x72\x65\x70\x6F\x72\x74\x5F\x25\x73","\x74\x61\x62\x6C\x65","\x71\x75\x65\x72\x79","\x66\x6F\x72\x6D\x61\x74","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x53\x45\x4C\x45\x43\x54\x20\x43\x4F\x55\x4E\x54\x28\x2A\x29\x20\x61\x73\x20\x63\x6F\x75\x6E\x74\x20\x46\x52\x4F\x4D\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x25\x73","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x53\x45\x4C\x45\x43\x54","\x51\x75\x65\x72\x79\x54\x79\x70\x65\x73","\x66\x69\x65\x6C\x64\x73","\x69\x73\x41\x72\x72\x61\x79","\x70\x61\x72\x73\x65","\x63\x6F\x6C\x75\x6D\x6E","\x61\x6C\x69\x61\x73","\x20\x41\x53\x20\x22","\x22","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x69\x73\x53\x74\x72\x69\x6E\x67","\x6C\x65\x6E\x67\x74\x68","\x2C","\x6A\x6F\x69\x6E","\x2A","\x53\x45\x4C\x45\x43\x54\x20\x25\x73\x20\x46\x52\x4F\x4D\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x25\x73","\x70\x69\x65\x63\x68\x61\x72\x74","","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x20\x57\x48\x45\x52\x45\x20\x25\x73","\x53\x45\x4C\x45\x43\x54\x20\x25\x73\x20\x46\x52\x4F\x4D\x20\x25\x73\x25\x73"];_0x90fa[0];var _=require(_0x90fa[1]);var util=require(_0x90fa[2]);var sequelize=require(_0x90fa[4])[_0x90fa[3]];exports[_0x90fa[5]]=function(_0x895ex4,_0x895ex5){var _0x895ex6=util[_0x90fa[9]](_0x90fa[6],_0x895ex4[_0x90fa[8]][_0x90fa[7]]);sequelize[_0x90fa[8]](util[_0x90fa[9]](_0x90fa[14],_0x895ex6,decodeURIComponent(_0x895ex4[_0x90fa[8]][_0x90fa[15]])),{type:sequelize[_0x90fa[17]][_0x90fa[16]]})[_0x90fa[13]](function(_0x895ex8){return _0x895ex5[_0x90fa[12]](200)[_0x90fa[11]](_0x895ex8)})[_0x90fa[10]](function(_0x895ex7){return handleError(_0x895ex5,_0x895ex7)});};exports[_0x90fa[7]]=function(_0x895ex4,_0x895ex5){var _0x895ex9=[];var _0x895exa;if(_0x895ex4[_0x90fa[8]][_0x90fa[18]]){if(_[_0x90fa[19]](_0x895ex4[_0x90fa[8]][_0x90fa[18]])){_0x895ex4[_0x90fa[8]][_0x90fa[18]][_0x90fa[26]](function(_0x895exb){_0x895exa=JSON[_0x90fa[20]](_0x895exb);if(_0x895exa[_0x90fa[21]]&&_0x895exa[_0x90fa[22]]){_0x895ex9[_0x90fa[25]](_0x895exa[_0x90fa[21]]+_0x90fa[23]+_0x895exa[_0x90fa[22]]+_0x90fa[24])};})}else {if(_[_0x90fa[27]](_0x895ex4[_0x90fa[8]][_0x90fa[18]])){_0x895exa=JSON[_0x90fa[20]](_0x895ex4[_0x90fa[8]][_0x90fa[18]]);if(_0x895exa[_0x90fa[21]]&&_0x895exa[_0x90fa[22]]){_0x895ex9[_0x90fa[25]](_0x895exa[_0x90fa[21]]+_0x90fa[23]+_0x895exa[_0x90fa[22]]+_0x90fa[24])};}}};var _0x895exc=_0x895ex9[_0x90fa[28]]?_0x895ex9[_0x90fa[30]](_0x90fa[29]):_0x90fa[31];var _0x895ex6=util[_0x90fa[9]](_0x90fa[6],_0x895ex4[_0x90fa[8]][_0x90fa[7]]);sequelize[_0x90fa[8]](util[_0x90fa[9]](_0x90fa[32],_0x895exc,_0x895ex6,decodeURIComponent(_0x895ex4[_0x90fa[8]][_0x90fa[15]])),{type:sequelize[_0x90fa[17]][_0x90fa[16]]})[_0x90fa[13]](function(_0x895ex8){return _0x895ex5[_0x90fa[12]](200)[_0x90fa[11]](_0x895ex8)})[_0x90fa[10]](function(_0x895ex7){return handleError(_0x895ex5,_0x895ex7)});};exports[_0x90fa[33]]=function(_0x895ex4,_0x895ex5){var _0x895ex9=[];var _0x895exa;if(_0x895ex4[_0x90fa[8]][_0x90fa[18]]){if(_[_0x90fa[19]](_0x895ex4[_0x90fa[8]][_0x90fa[18]])){_0x895ex4[_0x90fa[8]][_0x90fa[18]][_0x90fa[26]](function(_0x895exb){_0x895exa=JSON[_0x90fa[20]](_0x895exb);if(_0x895exa[_0x90fa[21]]&&_0x895exa[_0x90fa[22]]){_0x895ex9[_0x90fa[25]](_0x895exa[_0x90fa[21]]+_0x90fa[23]+_0x895exa[_0x90fa[22]]+_0x90fa[24])};})}else {if(_[_0x90fa[27]](_0x895ex4[_0x90fa[8]][_0x90fa[18]])){_0x895exa=JSON[_0x90fa[20]](_0x895ex4[_0x90fa[8]][_0x90fa[18]]);if(_0x895exa[_0x90fa[21]]&&_0x895exa[_0x90fa[22]]){_0x895ex9[_0x90fa[25]](_0x895exa[_0x90fa[21]]+_0x90fa[23]+_0x895exa[_0x90fa[22]]+_0x90fa[24])};}}};var _0x895exc=_0x895ex9[_0x90fa[28]]?_0x895ex9[_0x90fa[30]](_0x90fa[29]):_0x90fa[31];var _0x895ex6=util[_0x90fa[9]](_0x90fa[6],_0x895ex4[_0x90fa[8]][_0x90fa[7]]);var _0x895exd=_0x90fa[34];if(_0x895ex4[_0x90fa[8]][_0x90fa[15]]!==_0x90fa[35]){_0x895exd=util[_0x90fa[9]](_0x90fa[36],decodeURIComponent(_0x895ex4[_0x90fa[8]][_0x90fa[15]]))};sequelize[_0x90fa[8]](util[_0x90fa[9]](_0x90fa[37],_0x895exc,_0x895ex6,_0x895exd),{type:sequelize[_0x90fa[17]][_0x90fa[16]]})[_0x90fa[13]](function(_0x895ex8){return _0x895ex5[_0x90fa[12]](200)[_0x90fa[11]](_0x895ex8)})[_0x90fa[10]](function(_0x895ex7){return handleError(_0x895ex5,_0x895ex7)});};function handleError(_0x895ex5,_0x895ex7){return _0x895ex5[_0x90fa[12]](500)[_0x90fa[11]](_0x895ex7)} \ No newline at end of file diff --git a/server/api/widget/widget.spec.js b/server/api/widget/widget.spec.js index 94ea420..0fbdd19 100644 --- a/server/api/widget/widget.spec.js +++ b/server/api/widget/widget.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/widgets', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/widgets') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x6d18=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x77\x69\x64\x67\x65\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x77\x69\x64\x67\x65\x74\x73","\x67\x65\x74"];_0x6d18[0];var should=require(_0x6d18[1]);var app=require(_0x6d18[2]);var request=require(_0x6d18[3]);describe(_0x6d18[4],function(){it(_0x6d18[5],function(_0x2751x4){request(app)[_0x6d18[13]](_0x6d18[12])[_0x6d18[11]](200)[_0x6d18[11]](_0x6d18[10],/json/)[_0x6d18[9]](function(_0x2751x5,_0x2751x6){if(_0x2751x5){return _0x2751x4(_0x2751x5)};_0x2751x6[_0x6d18[8]][_0x6d18[1]][_0x6d18[7]][_0x6d18[6]](Array);_0x2751x4();})})}); \ No newline at end of file diff --git a/server/api/xchatty/index.js b/server/api/xchatty/index.js index aa25480..a48bcaa 100644 --- a/server/api/xchatty/index.js +++ b/server/api/xchatty/index.js @@ -1,29 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./xchatty.controller'); - -var router = express.Router(); - -router.get('/jquery', controller.getJqueryLibrary); -router.get('/assets', controller.getAssets); - -router.get('/status', controller.getStatus); -router.get('/signup', controller.signupCustomer); -router.get('/read', controller.getMessages); -router.get('/send', controller.sendMessage); -router.get('/signout', controller.signoutCustomer); -router.get('/submit', controller.submitEnquiry); -router.get('/unserved', controller.unservedCustomer); -router.get('/transcript', controller.getTranscript); - -router.get('/:id', controller.getJsByWebsite); -router.get('/:id/styles', controller.getStyleByWebsite); - -// router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0x18ba=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x78\x63\x68\x61\x74\x74\x79\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F\x6A\x71\x75\x65\x72\x79","\x67\x65\x74\x4A\x71\x75\x65\x72\x79\x4C\x69\x62\x72\x61\x72\x79","\x67\x65\x74","\x2F\x61\x73\x73\x65\x74\x73","\x67\x65\x74\x41\x73\x73\x65\x74\x73","\x2F\x73\x74\x61\x74\x75\x73","\x67\x65\x74\x53\x74\x61\x74\x75\x73","\x2F\x73\x69\x67\x6E\x75\x70","\x73\x69\x67\x6E\x75\x70\x43\x75\x73\x74\x6F\x6D\x65\x72","\x2F\x72\x65\x61\x64","\x67\x65\x74\x4D\x65\x73\x73\x61\x67\x65\x73","\x2F\x73\x65\x6E\x64","\x73\x65\x6E\x64\x4D\x65\x73\x73\x61\x67\x65","\x2F\x73\x69\x67\x6E\x6F\x75\x74","\x73\x69\x67\x6E\x6F\x75\x74\x43\x75\x73\x74\x6F\x6D\x65\x72","\x2F\x73\x75\x62\x6D\x69\x74","\x73\x75\x62\x6D\x69\x74\x45\x6E\x71\x75\x69\x72\x79","\x2F\x75\x6E\x73\x65\x72\x76\x65\x64","\x75\x6E\x73\x65\x72\x76\x65\x64\x43\x75\x73\x74\x6F\x6D\x65\x72","\x2F\x74\x72\x61\x6E\x73\x63\x72\x69\x70\x74","\x67\x65\x74\x54\x72\x61\x6E\x73\x63\x72\x69\x70\x74","\x2F\x3A\x69\x64","\x67\x65\x74\x4A\x73\x42\x79\x57\x65\x62\x73\x69\x74\x65","\x2F\x3A\x69\x64\x2F\x73\x74\x79\x6C\x65\x73","\x67\x65\x74\x53\x74\x79\x6C\x65\x42\x79\x57\x65\x62\x73\x69\x74\x65","\x2F","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x18ba[0];var express=require(_0x18ba[1]);var controller=require(_0x18ba[2]);var router=express.Router();router[_0x18ba[5]](_0x18ba[3],controller[_0x18ba[4]]);router[_0x18ba[5]](_0x18ba[6],controller[_0x18ba[7]]);router[_0x18ba[5]](_0x18ba[8],controller[_0x18ba[9]]);router[_0x18ba[5]](_0x18ba[10],controller[_0x18ba[11]]);router[_0x18ba[5]](_0x18ba[12],controller[_0x18ba[13]]);router[_0x18ba[5]](_0x18ba[14],controller[_0x18ba[15]]);router[_0x18ba[5]](_0x18ba[16],controller[_0x18ba[17]]);router[_0x18ba[5]](_0x18ba[18],controller[_0x18ba[19]]);router[_0x18ba[5]](_0x18ba[20],controller[_0x18ba[21]]);router[_0x18ba[5]](_0x18ba[22],controller[_0x18ba[23]]);router[_0x18ba[5]](_0x18ba[24],controller[_0x18ba[25]]);router[_0x18ba[5]](_0x18ba[26],controller[_0x18ba[27]]);router[_0x18ba[30]](_0x18ba[28],controller[_0x18ba[29]]);router[_0x18ba[32]](_0x18ba[24],controller[_0x18ba[31]]);router[_0x18ba[33]](_0x18ba[24],controller[_0x18ba[31]]);router[_0x18ba[35]](_0x18ba[24],controller[_0x18ba[34]]);module[_0x18ba[36]]=router; \ No newline at end of file diff --git a/server/api/xchatty/xchatty.controller.js b/server/api/xchatty/xchatty.controller.js index 17a3330..1c81eaf 100644 --- a/server/api/xchatty/xchatty.controller.js +++ b/server/api/xchatty/xchatty.controller.js @@ -1,566 +1 @@ -'use strict'; - -var _ = require('lodash'); -var jsmin = require('jsmin').jsmin; -var Mustache = require('mustache'); -var querystring = require('querystring'); -var path = require('path'); -var md5 = require('md5'); -var fs = require('fs'); -var UAParser = require('ua-parser-js'); -var uaParser = new UAParser(); -var languageParser = require('accept-language-parser'); -var ipaddr = require('ipaddr.js'); -var geoip = require('geoip-lite'); -var csv = require('to-csv') - -var config = require('../../config/environment'); -var Xchatty = require('../../models').Xchatty; -var xchatty_components = require('../../components/xchatty'); - -var sequelize = require('../../models').sequelize; -var User = require('../../models').User; -var Agent = require('../../models').User; -var ChatRoom = require('../../models').ChatRoom; -var ChatEnquiry = require('../../models').ChatEnquiry; -var ChatVisitor = require('../../models').ChatVisitor; -var ChatMessage = require('../../models').ChatMessage; -var ChatWebsite = require('../../models').ChatWebsite; - -var id = 1; - -// var ip = addr.toIPv4Address().octets.join('.'); - -// Get list of xchattys -exports.index = function (req, res, next) { - Xchatty - .findAll() - .then(function (xchattys) { - return res.status(200).send(xchattys); - }) - .catch(function (err) { - return next(err); - }); -}; - -exports.getJsByWebsite = function (req, res, next) { - - // TO DO: Find the configuration of the website and replace configuration in the file - ChatWebsite - .findById(req.params.id) - .then(function (chatWebsite) { - res.set({ - 'Content-Type': 'application/javascript', - 'x-timestamp': Date.now(), - 'x-sent': true - }); - - var js = xchatty_components.js; - /*jshint multistr: true */ - var configJS = { - websiteId: req.params.id, - // rootPath: path.join(chatWebsite.remote, 'api', 'xchatty/'), - rootPath: chatWebsite.remote + '/api/xchatty/', - signedUp: 'false', - windowFocused: 'false', - isNewPage: 'true', - processingSignUp: 'false', - processingEnquiry: 'false', - processingSend: 'false', - visitorFullname: '""', - visitorAvatar: '""', - timerReadMessages: 'null', - timerCheckStatus: 'null', - isOnline: 'false', - decayHistory: 0, - defaultTimeout: 2000, - isInitialStatusCheck: 'true', - muteNotificationSoundOnce: 'false', - assetBase: chatWebsite.remote + '/api/xchatty/assets', - hasSessionSaf: 'false', - restoreOpenState: 'false', - animateHover: chatWebsite.animation, - hideEmail: 'false', - hideOffline: 'false', - headerShape: chatWebsite.header_shape, - HeaderOnline: chatWebsite.header_online, - OnlineMessage: chatWebsite.online_message, - UsernamePlaceholder: chatWebsite.username_placeholder, - EmailPlaceholder: chatWebsite.email_placeholder, - StartChatButtonText: chatWebsite.start_chat_button, - OfflineMessage: chatWebsite.offline_message, - HeaderOffline: chatWebsite.header_offline, - EnquiryMessagePlaceholder: chatWebsite.enquiry_message_placeholder, - EnquiryButtonText: chatWebsite.enquiry_button, - downloadTranscript: chatWebsite.download_transcript - }; - - js = Mustache.render(js, configJS); - res.send(js); - - }) - .catch(function (err) { - next(err); - }); - -}; - -exports.getStyleByWebsite = function (req, res, next) { - - // TO DO: Find the configuration of the website and replace configuration in the file - ChatWebsite - .findById(req.params.id) - .then(function (chatWebsite) { - - res.set({ - 'Content-Type': 'text/css', - 'x-timestamp': Date.now(), - 'x-sent': true - }); - - var css = xchatty_components.css; - - var configCSS = { - // assetBase: path.join(chatWebsite.remote, 'api', 'xchatty', - // 'assets'), - assetBase: chatWebsite.remote + '/api/xchatty/assets', - color: chatWebsite.color, - colorFocus: chatWebsite.color_focus, - colorButton: chatWebsite.color_button - }; - - css = Mustache.render(css, configCSS); - res.send(css); - }) - .catch(function (err) { - next(err); - }); -}; - -exports.getAssets = function (req, res, next) { - res.download(path.join(config.root, 'server', 'components', 'xchatty', 'assets', req.query.resource)); -}; - -exports.getJqueryLibrary = function (req, res, next) { - - // TODO: Find the configuration of the website and replace configuration in the file - res.set({ - 'Content-Type': 'application/javascript', - 'x-timestamp': Date.now(), - 'x-sent': true - }); - - var jquery = xchatty_components.jquery; - res.send(jquery); - -}; - -exports.getStatus = function (req, res, next) { - - if (!req.session.xchatty) { - req.session.xchatty = {}; - } - // Get all users (later agents) online in the interface - Agent - .findAll({ - where: { - online: true, - role: 'agent' - } - }) - .then(function (users) { - - if (req.query.data.open_state) - req.session.xchatty.open_state = req.query.data.open_state === 'true' ? true : false; - - var jsonResponse = { - success: true, - has_session_saf: null, - signed_up: req.session.xchatty.room_id ? true : false, - fullname: req.session.xchatty.fullname ? req.session.xchatty.fullname : '', - email: req.session.xchatty.email ? req.session.xchatty.email : '', - avatar: req.session.xchatty.avatar ? req.session.xchatty.avatar : '', - open_state: req.session.xchatty.open_state || req.session.xchatty.room_id ? true : false, - online: users.length ? true : false - }; - - if (req.session.xchatty.visitor_id) { - ChatRoom - .findOne({ - where: { - ChatVisitorId: req.session.xchatty.visitor_id, - status: 'open' - } - }) - .then(function (chatRoom) { - if (chatRoom) { - req.session.xchatty.room_id = chatRoom.id; - jsonResponse.signed_up = true; - } else { - jsonResponse.signed_up = false; - } - - res.send(req.query.callback + '(' + JSON.stringify(jsonResponse) + ')'); - }) - .catch(function (err) { - next(err); - }); - } else { - res.send(req.query.callback + '(' + JSON.stringify(jsonResponse) + ')'); - } - - }) - .catch(function (err) { - return next(err); - }); -}; - -exports.getMessages = function (req, res, next) { - - /*jshint multistr: true */ - var condition = { - where: { - ChatRoomId: req.session.xchatty.room_id - }, - include: [{ - model: User, - attributes: ['id', 'name', 'fullname', 'email'] - }, { - model: ChatVisitor, - attributes: ['id', 'fullname', 'email'] - }] - }; - - if (req.query.data.is_new_page === 'false') { - condition.where.id = { - $gt: req.query.data.last_id - }; - } - - ChatMessage - .findAll(condition) - .then(function (chatMessages) { - var json = { - success: true, - messages: chatMessages, - composing: false, - composing_fullname: null - }; - - res.send(req.query.callback + '(' + JSON.stringify(json) + ')'); - }) - .catch(function (err) { - next(err); - }); -}; - -exports.sendMessage = function (req, res, next) { - - /*jshint multistr: true */ - var condition = { - where: { - ChatRoomId: req.session.xchatty.room_id - }, - include: [{ - model: User, - attributes: ['id', 'name', 'fullname', 'email'] - }, { - model: ChatVisitor, - attributes: ['id', 'fullname', 'email'] - }] - }; - - if (req.query.data.is_new_page === 'false') { - condition.where.id = { - $gt: req.query.data.last_id - }; - } - - ChatMessage - .create({ - body: req.query.data.Message.message, - ChatRoomId: req.session.xchatty.room_id, - ChatVisitorId: req.session.xchatty.visitor_id - }) - .then(function (chatMessage) { - console.log('chatMessage', chatMessage); - ChatMessage - .findAll(condition) - .then(function (chatMessages) { - var json = { - errors: [], - success: true, - data: chatMessage, - messages: chatMessages - }; - - res.send(req.query.callback + '(' + JSON.stringify(json) + ')'); - }) - .catch(function (err) { - next(err); - }); - }) - .catch(function (err) { - next(err); - }); - -}; - -exports.signoutCustomer = function (req, res, next) { - - ChatRoom - .findById(req.session.xchatty.room_id) - .then(function (chatRoom) { - chatRoom.updateAttributes({ - status: 'close' - }) - .then(function (chatRoom) { - var json = { - success: true, - errors: [] - }; - req.session.xchatty = {}; - res.send(req.query.callback + '(' + JSON.stringify(json) + ')'); - }) - .catch(function (err) { - next(err); - }) - }) - .catch(function (err) { - next(err); - }); -}; - -exports.signupCustomer = function (req, res, next) { - var ua = uaParser.setUA(req.headers['user-agent']).getResult(); - var languages = languageParser.parse(req.headers['accept-language']); - // var addr = ipaddr.parse(req.connection.remoteAddress); - - // var ipv4Addr = "151.0.175.186"; - // var geo = geoip.lookup(ipv4Addr); - - var body = { - fullname: req.query.data.Discussion.fullname, - email: req.query.data.Discussion.email, - // remote_address: addr, - remote_address: req.connection.remoteAddress, - user_agent: req.headers['user-agent'], - visitor_language: req.headers['accept-language'], - referer: req.headers.referer, - origin: 'webchat', - browser: ua.browser.name + ' ' + ua.browser.version, - engine: ua.engine.name + ' ' + ua.engine.version, - os: ua.os.name + ' ' + ua.os.version, - device: ua.device.model ? ua.device.model + ' ' + ua.device.vendor + ' ' + ua.device.type : null, - // country: geo.country, - // city: geo.city, - // region: geo.region, - // latitude: geo.ll.length ? geo.ll[0].toString() : null, - // longitude: geo.ll.length ? geo.ll[1].toString() : null, - ChatWebsiteId: req.query.chatWebsiteId - }; - - return ChatVisitor - .create(body) - .then(function (chatVisitor) { - - req.session.xchatty.fullname = chatVisitor.fullname; - req.session.xchatty.email = chatVisitor.email; - req.session.xchatty.avatar = md5(chatVisitor.email).toString('base64'); - req.session.xchatty.visitor_id = chatVisitor.id; - - var json = { - success: true, - errors: [], - chatVisitor: { - id: chatVisitor.id - } - }; - - /*jshint multistr: true */ - res.send(req.query.callback + '(' + JSON.stringify(json) + ')'); - }) - .catch(function (err) { - next(err); - }); -}; - -exports.unservedCustomer = function (req, res, next) { - - ChatVisitor - .findById(req.session.xchatty.visitor_id) - .then(function (chatVisitor) { - - chatVisitor.updateAttributes({ - status: 'unserved' - }).then(function () { - var json = { - success: true, - errors: [] - }; - req.session.xchatty = {}; - res.send(req.query.callback + '(' + JSON.stringify(json) + ')'); - }) - .catch(function (err) { - next(err); - }); - }) - .catch(function (err) { - next(err); - }); -}; - -exports.submitEnquiry = function (req, res, next) { - - var _chatVisitor; - var _chatEnquiry; - - return sequelize.transaction().then(function (t) { - - return ChatVisitor - .create({ - fullname: req.query.data.Enquiry.fullname, - email: req.query.data.Enquiry.email, - remote_address: req.connection.remoteAddress, - user_agent: req.headers['user-agent'], - visitor_language: req.headers['accept-language'], - referer: req.headers.referer, - origin: 'enquiry', - status: 'unserved' - }, { - transaction: t - }) - .then(function (chatVisitor) { - _chatVisitor = chatVisitor; - return ChatEnquiry - .create({ - username: req.query.data.Enquiry.fullname, - email: chatVisitor.email, - text: req.query.data.Enquiry.message, - ChatWebsiteId: parseInt(req.query.data.Enquiry.websiteId, 10), - ChatVisitorId: _chatVisitor.id - }, { - include: [{ - all: true, - include: [{ - all: true - }] - }], - transaction: t - }); - }) - .then(function () { - t.commit(); - res.send(req.query.callback + '(' + JSON.stringify({ - success: true, - errors: [] - }) + ')'); - }) - .catch(function (err) { - t.rollback(); - next(err); - }); - }); -}; - -exports.getTranscript = function (req, res, next) { - if (req.session.xchatty && req.session.xchatty.visitor_id && req.session.xchatty - .room_id) { - ChatMessage - .findAll({ - where: { - ChatRoomId: req.session.xchatty.room_id - } - }) - .then(function (chatMessages) { - - var chatMessageForCSV = []; - chatMessages.forEach(function (chatMessage) { - var chatMsg = { - name: chatMessage.fullname, - text: chatMessage.body.replace(/(\r\n|\n|\r)/gm, " "), - date: chatMessage.createdAt - }; - chatMessageForCSV.push(chatMsg); - }); - var csv_transcript = csv(chatMessageForCSV); - res.type('text/csv').status(200).send(csv_transcript); - }) - .catch(function (err) { - next(err); - }); - } -}; - -// Get a single xchatty -exports.show = function (req, res, next) { - Xchatty - .findById(req.params.id) - .then(function (xchatty) { - if (!xchatty) { - return res.sendStatus(404); - } - return res.send(xchatty); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Creates a new xchatty in the DB. -exports.create = function (req, res, next) { - Xchatty - .create(req.body) - .then(function (xchatty) { - return res.status(201).send(xchatty); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Updates an existing xchatty in the DB. -exports.update = function (req, res, next) { - if (req.body.id) { - delete req.body.id; - } - Xchatty - .findById(req.params.id) - .then(function (xchatty) { - if (!xchatty) { - return res.sendStatus(404); - } - var updated = _.merge(xchatty, req.body); - updated.save() - .then(function () { - return res.status(200).send(xchatty); - }) - .catch(function (err) { - return next(err); - }); - }) - .catch(function (err) { - return next(err); - }); -}; - -// Deletes a xchatty from the DB. -exports.destroy = function (req, res, next) { - Xchatty - .findById(req.params.id) - .then(function (xchatty) { - if (!xchatty) { - return res.sendStatus(404); - } - xchatty.destroy() - .then(function () { - return res.sendStatus(204); - }) - .catch(function (err) { - return next(err); - }); - }) - .catch(function (err) { - return next(err); - }); -}; +var _0x9613=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6A\x73\x6D\x69\x6E","\x6D\x75\x73\x74\x61\x63\x68\x65","\x71\x75\x65\x72\x79\x73\x74\x72\x69\x6E\x67","\x70\x61\x74\x68","\x6D\x64\x35","\x66\x73","\x75\x61\x2D\x70\x61\x72\x73\x65\x72\x2D\x6A\x73","\x61\x63\x63\x65\x70\x74\x2D\x6C\x61\x6E\x67\x75\x61\x67\x65\x2D\x70\x61\x72\x73\x65\x72","\x69\x70\x61\x64\x64\x72\x2E\x6A\x73","\x67\x65\x6F\x69\x70\x2D\x6C\x69\x74\x65","\x74\x6F\x2D\x63\x73\x76","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x58\x63\x68\x61\x74\x74\x79","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x2F\x78\x63\x68\x61\x74\x74\x79","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x55\x73\x65\x72","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x45\x6E\x71\x75\x69\x72\x79","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x67\x65\x74\x4A\x73\x42\x79\x57\x65\x62\x73\x69\x74\x65","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74","\x6E\x6F\x77","\x73\x65\x74","\x6A\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x72\x65\x6D\x6F\x74\x65","\x2F\x61\x70\x69\x2F\x78\x63\x68\x61\x74\x74\x79\x2F","\x66\x61\x6C\x73\x65","\x74\x72\x75\x65","\x22\x22","\x6E\x75\x6C\x6C","\x2F\x61\x70\x69\x2F\x78\x63\x68\x61\x74\x74\x79\x2F\x61\x73\x73\x65\x74\x73","\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E","\x68\x65\x61\x64\x65\x72\x5F\x73\x68\x61\x70\x65","\x68\x65\x61\x64\x65\x72\x5F\x6F\x6E\x6C\x69\x6E\x65","\x6F\x6E\x6C\x69\x6E\x65\x5F\x6D\x65\x73\x73\x61\x67\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65\x5F\x70\x6C\x61\x63\x65\x68\x6F\x6C\x64\x65\x72","\x65\x6D\x61\x69\x6C\x5F\x70\x6C\x61\x63\x65\x68\x6F\x6C\x64\x65\x72","\x73\x74\x61\x72\x74\x5F\x63\x68\x61\x74\x5F\x62\x75\x74\x74\x6F\x6E","\x6F\x66\x66\x6C\x69\x6E\x65\x5F\x6D\x65\x73\x73\x61\x67\x65","\x68\x65\x61\x64\x65\x72\x5F\x6F\x66\x66\x6C\x69\x6E\x65","\x65\x6E\x71\x75\x69\x72\x79\x5F\x6D\x65\x73\x73\x61\x67\x65\x5F\x70\x6C\x61\x63\x65\x68\x6F\x6C\x64\x65\x72","\x65\x6E\x71\x75\x69\x72\x79\x5F\x62\x75\x74\x74\x6F\x6E","\x64\x6F\x77\x6E\x6C\x6F\x61\x64\x5F\x74\x72\x61\x6E\x73\x63\x72\x69\x70\x74","\x72\x65\x6E\x64\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x67\x65\x74\x53\x74\x79\x6C\x65\x42\x79\x57\x65\x62\x73\x69\x74\x65","\x74\x65\x78\x74\x2F\x63\x73\x73","\x63\x73\x73","\x63\x6F\x6C\x6F\x72","\x63\x6F\x6C\x6F\x72\x5F\x66\x6F\x63\x75\x73","\x63\x6F\x6C\x6F\x72\x5F\x62\x75\x74\x74\x6F\x6E","\x67\x65\x74\x41\x73\x73\x65\x74\x73","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73","\x78\x63\x68\x61\x74\x74\x79","\x61\x73\x73\x65\x74\x73","\x72\x65\x73\x6F\x75\x72\x63\x65","\x71\x75\x65\x72\x79","\x6A\x6F\x69\x6E","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x67\x65\x74\x4A\x71\x75\x65\x72\x79\x4C\x69\x62\x72\x61\x72\x79","\x6A\x71\x75\x65\x72\x79","\x67\x65\x74\x53\x74\x61\x74\x75\x73","\x73\x65\x73\x73\x69\x6F\x6E","\x6F\x70\x65\x6E\x5F\x73\x74\x61\x74\x65","\x64\x61\x74\x61","\x72\x6F\x6F\x6D\x5F\x69\x64","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","","\x65\x6D\x61\x69\x6C","\x61\x76\x61\x74\x61\x72","\x6C\x65\x6E\x67\x74\x68","\x76\x69\x73\x69\x74\x6F\x72\x5F\x69\x64","\x73\x69\x67\x6E\x65\x64\x5F\x75\x70","\x63\x61\x6C\x6C\x62\x61\x63\x6B","\x28","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x29","\x6F\x70\x65\x6E","\x66\x69\x6E\x64\x4F\x6E\x65","\x61\x67\x65\x6E\x74","\x67\x65\x74\x4D\x65\x73\x73\x61\x67\x65\x73","\x6E\x61\x6D\x65","\x69\x73\x5F\x6E\x65\x77\x5F\x70\x61\x67\x65","\x77\x68\x65\x72\x65","\x6C\x61\x73\x74\x5F\x69\x64","\x73\x65\x6E\x64\x4D\x65\x73\x73\x61\x67\x65","\x63\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x6C\x6F\x67","\x6D\x65\x73\x73\x61\x67\x65","\x4D\x65\x73\x73\x61\x67\x65","\x63\x72\x65\x61\x74\x65","\x73\x69\x67\x6E\x6F\x75\x74\x43\x75\x73\x74\x6F\x6D\x65\x72","\x63\x6C\x6F\x73\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x73\x69\x67\x6E\x75\x70\x43\x75\x73\x74\x6F\x6D\x65\x72","\x67\x65\x74\x52\x65\x73\x75\x6C\x74","\x75\x73\x65\x72\x2D\x61\x67\x65\x6E\x74","\x68\x65\x61\x64\x65\x72\x73","\x73\x65\x74\x55\x41","\x61\x63\x63\x65\x70\x74\x2D\x6C\x61\x6E\x67\x75\x61\x67\x65","\x70\x61\x72\x73\x65","\x44\x69\x73\x63\x75\x73\x73\x69\x6F\x6E","\x72\x65\x6D\x6F\x74\x65\x41\x64\x64\x72\x65\x73\x73","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E","\x72\x65\x66\x65\x72\x65\x72","\x77\x65\x62\x63\x68\x61\x74","\x62\x72\x6F\x77\x73\x65\x72","\x20","\x76\x65\x72\x73\x69\x6F\x6E","\x65\x6E\x67\x69\x6E\x65","\x6F\x73","\x6D\x6F\x64\x65\x6C","\x64\x65\x76\x69\x63\x65","\x76\x65\x6E\x64\x6F\x72","\x74\x79\x70\x65","\x63\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x49\x64","\x62\x61\x73\x65\x36\x34","\x75\x6E\x73\x65\x72\x76\x65\x64\x43\x75\x73\x74\x6F\x6D\x65\x72","\x75\x6E\x73\x65\x72\x76\x65\x64","\x73\x75\x62\x6D\x69\x74\x45\x6E\x71\x75\x69\x72\x79","\x72\x6F\x6C\x6C\x62\x61\x63\x6B","\x63\x6F\x6D\x6D\x69\x74","\x45\x6E\x71\x75\x69\x72\x79","\x77\x65\x62\x73\x69\x74\x65\x49\x64","\x65\x6E\x71\x75\x69\x72\x79","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x67\x65\x74\x54\x72\x61\x6E\x73\x63\x72\x69\x70\x74","\x72\x65\x70\x6C\x61\x63\x65","\x62\x6F\x64\x79","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x74\x65\x78\x74\x2F\x63\x73\x76","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x9613[0];var _=require(_0x9613[1]);var jsmin=require(_0x9613[2])[_0x9613[2]];var Mustache=require(_0x9613[3]);var querystring=require(_0x9613[4]);var path=require(_0x9613[5]);var md5=require(_0x9613[6]);var fs=require(_0x9613[7]);var UAParser=require(_0x9613[8]);var uaParser= new UAParser();var languageParser=require(_0x9613[9]);var ipaddr=require(_0x9613[10]);var geoip=require(_0x9613[11]);var csv=require(_0x9613[12]);var config=require(_0x9613[13]);var Xchatty=require(_0x9613[15])[_0x9613[14]];var xchatty_components=require(_0x9613[16]);var sequelize=require(_0x9613[15])[_0x9613[17]];var User=require(_0x9613[15])[_0x9613[18]];var Agent=require(_0x9613[15])[_0x9613[18]];var ChatRoom=require(_0x9613[15])[_0x9613[19]];var ChatEnquiry=require(_0x9613[15])[_0x9613[20]];var ChatVisitor=require(_0x9613[15])[_0x9613[21]];var ChatMessage=require(_0x9613[15])[_0x9613[22]];var ChatWebsite=require(_0x9613[15])[_0x9613[23]];var id=1;exports[_0x9613[24]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){Xchatty[_0x9613[29]]()[_0x9613[28]](function(_0x3410x1e){return _0x3410x1b[_0x9613[27]](200)[_0x9613[26]](_0x3410x1e)})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)})};exports[_0x9613[30]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){ChatWebsite[_0x9613[57]](_0x3410x1a[_0x9613[36]][_0x9613[35]])[_0x9613[28]](function(_0x3410x1f){_0x3410x1b[_0x9613[33]]({"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65":_0x9613[31],"\x78\x2D\x74\x69\x6D\x65\x73\x74\x61\x6D\x70":Date[_0x9613[32]](),"\x78\x2D\x73\x65\x6E\x74":true});var _0x3410x20=xchatty_components[_0x9613[34]];var _0x3410x21={websiteId:_0x3410x1a[_0x9613[36]][_0x9613[35]],rootPath:_0x3410x1f[_0x9613[37]]+_0x9613[38],signedUp:_0x9613[39],windowFocused:_0x9613[39],isNewPage:_0x9613[40],processingSignUp:_0x9613[39],processingEnquiry:_0x9613[39],processingSend:_0x9613[39],visitorFullname:_0x9613[41],visitorAvatar:_0x9613[41],timerReadMessages:_0x9613[42],timerCheckStatus:_0x9613[42],isOnline:_0x9613[39],decayHistory:0,defaultTimeout:2000,isInitialStatusCheck:_0x9613[40],muteNotificationSoundOnce:_0x9613[39],assetBase:_0x3410x1f[_0x9613[37]]+_0x9613[43],hasSessionSaf:_0x9613[39],restoreOpenState:_0x9613[39],animateHover:_0x3410x1f[_0x9613[44]],hideEmail:_0x9613[39],hideOffline:_0x9613[39],headerShape:_0x3410x1f[_0x9613[45]],HeaderOnline:_0x3410x1f[_0x9613[46]],OnlineMessage:_0x3410x1f[_0x9613[47]],UsernamePlaceholder:_0x3410x1f[_0x9613[48]],EmailPlaceholder:_0x3410x1f[_0x9613[49]],StartChatButtonText:_0x3410x1f[_0x9613[50]],OfflineMessage:_0x3410x1f[_0x9613[51]],HeaderOffline:_0x3410x1f[_0x9613[52]],EnquiryMessagePlaceholder:_0x3410x1f[_0x9613[53]],EnquiryButtonText:_0x3410x1f[_0x9613[54]],downloadTranscript:_0x3410x1f[_0x9613[55]]};_0x3410x20=Mustache[_0x9613[56]](_0x3410x20,_0x3410x21);_0x3410x1b[_0x9613[26]](_0x3410x20);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})};exports[_0x9613[58]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){ChatWebsite[_0x9613[57]](_0x3410x1a[_0x9613[36]][_0x9613[35]])[_0x9613[28]](function(_0x3410x1f){_0x3410x1b[_0x9613[33]]({"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65":_0x9613[59],"\x78\x2D\x74\x69\x6D\x65\x73\x74\x61\x6D\x70":Date[_0x9613[32]](),"\x78\x2D\x73\x65\x6E\x74":true});var _0x3410x22=xchatty_components[_0x9613[60]];var _0x3410x23={assetBase:_0x3410x1f[_0x9613[37]]+_0x9613[43],color:_0x3410x1f[_0x9613[61]],colorFocus:_0x3410x1f[_0x9613[62]],colorButton:_0x3410x1f[_0x9613[63]]};_0x3410x22=Mustache[_0x9613[56]](_0x3410x22,_0x3410x23);_0x3410x1b[_0x9613[26]](_0x3410x22);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})};exports[_0x9613[64]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){_0x3410x1b[_0x9613[73]](path[_0x9613[72]](config[_0x9613[65]],_0x9613[66],_0x9613[67],_0x9613[68],_0x9613[69],_0x3410x1a[_0x9613[71]][_0x9613[70]]))};exports[_0x9613[74]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){_0x3410x1b[_0x9613[33]]({"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65":_0x9613[31],"\x78\x2D\x74\x69\x6D\x65\x73\x74\x61\x6D\x70":Date[_0x9613[32]](),"\x78\x2D\x73\x65\x6E\x74":true});var _0x3410x24=xchatty_components[_0x9613[75]];_0x3410x1b[_0x9613[26]](_0x3410x24);};exports[_0x9613[76]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){if(!_0x3410x1a[_0x9613[77]][_0x9613[68]]){_0x3410x1a[_0x9613[77]][_0x9613[68]]={}};Agent[_0x9613[29]]({where:{online:true,role:_0x9613[94]}})[_0x9613[28]](function(_0x3410x25){if(_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[78]]){_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[78]]=_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[78]]===_0x9613[40]?true:false};var _0x3410x26={success:true,has_session_saf:null,signed_up:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]]?true:false,fullname:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[81]]?_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[81]]:_0x9613[82],email:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[83]]?_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[83]]:_0x9613[82],avatar:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[84]]?_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[84]]:_0x9613[82],open_state:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[78]]||_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]]?true:false,online:_0x3410x25[_0x9613[85]]?true:false};if(_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[86]]){ChatRoom[_0x9613[93]]({where:{ChatVisitorId:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[86]],status:_0x9613[92]}})[_0x9613[28]](function(_0x3410x27){if(_0x3410x27){_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]]=_0x3410x27[_0x9613[35]];_0x3410x26[_0x9613[87]]=true;}else {_0x3410x26[_0x9613[87]]=false};_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]](_0x3410x26)+_0x9613[91]);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})}else {_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]](_0x3410x26)+_0x9613[91])};})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)});};exports[_0x9613[95]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){var _0x3410x28={where:{ChatRoomId:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]]},include:[{model:User,attributes:[_0x9613[35],_0x9613[96],_0x9613[81],_0x9613[83]]},{model:ChatVisitor,attributes:[_0x9613[35],_0x9613[81],_0x9613[83]]}]};if(_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[97]]===_0x9613[39]){_0x3410x28[_0x9613[98]][_0x9613[35]]={$gt:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[99]]}};ChatMessage[_0x9613[29]](_0x3410x28)[_0x9613[28]](function(_0x3410x29){var _0x3410x2a={success:true,messages:_0x3410x29,composing:false,composing_fullname:null};_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]](_0x3410x2a)+_0x9613[91]);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)});};exports[_0x9613[100]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){var _0x3410x28={where:{ChatRoomId:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]]},include:[{model:User,attributes:[_0x9613[35],_0x9613[96],_0x9613[81],_0x9613[83]]},{model:ChatVisitor,attributes:[_0x9613[35],_0x9613[81],_0x9613[83]]}]};if(_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[97]]===_0x9613[39]){_0x3410x28[_0x9613[98]][_0x9613[35]]={$gt:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[99]]}};ChatMessage[_0x9613[105]]({body:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[104]][_0x9613[103]],ChatRoomId:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]],ChatVisitorId:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[86]]})[_0x9613[28]](function(_0x3410x2b){console[_0x9613[102]](_0x9613[101],_0x3410x2b);ChatMessage[_0x9613[29]](_0x3410x28)[_0x9613[28]](function(_0x3410x29){var _0x3410x2a={errors:[],success:true,data:_0x3410x2b,messages:_0x3410x29};_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]](_0x3410x2a)+_0x9613[91]);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)});})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)});};exports[_0x9613[106]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){ChatRoom[_0x9613[57]](_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]])[_0x9613[28]](function(_0x3410x27){_0x3410x27[_0x9613[108]]({status:_0x9613[107]})[_0x9613[28]](function(_0x3410x27){var _0x3410x2a={success:true,errors:[]};_0x3410x1a[_0x9613[77]][_0x9613[68]]={};_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]](_0x3410x2a)+_0x9613[91]);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})};exports[_0x9613[109]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){var _0x3410x2c=uaParser[_0x9613[113]](_0x3410x1a[_0x9613[112]][_0x9613[111]])[_0x9613[110]]();var _0x3410x2d=languageParser[_0x9613[115]](_0x3410x1a[_0x9613[112]][_0x9613[114]]);var _0x3410x2e={fullname:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[116]][_0x9613[81]],email:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[116]][_0x9613[83]],remote_address:_0x3410x1a[_0x9613[118]][_0x9613[117]],user_agent:_0x3410x1a[_0x9613[112]][_0x9613[111]],visitor_language:_0x3410x1a[_0x9613[112]][_0x9613[114]],referer:_0x3410x1a[_0x9613[112]][_0x9613[119]],origin:_0x9613[120],browser:_0x3410x2c[_0x9613[121]][_0x9613[96]]+_0x9613[122]+_0x3410x2c[_0x9613[121]][_0x9613[123]],engine:_0x3410x2c[_0x9613[124]][_0x9613[96]]+_0x9613[122]+_0x3410x2c[_0x9613[124]][_0x9613[123]],os:_0x3410x2c[_0x9613[125]][_0x9613[96]]+_0x9613[122]+_0x3410x2c[_0x9613[125]][_0x9613[123]],device:_0x3410x2c[_0x9613[127]][_0x9613[126]]?_0x3410x2c[_0x9613[127]][_0x9613[126]]+_0x9613[122]+_0x3410x2c[_0x9613[127]][_0x9613[128]]+_0x9613[122]+_0x3410x2c[_0x9613[127]][_0x9613[129]]:null,ChatWebsiteId:_0x3410x1a[_0x9613[71]][_0x9613[130]]};return ChatVisitor[_0x9613[105]](_0x3410x2e)[_0x9613[28]](function(_0x3410x2f){_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[81]]=_0x3410x2f[_0x9613[81]];_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[83]]=_0x3410x2f[_0x9613[83]];_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[84]]=md5(_0x3410x2f[_0x9613[83]]).toString(_0x9613[131]);_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[86]]=_0x3410x2f[_0x9613[35]];var _0x3410x2a={success:true,errors:[],chatVisitor:{id:_0x3410x2f[_0x9613[35]]}};_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]](_0x3410x2a)+_0x9613[91]);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)});};exports[_0x9613[132]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){ChatVisitor[_0x9613[57]](_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[86]])[_0x9613[28]](function(_0x3410x2f){_0x3410x2f[_0x9613[108]]({status:_0x9613[133]})[_0x9613[28]](function(){var _0x3410x2a={success:true,errors:[]};_0x3410x1a[_0x9613[77]][_0x9613[68]]={};_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]](_0x3410x2a)+_0x9613[91]);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})};exports[_0x9613[134]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){var _0x3410x30;var _0x3410x31;return sequelize[_0x9613[140]]()[_0x9613[28]](function(_0x3410x32){return ChatVisitor[_0x9613[105]]({fullname:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[137]][_0x9613[81]],email:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[137]][_0x9613[83]],remote_address:_0x3410x1a[_0x9613[118]][_0x9613[117]],user_agent:_0x3410x1a[_0x9613[112]][_0x9613[111]],visitor_language:_0x3410x1a[_0x9613[112]][_0x9613[114]],referer:_0x3410x1a[_0x9613[112]][_0x9613[119]],origin:_0x9613[139],status:_0x9613[133]},{transaction:_0x3410x32})[_0x9613[28]](function(_0x3410x2f){_0x3410x30=_0x3410x2f;return ChatEnquiry[_0x9613[105]]({username:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[137]][_0x9613[81]],email:_0x3410x2f[_0x9613[83]],text:_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[137]][_0x9613[103]],ChatWebsiteId:parseInt(_0x3410x1a[_0x9613[71]][_0x9613[79]][_0x9613[137]][_0x9613[138]],10),ChatVisitorId:_0x3410x30[_0x9613[35]]},{include:[{all:true,include:[{all:true}]}],transaction:_0x3410x32});})[_0x9613[28]](function(){_0x3410x32[_0x9613[136]]();_0x3410x1b[_0x9613[26]](_0x3410x1a[_0x9613[71]][_0x9613[88]]+_0x9613[89]+JSON[_0x9613[90]]({success:true,errors:[]})+_0x9613[91]);})[_0x9613[25]](function(_0x3410x1d){_0x3410x32[_0x9613[135]]();_0x3410x1c(_0x3410x1d);})});};exports[_0x9613[141]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){if(_0x3410x1a[_0x9613[77]][_0x9613[68]]&&_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[86]]&&_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]]){ChatMessage[_0x9613[29]]({where:{ChatRoomId:_0x3410x1a[_0x9613[77]][_0x9613[68]][_0x9613[80]]}})[_0x9613[28]](function(_0x3410x29){var _0x3410x33=[];_0x3410x29[_0x9613[146]](function(_0x3410x2b){var _0x3410x34={name:_0x3410x2b[_0x9613[81]],text:_0x3410x2b[_0x9613[143]][_0x9613[142]](/(\r\n|\n|\r)/gm,_0x9613[122]),date:_0x3410x2b[_0x9613[144]]};_0x3410x33[_0x9613[145]](_0x3410x34);});var _0x3410x35=csv(_0x3410x33);_0x3410x1b[_0x9613[129]](_0x9613[147])[_0x9613[27]](200)[_0x9613[26]](_0x3410x35);})[_0x9613[25]](function(_0x3410x1d){_0x3410x1c(_0x3410x1d)})}};exports[_0x9613[148]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){Xchatty[_0x9613[57]](_0x3410x1a[_0x9613[36]][_0x9613[35]])[_0x9613[28]](function(_0x3410x36){if(!_0x3410x36){return _0x3410x1b[_0x9613[149]](404)};return _0x3410x1b[_0x9613[26]](_0x3410x36);})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)})};exports[_0x9613[105]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){Xchatty[_0x9613[105]](_0x3410x1a[_0x9613[143]])[_0x9613[28]](function(_0x3410x36){return _0x3410x1b[_0x9613[27]](201)[_0x9613[26]](_0x3410x36)})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)})};exports[_0x9613[150]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){if(_0x3410x1a[_0x9613[143]][_0x9613[35]]){delete _0x3410x1a[_0x9613[143]][_0x9613[35]]};Xchatty[_0x9613[57]](_0x3410x1a[_0x9613[36]][_0x9613[35]])[_0x9613[28]](function(_0x3410x36){if(!_0x3410x36){return _0x3410x1b[_0x9613[149]](404)};var _0x3410x37=_[_0x9613[151]](_0x3410x36,_0x3410x1a[_0x9613[143]]);_0x3410x37[_0x9613[152]]()[_0x9613[28]](function(){return _0x3410x1b[_0x9613[27]](200)[_0x9613[26]](_0x3410x36)})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)});})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)});};exports[_0x9613[153]]=function(_0x3410x1a,_0x3410x1b,_0x3410x1c){Xchatty[_0x9613[57]](_0x3410x1a[_0x9613[36]][_0x9613[35]])[_0x9613[28]](function(_0x3410x36){if(!_0x3410x36){return _0x3410x1b[_0x9613[149]](404)};_0x3410x36[_0x9613[153]]()[_0x9613[28]](function(){return _0x3410x1b[_0x9613[149]](204)})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)});})[_0x9613[25]](function(_0x3410x1d){return _0x3410x1c(_0x3410x1d)})}; \ No newline at end of file diff --git a/server/api/xchatty/xchatty.socket.js b/server/api/xchatty/xchatty.socket.js index b8ec557..fcf9a07 100644 --- a/server/api/xchatty/xchatty.socket.js +++ b/server/api/xchatty/xchatty.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var xchatty = require('../../models').Xchatty; - -exports.register = function(socket) { - // xchatty.afterCreate(function (doc) { - // onSave(socket, doc); - // }); - // xchatty.afterDestroy(function (doc) { - // onRemove(socket, doc); - // }); -} - -function onSave(socket, doc, cb) { - socket.emit('xchatty:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('xchatty:remove', doc); -} +var _0x9e70=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x58\x63\x68\x61\x74\x74\x79","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x78\x63\x68\x61\x74\x74\x79\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x78\x63\x68\x61\x74\x74\x79\x3A\x72\x65\x6D\x6F\x76\x65"];_0x9e70[0];var xchatty=require(_0x9e70[2])[_0x9e70[1]];exports[_0x9e70[3]]=function(_0xf1bax2){};function onSave(_0xf1bax2,_0xf1bax4,_0xf1bax5){_0xf1bax2[_0x9e70[5]](_0x9e70[4],_0xf1bax4)}function onRemove(_0xf1bax2,_0xf1bax4,_0xf1bax5){_0xf1bax2[_0x9e70[5]](_0x9e70[6],_0xf1bax4)} \ No newline at end of file diff --git a/server/api/zendesk_account/index.js b/server/api/zendesk_account/index.js index d64cd4a..afaa9c9 100644 --- a/server/api/zendesk_account/index.js +++ b/server/api/zendesk_account/index.js @@ -1,20 +1 @@ -'use strict'; - -var express = require('express'); -var auth = require('../../auth/auth.service'); -var controller = require('./zendesk_account.controller'); - -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount); -router.get('/:id/fields', auth.isAuthenticated(), controller.getFields); -router.post('/validate/:field', auth.isAuthenticated(), controller.zendeskValidation); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/', auth.isAuthenticated(), controller.bulkDestroy); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x3f2e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2E\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x2F\x3A\x69\x64\x2F\x63\x68\x65\x63\x6B","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2F\x3A\x69\x64\x2F\x66\x69\x65\x6C\x64\x73","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x2F\x76\x61\x6C\x69\x64\x61\x74\x65\x2F\x3A\x66\x69\x65\x6C\x64","\x7A\x65\x6E\x64\x65\x73\x6B\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x6F\x73\x74","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x3f2e[0];var express=require(_0x3f2e[1]);var auth=require(_0x3f2e[2]);var controller=require(_0x3f2e[3]);var router=express.Router();router[_0x3f2e[7]](_0x3f2e[4],auth[_0x3f2e[5]](),controller[_0x3f2e[6]]);router[_0x3f2e[7]](_0x3f2e[8],auth[_0x3f2e[5]](),controller[_0x3f2e[9]]);router[_0x3f2e[7]](_0x3f2e[10],auth[_0x3f2e[5]](),controller[_0x3f2e[11]]);router[_0x3f2e[7]](_0x3f2e[12],auth[_0x3f2e[5]](),controller[_0x3f2e[13]]);router[_0x3f2e[16]](_0x3f2e[14],auth[_0x3f2e[5]](),controller[_0x3f2e[15]]);router[_0x3f2e[16]](_0x3f2e[4],auth[_0x3f2e[5]](),controller[_0x3f2e[17]]);router[_0x3f2e[19]](_0x3f2e[8],auth[_0x3f2e[5]](),controller[_0x3f2e[18]]);router[_0x3f2e[20]](_0x3f2e[8],auth[_0x3f2e[5]](),controller[_0x3f2e[18]]);router[_0x3f2e[22]](_0x3f2e[4],auth[_0x3f2e[5]](),controller[_0x3f2e[21]]);router[_0x3f2e[22]](_0x3f2e[8],auth[_0x3f2e[5]](),controller[_0x3f2e[23]]);module[_0x3f2e[24]]=router; \ No newline at end of file diff --git a/server/api/zendesk_account/zendesk_account.controller.js b/server/api/zendesk_account/zendesk_account.controller.js index 2cac790..3f84597 100644 --- a/server/api/zendesk_account/zendesk_account.controller.js +++ b/server/api/zendesk_account/zendesk_account.controller.js @@ -1,253 +1 @@ -'use strict'; - -var _ = require('lodash'); -var util = require('util'); -var zendesk = require('node-zendesk'); - -var ZendeskAccount = require('../../models').ZendeskAccount; - -// Get list of zendesk_accounts -exports.index = function(req, res, next) { - - var attributes = ['description', 'name', 'username', 'remoteUri']; - var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100; - var page = req.query.page ? parseInt(req.query.page, 10) : 0; - - var query = { - where: {}, - limit: per_page, - offset: page * per_page - }; - - _.forIn(req.query, function(value, key) { - switch (key) { - case 'per_page': - case 'page': - break; - case 'sort_by': - query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null; - break; - case 'sort_order': - break; - case '$': - query.where.$or = []; - attributes.forEach(function(attribute) { - var tmp = {}; - tmp[attribute] = { - $like: '%' + value + '%' - }; - - query.where.$or.push(tmp); - }); - break; - default: - query.where[key] = { - $like: {} - }; - query.where[key].$like = '%' + value + '%'; - } - }); - - ZendeskAccount - .findAndCountAll(query) - .then(function(result) { - - var total_pages = Math.ceil(result.count / per_page); - var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null; - var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null; - - return res.status(200).send({ - count: result.count, - rows: result.rows, - next_page: next_page, - previous_page: previous_page, - total_pages: total_pages - }); - - }) - .catch(function(err) { - return res.status(500).send({ - error: 'Something blew up!' - }); - }); -}; - -// Get a single zendesk_account -exports.show = function(req, res) { - ZendeskAccount - .findById(req.params.id) - .then(function(zendesk_account) { - if (!zendesk_account) { - return res.sendStatus(404); - } - return res.send(zendesk_account); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new zendesk_account in the DB. -exports.create = function(req, res) { - ZendeskAccount - .create(req.body) - .then(function(zendesk_account) { - return res.status(201).send(zendesk_account); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing zendesk_account in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ZendeskAccount - .findById(req.params.id) - .then(function(zendesk_account) { - if (!zendesk_account) { - return res.sendStatus(404); - } - var updated = _.merge(zendesk_account, req.body); - updated.save() - .then(function() { - return res.status(200).send(zendesk_account); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a zendesk_account from the DB. -exports.destroy = function(req, res) { - ZendeskAccount - .findById(req.params.id) - .then(function(zendesk_account) { - if (!zendesk_account) { - return res.sendStatus(404); - } - zendesk_account.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.bulkDestroy = function(req, res) { - ZendeskAccount - .destroy({ - where: { - id: req.query.id - }, - individualHooks: true - }) - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.zendeskValidation = function(req, res) { - var where = {}; - where[req.params.field] = req.body.value; - ZendeskAccount - .findAndCountAll({ - where: where - }) - .then(function(result) { - if (result.count) { - return res.status(200).send({ - isValid: false, - value: req.body.value - }); - } - return res.status(200).send({ - isValid: true, - value: req.body.value - }); - }) - .catch(function(err) { - return handleError(res, err); - }); - -}; - -exports.checkAccount = function(req, res) { - ZendeskAccount - .findById(req.params.id) - .then(function(account) { - var accountZendesk = { - username: account.username, - remoteUri: account.remoteUri, - // debug: true - }; - if (account.authType === 'password') { - accountZendesk.password = account.password; - } else if (account.authType === 'token') { - accountZendesk.token = account.token; - // accountZendesk.oauth = true; - } - // console.log(accountZendesk); - var client = zendesk.createClient(accountZendesk); - client.users.auth(function(err, res2, result) { - if (err) { - console.error(err); - return handleError(res, err); - } - // console.log(result); - if (!result.verified) { - return res.sendStatus(500); - } - return res.sendStatus(204); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.getFields = function(req, res) { - ZendeskAccount - .findById(req.params.id) - .then(function(account) { - var accountZendesk = { - username: account.username, - remoteUri: account.remoteUri, - // debug: true - }; - if (account.authType === 'password') { - accountZendesk.password = account.password; - } else if (account.authType === 'token') { - accountZendesk.token = account.token; - } - var client = zendesk.createClient(accountZendesk); - client.ticketfields.list(function(err, res2, result) { - if (err) { - console.error(err); - return handleError(res, err); - } - return res.status(200).send(result); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -} - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0xf805=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x6E\x6F\x64\x65\x2D\x7A\x65\x6E\x64\x65\x73\x6B","\x5A\x65\x6E\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x7A\x65\x6E\x64\x65\x73\x6B\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x61\x75\x74\x68\x54\x79\x70\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x74\x6F\x6B\x65\x6E","\x63\x72\x65\x61\x74\x65\x43\x6C\x69\x65\x6E\x74","\x65\x72\x72\x6F\x72","\x76\x65\x72\x69\x66\x69\x65\x64","\x61\x75\x74\x68","\x75\x73\x65\x72\x73","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x6C\x69\x73\x74","\x74\x69\x63\x6B\x65\x74\x66\x69\x65\x6C\x64\x73"];_0xf805[0];var _=require(_0xf805[1]);var util=require(_0xf805[2]);var zendesk=require(_0xf805[3]);var ZendeskAccount=require(_0xf805[5])[_0xf805[4]];exports[_0xf805[6]]=function(_0xa069x5,_0xa069x6,_0xa069x7){var _0xa069x8=[_0xf805[7],_0xf805[8],_0xf805[9],_0xf805[10]];var _0xa069x9=_0xa069x5[_0xf805[12]][_0xf805[11]]?parseInt(_0xa069x5[_0xf805[12]][_0xf805[11]],10):100;var _0xa069xa=_0xa069x5[_0xf805[12]][_0xf805[13]]?parseInt(_0xa069x5[_0xf805[12]][_0xf805[13]],10):0;var _0xa069xb={where:{},limit:_0xa069x9,offset:_0xa069xa*_0xa069x9};_[_0xf805[27]](_0xa069x5[_0xf805[12]],function(_0xa069xc,_0xa069xd){switch(_0xa069xd){case _0xf805[11]:;case _0xf805[13]:break ;;case _0xf805[16]:_0xa069xb[_0xf805[14]]=util[_0xf805[19]](_0xf805[15],_0xa069x5[_0xf805[12]][_0xf805[16]],_0xa069x5[_0xf805[12]][_0xf805[17]]||_0xf805[18])||null;break ;;case _0xf805[17]:break ;;case _0xf805[25]:_0xa069xb[_0xf805[21]][_0xf805[20]]=[];_0xa069x8[_0xf805[24]](function(_0xa069xe){var _0xa069xf={};_0xa069xf[_0xa069xe]={$like:_0xf805[22]+_0xa069xc+_0xf805[22]};_0xa069xb[_0xf805[21]][_0xf805[20]][_0xf805[23]](_0xa069xf);});break ;;default:_0xa069xb[_0xf805[21]][_0xa069xd]={$like:{}};_0xa069xb[_0xf805[21]][_0xa069xd][_0xf805[26]]=_0xf805[22]+_0xa069xc+_0xf805[22];;}});ZendeskAccount[_0xf805[42]](_0xa069xb)[_0xf805[41]](function(_0xa069x11){var _0xa069x12=Math[_0xf805[33]](_0xa069x11[_0xf805[32]]/_0xa069x9);var _0xa069x13=_0xa069x12>(_0xa069xb[_0xf805[34]]+1)?util[_0xf805[19]](_0xf805[35],_0xa069x5[_0xf805[36]],_0xa069x5[_0xf805[38]][_0xf805[37]],_0xa069x5[_0xf805[39]],_0xa069xa+1):null;var _0xa069x14=_0xa069xa>0?util[_0xf805[19]](_0xf805[35],_0xa069x5[_0xf805[36]],_0xa069x5[_0xf805[38]][_0xf805[37]],_0xa069x5[_0xf805[39]],_0xa069xa-1):null;return _0xa069x6[_0xf805[30]](200)[_0xf805[29]]({count:_0xa069x11[_0xf805[32]],rows:_0xa069x11[_0xf805[40]],next_page:_0xa069x13,previous_page:_0xa069x14,total_pages:_0xa069x12});})[_0xf805[31]](function(_0xa069x10){return _0xa069x6[_0xf805[30]](500)[_0xf805[29]]({error:_0xf805[28]})});};exports[_0xf805[43]]=function(_0xa069x5,_0xa069x6){ZendeskAccount[_0xf805[47]](_0xa069x5[_0xf805[46]][_0xf805[45]])[_0xf805[41]](function(_0xa069x15){if(!_0xa069x15){return _0xa069x6[_0xf805[44]](404)};return _0xa069x6[_0xf805[29]](_0xa069x15);})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)})};exports[_0xf805[48]]=function(_0xa069x5,_0xa069x6){ZendeskAccount[_0xf805[48]](_0xa069x5[_0xf805[49]])[_0xf805[41]](function(_0xa069x15){return _0xa069x6[_0xf805[30]](201)[_0xf805[29]](_0xa069x15)})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)})};exports[_0xf805[50]]=function(_0xa069x5,_0xa069x6){if(_0xa069x5[_0xf805[49]][_0xf805[45]]){delete _0xa069x5[_0xf805[49]][_0xf805[45]]};ZendeskAccount[_0xf805[47]](_0xa069x5[_0xf805[46]][_0xf805[45]])[_0xf805[41]](function(_0xa069x15){if(!_0xa069x15){return _0xa069x6[_0xf805[44]](404)};var _0xa069x16=_[_0xf805[51]](_0xa069x15,_0xa069x5[_0xf805[49]]);_0xa069x16[_0xf805[52]]()[_0xf805[41]](function(){return _0xa069x6[_0xf805[30]](200)[_0xf805[29]](_0xa069x15)})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)});})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)});};exports[_0xf805[53]]=function(_0xa069x5,_0xa069x6){ZendeskAccount[_0xf805[47]](_0xa069x5[_0xf805[46]][_0xf805[45]])[_0xf805[41]](function(_0xa069x15){if(!_0xa069x15){return _0xa069x6[_0xf805[44]](404)};_0xa069x15[_0xf805[53]]()[_0xf805[41]](function(){return _0xa069x6[_0xf805[44]](204)})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)});})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)})};exports[_0xf805[54]]=function(_0xa069x5,_0xa069x6){ZendeskAccount[_0xf805[53]]({where:{id:_0xa069x5[_0xf805[12]][_0xf805[45]]},individualHooks:true})[_0xf805[41]](function(){return _0xa069x6[_0xf805[44]](204)})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)})};exports[_0xf805[55]]=function(_0xa069x5,_0xa069x6){var _0xa069x17={};_0xa069x17[_0xa069x5[_0xf805[46]][_0xf805[56]]]=_0xa069x5[_0xf805[49]][_0xf805[57]];ZendeskAccount[_0xf805[42]]({where:_0xa069x17})[_0xf805[41]](function(_0xa069x11){if(_0xa069x11[_0xf805[32]]){return _0xa069x6[_0xf805[30]](200)[_0xf805[29]]({isValid:false,value:_0xa069x5[_0xf805[49]][_0xf805[57]]})};return _0xa069x6[_0xf805[30]](200)[_0xf805[29]]({isValid:true,value:_0xa069x5[_0xf805[49]][_0xf805[57]]});})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)});};exports[_0xf805[58]]=function(_0xa069x5,_0xa069x6){ZendeskAccount[_0xf805[47]](_0xa069x5[_0xf805[46]][_0xf805[45]])[_0xf805[41]](function(_0xa069x18){var _0xa069x19={username:_0xa069x18[_0xf805[9]],remoteUri:_0xa069x18[_0xf805[10]]};if(_0xa069x18[_0xf805[59]]===_0xf805[60]){_0xa069x19[_0xf805[60]]=_0xa069x18[_0xf805[60]]}else {if(_0xa069x18[_0xf805[59]]===_0xf805[61]){_0xa069x19[_0xf805[61]]=_0xa069x18[_0xf805[61]]}};var _0xa069x1a=zendesk[_0xf805[62]](_0xa069x19);_0xa069x1a[_0xf805[66]][_0xf805[65]](function(_0xa069x10,_0xa069x1b,_0xa069x11){if(_0xa069x10){console[_0xf805[63]](_0xa069x10);return handleError(_0xa069x6,_0xa069x10);};if(!_0xa069x11[_0xf805[64]]){return _0xa069x6[_0xf805[44]](500)};return _0xa069x6[_0xf805[44]](204);});})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)})};exports[_0xf805[67]]=function(_0xa069x5,_0xa069x6){ZendeskAccount[_0xf805[47]](_0xa069x5[_0xf805[46]][_0xf805[45]])[_0xf805[41]](function(_0xa069x18){var _0xa069x19={username:_0xa069x18[_0xf805[9]],remoteUri:_0xa069x18[_0xf805[10]]};if(_0xa069x18[_0xf805[59]]===_0xf805[60]){_0xa069x19[_0xf805[60]]=_0xa069x18[_0xf805[60]]}else {if(_0xa069x18[_0xf805[59]]===_0xf805[61]){_0xa069x19[_0xf805[61]]=_0xa069x18[_0xf805[61]]}};var _0xa069x1a=zendesk[_0xf805[62]](_0xa069x19);_0xa069x1a[_0xf805[69]][_0xf805[68]](function(_0xa069x10,_0xa069x1b,_0xa069x11){if(_0xa069x10){console[_0xf805[63]](_0xa069x10);return handleError(_0xa069x6,_0xa069x10);};return _0xa069x6[_0xf805[30]](200)[_0xf805[29]](_0xa069x11);});})[_0xf805[31]](function(_0xa069x10){return handleError(_0xa069x6,_0xa069x10)})};function handleError(_0xa069x6,_0xa069x10){return _0xa069x6[_0xf805[30]](500)[_0xf805[29]](_0xa069x10)} \ No newline at end of file diff --git a/server/api/zendesk_account/zendesk_account.socket.js b/server/api/zendesk_account/zendesk_account.socket.js index 96c8214..f70b862 100644 --- a/server/api/zendesk_account/zendesk_account.socket.js +++ b/server/api/zendesk_account/zendesk_account.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ZendeskAccount = require('../../models').ZendeskAccount; - -exports.register = function(socket) { - ZendeskAccount.afterCreate(function (doc) { - onSave(socket, doc); - }); - ZendeskAccount.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('zendesk_account:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('zendesk_account:remove', doc); -} +var _0xcdce=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x5A\x65\x6E\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x3A\x72\x65\x6D\x6F\x76\x65"];_0xcdce[0];var ZendeskAccount=require(_0xcdce[2])[_0xcdce[1]];exports[_0xcdce[3]]=function(_0xcc5bx2){ZendeskAccount[_0xcdce[4]](function(_0xcc5bx3){onSave(_0xcc5bx2,_0xcc5bx3)});ZendeskAccount[_0xcdce[5]](function(_0xcc5bx3){onRemove(_0xcc5bx2,_0xcc5bx3)});};function onSave(_0xcc5bx2,_0xcc5bx3,_0xcc5bx5){_0xcc5bx2[_0xcdce[7]](_0xcdce[6],_0xcc5bx3)}function onRemove(_0xcc5bx2,_0xcc5bx3,_0xcc5bx5){_0xcc5bx2[_0xcdce[7]](_0xcdce[8],_0xcc5bx3)} \ No newline at end of file diff --git a/server/api/zendesk_account/zendesk_account.spec.js b/server/api/zendesk_account/zendesk_account.spec.js index 68c8389..732f4c5 100644 --- a/server/api/zendesk_account/zendesk_account.spec.js +++ b/server/api/zendesk_account/zendesk_account.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/zendesk/accounts', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/zendesk/accounts') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0xcd02=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x67\x65\x74"];_0xcd02[0];var should=require(_0xcd02[1]);var app=require(_0xcd02[2]);var request=require(_0xcd02[3]);describe(_0xcd02[4],function(){it(_0xcd02[5],function(_0xce5bx4){request(app)[_0xcd02[13]](_0xcd02[12])[_0xcd02[11]](200)[_0xcd02[11]](_0xcd02[10],/json/)[_0xcd02[9]](function(_0xce5bx5,_0xce5bx6){if(_0xce5bx5){return _0xce5bx4(_0xce5bx5)};_0xce5bx6[_0xcd02[8]][_0xcd02[1]][_0xcd02[7]][_0xcd02[6]](Array);_0xce5bx4();})})}); \ No newline at end of file diff --git a/server/api/zendesk_configuration/index.js b/server/api/zendesk_configuration/index.js index 9df7d1b..03cb650 100644 --- a/server/api/zendesk_configuration/index.js +++ b/server/api/zendesk_configuration/index.js @@ -1,16 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./zendesk_configuration.controller'); -var auth = require('../../auth/auth.service'); -var router = express.Router(); - -router.get('/', auth.isAuthenticated(), controller.index); -router.get('/:id', auth.isAuthenticated(), controller.show); -router.post('/', auth.isAuthenticated(), controller.create); -router.put('/:id', auth.isAuthenticated(), controller.update); -router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField); -router.patch('/:id', auth.isAuthenticated(), controller.update); -router.delete('/:id', auth.isAuthenticated(), controller.destroy); - -module.exports = router; +var _0x67ba=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x75\x74\x68\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x2F\x3A\x69\x64\x2F\x3A\x74\x79\x70\x65","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x67ba[0];var express=require(_0x67ba[1]);var controller=require(_0x67ba[2]);var auth=require(_0x67ba[3]);var router=express.Router();router[_0x67ba[7]](_0x67ba[4],auth[_0x67ba[5]](),controller[_0x67ba[6]]);router[_0x67ba[7]](_0x67ba[8],auth[_0x67ba[5]](),controller[_0x67ba[9]]);router[_0x67ba[11]](_0x67ba[4],auth[_0x67ba[5]](),controller[_0x67ba[10]]);router[_0x67ba[13]](_0x67ba[8],auth[_0x67ba[5]](),controller[_0x67ba[12]]);router[_0x67ba[11]](_0x67ba[14],auth[_0x67ba[5]](),controller[_0x67ba[15]]);router[_0x67ba[16]](_0x67ba[8],auth[_0x67ba[5]](),controller[_0x67ba[12]]);router[_0x67ba[18]](_0x67ba[8],auth[_0x67ba[5]](),controller[_0x67ba[17]]);module[_0x67ba[19]]=router; \ No newline at end of file diff --git a/server/api/zendesk_configuration/zendesk_configuration.controller.js b/server/api/zendesk_configuration/zendesk_configuration.controller.js index 1bcfaae..3ea1035 100644 --- a/server/api/zendesk_configuration/zendesk_configuration.controller.js +++ b/server/api/zendesk_configuration/zendesk_configuration.controller.js @@ -1,162 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ZendeskConfiguration = require('../../models').ZendeskConfiguration; -var ZendeskField = require('../../models').ZendeskField; - -// Get list of zendesk_configurations -exports.index = function(req, res) { - ZendeskConfiguration - .findAll({ - where: req.query - }) - .then(function(zendesk_configurations) { - return res.status(200).send(zendesk_configurations); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single zendesk_configuration -exports.show = function(req, res) { - ZendeskConfiguration - .find({ - where: { - id: req.params.id - }, - include: [{ - model: ZendeskField, - as: 'Subject' - }, { - model: ZendeskField, - as: 'Description' - }, { - model: ZendeskField, - as: 'Field' - }] - }) - .then(function(zendesk_configuration) { - if (!zendesk_configuration) { - return res.sendStatus(404); - } - return res.send(zendesk_configuration); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new zendesk_configuration in the DB. -exports.create = function(req, res) { - ZendeskConfiguration - .create(req.body) - .then(function(zendesk_configuration) { - return res.status(201).send(zendesk_configuration); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing zendesk_configuration in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ZendeskConfiguration - .findById(req.params.id) - .then(function(zendesk_configuration) { - if (!zendesk_configuration) { - return res.sendStatus(404); - } - var updated = _.merge(zendesk_configuration, req.body); - updated.save() - .then(function() { - return res.status(200).send(zendesk_configuration); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a zendesk_configuration from the DB. -exports.destroy = function(req, res) { - ZendeskConfiguration - .findById(req.params.id) - .then(function(zendesk_configuration) { - if (!zendesk_configuration) { - return res.sendStatus(404); - } - zendesk_configuration.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -exports.addConfigurationField = function(req, res, next) { - // console.log(req.params); - ZendeskConfiguration - .findById(req.params.id) - .then(function(configuration) { - if (!configuration) { - return res.sendStatus(500); - } - ZendeskField - .create(req.body) - .then(function(field) { - switch (req.params.type) { - case 'subject': - configuration.addSubject(field) - .then(function() { - return res.status(200).send(field); - }) - .catch(function(err) { - return handleError(res, err); - }); - break; - case 'description': - configuration.addDescription(field) - .then(function() { - return res.status(200).send(field); - }) - .catch(function(err) { - return handleError(res, err); - }); - break; - case 'field': - configuration.addField(field) - .then(function() { - return res.status(200).send(field); - }) - .catch(function(err) { - return handleError(res, err); - }); - break; - } - }) - .catch(function(err) { - return handleError(res, err); - // return next(err); - }); - }) - .catch(function(err) { - // return next(err); - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x601a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x5A\x65\x6E\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5A\x65\x6E\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x53\x75\x62\x6A\x65\x63\x74","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x46\x69\x65\x6C\x64","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x64\x65\x73\x74\x72\x6F\x79","\x61\x64\x64\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x46\x69\x65\x6C\x64","\x61\x64\x64\x53\x75\x62\x6A\x65\x63\x74","\x73\x75\x62\x6A\x65\x63\x74","\x61\x64\x64\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x61\x64\x64\x46\x69\x65\x6C\x64","\x66\x69\x65\x6C\x64","\x74\x79\x70\x65"];_0x601a[0];var _=require(_0x601a[1]);var ZendeskConfiguration=require(_0x601a[3])[_0x601a[2]];var ZendeskField=require(_0x601a[3])[_0x601a[4]];exports[_0x601a[5]]=function(_0x1648x4,_0x1648x5){ZendeskConfiguration[_0x601a[11]]({where:_0x1648x4[_0x601a[10]]})[_0x601a[9]](function(_0x1648x7){return _0x1648x5[_0x601a[8]](200)[_0x601a[7]](_0x1648x7)})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)})};exports[_0x601a[12]]=function(_0x1648x4,_0x1648x5){ZendeskConfiguration[_0x601a[19]]({where:{id:_0x1648x4[_0x601a[15]][_0x601a[14]]},include:[{model:ZendeskField,as:_0x601a[16]},{model:ZendeskField,as:_0x601a[17]},{model:ZendeskField,as:_0x601a[18]}]})[_0x601a[9]](function(_0x1648x8){if(!_0x1648x8){return _0x1648x5[_0x601a[13]](404)};return _0x1648x5[_0x601a[7]](_0x1648x8);})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)})};exports[_0x601a[20]]=function(_0x1648x4,_0x1648x5){ZendeskConfiguration[_0x601a[20]](_0x1648x4[_0x601a[21]])[_0x601a[9]](function(_0x1648x8){return _0x1648x5[_0x601a[8]](201)[_0x601a[7]](_0x1648x8)})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)})};exports[_0x601a[22]]=function(_0x1648x4,_0x1648x5){if(_0x1648x4[_0x601a[21]][_0x601a[14]]){delete _0x1648x4[_0x601a[21]][_0x601a[14]]};ZendeskConfiguration[_0x601a[25]](_0x1648x4[_0x601a[15]][_0x601a[14]])[_0x601a[9]](function(_0x1648x8){if(!_0x1648x8){return _0x1648x5[_0x601a[13]](404)};var _0x1648x9=_[_0x601a[23]](_0x1648x8,_0x1648x4[_0x601a[21]]);_0x1648x9[_0x601a[24]]()[_0x601a[9]](function(){return _0x1648x5[_0x601a[8]](200)[_0x601a[7]](_0x1648x8)})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)});})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)});};exports[_0x601a[26]]=function(_0x1648x4,_0x1648x5){ZendeskConfiguration[_0x601a[25]](_0x1648x4[_0x601a[15]][_0x601a[14]])[_0x601a[9]](function(_0x1648x8){if(!_0x1648x8){return _0x1648x5[_0x601a[13]](404)};_0x1648x8[_0x601a[26]]()[_0x601a[9]](function(){return _0x1648x5[_0x601a[13]](204)})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)});})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)})};exports[_0x601a[27]]=function(_0x1648x4,_0x1648x5,_0x1648xa){ZendeskConfiguration[_0x601a[25]](_0x1648x4[_0x601a[15]][_0x601a[14]])[_0x601a[9]](function(_0x1648xb){if(!_0x1648xb){return _0x1648x5[_0x601a[13]](500)};ZendeskField[_0x601a[20]](_0x1648x4[_0x601a[21]])[_0x601a[9]](function(_0x1648xc){switch(_0x1648x4[_0x601a[15]][_0x601a[34]]){case _0x601a[29]:_0x1648xb[_0x601a[28]](_0x1648xc)[_0x601a[9]](function(){return _0x1648x5[_0x601a[8]](200)[_0x601a[7]](_0x1648xc)})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)});break ;;case _0x601a[31]:_0x1648xb[_0x601a[30]](_0x1648xc)[_0x601a[9]](function(){return _0x1648x5[_0x601a[8]](200)[_0x601a[7]](_0x1648xc)})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)});break ;;case _0x601a[33]:_0x1648xb[_0x601a[32]](_0x1648xc)[_0x601a[9]](function(){return _0x1648x5[_0x601a[8]](200)[_0x601a[7]](_0x1648xc)})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)});break ;;}})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)});})[_0x601a[6]](function(_0x1648x6){return handleError(_0x1648x5,_0x1648x6)})};function handleError(_0x1648x5,_0x1648x6){return _0x1648x5[_0x601a[8]](500)[_0x601a[7]](_0x1648x6)} \ No newline at end of file diff --git a/server/api/zendesk_configuration/zendesk_configuration.socket.js b/server/api/zendesk_configuration/zendesk_configuration.socket.js index d9a56f1..8cc2168 100644 --- a/server/api/zendesk_configuration/zendesk_configuration.socket.js +++ b/server/api/zendesk_configuration/zendesk_configuration.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ZendeskConfiguration = require('../../models').ZendeskConfiguration; - -exports.register = function(socket) { - ZendeskConfiguration.afterCreate(function (doc) { - onSave(socket, doc); - }); - ZendeskConfiguration.afterDestroy(function (doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('zendesk_configuration:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('zendesk_configuration:remove', doc); -} +var _0x5ba0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x5A\x65\x6E\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x3A\x72\x65\x6D\x6F\x76\x65"];_0x5ba0[0];var ZendeskConfiguration=require(_0x5ba0[2])[_0x5ba0[1]];exports[_0x5ba0[3]]=function(_0xadb0x2){ZendeskConfiguration[_0x5ba0[4]](function(_0xadb0x3){onSave(_0xadb0x2,_0xadb0x3)});ZendeskConfiguration[_0x5ba0[5]](function(_0xadb0x3){onRemove(_0xadb0x2,_0xadb0x3)});};function onSave(_0xadb0x2,_0xadb0x3,_0xadb0x5){_0xadb0x2[_0x5ba0[7]](_0x5ba0[6],_0xadb0x3)}function onRemove(_0xadb0x2,_0xadb0x3,_0xadb0x5){_0xadb0x2[_0x5ba0[7]](_0x5ba0[8],_0xadb0x3)} \ No newline at end of file diff --git a/server/api/zendesk_configuration/zendesk_configuration.spec.js b/server/api/zendesk_configuration/zendesk_configuration.spec.js index 3589f5d..1ce70b3 100644 --- a/server/api/zendesk_configuration/zendesk_configuration.spec.js +++ b/server/api/zendesk_configuration/zendesk_configuration.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/zendesk/configurations', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/zendesk/configurations') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); \ No newline at end of file +var _0x298b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x67\x65\x74"];_0x298b[0];var should=require(_0x298b[1]);var app=require(_0x298b[2]);var request=require(_0x298b[3]);describe(_0x298b[4],function(){it(_0x298b[5],function(_0x90e5x4){request(app)[_0x298b[13]](_0x298b[12])[_0x298b[11]](200)[_0x298b[11]](_0x298b[10],/json/)[_0x298b[9]](function(_0x90e5x5,_0x90e5x6){if(_0x90e5x5){return _0x90e5x4(_0x90e5x5)};_0x90e5x6[_0x298b[8]][_0x298b[1]][_0x298b[7]][_0x298b[6]](Array);_0x90e5x4();})})}); \ No newline at end of file diff --git a/server/api/zendesk_field/index.js b/server/api/zendesk_field/index.js index 76f5c48..6de3318 100644 --- a/server/api/zendesk_field/index.js +++ b/server/api/zendesk_field/index.js @@ -1,15 +1 @@ -'use strict'; - -var express = require('express'); -var controller = require('./zendesk_field.controller'); - -var router = express.Router(); - -router.get('/', controller.index); -router.get('/:id', controller.show); -router.post('/', controller.create); -router.put('/:id', controller.update); -router.patch('/:id', controller.update); -router.delete('/:id', controller.destroy); - -module.exports = router; +var _0xae3d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x63\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72","\x2F","\x69\x6E\x64\x65\x78","\x67\x65\x74","\x2F\x3A\x69\x64","\x73\x68\x6F\x77","\x63\x72\x65\x61\x74\x65","\x70\x6F\x73\x74","\x75\x70\x64\x61\x74\x65","\x70\x75\x74","\x70\x61\x74\x63\x68","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x6C\x65\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xae3d[0];var express=require(_0xae3d[1]);var controller=require(_0xae3d[2]);var router=express.Router();router[_0xae3d[5]](_0xae3d[3],controller[_0xae3d[4]]);router[_0xae3d[5]](_0xae3d[6],controller[_0xae3d[7]]);router[_0xae3d[9]](_0xae3d[3],controller[_0xae3d[8]]);router[_0xae3d[11]](_0xae3d[6],controller[_0xae3d[10]]);router[_0xae3d[12]](_0xae3d[6],controller[_0xae3d[10]]);router[_0xae3d[14]](_0xae3d[6],controller[_0xae3d[13]]);module[_0xae3d[15]]=router; \ No newline at end of file diff --git a/server/api/zendesk_field/zendesk_field.controller.js b/server/api/zendesk_field/zendesk_field.controller.js index 48d0c38..91e6ced 100644 --- a/server/api/zendesk_field/zendesk_field.controller.js +++ b/server/api/zendesk_field/zendesk_field.controller.js @@ -1,93 +1 @@ -'use strict'; - -var _ = require('lodash'); -var ZendeskField = require('../../models').ZendeskField; - -// Get list of zendesk_fields -exports.index = function(req, res) { - ZendeskField - .findAll() - .then(function(zendesk_fields) { - return res.status(200).send(zendesk_fields); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Get a single zendesk_field -exports.show = function(req, res) { - ZendeskField - .findById(req.params.id) - .then(function(zendesk_field) { - if (!zendesk_field) { - return res.sendStatus(404); - } - return res.send(zendesk_field); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Creates a new zendesk_field in the DB. -exports.create = function(req, res) { - ZendeskField - .create(req.body) - .then(function(zendesk_field) { - return res.status(201).send(zendesk_field); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Updates an existing zendesk_field in the DB. -exports.update = function(req, res) { - if (req.body.id) { - delete req.body.id; - } - ZendeskField - .findById(req.params.id) - .then(function(zendesk_field) { - if (!zendesk_field) { - return res.sendStatus(404); - } - var updated = _.merge(zendesk_field, req.body); - updated.save() - .then(function() { - return res.status(200).send(zendesk_field); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -// Deletes a zendesk_field from the DB. -exports.destroy = function(req, res) { - ZendeskField - .findById(req.params.id) - .then(function(zendesk_field) { - if (!zendesk_field) { - return res.sendStatus(404); - } - zendesk_field.destroy() - .then(function() { - return res.sendStatus(204); - }) - .catch(function(err) { - return handleError(res, err); - }); - }) - .catch(function(err) { - return handleError(res, err); - }); -}; - -function handleError(res, err) { - return res.status(500).send(err); -} +var _0x8bc4=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x5A\x65\x6E\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79"];_0x8bc4[0];var _=require(_0x8bc4[1]);var ZendeskField=require(_0x8bc4[3])[_0x8bc4[2]];exports[_0x8bc4[4]]=function(_0x38ccx3,_0x38ccx4){ZendeskField[_0x8bc4[9]]()[_0x8bc4[8]](function(_0x38ccx6){return _0x38ccx4[_0x8bc4[7]](200)[_0x8bc4[6]](_0x38ccx6)})[_0x8bc4[5]](function(_0x38ccx5){return handleError(_0x38ccx4,_0x38ccx5)})};exports[_0x8bc4[10]]=function(_0x38ccx3,_0x38ccx4){ZendeskField[_0x8bc4[14]](_0x38ccx3[_0x8bc4[13]][_0x8bc4[12]])[_0x8bc4[8]](function(_0x38ccx7){if(!_0x38ccx7){return _0x38ccx4[_0x8bc4[11]](404)};return _0x38ccx4[_0x8bc4[6]](_0x38ccx7);})[_0x8bc4[5]](function(_0x38ccx5){return handleError(_0x38ccx4,_0x38ccx5)})};exports[_0x8bc4[15]]=function(_0x38ccx3,_0x38ccx4){ZendeskField[_0x8bc4[15]](_0x38ccx3[_0x8bc4[16]])[_0x8bc4[8]](function(_0x38ccx7){return _0x38ccx4[_0x8bc4[7]](201)[_0x8bc4[6]](_0x38ccx7)})[_0x8bc4[5]](function(_0x38ccx5){return handleError(_0x38ccx4,_0x38ccx5)})};exports[_0x8bc4[17]]=function(_0x38ccx3,_0x38ccx4){if(_0x38ccx3[_0x8bc4[16]][_0x8bc4[12]]){delete _0x38ccx3[_0x8bc4[16]][_0x8bc4[12]]};ZendeskField[_0x8bc4[14]](_0x38ccx3[_0x8bc4[13]][_0x8bc4[12]])[_0x8bc4[8]](function(_0x38ccx7){if(!_0x38ccx7){return _0x38ccx4[_0x8bc4[11]](404)};var _0x38ccx8=_[_0x8bc4[18]](_0x38ccx7,_0x38ccx3[_0x8bc4[16]]);_0x38ccx8[_0x8bc4[19]]()[_0x8bc4[8]](function(){return _0x38ccx4[_0x8bc4[7]](200)[_0x8bc4[6]](_0x38ccx7)})[_0x8bc4[5]](function(_0x38ccx5){return handleError(_0x38ccx4,_0x38ccx5)});})[_0x8bc4[5]](function(_0x38ccx5){return handleError(_0x38ccx4,_0x38ccx5)});};exports[_0x8bc4[20]]=function(_0x38ccx3,_0x38ccx4){ZendeskField[_0x8bc4[14]](_0x38ccx3[_0x8bc4[13]][_0x8bc4[12]])[_0x8bc4[8]](function(_0x38ccx7){if(!_0x38ccx7){return _0x38ccx4[_0x8bc4[11]](404)};_0x38ccx7[_0x8bc4[20]]()[_0x8bc4[8]](function(){return _0x38ccx4[_0x8bc4[11]](204)})[_0x8bc4[5]](function(_0x38ccx5){return handleError(_0x38ccx4,_0x38ccx5)});})[_0x8bc4[5]](function(_0x38ccx5){return handleError(_0x38ccx4,_0x38ccx5)})};function handleError(_0x38ccx4,_0x38ccx5){return _0x38ccx4[_0x8bc4[7]](500)[_0x8bc4[6]](_0x38ccx5)} \ No newline at end of file diff --git a/server/api/zendesk_field/zendesk_field.socket.js b/server/api/zendesk_field/zendesk_field.socket.js index 8a5419b..1d52384 100644 --- a/server/api/zendesk_field/zendesk_field.socket.js +++ b/server/api/zendesk_field/zendesk_field.socket.js @@ -1,24 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var ZendeskField = require('../../models').ZendeskField; - -exports.register = function(socket) { - ZendeskField.afterCreate(function(doc) { - onSave(socket, doc); - }); - ZendeskField.afterDestroy(function(doc) { - onRemove(socket, doc); - }); -} - -function onSave(socket, doc, cb) { - socket.emit('zendesk_field:save', doc); -} - -function onRemove(socket, doc, cb) { - socket.emit('zendesk_field:remove', doc); -} +var _0x2e41=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x5A\x65\x6E\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x3A\x72\x65\x6D\x6F\x76\x65"];_0x2e41[0];var ZendeskField=require(_0x2e41[2])[_0x2e41[1]];exports[_0x2e41[3]]=function(_0xb003x2){ZendeskField[_0x2e41[4]](function(_0xb003x3){onSave(_0xb003x2,_0xb003x3)});ZendeskField[_0x2e41[5]](function(_0xb003x3){onRemove(_0xb003x2,_0xb003x3)});};function onSave(_0xb003x2,_0xb003x3,_0xb003x5){_0xb003x2[_0x2e41[7]](_0x2e41[6],_0xb003x3)}function onRemove(_0xb003x2,_0xb003x3,_0xb003x5){_0xb003x2[_0x2e41[7]](_0x2e41[8],_0xb003x3)} \ No newline at end of file diff --git a/server/api/zendesk_field/zendesk_field.spec.js b/server/api/zendesk_field/zendesk_field.spec.js index 1527fe8..c275632 100644 --- a/server/api/zendesk_field/zendesk_field.spec.js +++ b/server/api/zendesk_field/zendesk_field.spec.js @@ -1,20 +1 @@ -'use strict'; - -var should = require('should'); -var app = require('../../app'); -var request = require('supertest'); - -describe('GET /api/zendesk/fields', function() { - - it('should respond with JSON array', function(done) { - request(app) - .get('/api/zendesk/fields') - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - if (err) return done(err); - res.body.should.be.instanceof(Array); - done(); - }); - }); -}); +var _0x3e91=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x73\x68\x6F\x75\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x70","\x73\x75\x70\x65\x72\x74\x65\x73\x74","\x47\x45\x54\x20\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x73\x68\x6F\x75\x6C\x64\x20\x72\x65\x73\x70\x6F\x6E\x64\x20\x77\x69\x74\x68\x20\x4A\x53\x4F\x4E\x20\x61\x72\x72\x61\x79","\x69\x6E\x73\x74\x61\x6E\x63\x65\x6F\x66","\x62\x65","\x62\x6F\x64\x79","\x65\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65","\x65\x78\x70\x65\x63\x74","\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x67\x65\x74"];_0x3e91[0];var should=require(_0x3e91[1]);var app=require(_0x3e91[2]);var request=require(_0x3e91[3]);describe(_0x3e91[4],function(){it(_0x3e91[5],function(_0xf4dbx4){request(app)[_0x3e91[13]](_0x3e91[12])[_0x3e91[11]](200)[_0x3e91[11]](_0x3e91[10],/json/)[_0x3e91[9]](function(_0xf4dbx5,_0xf4dbx6){if(_0xf4dbx5){return _0xf4dbx4(_0xf4dbx5)};_0xf4dbx6[_0x3e91[8]][_0x3e91[1]][_0x3e91[7]][_0x3e91[6]](Array);_0xf4dbx4();})})}); \ No newline at end of file diff --git a/server/app.js b/server/app.js index 57d32fb..5fdd9e7 100644 --- a/server/app.js +++ b/server/app.js @@ -1,12 +1 @@ -"use strict";function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("agent:save",b)}function onRemove(a,b,c){a.emit("agent:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("ami:save",b)}function onRemove(a,b,c){a.emit("ami:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("automation:save",b)}function onRemove(a,b,c){a.emit("automation:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("business_action:save",b)}function onRemove(a,b,c){a.emit("business_action:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("business_condition:save",b)}function onRemove(a,b,c){a.emit("business_condition:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("chat_application:save",b)}function onRemove(a,b,c){a.emit("chat_application:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("enquiry:save",b)}function onRemove(a,b,c){a.emit("enquiry:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){return b.getChatRoom().then(function(a){return[a.getUsers({attributes:["id","name","fullname","email","role","internal"],raw:!0}),a.getChatVisitor({attributes:["id","fullname","email"],raw:!0})]}).spread(function(c,d){var e=_.find(c,{id:b.UserId});c.forEach(function(c){a.userId==c.id&&(e||d)&&a.emit("chat_message:save",_.merge(b.dataValues,{User:e,ChatVisitor:d}))})})["catch"](function(a){console.error(a)})}function onRemove(a,b,c){a.emit("chat_message:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("chat_queue:save",b)}function onRemove(a,b,c){a.emit("chat_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("chat_room:save",b)}function onRemove(a,b,c){a.emit("chat_room:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("chat_visitor:save",b)}function onRemove(a,b,c){a.emit("chat_visitor:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("chat_website:save",b)}function onRemove(a,b,c){a.emit("chat_website:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("company:save",b)}function onRemove(a,b,c){a.emit("company:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("contact:save",b)}function onRemove(a,b,c){a.emit("contact:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("contact_manager:save",b)}function onRemove(a,b,c){a.emit("contact_manager:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("custom_field:save",b)}function onRemove(a,b,c){a.emit("custom_field:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("custom_report:save",b)}function onRemove(a,b,c){a.emit("custom_report:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("dashboard:save",b)}function onRemove(a,b,c){a.emit("dashboard:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("default_report:save",b)}function onRemove(a,b,c){a.emit("default_report:remove",b)}function stripTrailingSlash(a){return"/"===a.substr(-1)?a.substr(0,a.length-1):a}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("desk_account:save",b)}function onRemove(a,b,c){a.emit("desk_account:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("desk_configuration:save",b)}function onRemove(a,b,c){a.emit("desk_configuration:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("desk_field:save",b)}function onRemove(a,b,c){a.emit("desk_field:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit(("event:"+b.channel+":save").toLowerCase(),b)}function onRemove(a,b,c){a.emit("event:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("fax_account:save",b)}function onRemove(a,b,c){a.emit("fax_account:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("fax_application:save",b)}function onRemove(a,b,c){a.emit("fax_application:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("fax_business_automation:save",b)}function onRemove(a,b,c){a.emit("fax_business_automation:remove",b)}function onSave(a,b,c){if("NOT SENT"===b.status&&!b.actionid){var d=JSON.parse(b.body);console.log("faxBody",d),Trunk.findById(d.trunk.id).then(function(c){var e={Action:"originate",CallerID:d.from,Channel:util.format("%s/%s@%s",d.technology,d.to,c.name),Context:"outbound-fax",Exten:"s",Priority:1,Async:"true",Variable:{MAXRATE:d.maxrate,MINRATE:d.minrate,ECM:d.ecm?"yes":"no",LOCALID:d.fax_localid,FAXFILE:d.fax_file,FAXHEADER:d.fax_header,FAXUUID:d.uuid}};a.action(e,function(a,c){a?b.updateAttributes({status:"FAILED"}):c.response&&c.actionid&&b.updateAttributes({actionid:c.actionid})})})["catch"](function(a){console.error(a)})}}function convertPdfAndSendFax(a,b,c,d){var e=path.join(config.root,"server","files","fax","outbound","original",c+".pdf"),f=path.join(config.root,"server","files","fax","outbound","converted",c+".tif"),g="gs -q -dNOPAUSE -dBATCH -sDEVICE=tiffg4 -sPAPERSIZE=letter -sOutputFile="+f+" "+e,h=uuidLib.v4();FaxAccount.findById(d.accountId).then(function(a){if(a){var i={technology:"SIP",to:d.toNum,from:a.phone,fax_file:f,fax_header:a.faxheader,fax_localid:a.localid,maxrate:a.maxrate,minrate:a.minrate,ecm:a.ecm,uuid:h,trunk:{id:a.TrunkId}};fs.exists(e,function(a){a?exec(g,function(a){a?(console.error(a),handleError(b,a)):(console.log("Fax: PDF converted to TIFF"),fs.chmod(f,511,function(a){d.roomId?FaxRoom.findOrCreate({where:{id:d.roomId},defaults:{}}).spread(function(a,d){FaxMessage.create({status:"NOT SENT",read:!0,filenamePDF:c+".pdf",filename:c+".tif",body:JSON.stringify(i),uuid:h,FaxRoomId:a.id}).then(function(a){return Contact.findOrCreate({where:{phone:i.from},defaults:{phone:i.from,fullname:i.from}}).spread(function(b,c){a.setFrom(b)}),Contact.findOrCreate({where:{phone:i.to},defaults:{phone:i.to,fullname:i.to}}).spread(function(b,c){a.setTo(b)}),b.status(200).send(a)})["catch"](function(a){handleError(b,a)})}):FaxRoom.create({status:"OPEN",from:d.toNum,FaxAccountId:d.accountId,UserId:d.userId}).then(function(a){FaxMessage.create({status:"NOT SENT",read:!0,filenamePDF:c+".pdf",filename:c+".tif",body:JSON.stringify(i),uuid:h,FaxRoomId:a.id}).then(function(a){return Contact.findOrCreate({where:{phone:i.from},defaults:{phone:i.from,fullname:i.from}}).spread(function(b,c){a.setFrom(b)}),Contact.findOrCreate({where:{phone:i.to},defaults:{phone:i.to,fullname:i.to}}).spread(function(b,c){a.setTo(b)}),b.status(200).send(a)})["catch"](function(a){handleError(b,a)})})["catch"](function(a){handleError(b,a)})}))}):handleError(b,new Error("File not exists"))})}})}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("fax_message:save",b)}function onUpdate(a,b,c){a.emit("fax_message:update",b)}function onRemove(a,b,c){a.emit("fax_message:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("fax_queue:save",b)}function onRemove(a,b,c){a.emit("fax_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){"NEW"===b.status&&FaxAccount.findById(b.FaxAccountId).then(function(c){c.getFaxApplications({include:[{model:User,attributes:["id"]},{model:FaxQueue,attributes:["id","strategy","timeout"],include:{model:User,attributes:["id"]}}],order:[["priority"]]}).then(function(c){var d={roomId:b.id,accountId:b.FaxAccountId,channel:"FAX",msg:{from:b.from},applications:c};a.create("fax",d).save()})["catch"](function(a){console.error(a)})})["catch"](function(a){console.error(a)})}function onSave(a,b,c){a.emit("fax_room:save",b)}function onRemove(a,b,c){a.emit("fax_room:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("freshdesk_account:save",b)}function onRemove(a,b,c){a.emit("freshdesk_account:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("freshdesk_configuration:save",b)}function onRemove(a,b,c){a.emit("freshdesk_configuration:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("freshdesk_field:save",b)}function onRemove(a,b,c){a.emit("freshdesk_field:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("integration:save",b)}function onRemove(a,b,c){a.emit("integration:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("interval:save",b)}function onRemove(a,b,c){a.emit("interval:remove",b)}function onUpdate(a,b,c){a.emit("interval:update",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_account:save",b)}function onRemove(a,b,c){a.emit("mail_account:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_application:save",b)}function onRemove(a,b,c){a.emit("mail_application:remove",b)}function onSave(a,b,c){a.emit("mail_attachment:save",b)}function onRemove(a,b,c){a.emit("mail_attachment:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_business_automation:save",b)}function onRemove(a,b,c){a.emit("mail_business_automation:remove",b)}function handleError(a,b,c){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_message:save",b)}function onRemove(a,b,c){a.emit("mail_message:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_queue:save",b)}function onRemove(a,b,c){a.emit("mail_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_room:save",b)}function onRemove(a,b,c){a.emit("mail_room:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_server_in:save",b)}function onRemove(a,b,c){a.emit("mail_server_in:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_server_out:save",b)}function onRemove(a,b,c){a.emit("mail_server_out:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("mail_template:save",b)}function onRemove(a,b,c){a.emit("mail_template:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("metric:save",b)}function onRemove(a,b,c){a.emit("metric:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("module:save",b)}function onRemove(a,b,c){a.emit("module:remove",b)}function handleError(a,b){return a.status(500).send(b)}function decrypt(a,b,c){var d=crypto.createDecipher(a,b),e=d.update(c,"hex","utf8");return e+=d["final"]("utf8")}function onSave(a,b,c){a.emit("setting:save",b)}function onRemove(a,b,c){a.emit("setting:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.userId==b.UserId&&a.emit("motionbar:save",b)}function onRemove(a,b,c){a.emit("motionbar:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){(a.name===b.membername||"admin"===a.role)&&a.emit("report_agent:save",b)}function onRemove(a,b,c){a.emit("report_agent:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){(a.name===b.membername||"admin"===a.role)&&a.emit("report_chat:save",b)}function onUpdate(a,b,c){(a.name===b.membername||"admin"===a.role)&&(b.changed("agentid")?a.emit("report_chat:assignment",b):a.emit("report_chat:update",b))}function onRemove(a,b,c){a.emit("report_chat:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("report_chat_session:save",b)}function onRemove(a,b,c){a.emit("report_chat_session:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.name===b.membername&&a.emit(util.format("report_integration:%s",b.integration),b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){(a.name===b.membername||"admin"===a.role)&&a.emit("report_mail:save",b)}function onUpdate(a,b,c){(a.name===b.membername||"admin"===a.role)&&a.emit("report_mail:update",b)}function onRemove(a,b,c){a.emit("report_mail:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("report_mail_session:save",b)}function onRemove(a,b,c){a.emit("report_mail_session:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){"admin"===a.role&&a.emit("report_queue:save",b)}function onRemove(a,b,c){a.emit("report_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("report_tree:save",b)}function onRemove(a,b,c){a.emit("report_tree:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("salesforce_account:save",b)}function onRemove(a,b,c){a.emit("salesforce_account:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("salesforce_configuration:save",b)}function onRemove(a,b,c){a.emit("salesforce_configuration:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("salesforce_field:save",b)}function onRemove(a,b,c){a.emit("salesforce_field:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("setting:save",b)}function onRemove(a,b,c){a.emit("setting:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("square_odbc:save",b)}function onRemove(a,b,c){a.emit("square_odbc:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("square_project:save",b)}function onRemove(a,b,c){a.emit("square_project:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function stripTrailingSlash(a){return"/"===a.substr(-1)?a.substr(0,a.length-1):a}function onSave(a,b,c){a.emit("sugarcrm_account:save",b)}function onRemove(a,b,c){a.emit("sugarcrm_account:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("sugarcrm_configuration:save",b)}function onRemove(a,b,c){a.emit("sugarcrm_configuration:remove",b)}function handleError(a,b){return b=b||500,function(c){a.status(b).send(c)}}function responseWithResult(a,b){return b=b||200,function(c){c&&a.status(b).json(c)}}function handleEntityNotFound(a){return function(b){return b?b:(a.status(404).end(),null)}}function saveUpdates(a){return function(b){return b.updateAttributes(a).then(function(a){return a})}}function removeEntity(a){return function(b){return b?b.destroy().then(function(){a.status(204).end()}):void 0}}function onSave(a,b,c){a.emit("sugarcrm_field:save",b)}function onRemove(a,b,c){a.emit("sugarcrm_field:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("tag:save",b)}function onRemove(a,b,c){a.emit("tag:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("team:save",b)}function onRemove(a,b,c){a.emit("team:remove",b)}function onSave(a,b,c){a.emit("thing:save",b)}function onRemove(a,b,c){a.emit("thing:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("trigger:save",b)}function onRemove(a,b,c){a.emit("trigger:remove",b)}function trunksRewrite(a,b,c){var d="";if(!c){var e=_.clone(a.dataValues);delete e.id,delete e.createdAt,delete e.updatedAt,d+=util.format("[%s]\n",e.name),e.otherFields&&(d+=util.format("%s\n",e.otherFields),delete e.otherFields);for(var f in e)e[f]&&(d+=util.format("%s=%s\n",f,e[f]))}Trunk.findAll({where:{id:{$ne:a.id}}}).then(function(a){var c=_.pluck(a,"dataValues");c.forEach(function(a){delete a.id,delete a.createdAt,delete a.updatedAt,d+=util.format("[%s]\n",a.name),a.otherFields&&(d+=util.format("%s\n",a.otherFields),delete a.otherFields);for(var b in a)a[b]&&(d+=util.format("%s=%s\n",b,a[b]))}),fs.writeFile(path.join(config.root,"server/files/asterisk/sip_xcally_trunks.conf"),d,{flags:"w",mode:parseInt("0777",8)},function(a){if(a)throw a;console.log("Trunks file saved!"),b.action({Action:"Reload",Module:"chan_sip"},function(a,b){a?console.error(a):console.log(b)})})})["catch"](function(a){console.log(a)})}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("trunk:save",b)}function onRemove(a,b,c){a.emit("trunk:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("update:save",b)}function onRemove(a,b,c){a.emit("update:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("upload:save",b)}function onRemove(a,b,c){a.emit("upload:remove",b)}function createCallerID(a){a.name&&a.internal&&(a.callerid=util.format('"%s" <%s>',a.name,a.internal),a.save())}function updateExtension(a){a.changed("name")&&a.getUserExtensions().then(function(b){b.forEach(function(b){b.exten=b.exten===a._previousDataValues.internal?a.internal:a.name,b.appdata="SIP/"+a.name,b.save()})})["catch"](function(a){console.log(a)})}function createExtension(a){if(a.internal){var b=[{context:"from-sip",exten:a.internal,priority:1,app:"Dial",appdata:"SIP/"+a.name,UserId:a.id,type:"internal"},{context:"from-sip",exten:a.name,priority:1,app:"Dial",appdata:"SIP/"+a.name,UserId:a.id,type:"internal"}];return VoiceExtension.bulkCreate(b)["catch"](function(a){console.log(a)})}}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){"admin"===b.role&&a.emit("user:save",b)}function onRemove(a,b,c){"admin"===b.role&&a.emit("user:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("user_has_chat_queue:save",b)}function onRemove(a,b,c){a.emit("user_has_chat_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b){var c;return ChatRoom.findById(b.ChatRoomId,{include:[{model:ChatVisitor,attributes:["id","email","fullname"]},{model:User,attributes:["id","email","name","fullname"]}]}).then(function(b){c=b,c.dataValues.ChatMessages=[],console.log("_chatRoom",c);var d=_.pluck(c.Users,"id");d.forEach(function(b){a.userId==b&&a.emit("user_has_chat_room:save",c.dataValues)})})["catch"](function(a){console.error(a)})}function onRemove(a,b){a.emit("user_has_chat_room:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("user_has_fax_queue:save",b)}function onRemove(a,b,c){a.emit("user_has_fax_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("user_has_mail_queue:save",b)}function onRemove(a,b,c){a.emit("user_has_mail_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("user_has_team:save",b)}function onRemove(a,b,c){a.emit("user_has_team:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("user_has_voice_queue:save",{logged:b.logged,loggedAt:b.loggedAt,queue:b.queue,membername:b.membername,"interface":b["interface"],callstaken:b.callstaken,lastcall:b.lastcall,status:b.status,statusdesc:b.statusdesc,statusAt:b.statusAt,paused:b.paused,pausedAt:b.pausedAt,reason:b.reason})}function onRemove(a,b,c){a.emit("user_has_voice_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("variable:save",b)}function onRemove(a,b,c){a.emit("variable:remove",b)}function rewriteContexts(a,b,c){var d="";c||(d=util.format("[%s]\nswitch => Realtime\n",a.name)),VoiceContext.findAll({where:{id:{$ne:a.id}}}).then(function(a){a.forEach(function(a){d+=util.format("[%s]\nswitch => Realtime\n",a.name)}),fs.writeFile(path.join(config.root,"server/files/asterisk/sip_xcally_contexts.conf"),d,{flags:"w",mode:parseInt("0777",8)},function(a){if(a)throw a;console.log("Contexts file saved!"),b.action({Action:"Reload"},function(a,b){a?console.error(a):console.log(b)})})})["catch"](function(a){console.log(a)})}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("voice_context:save",b)}function onRemove(a,b,c){a.emit("voice_context:remove",b)}function appCreate(a,b,c,d,e){var f=d.length;switch(b.customApp&&(b.app="custom"),b.app){case"Dial":b.callerID||_.remove(a,{app:"Set"}),a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"Dial":"outbound"===b.type?(a.IntervalId=b.IntervalId,a.interval=b.interval,a.trunk=b.trunk,a.TrunkId=b.TrunkId,a.cutdigits=b.cutdigits||0,a.callerID=b.callerID||null):(a.IntervalId=b.IntervalId,a.interval=b.interval,a["interface"]=b["interface"],a.app_options=b.app_options||"",a.timeout=b.timeout||"",a.url=b.url||"",a.appdata=util.format(a.appdata,b["interface"],a.timeout,a.app_options?a.app_options.replace(",",""):"",a.url));break;case"Set":a.appdata=util.format(a.appdata,b.callerID);break;case"NoOp":"outbound"===b.type&&(a.appdata="Outbound Dial Application End")}});break;case"Queue":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"Queue":a.IntervalId=b.IntervalId,a.app_options=b.app_options||"",a.audiofile=b.audiofile||"",a.queue=b.queue,a.interval=b.interval,a["interface"]=b["interface"],a.app_options=b.app_options,a.timeout=b.timeout||"",a.url=b.url||"",a.appdata=util.format(a.appdata,a.queue,a.app_options?a.app_options.replace(",",""):"",a.url,a.audiofile,a.timeout)}});break;case"Playback":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"Playback":a.IntervalId=b.IntervalId,a.interval=b.interval,a.audiofile=b.audiofile||"",a.app_options=b.app_options||"",a.appdata=util.format(a.appdata,a.audiofile,a.app_options?a.app_options.replace(",",""):"")}});break;case"AGI":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"AGI":a.IntervalId=b.IntervalId,a.interval=b.interval,a.project=b.project,a.appdata=util.format(a.appdata,a.project)}});break;case"Goto":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"Goto":a.IntervalId=b.IntervalId,a.interval=b.interval,a.alt_priority=b.alt_priority,a.alt_extension=b.alt_extension,a.alt_context=b.alt_context,a.appdata=util.format(a.appdata,a.alt_context,a.alt_extension,a.alt_priority)}});break;case"Hangup":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"Hangup":a.IntervalId=b.IntervalId,a.interval=b.interval,a.causecode=b.causecode,a.appdata=util.format(a.appdata,a.causecode)}});break;case"Set":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"Set":a.IntervalId=b.IntervalId,a.interval=b.interval,a.variable=b.variable,a.value=b.value,a.appdata=util.format(a.appdata,a.variable,a.value)}});break;case"custom":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"custom":a.IntervalId=b.IntervalId,a.interval=b.interval,a.app=a.customApp=b.customApp,a.appdata=util.format(a.appdata,b.appdata)}});break;case"Voicemail":a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"Voicemail":a.IntervalId=b.IntervalId,a.interval=b.interval,a.mailbox=b.mailbox,a.appdata=util.format(a.appdata,a.mailbox)}});break;default:a.forEach(function(a,d){switch(a.exten=b.exten,a.type=b.type,a.context=b.context,a.VoiceExtensionId=b.VoiceExtensionId,a.priority=e?e++:b.priority++,a.appGroup=c,a.app){case"GotoIfTime":a.appdata=util.format(a.appdata,b.IntervalId?"*,*,*,*":b.interval,a.context,a.priority+1,a.context,a.priority+2);break;case"GotoIfTimeFromArray":a.app="GotoIfTime",a.appdata=util.format(a.appdata,a.context,a.priority+f-d,a.context,f>d+1?a.priority+1:a.priority+2);break;case"custom":a.IntervalId=b.IntervalId,a.interval=b.interval,a.app=a.customApp=b.customApp,a.appdata=util.format(a.appdata,b.appdata)}})}return e?e:void 0}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("voice_extension:save",b); -}function onRemove(a,b,c){a.emit("voice_extension:remove",b)}function onUpdate(a,b,c){a.emit("voice_extension:update",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("voice_musiconhold:save",b)}function onRemove(a,b,c){a.emit("voice_musiconhold:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("voice_queue:save",b)}function onRemove(a,b,c){a.emit("voice_queue:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("voice_voicemail:save",b)}function onRemove(a,b,c){a.emit("voice_voicemail:remove",b)}function onMessageSave(a,b,c){a.emit("voice_voicemail_messages:save",b)}function onMessageRemove(a,b,c){a.emit("voice_voicemail_messages:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("xchatty:save",b)}function onRemove(a,b,c){a.emit("xchatty:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("zendesk_account:save",b)}function onRemove(a,b,c){a.emit("zendesk_account:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("zendesk_configuration:save",b)}function onRemove(a,b,c){a.emit("zendesk_configuration:remove",b)}function handleError(a,b){return a.status(500).send(b)}function onSave(a,b,c){a.emit("zendesk_field:save",b)}function onRemove(a,b,c){a.emit("zendesk_field:remove",b)}process.env.NODE_ENV=process.env.NODE_ENV||"development",process.env.NODE_TLS_REJECT_UNAUTHORIZED=0,process.on("uncaughtException",function(a){"object"==typeof a?(a.message&&console.log("\nMessage: "+a.message),a.stack&&(console.log("\nStacktrace:"),console.log("===================="),console.log(a.stack))):console.log("dumpError :: argument is not an object")});var os=require("os"),http=require("http"),util=require("util"),crypto=require("crypto"),express=require("express"),models=require("./models"),config=require("./config/environment"),Setting=models.Setting,app=express(),server=require("http").createServer(app),io=require("socket.io")(server,{serveClient:"production"===config.env?!1:!0,path:"/socket.io-client"}),ami=require("asterisk-manager")(config.asterisk.port,config.asterisk.host,config.asterisk.username,config.asterisk.password,!0);ami.keepConnected();var kue=require("kue");kue.app.listen(3001);var cronjob=require("cron").CronJob;require("./config/express")(app),models.sequelize.sync().then(function(){require("./routes")(app),config.seedDB&&require("./config/seed"),require("./config/socketio")(io),require("./config/kue.mail")(kue),require("./config/kue.chat")(kue),require("./config/kue.fax")(io,kue),require("./config/automations/mail")(),require("./config/automations/fax")(),require("./config/triggers")(),require("./config/imap").init(),require("./config/smtp").init(),require("./config/ami")(ami),require("./config/agi")(),require("./config/autodialer")(ami),server.listen(config.port,config.ip,function(){console.log("Express server listening on %d, in %s mode",config.port,app.get("env"))})})["catch"](function(a){console.error(a)}),models.sequelize_history.sync().then(function(){require("./config/history")(cronjob)})["catch"](function(a){console.error(a)}),exports=module.exports=app;var _=require("lodash"),util=require("util"),Agent=require("../../models").User,Team=require("../../models").Team;exports.index=function(a,b,c){var d=["fullname","name","email"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{role:"agent"},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),Agent.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){Agent.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.internalValidation=function(a,b){Agent.findAll({where:{internal:a.body.internal}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Agent.create(a.body).then(function(a){Team.findOne({where:{defaultEntry:!0}}).then(function(c){c.addUser(a.id).then(function(){return b.status(201).send(a)})["catch"](function(a){return console.log(a),handleError(b,a)})})["catch"](function(a){return console.log(a),handleError(b,a)})})["catch"](function(a){return console.log(a),handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Agent.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Agent.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Agent.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.changePassword=function(a,b,c){console.log(a.body);var d=a.user.id,e=String(a.body.oldPassword),f=String(a.body.newPassword);Agent.findById(d).then(function(a){a.authenticate(e)?(a.password=f,a.save().then(function(){b.status(200).send(a)})["catch"](function(a){return c(a)})):b.sendStatus(403)})},exports.resetPassword=function(a,b,c){var d=String(a.body.newPassword);Agent.findById(a.params.id).then(function(a){a.password=d,a.save().then(function(){b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})})},exports.agentValidation=function(a,b){var c={};c[a.params.field]=a.body.value,Agent.findAndCountAll({where:c}).then(function(c){return c.count?b.status(200).send({isValid:!1,value:a.body.value}):b.status(200).send({isValid:!0,value:a.body.value})})["catch"](function(a){return handleError(b,a)})};var agent=require("../../models").User;exports.register=function(a){agent.afterCreate(function(b){"agent"===b.role&&onSave(a,b)}),agent.afterUpdate(function(b){"agent"===b.role&&onSave(a,b)}),agent.afterDestroy(function(b){"agent"===b.role&&onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/agents",function(){it("should respond with JSON array",function(a){request(app).get("/api/agents").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./agent.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/validate/:field",auth.isAuthenticated(),controller.agentValidation),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.internalValidation),router.put("/password",auth.isAuthenticated(),controller.changePassword),router.put("/password/:id/reset",auth.isAuthenticated(),auth.hasRole("admin"),controller.resetPassword),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var Ami=require("../../models").Ami,async=require("async"),_=require("lodash"),ami=null;exports.register=function(a){this.ami=a},exports.action=function(a,b){this.ami&&this.ami.isConnected()?this.ami.action(a,function(c,d){c&&b(c);var e=_.merge(d,a);Ami.create(e).then(function(a){b(null,a)})["catch"](function(a){return b(a)})}):b(new Error("Asterisk Manager disconnected.."))};var _=require("lodash"),Ami=require("../../models").Ami;exports.index=function(a,b){Ami.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Ami.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){a.body.data=JSON.stringify(a.body),a.body.UserId=a.user.id,require("./ami.ami").action(a.body,function(a,c){return a?void handleError(b,a):b.status(201).send(c)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Ami.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Ami.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var Ami=require("../../models").Ami;exports.register=function(a){Ami.afterCreate(function(b){onSave(a,b)}),Ami.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/ami",function(){it("should respond with JSON array",function(a){request(app).get("/api/ami").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./ami.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.post("/",auth.isAuthenticated(),controller.create),module.exports=router;var _=require("lodash"),util=require("util"),Automation=require("../../models").Automation;exports.index=function(a,b,c){var d=["fullname","name","email"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),Automation.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){Automation.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){Automation.create(a.body).then(function(){return b.sendStatus(201)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b,c){a.body.id&&delete a.body.id,Automation.findById(a.params.id).then(function(d){if(!d)return b.sendStatus(404);var e=_.merge(d,a.body);e.save().then(function(){return b.status(200).send(d)})["catch"](function(a){return c(a)})})["catch"](function(a){return c(a)})},exports.destroy=function(a,b){Automation.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Automation.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Automation=require("../../models").Automation;exports.register=function(a){Automation.afterCreate(function(b){onSave(a,b)}),Automation.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/automations",function(){it("should respond with JSON array",function(a){request(app).get("/api/automations").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./automation.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),module.exports=router;var _=require("lodash"),BusinessAction=require("../../models").BusinessAction;exports.index=function(a,b){BusinessAction.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){BusinessAction.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){BusinessAction.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,BusinessAction.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){BusinessAction.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var BusinessAction=require("../../models").BusinessAction;exports.register=function(a){BusinessAction.afterCreate(function(b){onSave(a,b)}),BusinessAction.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/business/actions",function(){it("should respond with JSON array",function(a){request(app).get("/api/business/actions").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./business_action.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),BusinessCondition=require("../../models").BusinessCondition;exports.index=function(a,b){BusinessCondition.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){BusinessCondition.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){BusinessCondition.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,BusinessCondition.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){BusinessCondition.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var BusinessCondition=require("../../models").BusinessCondition;exports.register=function(a){BusinessCondition.afterCreate(function(b){onSave(a,b)}),BusinessCondition.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/business/conditions",function(){it("should respond with JSON array",function(a){request(app).get("/api/business/conditions").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./business_condition.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ChatApplication=require("../../models").ChatApplication;exports.index=function(a,b){ChatApplication.findAll({where:a.query,order:"priority",include:[{all:!0}]}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ChatApplication.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){ChatApplication.max("priority",{where:{ChatWebsiteId:a.body.ChatWebsiteId}}).then(function(d){a.body.priority=d?++d:1,ChatApplication.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return c(a)})})["catch"](function(a){c(a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ChatApplication.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ChatApplication.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ChatApplication=require("../../models").ChatApplication;exports.register=function(a){ChatApplication.afterCreate(function(b){onSave(a,b)}),ChatApplication.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/chat/applications",function(){it("should respond with JSON array",function(a){request(app).get("/api/chat/applications").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./chat_application.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ChatEnquiry=require("../../models").ChatEnquiry,ChatVisitor=require("../../models").ChatVisitor;exports.index=function(a,b){ChatEnquiry.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ChatEnquiry.findOne({where:{id:a.params.id},include:[ChatVisitor]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ChatEnquiry.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ChatEnquiry.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ChatEnquiry.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var enquiry=require("../../models").ChatEnquiry;exports.register=function(a){enquiry.afterCreate(function(b){onSave(a,b)}),enquiry.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./enquiry.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),md5=require("md5"),User=require("../../models").User,ChatRoom=require("../../models").ChatRoom,ChatMessage=require("../../models").ChatMessage,ChatVisitor=require("../../models").ChatVisitor;exports.index=function(a,b){ChatMessage.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ChatMessage.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){ChatMessage.create(_.merge(a.body,{UserId:a.user.id})).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){return a.body.id&&delete a.body.id,ChatMessage.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);return d.save()}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ChatMessage.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var chat_message=require("../../models").ChatMessage,_=require("lodash");exports.register=function(a){chat_message.afterCreate(function(b){onSave(a,b)}),chat_message.afterUpdate(function(b){onSave(a,b)}),chat_message.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/chat/messages",function(){it("should respond with JSON array",function(a){request(app).get("/api/chat/messages").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./chat_message.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),ChatQueue=require("../../models").ChatQueue,UserHasChatQueue=require("../../models").UserHasChatQueue;exports.index=function(a,b){var c=["description","name","timeout","strategy"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d,include:[{all:!0}]};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),ChatQueue.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return handleError(b,a)})},exports.me=function(a,b,c){UserHasChatQueue.findAll({where:{UserId:a.user.id}}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ChatQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ChatQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ChatQueue.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.addAgents=function(a,b,c){return ChatQueue.findById(a.params.id).then(function(b){if(b)return b.addUsers(a.body.agents,{individualHooks:!0});throw new Error("No mail queue found")}).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)})},exports.removeAgents=function(a,b,c){return ChatQueue.findById(a.params.id).then(function(b){if(b)return b.removeUsers(a.body.agents,{individualHooks:!0});throw new Error("no mail queue found")}).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)})},exports.destroy=function(a,b){ChatQueue.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){ChatQueue.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var chatQueue=require("../../models").ChatQueue;exports.register=function(a){chatQueue.afterCreate(function(b){onSave(a,b)}),chatQueue.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/chat/queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/chat/queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./chat_queue.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",controller.index),router.get("/me",auth.isAuthenticated(),controller.me),router.get("/:id",controller.show),router.post("/",controller.create),router.post("/:id/agents",controller.addAgents),router.put("/:id",controller.update),router.put("/:id/agents",controller.removeAgents),router.patch("/:id",controller.update),router["delete"]("/",controller.bulkDestroy),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),md5=require("md5"),moment=require("moment"),User=require("../../models").User,ChatRoom=require("../../models").ChatRoom,ChatMessage=require("../../models").ChatMessage,ChatVisitor=require("../../models").ChatVisitor,UserHasChatRoom=require("../../models").UserHasChatRoom;exports.index=function(a,b){return ChatRoom.findAll({include:[User,ChatMessage,ChatVisitor]}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.me=function(a,b){return User.findById(a.user.id).then(function(a){return a.getChatRooms({include:[{model:ChatVisitor,attributes:["id","fullname","email"]},{model:User,attributes:["id","name","fullname","email","role","internal"]}]})}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){return ChatRoom.findById(a.params.id,{include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:["id","email","fullname"]},{model:User,attributes:["id","email","name","fullname"]}]},{model:User,attributes:["id","email","name","fullname"]}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.getRoomByUsers=function(a,b,c){var d;return ChatRoom.findOrCreate({where:{token:md5(JSON.stringify(a.query.users.sort())).toString("base64")},defaults:{type:"internal",token:md5(JSON.stringify(a.query.users.sort())).toString("base64"),status:"open"},include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:["id","email","fullname"]},{model:User,attributes:["id","name","fullname","email","role","internal"]}]},{model:User,attributes:["id","name","fullname","email","role","internal"]}]}).spread(function(b,c){return d=b,c?d.setUsers(a.query.users):void 0}).then(function(){return d.getUsers()}).then(function(a){return b.status(200).send(_.merge(d.dataValues,{Users:a}))})["catch"](function(a){return handleError(b,a)})},exports.getRoomByType=function(a,b){User.findById(a.user.id).then(function(c){c.getChatRooms({where:{type:a.params.type},include:[{model:ChatVisitor,attributes:["id","fullname","email"]}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.getRoomGroups=function(a,b){User.findById(a.user.id).then(function(a){a.getChatRooms({include:[{model:ChatVisitor,attributes:["id","fullname","email"]},{model:User,attributes:["id","name","fullname","email","role","internal"]}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){},exports.update=function(a,b){a.body.id&&delete a.body.id,ChatRoom.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.updateUsers=function(a,b){var c;return a.body.id&&delete a.body.id,ChatRoom.findById(a.params.id).then(function(c){return c&&a.body.users?c:b.sendStatus(404)}).then(function(b){return b.update({token:md5(JSON.stringify(a.body.users.sort())).toString("base64")})}).then(function(b){return c=b,b.setUsers(a.body.users.sort(),{individualHooks:!0})}).then(function(){return c.getUsers()}).then(function(a){return b.status(200).send(_.merge(c.dataValues,{Users:a,ChatMessages:[]}))})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ChatRoom.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var User=require("../../models").User,ChatRoom=require("../../models").ChatRoom,ChatMessage=require("../../models").ChatMessage,ChatVisitor=require("../../models").ChatVisitor;exports.register=function(a){ -ChatRoom.afterCreate(function(b){onSave(a,b)}),ChatRoom.afterUpdate(function(b){onSave(a,b)}),ChatRoom.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/chat/rooms",function(){it("should respond with JSON array",function(a){request(app).get("/api/chat/rooms").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./chat_room.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",controller.index),router.get("/me",auth.isAuthenticated(),controller.me),router.get("/users",auth.isAuthenticated(),controller.getRoomByUsers),router.get("/groups",auth.isAuthenticated(),controller.getRoomGroups),router.get("/type/:type",auth.isAuthenticated(),controller.getRoomByType),router.get("/:id",controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",controller.update),router.put("/:id/users",controller.updateUsers),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ChatVisitor=require("../../models").ChatVisitor;exports.index=function(a,b){ChatVisitor.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ChatVisitor.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ChatVisitor.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ChatVisitor.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ChatVisitor.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var chat_visitor=require("../../models").ChatVisitor;exports.register=function(a){chat_visitor.afterCreate(function(b){onSave(a,b)}),chat_visitor.afterUpdate(function(b){onSave(a,b)}),chat_visitor.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/chat/visitors",function(){it("should respond with JSON array",function(a){request(app).get("/api/chat/visitors").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./chat_visitor.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),async=require("async"),Mustache=require("mustache"),sequelize=require("../../models").sequelize,ChatWebsite=require("../../models").ChatWebsite,ChatApplication=require("../../models").ChatApplication,snippet=require("../../components/xchatty").snippet;exports.index=function(a,b,c){var d=["name","address","description","remote"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),ChatWebsite.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){ChatWebsite.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.getSnippetCode=function(a,b){ChatWebsite.findById(a.params.id).then(function(c){var d={remote:c.remote,websiteId:a.params.id},e=Mustache.render(snippet,d);return b.send(e)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ChatWebsite.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){return a.body.id&&delete a.body.id,ChatWebsite.findById(a.params.id).then(function(c){return c?c.update(a.body).then(function(a){return b.status(200).send(a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ChatWebsite.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.sortApplications=function(a,b,c){ChatApplication.findAll({where:{id:a.body.applications}}).then(function(c){var d=c;async.waterfall([function(b){ChatApplication.destroy({where:{id:a.body.applications}}).then(function(){b()})["catch"](function(a){b(a)})},function(b){for(var c=[],e=0;ef.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.companyValidation=function(a,b){console.log(a.body),Company.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Company.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Company.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){Company.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_COMPANY"}):(a.body.id&&delete a.body.id,void Company.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Company.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Company.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Company=require("../../models").Company;exports.register=function(a){Company.afterCreate(function(b){onSave(a,b)}),Company.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/contactmanager/companies",function(){it("should respond with JSON array",function(a){request(app).get("/api/contactmanager/companies").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./company.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.companyValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),Contact=require("../../models").Contact;exports.index=function(a,b){Contact.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Contact.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Contact.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Contact.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Contact.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},module["export"]=function(a,b){var c=a.define("Contact",{name:String,info:String,active:Boolean});return c};var contact=require("../../models").Contact;exports.register=function(a){contact.afterCreate(function(b){onSave(a,b)}),contact.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/contacts",function(){it("should respond with JSON array",function(a){request(app).get("/api/contacts").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./contact.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),Contact=require("../../models").Contact,ContactPhone=require("../../models").ContactPhone,ContactEmail=require("../../models").ContactEmail,CustomField=require("../../models").CustomField,ReportCall=require("../../models").ReportCall,ReportCallHistory=require("../../models").history.ReportCallHistory,ReportMailSession=require("../../models").ReportMailSession,ReportMailSessionHistory=require("../../models").history.ReportMailSessionHistory,Tag=require("../../models").Tag,stream=require("stream"),sequelize=require("../../models").sequelize,util=require("util");exports.index=function(a,b){var c=["name","surname","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),Contact.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){Contact.findById(a.params.id,{include:[{model:ContactPhone,as:"Phones",include:[{model:ReportCall,as:"Inbounds",include:[{all:!0}]},{model:ReportCall,as:"Outbounds",include:[{all:!0}]},{model:ReportCallHistory,as:"HistoryInbounds",include:[{all:!0}]},{model:ReportCallHistory,as:"HistoryOutbounds",include:[{all:!0}]}]},{model:ContactEmail,as:"Emails",include:[{model:ReportMailSession,as:"InboundMessages",include:[{all:!0}]},{model:ReportMailSession,as:"OutboundMessages",include:[{all:!0}]},{model:ReportMailSessionHistory,as:"HistoryInboundMessages",include:[{all:!0}]},{model:ReportMailSessionHistory,as:"HistoryOutboundMessages",include:[{all:!0}]}]},{model:CustomField,as:"CustomFields"}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return console.log(a),handleError(b,a)})},exports.getHistory=function(a,b){},exports.contactValidation=function(a,b){Contact.findAll({where:{$or:{"$Phones.phone$":a.body.phones,"$Emails.email$":a.body.emails}},include:[{all:!0}]}).then(function(a){return console.log(a),b.status(200).send(a)})["catch"](function(a){return console.log(a),handleError(b,a)})},exports.create=function(a,b,c){var d=[],e=[],f={};Tag.findAll().then(function(b){var c=[];_.pluck(_.pluck(b,"dataValues"),"name");if(a.body.tags){var d=a.body.tags.split(",");d.forEach(function(a){_.includes(b,a)||c.push({name:a})}),c.length&&Tag.bulkCreate(c,{individualHooks:!0})}a.body.UserId=a.user.id;var e=_.uniq(_.pluck(a.body.Phones,"phone")),f=[];return e.forEach(function(a){f.push(ContactPhone.findOrCreate({where:{phone:a},defaults:{phone:a}}))}),f}).all().then(function(b){d=_.map(b,function(a){return a[0]});var c=[],e=_.uniq(_.pluck(a.body.Emails,"email"));return e.forEach(function(a){c.push(ContactEmail.findOrCreate({where:{email:a},defaults:{email:a}}))}),c}).all().then(function(b){return e=_.map(b,function(a){return a[0]}),delete a.body.Phones,delete a.body.Emails,f=_.clone(a.body.customFields),delete a.body.customFields,Contact.create(a.body)}).then(function(a){return[a,a.setPhones(d)]}).spread(function(a){return[a,a.setEmails(e)]}).spread(function(a){var b=_.keys(f);return[a,CustomField.findAll({where:{id:b}})]}).spread(function(a,b){return b.forEach(function(a){a.ContactHasCustomField={value:f[String(a.id)]}}),[a,a.setCustomFields(b)]}).spread(function(a){return b.status(201).send(a)})["catch"](function(a){return console.log(a),c(a)})},exports.update=function(a,b,c){var d=[],e=[],f={};Tag.findAll().then(function(b){var c=[];_.pluck(_.pluck(b,"dataValues"),"name");if(a.body.tags){var d=a.body.tags.split(",");d.forEach(function(a){_.includes(b,a)||c.push({name:a})}),c.length&&Tag.bulkCreate(c,{individualHooks:!0})}var e=[],f=_.uniq(_.pluck(a.body.Phones,"phone"));return f.forEach(function(a){e.push(ContactPhone.findOrCreate({where:{phone:a},defaults:{phone:a}}))}),e}).all().then(function(b){d=_.map(b,function(a){return a[0]});var c=[],e=_.uniq(_.pluck(a.body.Emails,"email"));return e.forEach(function(a){c.push(ContactEmail.findOrCreate({where:{email:a},defaults:{email:a}}))}),c}).all().then(function(b){e=_.map(b,function(a){return a[0]}),delete a.body.Phones,delete a.body.Emails,f=_.clone(a.body.customFields),delete a.body.customFields,delete a.body.CustomFields;var c=a.body.id;return delete a.body.id,Contact.findById(c)}).then(function(a){return[a,a.setPhones(d)]}).spread(function(a){return[a,a.setEmails(e)]}).spread(function(a){var b=_.keys(f);return[a,CustomField.findAll({where:{id:b}})]}).spread(function(a,b){return b.forEach(function(a){a.ContactHasCustomField={value:f[String(a.id)]}}),[a,a.setCustomFields(b)]}).spread(function(b){return b.updateAttributes(a.body)}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return console.log(a),handleError(b,a)})},exports.destroy=function(a,b){Contact.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Contact.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Contact=require("../../models").Contact;exports.register=function(a){Contact.afterCreate(function(b){onSave(a,b)}),Contact.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/contactmanager",function(){it("should respond with JSON array",function(a){request(app).get("/api/contactmanager").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./contact_manager.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/history",auth.isAuthenticated(),controller.getHistory),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.contactValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),CustomField=require("../../models").CustomField,util=require("util");exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{active:!0},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),CustomField.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.getAll=function(a,b){CustomField.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.customFieldValidation=function(a,b){console.log(a.body),CustomField.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){CustomField.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){CustomField.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){CustomField.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_CUSTOM_FIELD"}):(a.body.id&&delete a.body.id,void CustomField.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.deactivate=function(a,b){CustomField.findById(a.params.id).then(function(a){return a?void a.update({active:!1}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDeactivate=function(a,b){CustomField.update({active:!1},{where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var CustomField=require("../../models").CustomField;exports.register=function(a){CustomField.afterCreate(function(b){onSave(a,b)}),CustomField.afterUpdate(function(b){b.active||onRemove(a,b)}),CustomField.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/contactmanager/customfields",function(){it("should respond with JSON array",function(a){request(app).get("/api/contactmanager/customfields").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./custom_field.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/all",auth.isAuthenticated(),controller.getAll),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.customFieldValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDeactivate),router["delete"]("/:id",auth.isAuthenticated(),controller.deactivate),module.exports=router;var _=require("lodash"),util=require("util"),CustomReport=require("../../models").CustomReport,ReportTree=require("../../models").ReportTree;exports.index=function(a,b,c){var d=["name","description","parent"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;case"role":g.where.role={$or:b.split(/[\s,]+/)};break;case"clientQuery":var e=JSON.parse(b);_.forOwn(e,function(a,b){g.where[b]=a});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),CustomReport.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){CustomReport.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){CustomReport.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,CustomReport.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){CustomReport.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var CustomReport=require("../../models").CustomReport;exports.register=function(a){CustomReport.afterCreate(function(b){onSave(a,b)}),CustomReport.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/analytics/reports/custom",function(){it("should respond with JSON array",function(a){request(app).get("/api/analytic/reports/custom").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./custom_report.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),Dashboard=require("../../models").Dashboard;exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),Dashboard.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;return b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return b.status(500).send({error:"Something blew up!"})})},exports.all=function(a,b){Dashboard.findAll().then(function(a){return a?b.status(200).send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Dashboard.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Dashboard.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Dashboard.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Dashboard.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Dashboard.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Dashboard=require("../../models").Dashboard;exports.register=function(a){Dashboard.afterCreate(function(b){onSave(a,b)}),Dashboard.afterUpdate(function(b){onSave(a,b)}),Dashboard.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/dashboards",function(){it("should respond with JSON array",function(a){request(app).get("/api/dashboards").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./dashboard.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/all",auth.isAuthenticated(),controller.all),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),DefaultReport=require("../../models").DefaultReport;exports.index=function(a,b,c){var d=["name","description","parent"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;case"role": -g.where.role={$or:b.split(/[\s,]+/)};break;case"clientQuery":var e=JSON.parse(b);_.forOwn(e,function(a,b){g.where[b]=a});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),DefaultReport.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){DefaultReport.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){DefaultReport.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,DefaultReport.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){DefaultReport.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var DefaultReport=require("../../models").DefaultReport;exports.register=function(a){DefaultReport.afterCreate(function(b){onSave(a,b)}),DefaultReport.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/analytics/reports/default",function(){it("should respond with JSON array",function(a){request(app).get("/api/analytic/reports/default").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./default_report.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),desk=require("desk.js"),DeskAccount=require("../../models").DeskAccount;exports.index=function(a,b){var c=["description","name","username","remoteUri"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),DeskAccount.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;return b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){DeskAccount.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){DeskAccount.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,DeskAccount.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){DeskAccount.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.checkAccount=function(a,b){DeskAccount.findById(a.params.id).then(function(a){var c={endpoint:stripTrailingSlash(a.remoteUri),retry:!1};"basic"===a.authType?(c.username=a.username,c.password=a.password):"oauth"===a.authType&&(c.consumerKey=a.consumerKey,c.consumerSecret=a.consumerSecret,c.token=a.token,c.tokenSecret=a.tokenSecret);var d=desk.createClient(c);d.get("/api/v2/users/me",function(a,c,d){return a?handleError(b,a):b.sendStatus(200)})})["catch"](function(a){return handleError(b,a)})},exports.deskValidation=function(a,b){var c={};c[a.params.field]=a.body.value,DeskAccount.findAndCountAll({where:c}).then(function(c){return c.count?b.status(200).send({isValid:!1,value:a.body.value}):b.status(200).send({isValid:!0,value:a.body.value})})["catch"](function(a){return handleError(b,a)})},exports.getFields=function(a,b){DeskAccount.findById(a.params.id).then(function(a){var c={endpoint:stripTrailingSlash(a.remoteUri),retry:!1};"basic"===a.authType?(c.username=a.username,c.password=a.password):"oauth"===a.authType&&(c.consumerKey=a.consumerKey,c.consumerSecret=a.consumerSecret,c.token=a.token,c.tokenSecret=a.tokenSecret);var d=desk.createClient(c);d.get("/api/v2/custom_fields",function(a,c,d){return a?handleError(b,a):b.status(200).json(c._embedded.entries)})})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){DeskAccount.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var DeskAccount=require("../../models").DeskAccount;exports.register=function(a){DeskAccount.afterCreate(function(b){onSave(a,b)}),DeskAccount.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/desk/accounts",function(){it("should respond with JSON array",function(a){request(app).get("/api/desk/accounts").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./desk_account.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/check",auth.isAuthenticated(),controller.checkAccount),router.get("/:id/fields",auth.isAuthenticated(),controller.getFields),router.post("/validate/:field",auth.isAuthenticated(),controller.deskValidation),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),DeskConfiguration=require("../../models").DeskConfiguration,DeskField=require("../../models").DeskField;exports.index=function(a,b){DeskConfiguration.findAll({where:a.query}).then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){DeskConfiguration.find({where:{id:a.params.id},include:[{model:DeskField,as:"Subject"},{model:DeskField,as:"Description"},{model:DeskField,as:"Field"}]}).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){DeskConfiguration.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,DeskConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){DeskConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))},exports.addConfigurationField=function(a,b,c){var d;DeskConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(function(b){return d=b,DeskField.create(a.body)}).then(function(b){switch(a.params.type){case"subject":return[d.addSubject(b),b];case"description":return[d.addDescription(b),b];case"field":return[d.addField(b),b]}}).spread(function(a,c){return b.status(201).json(c)})["catch"](handleError(b))};var DeskConfiguration=require("../../models").DeskConfiguration;exports.register=function(a){DeskConfiguration.afterCreate(function(b){onSave(a,b)}),DeskConfiguration.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./desk_configuration.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.post("/:id/:type",auth.isAuthenticated(),controller.addConfigurationField),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),deskConfigurationCtrlStub={index:"deskConfigurationCtrl.index",show:"deskConfigurationCtrl.show",create:"deskConfigurationCtrl.create",update:"deskConfigurationCtrl.update",destroy:"deskConfigurationCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},deskConfigurationIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./desk_configuration.controller":deskConfigurationCtrlStub});describe("DeskConfiguration API Router:",function(){it("should return an express router instance",function(){expect(deskConfigurationIndex).to.equal(routerStub)}),describe("GET /api/desk/configurations",function(){it("should route to deskConfiguration.controller.index",function(){expect(routerStub.get.withArgs("/","deskConfigurationCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/desk/configurations/:id",function(){it("should route to deskConfiguration.controller.show",function(){expect(routerStub.get.withArgs("/:id","deskConfigurationCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/desk/configurations",function(){it("should route to deskConfiguration.controller.create",function(){expect(routerStub.post.withArgs("/","deskConfigurationCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/desk/configurations/:id",function(){it("should route to deskConfiguration.controller.update",function(){expect(routerStub.put.withArgs("/:id","deskConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/desk/configurations/:id",function(){it("should route to deskConfiguration.controller.update",function(){expect(routerStub.patch.withArgs("/:id","deskConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/desk/configurations/:id",function(){it("should route to deskConfiguration.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","deskConfigurationCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),DeskField=require("../../models").DeskField;exports.index=function(a,b){DeskField.findAll().then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){DeskField.findById(a.params.id).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){DeskField.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,DeskField.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){DeskField.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))};var DeskField=require("../../models").DeskField;exports.register=function(a){DeskField.afterCreate(function(b){onSave(a,b)}),DeskField.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./desk_field.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),deskFieldCtrlStub={index:"deskFieldCtrl.index",show:"deskFieldCtrl.show",create:"deskFieldCtrl.create",update:"deskFieldCtrl.update",destroy:"deskFieldCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},deskFieldIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./desk_field.controller":deskFieldCtrlStub});describe("DeskField API Router:",function(){it("should return an express router instance",function(){expect(deskFieldIndex).to.equal(routerStub)}),describe("GET /api/desk/fields",function(){it("should route to deskField.controller.index",function(){expect(routerStub.get.withArgs("/","deskFieldCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/desk/fields/:id",function(){it("should route to deskField.controller.show",function(){expect(routerStub.get.withArgs("/:id","deskFieldCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/desk/fields",function(){it("should route to deskField.controller.create",function(){expect(routerStub.post.withArgs("/","deskFieldCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/desk/fields/:id",function(){it("should route to deskField.controller.update",function(){expect(routerStub.put.withArgs("/:id","deskFieldCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/desk/fields/:id",function(){it("should route to deskField.controller.update",function(){expect(routerStub.patch.withArgs("/:id","deskFieldCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/desk/fields/:id",function(){it("should route to deskField.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","deskFieldCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),Event=require("../../models").Event;exports.index=function(a,b){Event.findAll({include:[{all:!0}]}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.showByChannel=function(a,b){Event.findAll({where:{channel:a.params.channel.toUpperCase()},include:[{all:!0}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Event.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Event.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Event.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Event.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var Event=require("../../models").Event;exports.register=function(a){Event.afterCreate(function(b){Event.findOne({where:{id:b.id},include:[{all:!0}]}).then(function(b){onSave(a,b)})}),Event.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/events",function(){it("should respond with JSON array",function(a){request(app).get("/api/events").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./event.controller"),router=express.Router();router.get("/",controller.index),router.get("/channel/:channel",controller.showByChannel),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),async=require("async"),Trunk=require("../../models").Trunk,FaxAccount=require("../../models").FaxAccount,FaxApplication=require("../../models").FaxApplication,VoiceExtension=require("../../models").VoiceExtension,sequelize=require("../../models").sequelize;exports.index=function(a,b,c){var d=["description","name","phone"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),FaxAccount.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b,c){FaxAccount.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return c(a)})},exports.create=function(a,b,c){return sequelize.transaction().then(function(c){async.waterfall([function(b){return FaxAccount.create(a.body,{transaction:c}).then(function(a){b(null,a)})["catch"](function(a){b(a)})},function(b,d){return Trunk.findById(a.body.TrunkId,{transaction:c}).then(function(a){d(null,b,a)})["catch"](function(a){d(a)})},function(b,d,e){return VoiceExtension.create({context:d.context,exten:a.body.phone,priority:1,app:"Goto",appdata:"inbound-fax,s,1",type:"inbound-fax",TrunkId:d.id},{transaction:c}).then(function(a){e(null,b)})["catch"](function(a){e(a)})}],function(a,d){return a?(console.log(a),c.rollback(),b.status(404).send(a)):(console.log("ok"),c.commit(),b.status(201).send(d))})})},exports.update=function(a,b,c){return a.body.id&&delete a.body.id,sequelize.transaction().then(function(c){async.waterfall([function(b){return FaxAccount.findOne({where:{id:a.params.id},include:[{model:Trunk}]},{transaction:c}).then(function(a){b(null,a)})["catch"](function(a){b(a)})},function(b,d){return Trunk.findById(a.body.TrunkId,{transaction:c}).then(function(a){return b.updateAttributes({TrunkId:a.id},{transaction:c}).then(function(c){d(null,b,a)})["catch"](function(a){d(a)})})["catch"](function(a){d(a)})},function(b,d,e){return VoiceExtension.findOne({where:{priority:1,exten:b.phone,context:b.Trunk.context}},{transaction:c}).then(function(f){return f||e(null,b),f.updateAttributes({exten:a.body.phone,context:d.context,TrunkId:a.body.UserId},{transaction:c}).then(function(){console.log("voiceExtension edited"),e(null,b)})["catch"](function(a){e(a)})})["catch"](function(a){e(a)})},function(b,d){var e=_.merge(b,a.body);return e.save({transaction:c}).then(function(){console.log("faxAccount saved"),d(null,b)})["catch"](function(a){d(a)})}],function(a,d){return a?(console.log(a),c.rollback(),b.status(404).send(a)):(console.log("ok"),c.commit(),b.status(201).send(d))})})},exports.destroy=function(a,b,c){FaxAccount.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){c(a)}):b.sendStatus(404)})["catch"](function(a){c(a)})},exports.addApplications=function(a,b,c){FaxApplication.findAll({where:{id:a.body.applications}}).then(function(c){var d=c;return sequelize.transaction(function(b){return FaxApplication.destroy({where:{id:a.body.applications}},{transaction:b}).then(function(){for(var c=[],e=0;eg.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){FaxBusinessAutomation.findById(a.params.id,{include:[{all:!0}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){return sequelize.transaction(function(b){return FaxBusinessAutomation.create(a.body,{transaction:b}).then(function(c){var d=[];return a.body.or&&(a.body.or.forEach(function(a){a.FaxBusinessAutomationId=c.id}),d=d.concat(a.body.or)),a.body.and&&(a.body.and.forEach(function(a){a.FaxBusinessAutomationId=c.id}),d=d.concat(a.body.and)),BusinessCondition.bulkCreate(d,{transaction:b}).then(function(d){return a.body.actions&&a.body.actions.forEach(function(a){a.FaxBusinessAutomationId=c.id}),BusinessAction.bulkCreate(a.body.actions,{transaction:b})})})}).then(function(){return b.sendStatus(201)})["catch"](function(a){return c(a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,FaxBusinessAutomation.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){FaxBusinessAutomation.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var FaxBusinessAutomation=require("../../models").FaxBusinessAutomation;exports.register=function(a){FaxBusinessAutomation.afterCreate(function(b){onSave(a,b)}),FaxBusinessAutomation.afterUpdate(function(b,c){onSave(a,b)}),FaxBusinessAutomation.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/fax/business/automations",function(){it("should respond with JSON array",function(a){request(app).get("/api/fax/business/automations").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./fax_business_automation.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),FaxMessage=require("../../models").FaxMessage,Trunk=require("../../models").User;exports.register=function(a){FaxMessage.afterCreate(function(b){console.log("FaxMessage afterCreate"),onSave(a,b)})};var _=require("lodash"),fs=require("fs"),path=require("path"),uploadFile=require("upload-file"),uuidLib=require("node-uuid"),pdf=require("html-pdf"),spindrift=require("spindrift"),formidable=require("formidable"),exec=require("child_process").exec,config=require("../../config/environment"),FaxMessage=require("../../models").FaxMessage,FaxRoom=require("../../models").FaxRoom,FaxAccount=require("../../models").FaxAccount,Contact=require("../../models").Contact;exports.index=function(a,b){FaxMessage.findAll({where:a.query,order:"createdAt DESC",include:[{model:Contact,as:"From"},{model:Contact,as:"To"},{model:FaxRoom,include:[{model:FaxAccount}]}]}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){FaxMessage.findOne({where:{id:a.params.id},include:[{model:Contact,as:"From"},{model:Contact,as:"To"}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){var d=new formidable.IncomingForm;if(d.uploadDir=path.join(config.root,"server/files/fax/outbound/original"),d.keepExtensions=!0,d.multiples=!1,a.body.onlyText){if(a.body.html){var e=uuidLib.v4(),f=path.join(config.root,"server/files/fax/outbound/original",e+".pdf");pdf.create(a.body.html,{timeout:3e4}).toFile(f,function(c,d){console.log("Fax: HTML Converted"),convertPdfAndSendFax(a,b,e,a.body)})}}else d.parse(a,function(c,d,e){if(c)return handleError(b,c);if(d.html){var f=uuidLib.v4(),g=path.join(config.root,"server/files/fax/outbound/original",f+".pdf");pdf.create(d.html,{timeout:3e4}).toFile(g,function(c,f){console.log("Fax: HTML Converted");var g=spindrift(f.filename),h=spindrift(e.file.path),i=uuidLib.v4();spindrift.join(g,h).pdfStream().pipe(fs.createWriteStream(path.join(config.root,"server/files/fax/outbound/original",i+".pdf"))),console.log("Fax: HTML joined with PDF uploaded"),convertPdfAndSendFax(a,b,i,d)})}else{var f=uuidLib.v4(),g=path.join(config.root,"server/files/fax/outbound/original",f+".pdf");fs.rename(e.file.path,g,function(c){return c?(console.error(c),handleError(b,a)):(console.log("Fax: PDF Rename"),void convertPdfAndSendFax(a,b,f,d))})}})},exports.update=function(a,b){a.body.id&&delete a.body.id,FaxMessage.findOne({where:{id:a.params.id},include:[{model:Contact,as:"From"},{model:Contact,as:"To"}]}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){FaxMessage.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.getContentFromMessage=function(a,b){FaxMessage.findById(a.params.id).then(function(a){if(!a)return b.sendStatus(404);if(a.filenamePDF){if("RECEIVED"===a.status){var c=path.join(config.root,"server","files","fax","inbound",a.filenamePDF);fs.exists(c,function(a){return a?b.sendFile(c):b.sendStatus(404)})}else if("NOT SENT"===a.status||"SENT"===a.directory||"FAILED"===a.status){var c=path.join(config.root,"server","files","fax","outbound","original",a.filenamePDF); -fs.exists(c,function(a){return a?b.sendFile(c):b.sendStatus(404)})}}else b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var FaxMessage=require("../../models").FaxMessage,Contact=require("../../models").Contact,FaxRoom=require("../../models").FaxRoom,FaxAccount=require("../../models").FaxAccount;exports.register=function(a){FaxMessage.afterCreate(function(b){FaxMessage.findOne({where:{id:b.id},include:[{model:Contact,as:"From"},{model:Contact,as:"To"},{model:FaxRoom,include:[{model:FaxAccount}]}]}).then(function(b){onSave(a,b)})["catch"](function(a){console.error(a)})}),FaxMessage.afterUpdate(function(b){FaxMessage.findOne({where:{id:b.id},include:[{model:Contact,as:"From"},{model:Contact,as:"To"},{model:FaxRoom,include:[{model:FaxAccount}]}]}).then(function(b){onSave(a,b),onUpdate(a,b)})["catch"](function(a){console.error(a)})}),FaxMessage.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/fax/messages",function(){it("should respond with JSON array",function(a){request(app).get("/api/fax/messages").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./fax_message.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id/content",controller.getContentFromMessage),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),FaxQueue=require("../../models").FaxQueue;exports.index=function(a,b){var c=["description","name","timeout","strategy"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d,include:[{all:!0}]};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),FaxQueue.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){FaxQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){FaxQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,FaxQueue.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){FaxQueue.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.addAgents=function(a,b,c){FaxQueue.findById(a.params.id).then(function(d){return d?void d.addUsers(a.body.agents).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)}):c(new Error("no fax queue found"))})["catch"](function(a){return c(a)})},exports.removeAgents=function(a,b,c){FaxQueue.findById(a.params.id).then(function(d){return d?void d.removeUsers(a.body.agents).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)}):c(new Error("no fax queue found"))})["catch"](function(a){return c(a)})},exports.bulkDestroy=function(a,b){FaxQueue.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var fax_queue=require("../../models").FaxQueue;exports.register=function(a){fax_queue.afterCreate(function(b){onSave(a,b)}),fax_queue.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/fax/queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/fax/queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./fax_queue.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.post("/:id/agents",controller.addAgents),router.put("/:id",controller.update),router.put("/:id/agents",controller.removeAgents),router.patch("/:id",controller.update),router["delete"]("/",controller.bulkDestroy),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),FaxRoom=require("../../models").FaxRoom,FaxAccount=require("../../models").FaxAccount,FaxMessage=require("../../models").FaxMessage,Contact=require("../../models").Contact,User=require("../../models").User;exports.index=function(a,b){FaxRoom.findAll({include:[{model:FaxMessage,attributes:["id"]},{model:FaxAccount},{model:User}]}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.agentIndex=function(a,b,c){FaxRoom.findAll({where:{UserId:a.params.id},include:[{model:FaxAccount},{model:User}]}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return c(a)})},exports.show=function(a,b){FaxRoom.findOne({where:{id:a.params.id},include:[{model:FaxMessage,include:[{model:FaxRoom,include:[{model:FaxAccount}]},{model:Contact,as:"From"},{model:Contact,as:"To"}]},{model:FaxAccount}],order:[[FaxMessage,"createdAt","DESC"]]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){FaxRoom.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){FaxRoom.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){FaxRoom.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var User=require("../../models").User,FaxRoom=require("../../models").FaxRoom,FaxQueue=require("../../models").FaxQueue,FaxAccount=require("../../models").FaxAccount,FaxApplication=require("../../models").FaxApplication;exports.register=function(a){FaxRoom.afterCreate(function(b){onSave(a,b)})};var fax_room=require("../../models").FaxRoom;exports.register=function(a){fax_room.afterCreate(function(b){onSave(a,b)}),fax_room.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/fax/rooms",function(){it("should respond with JSON array",function(a){request(app).get("/api/fax/rooms").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./fax_room.controller"),router=express.Router();router.get("/",controller.index),router.get("/agent/:id",controller.agentIndex),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),_fd=require("freshdesk"),FreshdeskAccount=require("../../models").FreshdeskAccount;exports.index=function(a,b){var c=["description","name","username","remoteUri"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),FreshdeskAccount.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;return b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){FreshdeskAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){FreshdeskAccount.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,FreshdeskAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){FreshdeskAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))},exports.bulkDestroy=function(a,b){FreshdeskAccount.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.checkAccount=function(a,b){FreshdeskAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(function(a){var c=new _fd(a.remoteUri,a.apiKey);c.listTickets(function(a,c,d){return a?b.sendStatus(400):(d=JSON.parse(d),d.require_login?b.sendStatus(400):b.sendStatus(200))})})["catch"](handleError(b))},exports.accountValidation=function(a,b){var c={};c[a.params.field]=a.body.value,FreshdeskAccount.findAndCountAll({where:c}).then(function(c){return c.count?b.status(200).send({isValid:!1,value:a.body.value}):b.status(200).send({isValid:!0,value:a.body.value})})["catch"](function(a){return handleError(b,a)})},exports.getFields=function(a,b,c){FreshdeskAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(function(a){var d=new _fd(a.remoteUri,a.apiKey);d.get("/ticket_fields.json",function(a,d,e){return a?c(a):(e=JSON.parse(e),b.status(200).send(e))})})["catch"](handleError(b))};var FreshdeskAccount=require("../../models").FreshdeskAccount;exports.register=function(a){FreshdeskAccount.afterCreate(function(b){onSave(a,b)}),FreshdeskAccount.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./freshdesk_account.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/fields",auth.isAuthenticated(),controller.getFields),router.get("/:id/check",auth.isAuthenticated(),controller.checkAccount),router.post("/validate/:field",auth.isAuthenticated(),controller.accountValidation),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),freshdeskAccountCtrlStub={index:"freshdeskAccountCtrl.index",show:"freshdeskAccountCtrl.show",create:"freshdeskAccountCtrl.create",update:"freshdeskAccountCtrl.update",destroy:"freshdeskAccountCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},freshdeskAccountIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./freshdesk_account.controller":freshdeskAccountCtrlStub});describe("FreshdeskAccount API Router:",function(){it("should return an express router instance",function(){expect(freshdeskAccountIndex).to.equal(routerStub)}),describe("GET /api/freshdesk/accounts",function(){it("should route to freshdeskAccount.controller.index",function(){expect(routerStub.get.withArgs("/","freshdeskAccountCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/freshdesk/accounts/:id",function(){it("should route to freshdeskAccount.controller.show",function(){expect(routerStub.get.withArgs("/:id","freshdeskAccountCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/freshdesk/accounts",function(){it("should route to freshdeskAccount.controller.create",function(){expect(routerStub.post.withArgs("/","freshdeskAccountCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/freshdesk/accounts/:id",function(){it("should route to freshdeskAccount.controller.update",function(){expect(routerStub.put.withArgs("/:id","freshdeskAccountCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/freshdesk/accounts/:id",function(){it("should route to freshdeskAccount.controller.update",function(){expect(routerStub.patch.withArgs("/:id","freshdeskAccountCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/freshdesk/accounts/:id",function(){it("should route to freshdeskAccount.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","freshdeskAccountCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),FreshdeskConfiguration=require("../../models").FreshdeskConfiguration,FreshdeskField=require("../../models").FreshdeskField;exports.index=function(a,b){FreshdeskConfiguration.findAll({where:a.query}).then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){FreshdeskConfiguration.find({where:{id:a.params.id},include:[{model:FreshdeskField,as:"Subject"},{model:FreshdeskField,as:"Description"},{model:FreshdeskField,as:"Field"}]}).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){FreshdeskConfiguration.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,FreshdeskConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){FreshdeskConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))},exports.addConfigurationField=function(a,b,c){var d;FreshdeskConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(function(b){return d=b,FreshdeskField.create(a.body)}).then(function(b){switch(a.params.type){case"subject":return[d.addSubject(b),b];case"description":return[d.addDescription(b),b];case"field":return[d.addField(b),b]}}).spread(function(a,c){return b.status(201).json(c)})["catch"](handleError(b))};var FreshdeskConfiguration=require("../../models").FreshdeskConfiguration;exports.register=function(a){FreshdeskConfiguration.afterCreate(function(b){onSave(a,b)}),FreshdeskConfiguration.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./freshdesk_configuration.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.post("/:id/:type",auth.isAuthenticated(),controller.addConfigurationField),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),freshdeskConfigurationCtrlStub={index:"freshdeskConfigurationCtrl.index",show:"freshdeskConfigurationCtrl.show",create:"freshdeskConfigurationCtrl.create",update:"freshdeskConfigurationCtrl.update",destroy:"freshdeskConfigurationCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},freshdeskConfigurationIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./freshdesk_configuration.controller":freshdeskConfigurationCtrlStub});describe("FreshdeskConfiguration API Router:",function(){it("should return an express router instance",function(){expect(freshdeskConfigurationIndex).to.equal(routerStub)}),describe("GET /api/freshdesk/configurations",function(){it("should route to freshdeskConfiguration.controller.index",function(){expect(routerStub.get.withArgs("/","freshdeskConfigurationCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/freshdesk/configurations/:id",function(){it("should route to freshdeskConfiguration.controller.show",function(){expect(routerStub.get.withArgs("/:id","freshdeskConfigurationCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/freshdesk/configurations",function(){it("should route to freshdeskConfiguration.controller.create",function(){expect(routerStub.post.withArgs("/","freshdeskConfigurationCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/freshdesk/configurations/:id",function(){it("should route to freshdeskConfiguration.controller.update",function(){expect(routerStub.put.withArgs("/:id","freshdeskConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/freshdesk/configurations/:id",function(){it("should route to freshdeskConfiguration.controller.update",function(){expect(routerStub.patch.withArgs("/:id","freshdeskConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/freshdesk/configurations/:id",function(){it("should route to freshdeskConfiguration.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","freshdeskConfigurationCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),FreshdeskField=require("../../models").FreshdeskField;exports.index=function(a,b){FreshdeskField.findAll().then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){FreshdeskField.findById(a.params.id).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){FreshdeskField.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,FreshdeskField.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){FreshdeskField.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))};var FreshdeskField=require("../../models").FreshdeskField;exports.register=function(a){FreshdeskField.afterCreate(function(b){onSave(a,b)}),FreshdeskField.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./freshdesk_field.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),freshdeskFieldCtrlStub={index:"freshdeskFieldCtrl.index",show:"freshdeskFieldCtrl.show",create:"freshdeskFieldCtrl.create",update:"freshdeskFieldCtrl.update",destroy:"freshdeskFieldCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},freshdeskFieldIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./freshdesk_field.controller":freshdeskFieldCtrlStub});describe("FreshdeskField API Router:",function(){it("should return an express router instance",function(){expect(freshdeskFieldIndex).to.equal(routerStub)}),describe("GET /api/freshdesk/fields",function(){it("should route to freshdeskField.controller.index",function(){expect(routerStub.get.withArgs("/","freshdeskFieldCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/freshdesk/fields/:id",function(){it("should route to freshdeskField.controller.show",function(){expect(routerStub.get.withArgs("/:id","freshdeskFieldCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/freshdesk/fields",function(){it("should route to freshdeskField.controller.create",function(){expect(routerStub.post.withArgs("/","freshdeskFieldCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/freshdesk/fields/:id",function(){it("should route to freshdeskField.controller.update",function(){expect(routerStub.put.withArgs("/:id","freshdeskFieldCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/freshdesk/fields/:id",function(){it("should route to freshdeskField.controller.update",function(){expect(routerStub.patch.withArgs("/:id","freshdeskFieldCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/freshdesk/fields/:id",function(){it("should route to freshdeskField.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","freshdeskFieldCtrl.destroy")).to.have.been.calledOnce})})});var express=require("express"),controller=require("./integration.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),uploadFile=require("upload-file"),config=require("../../config/environment"),path=require("path"),sr=require("simple-random"),admZip=require("adm-zip"),str2json=require("string-to-json"),fs=require("fs"),Integration=require("../../models").Integration;exports.index=function(a,b){Integration.findAll({where:a.query}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Integration.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){var c=new uploadFile({dest:path.join(config.root,"server/files/integrations"),maxFileSize:5e6,maxNumberOfFiles:1,minNumberOfFiles:1,acceptFileTypes:/(\.|\/)(zip)$/i,messages:{maxNumberOfFiles:"Max number of files upload exceeded",acceptFileTypes:"Only zip format accepted",maxFileSize:"The maximum file size is 5 Mb",invalidRequest:"Invalid request"}});c.on("end",function(a,c){var d=new admZip(c.file.path),e=!1,f=d.getEntries();if(f.forEach(function(a){if("manifest.json"===a.name){var f=a.getData().toString("utf8");console.log("uploadZip",f);try{e=JSON.parse(f),console.log("uploadZip",e),Integration.create(_.merge(c.file,e)).then(function(a){return d.extractAllTo(path.join(config.root,"server/files/integrations"),!0),b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})}catch(g){console.log(g);var h={errors:[{type:"json",message:g}]};return handleError(b,h)}}}),fs.unlinkSync(c.file.path),!e){var g={errors:[{type:"manifest",message:"manifest.json not found"}]};return handleError(b,g)}}),c.on("error",function(a){var c={errors:[{type:"upload",message:a}]};return handleError(b,c)}),c.parse(a)},exports.update=function(a,b){a.body.id&&delete a.body.id,Integration.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Integration.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var Integration=require("../../models").Integration;exports.register=function(a){Integration.afterCreate(function(b){onSave(a,b)}),Integration.afterUpdate(function(b){onSave(a,b)}),Integration.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/integrations",function(){it("should respond with JSON array",function(a){request(app).get("/api/integrations").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./interval.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/all",auth.isAuthenticated(),controller.getAll),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.intervalValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),Interval=require("../../models").Interval,VoiceExtension=require("../../models").VoiceExtension,sequelize=require("../../models").sequelize,util=require("util");exports.index=function(a,b){var c=["name"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{IntervalId:null},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),Interval.findAndCountAll(f).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.getAll=function(a,b){Interval.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Interval.findById(a.params.id,{include:[{all:!0}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.intervalValidation=function(a,b){var c={name:a.body.name,IntervalId:a.body.IntervalId?a.body.IntervalId:null};a.body.id&&(c.id={$ne:a.body.id}),console.log(a.body),Interval.findAll({where:c}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Interval.findAll({where:{name:a.body.name,IntervalId:a.body.IntervalId?a.body.IntervalId:null}}).then(function(c){return console.log(c),console.log("Finding app row....."),c?c.length>0?b.status(500).send({message:a.body.IntervalId?"MESSAGE_EXIST_SUBINTERVAL":"MESSAGE_EXIST_INTERVAL"}):void Interval.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){Interval.findAll({where:{name:a.body.name,IntervalId:a.body.IntervalId?a.body.IntervalId:null,id:{$ne:a.body.id}}}).then(function(c){return console.log(c),console.log("Finding app row....."),c?c.length>0?b.status(500).send({message:a.body.IntervalId?"MESSAGE_EXIST_SUBINTERVAL":"MESSAGE_EXIST_INTERVAL"}):(a.body.id&&delete a.body.id,void Interval.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);return sequelize.transaction(function(a){return d.save({transaction:a}).then(function(b){VoiceExtension.update({interval:b.name},{where:{IntervalId:b.id}},{transaction:a})})}).then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Interval.findById(a.params.id).then(function(a){return a?void a.getVoiceExtensions({where:{isApp:!0}}).then(function(c){return console.log(c.length),c.length>0?b.status(500).send({message:"MESSAGE_INTERVAL_ROUTE_ASSOCIATED"}):void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){var c=!1;Interval.findAll({where:{id:a.query.id},include:[{all:!0}]}).then(function(d){return d?(d.forEach(function(a){a.VoiceExtensions.length>0&&(c=!0)}),c?b.status(500).send({message:"MESSAGE_INTERVAL_ROUTE_ASSOCIATED"}):void Interval.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var Interval=require("../../models").Interval;exports.register=function(a){Interval.afterCreate(function(b){onSave(a,b)}),Interval.afterDestroy(function(b){onRemove(a,b)}),Interval.afterUpdate(function(b){onUpdate(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/intervals",function(){it("should respond with JSON array",function(a){request(app).get("/api/intervals").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./mail_account.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.post("/:id/applications",controller.sortApplications),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/",controller.bulkDestroy),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),async=require("async"),sequelize=require("../../models").sequelize,MailAccount=require("../../models").MailAccount,MailApplication=require("../../models").MailApplication,MailServerIn=require("../../models").MailServerIn,MailServerOut=require("../../models").MailServerOut;exports.index=function(a,b){var c=["description","name","address"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d,include:[{all:!0}]};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),MailAccount.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null; -b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b,c){MailAccount.findById(a.params.id,{include:[{all:!0}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return c(a)})},exports.create=function(a,b,c){return sequelize.transaction(function(b){return MailAccount.create({name:a.body.name,address:a.body.address,description:a.body.description},{transaction:b}).then(function(c){return a.body.incoming.MailAccountId=c.id,MailServerIn.create(a.body.incoming,{transaction:b}).then(function(d){return a.body.outgoing.MailAccountId=c.id,MailServerOut.create(a.body.outgoing,{transaction:b})})})}).then(function(a){return b.status(201).send(a)})["catch"](function(a){return c(a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,MailAccount.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.sortApplications=function(a,b,c){MailApplication.findAll({where:{id:a.body.applications}}).then(function(c){var d=c;async.waterfall([function(b){MailApplication.destroy({where:{id:a.body.applications}}).then(function(){console.log("destroy"),b()})["catch"](function(a){b(a)})},function(b){for(var c=[],e=0;eg.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,mailAutomations:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){MailBusinessAutomation.findById(a.params.id,{include:[{all:!0}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){return sequelize.transaction(function(b){return MailBusinessAutomation.create(a.body,{transaction:b}).then(function(c){var d=[];return a.body.or&&(a.body.or.forEach(function(a){a.MailBusinessAutomationId=c.id}),d=d.concat(a.body.or)),a.body.and&&(a.body.and.forEach(function(a){a.MailBusinessAutomationId=c.id}),d=d.concat(a.body.and)),BusinessCondition.bulkCreate(d,{transaction:b}).then(function(d){return a.body.actions&&a.body.actions.forEach(function(a){a.MailBusinessAutomationId=c.id}),BusinessAction.bulkCreate(a.body.actions,{transaction:b})})})}).then(function(){return b.sendStatus(201)})["catch"](function(a){return c(a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,MailBusinessAutomation.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){MailBusinessAutomation.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){MailBusinessAutomation.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var MailBusinessAutomation=require("../../models").MailBusinessAutomation;exports.register=function(a){MailBusinessAutomation.afterCreate(function(b,c){onSave(a,b)}),MailBusinessAutomation.afterUpdate(function(b,c){onSave(a,b)}),MailBusinessAutomation.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/mail/business/automations",function(){it("should respond with JSON array",function(a){request(app).get("/api/mail/business/automations").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./mail_message.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/",auth.isAuthenticated(),controller.update),router.put("/delete/bulk",controller.bulkDelete),router.put("/delete/:id",controller.update),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),async=require("async"),htmlToText=require("html-to-text"),formidable=require("formidable"),path=require("path"),config=require("../../config/environment"),sequelize=require("../../models").sequelize,MailMessage=require("../../models").MailMessage,MailAttachment=require("../../models").MailAttachment,MailRoom=require("../../models").MailRoom,MailAccount=require("../../models").MailAccount,Contact=require("../../models").Contact;exports.index=function(a,b,c){var d={order:"createdAt DESC",include:[{all:!0,include:[{all:!0}]}]};switch(a.user.role){case"admin":d.where=a.query;break;case"agent":}MailMessage.findAll(d).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a,c)})},exports.show=function(a,b,c){MailMessage.findById(a.params.id,{include:[{all:!0,include:[{all:!0}]}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a,c)})},exports.create=function(a,b,c){var d=new formidable.IncomingForm;return d.uploadDir=path.join(config.root,"server","files","attachments"),d.keepExtensions=!0,d.multiples=!0,_.isEmpty(a.body)?void d.parse(a,function(a,c,d){if(a)return b.status(400).send(a);var e=d.file;return c.MailAttachments=[{path:e.path,fileName:e.name,length:e.size,contentType:e.type}],sequelize.transaction().then(function(a){return MailMessage.create(c,{include:[{all:!0}],transaction:a}).then(function(c){return a.commit(),b.status(201).send(c)})["catch"](function(c){return a.rollback(),handleError(b,c)})})}):(console.log("NO ATTACHMENT"),a.body.status="SENDING",sequelize.transaction().then(function(c){return MailMessage.create(a.body,{transaction:c}).then(function(a){return c.commit(),b.status(201).send(a)})["catch"](function(a){return c.rollback(),handleError(b,a)})}))},exports.update=function(a,b,c){MailMessage.findById(a.params.id,{include:[{all:!0}]}).then(function(d){if(!d)return b.sendStatus(404);var e=_.merge(d,a.body);e.save().then(function(){return b.status(200).send(e)})["catch"](function(a){return handleError(b,a,c)})})["catch"](function(a){return handleError(b,a,c)})},exports.destroy=function(a,b,c){MailMessage.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a,c)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a,c)})},exports.bulkDelete=function(a,b,c){MailMessage.bulkUpdate({where:{id:{$in:a.body.id}},attributes:{directory:"TRASH"}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a,c)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a,c)})};var MailMessage=require("../../models").MailMessage;exports.register=function(a){MailMessage.afterCreate(function(b){onSave(a,b)}),MailMessage.afterUpdate(function(b){onSave(a,b)}),MailMessage.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./mail_queue.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.post("/:id/agents",controller.addAgents),router.put("/:id",controller.update),router.put("/:id/agents",controller.removeAgents),router.patch("/:id",controller.update),router["delete"]("/",controller.bulkDestroy),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),MailQueue=require("../../models").MailQueue;exports.index=function(a,b){var c=["description","name","timeout","strategy"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d,include:[{all:!0}]};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),MailQueue.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){MailQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){MailQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,MailQueue.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.addAgents=function(a,b,c){return MailQueue.findById(a.params.id).then(function(b){if(b)return b.addUsers(a.body.agents,{individualHooks:!0});throw new Error("MailQueue not found")}).then(function(){return b.sendStatus(200)})["catch"](function(a){return handleError(b,a)})},exports.removeAgents=function(a,b){return MailQueue.findById(a.params.id).then(function(b){if(b)return b.removeUsers(a.body.agents,{individualHooks:!0});throw new Error("MailQueue not found")}).then(function(){return b.sendStatus(200)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){MailQueue.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){MailQueue.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var MailQueue=require("../../models").MailQueue;exports.register=function(a){MailQueue.afterCreate(function(b){onSave(a,b)}),MailQueue.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/mail/queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/mail/queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./mail_room.controller"),router=express.Router();router.get("/",controller.index),router.get("/agent/:id",controller.agentIndex),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/",controller.bulkDestroy),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),User=require("../../models").User,Contact=require("../../models").Contact,MailRoom=require("../../models").MailRoom,MailMessage=require("../../models").MailMessage,MailAccount=require("../../models").MailAccount,MailAttachment=require("../../models").MailAttachment;exports.index=function(a,b,c){var d=["subject","from","status"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{status:{$or:["NEW","OPEN"]}},limit:e,offset:f*e,include:[{all:!0}]};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),MailRoom.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,mailRooms:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){return c(a)})},exports.agentIndex=function(a,b,c){MailRoom.findAll({where:{UserId:a.params.id},include:[{all:!0}]}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return c(a)})},exports.show=function(a,b,c){return MailRoom.findById(a.params.id,{include:[{model:MailMessage,include:[{model:MailRoom,include:[{model:MailAccount}]},{model:MailAttachment}]}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return c(a)})},exports.create=function(a,b,c){return MailRoom.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b,c){return MailRoom.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);if(c.jobId)throw new Error("Mail already assigned");var d=_.merge(c,a.body);return d.save()}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b,c){return MailRoom.findById(a.params.id).then(function(a){return a?a.destroy():b.sendStatus(404)}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){return MailRoom.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(200)})["catch"](function(a){return handleError(b,a)})};var MailMessage=require("../../models").MailMessage,MailRoom=require("../../models").MailRoom,User=require("../../models").User;exports.register=function(a){MailRoom.afterCreate(function(b){onSave(a,b)}),MailRoom.afterDestroy(function(b){onRemove(a,b)}),MailRoom.afterUpdate(function(b){MailRoom.findById(b.id,{include:[{all:!0}]}).then(function(b){onSave(a,b)})["catch"](function(a){console.error(a)})}),MailRoom.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./mail_server_in.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),MailServerIn=require("../../models").MailServerIn;exports.index=function(a,b){MailServerIn.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){MailServerIn.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){MailServerIn.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){return a.body.id&&delete a.body.id,MailServerIn.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return console.error(a),handleError(b,a)})})["catch"](function(a){return console.error(a),handleError(b,a)})},exports.destroy=function(a,b){MailServerIn.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var MailServerIn=require("../../models").MailServerIn;exports.register=function(a){MailServerIn.afterCreate(function(b){onSave(a,b)}),MailServerIn.afterUpdate(function(b){onSave(a,b)}),MailServerIn.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./mail_server_out.controller"),router=express.Router();router.get("/",controller.index),router.get("/service",controller.indexService),router.get("/:id",controller.show),router.get("/:id/test",controller.test),router.post("/",controller.create),router.post("/test",controller.test),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),MailServerOut=require("../../models").MailServerOut,MailMessage=require("../../models").MailMessage,sequelize=require("../../models").sequelize;exports.index=function(a,b){MailServerOut.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.indexService=function(a,b){MailServerOut.findAll({where:{service:!0}}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){MailServerOut.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){MailServerOut.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,MailServerOut.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){MailServerOut.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.test=function(a,b){return sequelize.transaction().then(function(c){var d,e;return MailServerOut.findById(a.params.id).then(function(a){return a?a:(c.rollback(),b.sendStatus(404))}).then(function(a){return d=a,MailMessage.create({subject:"MailAccount "+a.username+" test..",text:"MailAccount "+a.username+" test..",from:a.username,to:a.username,status:"SENDING"},{transaction:c})}).then(function(a){return e=a,d.update({state:"CONNECTED"})}).then(function(){return c.commit(),b.status(201).send(e)})["catch"](function(a){d.update({state:"ERROR"}).then(function(){return c.rollback(),handleError(b,a)})})})};var MailServerOut=require("../../models").MailServerOut;exports.register=function(a){MailServerOut.afterCreate(function(b){console.log("MailServerOut afterCreate"),onSave(a,b)}),MailServerOut.afterDestroy(function(b){console.log("MailServerOut afterDestroy"),onRemove(a,b)})};var express=require("express"),controller=require("./mail_template.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),MailTemplate=require("../../models").MailTemplate;exports.index=function(a,b){var c=["description","name","timeout","strategy"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d,include:[{all:!0}]};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),MailTemplate.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){MailTemplate.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){MailTemplate.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,MailTemplate.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){MailTemplate.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var MailTemplate=require("../../models").MailTemplate;exports.register=function(a){MailTemplate.afterCreate(function(b){onSave(a,b)}),MailTemplate.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./metric.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.metricValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),Metric=require("../../models").Metric,util=require("util");exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),Metric.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.metricValidation=function(a,b){console.log(a.body),Metric.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Metric.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Metric.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){Metric.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_METRIC"}):(a.body.id&&delete a.body.id,void Metric.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Metric.findById(a.params.id).then(function(a){return a?void a.getZendeskTexts().then(function(c){return c.length>0?b.status(500).send({message:"MESSAGE_METRIC_CONFIGURATION_ASSOCIATED" -}):void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Metric.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Metric=require("../../models").Metric;exports.register=function(a){Metric.afterCreate(function(b){onSave(a,b)}),Metric.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/analytics/metrics",function(){it("should respond with JSON array",function(a){request(app).get("/api/analytics/metrics").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./module.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),Module=require("../../models").Module;exports.index=function(a,b){Module.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){var c=a.params.id;Module.findById(c).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Module.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){var c=a.body.id;a.body.id&&delete a.body.id,Module.findById(c).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){var c=a.params.id;Module.findById(c).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var module=require("../../models").Module;exports.register=function(a){module.afterCreate(function(b){onSave(a,b)}),module.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/modules",function(){it("should respond with JSON array",function(a){request(app).get("/api/modules").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./setting.controller"),router=express.Router();router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),crypto=require("crypto"),Setting=require("../../models").Setting;exports.index=function(a,b){Setting.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Setting.findById(a.params.id).then(function(a){return a?(a.license&&(a.license=decrypt("aes-256-ctr",util.format("%s:%s:%s",a.address,a.netmask,a.mac),a.license),a.license=JSON.parse(a.license)),b.send(a)):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Setting.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Setting.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Setting.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var Setting=require("../../models").Setting;exports.register=function(a){Setting.afterCreate(function(b){onSave(a,b)}),Setting.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/settings",function(){it("should respond with JSON array",function(a){request(app).get("/api/settings").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./motionbar.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/:action/:state",auth.isAuthenticated(),controller.action),module.exports=router;var _=require("lodash"),Motionbar=require("../../models").Motionbar;exports.action=function(a,b){return a.query.userId?(a.body.UserId=parseInt(a.query.userId,10),a.body.action=a.params.action,a.body.state=a.params.state,a.body.AdminId=a.user.id,void Motionbar.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})):handleError(b,{message:"Use userId"})};var Motionbar=require("../../models").Motionbar;exports.register=function(a){Motionbar.afterCreate(function(b){onSave(a,b)}),Motionbar.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/motionbar",function(){it("should respond with JSON array",function(a){request(app).get("/api/motionbar").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./report_agent.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ReportAgent=require("../../models").ReportAgent;exports.index=function(a,b){ReportAgent.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ReportAgent.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ReportAgent.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ReportAgent.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ReportAgent.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ReportAgent=require("../../models").ReportAgent;exports.register=function(a){ReportAgent.afterCreate(function(b){onSave(a,b)}),ReportAgent.afterUpdate(function(b){onSave(a,b)}),ReportAgent.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./report_chat.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ReportChat=require("../../models").ReportChat,sequelize=require("../../models").sequelize;exports.index=function(a,b){ReportChat.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ReportChat.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ReportChat.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b,c){return a.body.id&&delete a.body.id,ReportChat.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);return d.save().then(function(){return b.status(200).send(c)})})["catch"](sequelize.ValidationError,function(a){return handleError(b,a)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ReportChat.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ReportChat=require("../../models").ReportChat;exports.register=function(a){ReportChat.afterCreate(function(b){onSave(a,b)}),ReportChat.afterUpdate(function(b){onUpdate(a,b)}),ReportChat.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/report/chats",function(){it("should respond with JSON array",function(a){request(app).get("/api/report/chats").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./report_chat_session.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ReportChatSession=require("../../models").ReportChatSession;exports.index=function(a,b){ReportChatSession.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ReportChatSession.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ReportChatSession.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ReportChatSession.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ReportChatSession.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ReportChatSession=require("../../models").ReportChatSession;exports.register=function(a){ReportChatSession.afterCreate(function(b){onSave(a,b)}),ReportChatSession.afterUpdate(function(b){onSave(a,b)}),ReportChatSession.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/report/chat/sessions",function(){it("should respond with JSON array",function(a){request(app).get("/api/report/chat/sessions").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./report_integration.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ReportIntegration=require("../../models").ReportIntegration;exports.index=function(a,b){ReportIntegration.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ReportIntegration.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ReportIntegration.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ReportIntegration.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ReportIntegration.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var util=require("util"),ReportIntegration=require("../../models").ReportIntegration;exports.register=function(a){ReportIntegration.afterCreate(function(b){onSave(a,b)})};var express=require("express"),controller=require("./report_mail.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ReportMail=require("../../models").ReportMail;exports.index=function(a,b){ReportMail.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ReportMail.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ReportMail.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ReportMail.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ReportMail.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ReportMail=require("../../models").ReportMail;exports.register=function(a){ReportMail.afterCreate(function(b){onSave(a,b)}),ReportMail.afterUpdate(function(b){onUpdate(a,b)}),ReportMail.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/report/mails",function(){it("should respond with JSON array",function(a){request(app).get("/api/report/mails").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./report_mail_session.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ReportMailSession=require("../../models").ReportMailSession;exports.index=function(a,b){ReportMailSession.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ReportMailSession.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ReportMailSession.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ReportMailSession.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ReportMailSession.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ReportMailSession=require("../../models").ReportMailSession;exports.register=function(a){ReportMailSession.afterCreate(function(b){onSave(a,b)}),ReportMailSession.afterUpdate(function(b){onSave(a,b)}),ReportMailSession.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/report/mail/sessions",function(){it("should respond with JSON array",function(a){request(app).get("/api/report/mail/sessions").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./report_queue.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ReportQueue=require("../../models").ReportQueue;exports.index=function(a,b){ReportQueue.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ReportQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ReportQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ReportQueue.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ReportQueue.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ReportQueue=require("../../models").ReportQueue;exports.register=function(a){ReportQueue.afterCreate(function(b){onSave(a,b)}),ReportQueue.afterUpdate(function(b){onSave(a,b)}),ReportQueue.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./report_tree.controller"),router=express.Router();router.get("/",controller.index),router.put("/:id",controller.update),router.patch("/:id",controller.update),module.exports=router;var _=require("lodash"),util=require("util"),ReportTree=require("../../models").ReportTree;exports.index=function(a,b){ReportTree.findAll().then(function(a){return a?b.status(200).send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){ReportTree.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})};var ReportTree=require("../../models").ReportTree;exports.register=function(a){ReportTree.afterCreate(function(b){onSave(a,b)}),ReportTree.afterUpdate(function(b){onSave(a,b)}),ReportTree.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/analytics/reports/trees",function(){it("should respond with JSON array",function(a){request(app).get("/api/analytic/reports/trees").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./salesforce_account.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/check",auth.isAuthenticated(),controller.checkAccount),router.get("/:id/fields",auth.isAuthenticated(),controller.getFields),router.post("/validate/:field",auth.isAuthenticated(),controller.accountValidation),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),salesforceAccountCtrlStub={index:"salesforceAccountCtrl.index",show:"salesforceAccountCtrl.show",create:"salesforceAccountCtrl.create",update:"salesforceAccountCtrl.update",destroy:"salesforceAccountCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},salesforceAccountIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./salesforce_account.controller":salesforceAccountCtrlStub});describe("SalesforceAccount API Router:",function(){it("should return an express router instance",function(){expect(salesforceAccountIndex).to.equal(routerStub)}),describe("GET /api/salesforce/accounts",function(){it("should route to salesforceAccount.controller.index",function(){expect(routerStub.get.withArgs("/","salesforceAccountCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/salesforce/accounts/:id",function(){it("should route to salesforceAccount.controller.show",function(){expect(routerStub.get.withArgs("/:id","salesforceAccountCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/salesforce/accounts",function(){it("should route to salesforceAccount.controller.create",function(){expect(routerStub.post.withArgs("/","salesforceAccountCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/salesforce/accounts/:id",function(){it("should route to salesforceAccount.controller.update",function(){expect(routerStub.put.withArgs("/:id","salesforceAccountCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/salesforce/accounts/:id",function(){it("should route to salesforceAccount.controller.update",function(){expect(routerStub.patch.withArgs("/:id","salesforceAccountCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/salesforce/accounts/:id",function(){it("should route to salesforceAccount.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","salesforceAccountCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),util=require("util"),jsforce=require("jsforce"),SalesforceAccount=require("../../models").SalesforceAccount;exports.index=function(a,b){var c=["description","name","username","remoteUri"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),SalesforceAccount.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;return b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){SalesforceAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){SalesforceAccount.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,SalesforceAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){SalesforceAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))},exports.checkAccount=function(a,b){SalesforceAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(function(a){var c=new jsforce.Connection({oauth2:{loginUrl:a.remoteUri,clientId:a.clientId,clientSecret:a.clientSecret}}),d=a.password.concat(a.securityToken);c.login(a.username,d,function(a,c){return a?b.status(400).send(a):b.sendStatus(200)})})["catch"](handleError(b))},exports.accountValidation=function(a,b){var c={};c[a.params.field]=a.body.value,SalesforceAccount.findAndCountAll({where:c}).then(function(c){return c.count?b.status(200).send({isValid:!1,value:a.body.value}):b.status(200).send({isValid:!0,value:a.body.value})})["catch"](function(a){return handleError(b,a)})},exports.getFields=function(a,b){SalesforceAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(function(a){var c=new jsforce.Connection({oauth2:{loginUrl:a.remoteUri,clientId:a.clientId,clientSecret:a.clientSecret}}),d=a.password.concat(a.securityToken);c.login(a.username,d,function(a,d){return a?b.status(400).send(a):void c.sobject("Task").describe(function(a,c){return a?b.status(400).send(a):b.status(200).send(c.fields)})})})["catch"](handleError(b))},exports.bulkDestroy=function(a,b){SalesforceAccount.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var SalesforceAccount=require("../../models").SalesforceAccount;exports.register=function(a){SalesforceAccount.afterCreate(function(b){onSave(a,b)}),SalesforceAccount.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./salesforce_configuration.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.post("/:id/:type",auth.isAuthenticated(),controller.addConfigurationField),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),salesforceConfigurationCtrlStub={index:"salesforceConfigurationCtrl.index",show:"salesforceConfigurationCtrl.show",create:"salesforceConfigurationCtrl.create",update:"salesforceConfigurationCtrl.update",destroy:"salesforceConfigurationCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},salesforceConfigurationIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./salesforce_configuration.controller":salesforceConfigurationCtrlStub});describe("SalesforceConfiguration API Router:",function(){it("should return an express router instance",function(){expect(salesforceConfigurationIndex).to.equal(routerStub)}),describe("GET /api/salesforce/configurations",function(){it("should route to salesforceConfiguration.controller.index",function(){expect(routerStub.get.withArgs("/","salesforceConfigurationCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/salesforce/configurations/:id",function(){it("should route to salesforceConfiguration.controller.show",function(){expect(routerStub.get.withArgs("/:id","salesforceConfigurationCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/salesforce/configurations",function(){it("should route to salesforceConfiguration.controller.create",function(){expect(routerStub.post.withArgs("/","salesforceConfigurationCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/salesforce/configurations/:id",function(){it("should route to salesforceConfiguration.controller.update",function(){expect(routerStub.put.withArgs("/:id","salesforceConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/salesforce/configurations/:id",function(){it("should route to salesforceConfiguration.controller.update",function(){expect(routerStub.patch.withArgs("/:id","salesforceConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/salesforce/configurations/:id",function(){it("should route to salesforceConfiguration.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","salesforceConfigurationCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),SalesforceConfiguration=require("../../models").SalesforceConfiguration,SalesforceField=require("../../models").SalesforceField;exports.index=function(a,b){SalesforceConfiguration.findAll({where:a.query}).then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){SalesforceConfiguration.find({where:{id:a.params.id},include:[{model:SalesforceField,as:"Subject"},{model:SalesforceField,as:"Description"},{model:SalesforceField,as:"Field"}]}).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){SalesforceConfiguration.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,SalesforceConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){SalesforceConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))},exports.addConfigurationField=function(a,b,c){var d;SalesforceConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(function(b){return d=b,SalesforceField.create(a.body)}).then(function(b){switch(a.params.type){case"subject":return[d.addSubject(b),b];case"description":return[d.addDescription(b),b];case"field":return[d.addField(b),b]}}).spread(function(a,c){return b.status(201).json(c)})["catch"](handleError(b))};var SalesforceConfiguration=require("../../models").SalesforceConfiguration;exports.register=function(a){SalesforceConfiguration.afterCreate(function(b){onSave(a,b)}),SalesforceConfiguration.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./salesforce_field.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create), -router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),salesforceFieldCtrlStub={index:"salesforceFieldCtrl.index",show:"salesforceFieldCtrl.show",create:"salesforceFieldCtrl.create",update:"salesforceFieldCtrl.update",destroy:"salesforceFieldCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},salesforceFieldIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./salesforce_field.controller":salesforceFieldCtrlStub});describe("SalesforceField API Router:",function(){it("should return an express router instance",function(){expect(salesforceFieldIndex).to.equal(routerStub)}),describe("GET /api/salesforce/fields",function(){it("should route to salesforceField.controller.index",function(){expect(routerStub.get.withArgs("/","salesforceFieldCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/salesforce/fields/:id",function(){it("should route to salesforceField.controller.show",function(){expect(routerStub.get.withArgs("/:id","salesforceFieldCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/salesforce/fields",function(){it("should route to salesforceField.controller.create",function(){expect(routerStub.post.withArgs("/","salesforceFieldCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/salesforce/fields/:id",function(){it("should route to salesforceField.controller.update",function(){expect(routerStub.put.withArgs("/:id","salesforceFieldCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/salesforce/fields/:id",function(){it("should route to salesforceField.controller.update",function(){expect(routerStub.patch.withArgs("/:id","salesforceFieldCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/salesforce/fields/:id",function(){it("should route to salesforceField.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","salesforceFieldCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),SalesforceField=require("../../models").SalesforceField;exports.index=function(a,b){SalesforceField.findAll().then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){SalesforceField.findById(a.params.id).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){SalesforceField.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,SalesforceField.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){SalesforceField.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))};var SalesforceField=require("../../models").SalesforceField;exports.register=function(a){SalesforceField.afterCreate(function(b){onSave(a,b)}),SalesforceField.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./setting.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/internal",auth.isAuthenticated(),controller.getInternal),router.get("/info",controller.getInfo),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),Settings=require("../../models").Settings,Agent=require("../../models").User;exports.index=function(a,b){Settings.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.getInternal=function(a,b){Settings.findOne().then(function(a){Agent.findAll({where:{internal:{$gte:a.min_internal}}}).then(function(c){var d=_.pluck(_.pluck(c,"dataValues"),"internal"),e=a.min_internal,f={value:null};do-1===d.indexOf(e)?f.value=e:e++;while(!f.value);return b.status(200).send(f)})["catch"](function(a){return console.log(a),handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.getInfo=function(a,b){var c=require("../../../package.json");return b.status(200).send({name:c.name,version:c.version,engines:c.engines})},exports.show=function(a,b){Settings.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Settings.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Settings.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Settings.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var Settings=require("../../models").Settings;exports.register=function(a){Settings.afterCreate(function(b){onSave(a,b)}),Settings.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/settings",function(){it("should respond with JSON array",function(a){request(app).get("/api/settings").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./square_odbc.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.odbcValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),SquareOdbc=require("../../models").SquareOdbc,util=require("util");exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),SquareOdbc.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.odbcValidation=function(a,b){console.log(a.body),SquareOdbc.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){SquareOdbc.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){SquareOdbc.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){SquareOdbc.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_ODBC"}):(a.body.id&&delete a.body.id,void SquareOdbc.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){SquareOdbc.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){SquareOdbc.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var SquareOdbc=require("../../models").SquareOdbc;exports.register=function(a){SquareOdbc.afterCreate(function(b){onSave(a,b)}),SquareOdbc.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/square/odbc",function(){it("should respond with JSON array",function(a){request(app).get("/api/square/odbc").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./square_project.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/download",controller.download),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.projectValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),path=require("path"),config=require("../../config/environment"),util=require("util"),SquareProject=require("../../models").SquareProject;exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),SquareProject.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.projectValidation=function(a,b){console.log(a.body),SquareProject.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){SquareProject.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){SquareProject.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,SquareProject.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){SquareProject.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){SquareProject.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.download=function(a,b,c){SquareProject.findById(a.params.id).then(function(c){return c?(console.log(a.query.filename),b.set({"Content-Disposition":'attachment; filename="'+a.query.filename+'.xml"',"Content-Type":"txt/xml"}),b.send(c.preproduction)):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var SquareProject=require("../../models").SquareProject;exports.register=function(a){SquareProject.afterCreate(function(b){onSave(a,b)}),SquareProject.afterUpdate(function(b){onSave(a,b)}),SquareProject.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/square/projects",function(){it("should respond with JSON array",function(a){request(app).get("/api/square/projects").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./sugarcrm_account.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id/check",auth.isAuthenticated(),controller.checkAccount),router.get("/:id/fields",auth.isAuthenticated(),controller.getFields),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/validate/:field",auth.isAuthenticated(),controller.accountValidation),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),sugarcrmAccountCtrlStub={index:"sugarcrmAccountCtrl.index",show:"sugarcrmAccountCtrl.show",create:"sugarcrmAccountCtrl.create",update:"sugarcrmAccountCtrl.update",destroy:"sugarcrmAccountCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},sugarcrmAccountIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./sugarcrm_account.controller":sugarcrmAccountCtrlStub});describe("SugarcrmAccount API Router:",function(){it("should return an express router instance",function(){expect(sugarcrmAccountIndex).to.equal(routerStub)}),describe("GET /api/sugarcrm/accounts",function(){it("should route to sugarcrmAccount.controller.index",function(){expect(routerStub.get.withArgs("/","sugarcrmAccountCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/sugarcrm/accounts/:id",function(){it("should route to sugarcrmAccount.controller.show",function(){expect(routerStub.get.withArgs("/:id","sugarcrmAccountCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/sugarcrm/accounts",function(){it("should route to sugarcrmAccount.controller.create",function(){expect(routerStub.post.withArgs("/","sugarcrmAccountCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/sugarcrm/accounts/:id",function(){it("should route to sugarcrmAccount.controller.update",function(){expect(routerStub.put.withArgs("/:id","sugarcrmAccountCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/sugarcrm/accounts/:id",function(){it("should route to sugarcrmAccount.controller.update",function(){expect(routerStub.patch.withArgs("/:id","sugarcrmAccountCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/sugarcrm/accounts/:id",function(){it("should route to sugarcrmAccount.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","sugarcrmAccountCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),util=require("util"),SugarcrmAccount=require("../../models").SugarcrmAccount;exports.index=function(a,b){var c=["description","name","username","remoteUri"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),SugarcrmAccount.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;return b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){SugarcrmAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){SugarcrmAccount.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,SugarcrmAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){SugarcrmAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))},exports.checkAccount=function(a,b){SugarcrmAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(function(a){var c=require("node-sugarcrm-client");c.init({apiURL:stripTrailingSlash(a.remoteUri)+"/service/v4_1/rest.php",login:a.username,passwd:a.password}),c.login(function(a){return a?b.sendStatus(200):b.sendStatus(400)})})["catch"](handleError(b))},exports.bulkDestroy=function(a,b){SugarcrmAccount.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.accountValidation=function(a,b){var c={};c[a.params.field]=a.body.value,SugarcrmAccount.findAndCountAll({where:c}).then(function(c){return c.count?b.status(200).send({isValid:!1,value:a.body.value}):b.status(200).send({isValid:!0,value:a.body.value})})["catch"](function(a){return handleError(b,a)})},exports.getFields=function(a,b){var c=require("node-sugarcrm-client");SugarcrmAccount.findById(a.params.id).then(handleEntityNotFound(b)).then(function(a){c.init({apiURL:stripTrailingSlash(a.remoteUri)+"/service/v4_1/rest.php",login:a.username,passwd:a.password}),c.login(function(a){if(!a)return b.sendStatus(400);var d={session:a,module_name:"Cases"};c.call("get_module_fields",d,function(a,c){return c?b.sendStatus(400):b.status(200).send(a.module_fields)})})})["catch"](handleError(b))};var SugarcrmAccount=require("../../models").SugarcrmAccount;exports.register=function(a){SugarcrmAccount.afterCreate(function(b){onSave(a,b)}),SugarcrmAccount.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./sugarcrm_configuration.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.post("/:id/:type",auth.isAuthenticated(),controller.addConfigurationField),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),sugarcrmConfigurationCtrlStub={index:"sugarcrmConfigurationCtrl.index",show:"sugarcrmConfigurationCtrl.show",create:"sugarcrmConfigurationCtrl.create",update:"sugarcrmConfigurationCtrl.update",destroy:"sugarcrmConfigurationCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},sugarcrmConfigurationIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./sugarcrm_configuration.controller":sugarcrmConfigurationCtrlStub});describe("SugarcrmConfiguration API Router:",function(){it("should return an express router instance",function(){expect(sugarcrmConfigurationIndex).to.equal(routerStub)}),describe("GET /api/sugarcrm/configurations",function(){it("should route to sugarcrmConfiguration.controller.index",function(){expect(routerStub.get.withArgs("/","sugarcrmConfigurationCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/sugarcrm/configurations/:id",function(){it("should route to sugarcrmConfiguration.controller.show",function(){expect(routerStub.get.withArgs("/:id","sugarcrmConfigurationCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/sugarcrm/configurations",function(){it("should route to sugarcrmConfiguration.controller.create",function(){expect(routerStub.post.withArgs("/","sugarcrmConfigurationCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/sugarcrm/configurations/:id",function(){it("should route to sugarcrmConfiguration.controller.update",function(){expect(routerStub.put.withArgs("/:id","sugarcrmConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/sugarcrm/configurations/:id",function(){it("should route to sugarcrmConfiguration.controller.update",function(){expect(routerStub.patch.withArgs("/:id","sugarcrmConfigurationCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/sugarcrm/configurations/:id",function(){it("should route to sugarcrmConfiguration.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","sugarcrmConfigurationCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),SugarcrmConfiguration=require("../../models").SugarcrmConfiguration,SugarcrmField=require("../../models").SugarcrmField;exports.index=function(a,b){SugarcrmConfiguration.findAll({where:a.query}).then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){SugarcrmConfiguration.find({where:{id:a.params.id},include:[{model:SugarcrmField,as:"Subject"},{model:SugarcrmField,as:"Description"},{model:SugarcrmField,as:"Field"}]}).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){SugarcrmConfiguration.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,SugarcrmConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){SugarcrmConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))},exports.addConfigurationField=function(a,b,c){var d;SugarcrmConfiguration.findById(a.params.id).then(handleEntityNotFound(b)).then(function(b){return d=b,SugarcrmField.create(a.body)}).then(function(b){switch(a.params.type){case"subject":return[d.addSubject(b),b];case"description":return[d.addDescription(b),b];case"field":return[d.addField(b),b]}}).spread(function(a,c){return b.status(201).json(c)})["catch"](handleError(b))};var SugarcrmConfiguration=require("../../models").SugarcrmConfiguration;exports.register=function(a){SugarcrmConfiguration.afterCreate(function(b){onSave(a,b)}),SugarcrmConfiguration.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./sugarcrm_field.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var proxyquire=require("proxyquire").noPreserveCache(),sugarcrmFieldCtrlStub={index:"sugarcrmFieldCtrl.index",show:"sugarcrmFieldCtrl.show",create:"sugarcrmFieldCtrl.create",update:"sugarcrmFieldCtrl.update",destroy:"sugarcrmFieldCtrl.destroy"},routerStub={get:sinon.spy(),put:sinon.spy(),patch:sinon.spy(),post:sinon.spy(),"delete":sinon.spy()},sugarcrmFieldIndex=proxyquire("./index.js",{express:{Router:function(){return routerStub}},"./sugarcrm_field.controller":sugarcrmFieldCtrlStub});describe("SugarcrmField API Router:",function(){it("should return an express router instance",function(){expect(sugarcrmFieldIndex).to.equal(routerStub)}),describe("GET /api/sugarcrm/fields",function(){it("should route to sugarcrmField.controller.index",function(){expect(routerStub.get.withArgs("/","sugarcrmFieldCtrl.index")).to.have.been.calledOnce})}),describe("GET /api/sugarcrm/fields/:id",function(){it("should route to sugarcrmField.controller.show",function(){expect(routerStub.get.withArgs("/:id","sugarcrmFieldCtrl.show")).to.have.been.calledOnce})}),describe("POST /api/sugarcrm/fields",function(){it("should route to sugarcrmField.controller.create",function(){expect(routerStub.post.withArgs("/","sugarcrmFieldCtrl.create")).to.have.been.calledOnce})}),describe("PUT /api/sugarcrm/fields/:id",function(){it("should route to sugarcrmField.controller.update",function(){expect(routerStub.put.withArgs("/:id","sugarcrmFieldCtrl.update")).to.have.been.calledOnce})}),describe("PATCH /api/sugarcrm/fields/:id",function(){it("should route to sugarcrmField.controller.update",function(){expect(routerStub.patch.withArgs("/:id","sugarcrmFieldCtrl.update")).to.have.been.calledOnce})}),describe("DELETE /api/sugarcrm/fields/:id",function(){it("should route to sugarcrmField.controller.destroy",function(){expect(routerStub["delete"].withArgs("/:id","sugarcrmFieldCtrl.destroy")).to.have.been.calledOnce})})});var _=require("lodash"),SugarcrmField=require("../../models").SugarcrmField;exports.index=function(a,b){SugarcrmField.findAll().then(responseWithResult(b))["catch"](handleError(b))},exports.show=function(a,b){SugarcrmField.findById(a.params.id).then(handleEntityNotFound(b)).then(responseWithResult(b))["catch"](handleError(b))},exports.create=function(a,b){SugarcrmField.create(a.body).then(responseWithResult(b,201))["catch"](handleError(b))},exports.update=function(a,b){a.body.id&&delete a.body.id,SugarcrmField.findById(a.params.id).then(handleEntityNotFound(b)).then(saveUpdates(a.body)).then(responseWithResult(b))["catch"](handleError(b))},exports.destroy=function(a,b){SugarcrmField.findById(a.params.id).then(handleEntityNotFound(b)).then(removeEntity(b))["catch"](handleError(b))};var SugarcrmField=require("../../models").SugarcrmField;exports.register=function(a){SugarcrmField.afterCreate(function(b){onSave(a,b)}),SugarcrmField.afterDestroy(function(b){onRemove(a,b)})};var express=require("express"),controller=require("./tag.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.tagValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),Tag=require("../../models").Tag,util=require("util");exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),console.log(f),Tag.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.tagValidation=function(a,b){console.log(a.body),Tag.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Tag.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Tag.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){Tag.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_TAG"}):(a.body.id&&delete a.body.id,void Tag.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Tag.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Tag.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Tag=require("../../models").Tag;exports.register=function(a){Tag.afterCreate(function(b){onSave(a,b)}),Tag.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/tags",function(){it("should respond with JSON array",function(a){request(app).get("/api/tags").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./team.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/:id/agents",auth.isAuthenticated(),controller.addAgents),router.put("/:id",auth.isAuthenticated(),controller.update),router.put("/:id/agents",auth.isAuthenticated(),controller.removeAgents),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy), -router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),Team=require("../../models").Team,User=require("../../models").User;exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},include:[{all:!0}],limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),Team.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){Team.find({where:{id:a.params.id},include:[User]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Team.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Team.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Team.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Team.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.addAgents=function(a,b,c){Team.findById(a.params.id).then(function(d){return d?void d.addUsers(a.body.agents).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)}):c(new Error("no mail queue found"))})["catch"](function(a){return c(a)})},exports.removeAgents=function(a,b,c){Team.findById(a.params.id).then(function(d){return d?void d.removeUsers(a.body.agents).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)}):c(new Error("no mail queue found"))})["catch"](function(a){return c(a)})};var team=require("../../models").Team;exports.register=function(a){team.afterCreate(function(b){onSave(a,b)}),team.afterUpdate(function(b){onSave(a,b)}),team.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/teams",function(){it("should respond with JSON array",function(a){request(app).get("/api/teams").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./thing.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),Thing=require("../../models").Thing;exports.index=function(a,b,c){Thing.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return c(a)})},exports.show=function(a,b,c){Thing.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return c(a)})},exports.create=function(a,b,c){Thing.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return c(a)})},exports.update=function(a,b,c){a.body.id&&delete a.body.id,Thing.findById(a.params.id).then(function(d){if(!d)return b.sendStatus(404);var e=_.merge(d,a.body);e.save().then(function(){return b.status(200).send(d)})["catch"](function(a){return c(a)})})["catch"](function(a){return c(a)})},exports.destroy=function(a,b,c){Thing.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return c(a)}):b.sendStatus(404)})["catch"](function(a){return c(a)})};var thing=require("../../models").Thing;exports.register=function(a){thing.afterCreate(function(b){onSave(a,b)}),thing.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/things",function(){it("should respond with JSON array",function(a){request(app).get("/api/things").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./trigger.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),module.exports=router;var _=require("lodash"),util=require("util"),Trigger=require("../../models").Trigger;exports.index=function(a,b,c){var d=["fullname","name","email"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),Trigger.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){Trigger.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Trigger.create(a.body).then(function(){return b.sendStatus(201)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b,c){a.body.id&&delete a.body.id,Trigger.findById(a.params.id).then(function(d){if(!d)return b.sendStatus(404);var e=_.merge(d,a.body);e.save().then(function(){return b.status(200).send(d)})["catch"](function(a){return c(a)})})["catch"](function(a){return c(a)})},exports.destroy=function(a,b){Trigger.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Trigger.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Trigger=require("../../models").Trigger;exports.register=function(a){Trigger.afterCreate(function(b){onSave(a,b)}),Trigger.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/triggers",function(){it("should respond with JSON array",function(a){request(app).get("/api/triggers").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./trunk.controller"),config=require("../../config/environment"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.trunkValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var fs=require("fs"),util=require("util"),path=require("path"),config=require("../../config/environment"),Trunk=require("../../models").Trunk,VoiceExtension=require("../../models").VoiceExtension,_=require("lodash");exports.register=function(a){Trunk.afterCreate(function(b){console.log("create trunk hook"),trunksRewrite(b,a,!1)}),Trunk.afterUpdate(function(b){console.log("update trunk hook"),trunksRewrite(b,a,!1)}),Trunk.afterDelete(function(b){console.log("delete trunk hook"),trunksRewrite(b,a,!0)})};var _=require("lodash"),Trunk=require("../../models").Trunk,VoiceExtension=require("../../models").VoiceExtension,sequelize=require("../../models").sequelize,util=require("util");exports.index=function(a,b,c){var d=["name","host","context","description"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;case"role":g.where.role={$or:b.split(/[\s,]+/)};break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),Trunk.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){Trunk.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.trunkValidation=function(a,b){console.log(a.body),Trunk.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Trunk.findAll({where:{name:a.body.name}}).then(function(c){return console.log(c),console.log("Finding app row....."),c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_TRUNK"}):void Trunk.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return console.log("trunks create",a),handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return console.log("trunks findall",a),handleError(b,a)})},exports.update=function(a,b,c){Trunk.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(d){return console.log(d),console.log("Finding app row....."),d?d.length>0?b.status(500).send({message:"MESSAGE_EXIST_TRUNK"}):(a.body.id&&delete a.body.id,void Trunk.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);return sequelize.transaction(function(a){return d.save({transaction:a}).then(function(c){return VoiceExtension.update({trunk:c.name,cutdigits:sequelize.literal("cutdigits")},{where:{TrunkId:c.id}},{transaction:a}).then(function(){return b.status(200).send(c)})})})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return c(a)})):b.sendStatus(404)})["catch"](function(a){return c(a)})},exports.destroy=function(a,b){Trunk.findById(a.params.id).then(function(a){return a?void a.getVoiceExtensions({where:{isApp:!0}}).then(function(c){return console.log(c.length),c.length>0?b.status(500).send({message:"MESSAGE_TRUNK_OUTBOUND_ASSOCIATED"}):void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){var c=!1;Trunk.findAll({where:{id:a.query.id},include:[{all:!0}]}).then(function(d){return d?(d.forEach(function(a){a.VoiceExtensions.length>0&&(c=!0)}),c?b.status(500).send({message:"MESSAGE_TRUNK_OUTBOUND_ASSOCIATED"}):void Trunk.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var Trunk=require("../../models").User;exports.register=function(a){Trunk.afterCreate(function(b){onSave(a,b)}),Trunk.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/trunks",function(){it("should respond with JSON array",function(a){request(app).get("/api/trunks").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./update.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),auth.hasRole("admin"),controller.index),router.get("/pull",auth.isAuthenticated(),auth.hasRole("admin"),controller.pull),module.exports=router;var _=require("lodash"),path=require("path"),config=require("../../config/environment"),Git=require("simple-git")(path.join(config.root)),Update=require("../../models").Update;exports.index=function(a,b){Git.log(function(a,c){if(a)return handleError(b,a);var d=[];return c.all.forEach(function(a){a.version=a.message.split("|")[1]||"unknown",a.message=a.message.split("|")[0],d.push(a)}),console.log("Latest available tag: %s",c.latest),b.status(200).send(d)})},exports.show=function(a,b){},exports.pull=function(a,b){Git.pull(function(a,c){return a?handleError(b,a):b.status(201).send(c)})},exports.checkout=function(a,b){console.log("req.params.hash",a.params.hash),Git.checkout(a.params.hash,function(a,c){return a?handleError(b,a):b.status(201).send(c)})},exports.create=function(a,b){Update.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,Update.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Update.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},module.exports=function(a,b){var c=a.define("Update",{name:b.STRING,description:b.STRING});return c};var Update=require("../../models").Update;exports.register=function(a){Update.afterCreate(function(b){onSave(a,b)}),Update.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/updates",function(){it("should respond with JSON array",function(a){request(app).get("/api/updates").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./upload.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.download),router.get("/stream/:id",auth.isAuthenticated(),controller.stream),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),Upload=require("../../models").Upload,uploadFile=require("upload-file"),sr=require("simple-random"),sox=require("sox"),path=require("path"),config=require("../../config/environment"),fs=require("fs"),sequelize=require("../../models").sequelize,base64=require("file-base64");exports.index=function(a,b){Upload.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Upload.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){var c=new uploadFile({dest:path.join(config.root,"server/files/sounds/original"),maxFileSize:15e6,maxNumberOfFiles:10,minNumberOfFiles:0,acceptFileTypes:/(\.|\/)(wav|mp3|gsm|ogg)$/i,rename:function(a,b){return sr()+path.extname(b.filename)},messages:{maxNumberOfFiles:"Max number of files upload exceeded",acceptFileTypes:"Only wav,mp3,gsm, and ogg format accepted",maxFileSize:"The maximum file size is 15 Mb",invalidRequest:"Invalid request"}});c.on("end",function(a,d){var e={};if(e.description="",e.name=e.display_name=path.basename(d.file.path,path.extname(d.file.filename)),e.save_name=path.basename(d.file.filename,path.extname(d.file.filename)),e.original_path=path.join(config.root,"server/files/sounds/original"),e.converted_path=path.join(config.root,"server/files/sounds/converted"),!d.file.filename)return b.status(500).send(c);var f=path.join(e.original_path,e.save_name+path.extname(d.file.filename)),g=path.join(e.converted_path,e.save_name+".wav");fs.chmodSync(f,parseInt("0777",8)),sox.identify(f,function(a,b){console.log("************** Result: ",b)});var h=sox.transcode(f,g,{sampleRate:8e3,format:"wav",channelCount:1,bitRate:196608,compressionQuality:5});h.on("error",function(a){return console.error("********** Conversion Error: ",a),fs.unlink(f,function(a){return a?handleError(b,a):void 0}),handleError(b,a)}),h.on("progress",function(a,b){}),h.on("src",function(a){e.original_format=a.format,e.original_duration=1e3*a.duration,e.original_sampleCount=a.sampleCount,e.original_channelCount=a.channelCount,e.original_bitRate=a.bitRate,e.original_sampleRate=a.sampleRate}),h.on("dest",function(a){e.converted_format=a.format,e.converted_duration=1e3*a.duration,e.converted_sampleCount=a.sampleCount,e.converted_channelCount=a.channelCount,e.converted_bitRate=a.bitRate,e.converted_sampleRate=a.sampleRate}),h.on("end",function(){console.log("Conversion completed"),fs.chmodSync(g,parseInt("0777",8)),Upload.create(e).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})}),h.start()}),c.on("error",function(a){return console.log("********** Upload error :",a),handleError(b,a)}),c.parse(a)},exports.update=function(a,b){a.body.id&&delete a.body.id,Upload.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Upload.findById(a.params.id).then(function(a){if(!a)return b.status(404).send(a);var c=path.join(a.original_path,a.save_name+"."+a.original_format),d=path.join(a.converted_path,a.save_name+"."+a.converted_format);return sequelize.transaction(function(e){return a.destroy({transaction:e}).then(function(){return fs.unlink(c,function(a){return a?handleError(b,a):void 0}),fs.unlink(d,function(a){return a?handleError(b,a):void 0}),b.status(200).send(a)})})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.download=function(a,b){Upload.findById(a.params.id).then(function(a){if(!a)return b.status(404).send(a);var c=path.join(a.original_path,a.save_name+"."+a.original_format);b.status(200).download(c,a.display_name+"."+a.original_format,function(a){return a?handleError(b,a):void console.log("Sent file under :",c)})})},exports.stream=function(a,b){Upload.findById(a.params.id).then(function(a){if(!a)return b.status(404).send(a);var c=path.join(a.converted_path,a.save_name+"."+a.original_format);base64.encode(c,function(a,c){return a?(console.log(a),handleError(b,a)):b.status(200).send(c)})})};var upload=require("../../models").Upload;exports.register=function(a){upload.afterCreate(function(b){onSave(a,b)}),upload.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/uploads",function(){it("should respond with JSON array",function(a){request(app).get("/api/uploads").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./user.controller"),config=require("../../config/environment"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/me",auth.isAuthenticated(),controller.me),router.get("/all",auth.isAuthenticated(),controller.getUsers),router.get("/avatar/:filename",controller.getAvatar),router.get("/:id/avatar",controller.getAvatarById),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/validate/:field",auth.isAuthenticated(),controller.userValidation),router.put("/password",auth.isAuthenticated(),controller.changePassword),router.put("/password/:id/reset",auth.isAuthenticated(),auth.hasRole("admin"),controller.resetPassword),router.put("/:id",auth.isAuthenticated(),controller.update),router.post("/",auth.isAuthenticated(),controller.create),router.post("/:id/avatar",auth.isAuthenticated(),controller.changeAvatar),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var fs=require("fs"),util=require("util"),path=require("path"),config=require("../../config/environment"),User=require("../../models").User,VoiceExtension=require("../../models").VoiceExtension;exports.register=function(a){User.afterCreate(function(a){createCallerID(a),createExtension(a)}),User.afterUpdate(function(a){updateExtension(a),createCallerID(a)})};var User=require("../../models").User,Module=require("../../models").Module,config=require("../../config/environment"),passport=require("passport"),moment=require("moment"),jwt=require("jsonwebtoken"),uploadFile=require("upload-file"),path=require("path"),fs=require("fs"),_=require("lodash"),util=require("util"),sr=require("simple-random");exports.index=function(a,b,c){var d=["fullname","name","email","role"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{role:["admin","user"]},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),User.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;return b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){return b.status(500).send({error:"Something blew up!"})})},exports.getUsers=function(a,b,c){User.findAll({where:{role:{$in:["admin","user","agent"]}}}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){var d=a.body;_(d).keys().sort().each(function(a){d[a]});var e=User.build(a.body);e.provider="local",e.save().then(function(a){var c=jwt.sign({id:a.id},config.session.secret,{expiresIn:"5h"});return b.status(201).send({token:c})})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b,c){User.findById(a.params.id).then(function(a){return a?b.status(200).send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b,c){var d=a.params.id;User.findById(d).then(function(a){return a?void a.destroy().then(function(a){return console.log(a),b.status(200).send(a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.changePassword=function(a,b,c){var d=a.user.id,e=String(a.body.oldPassword),f=String(a.body.newPassword);User.findById(d).then(function(a){return a.authenticate(e)?(a.password=f,void a.save().then(function(){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})):b.sendStatus(403)})},exports.resetPassword=function(a,b,c){var d=String(a.body.newPassword);User.findById(a.params.id).then(function(a){a.password=d,a.save().then(function(){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})})},exports.changeAvatar=function(a,b,c){var d=new uploadFile({dest:path.join(config.root,"server","files","images"),maxNumberOfFiles:1,minNumberOfFiles:0,acceptFileTypes:/(\.|\/)(jpeg|png)$/i,rename:function(a,b){return sr()+path.extname(b.filename)},messages:{maxNumberOfFiles:"Max number of files upload exceeded",acceptFileTypes:"Only jpeg and png format accepted",invalidRequest:"Invalid request"}});d.on("end",function(c,e){return e.file.filename?void User.findById(a.params.id).then(function(a){return a?void a.updateAttributes({userpic:e.file.filename}).then(function(){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)}):b.status(500).send(d)}),d.on("error",function(a){return console.log("********** Upload error :",a),handleError(b,a)}),d.parse(a)},exports.me=function(a,b,c){var d=a.user.id;User.findOne({where:{id:d},attributes:["id","fullname","name","email","role","userpic"],include:[Module]}).then(function(a){return a?b.status(200).send(a):b.sendStatus(401)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b,c){a.user.id;User.findById(a.params.id).then(function(c){return c?void c.updateAttributes(a.body).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(500)})["catch"](function(a){return handleError(b,a)})},exports.getAvatar=function(a,b,c){var d=path.join(config.root,"server","files","images",a.params.filename);fs.exists(d,function(a){return a||(d=path.join(config.root,"server","files","images","userpic.png")),b.sendFile(d)})},exports.getAvatarById=function(a,b,c){if("visitor"===a.params.id){var d=path.join(config.root,"server","files","images","customer.png");fs.exists(d,function(a){return b.sendFile(d)})}else User.findById(a.params.id).then(function(a){if(!a)return b.sendStatus(500);var c=path.join(config.root,"server","files","images",a.userpic?a.userpic:"userpic.png");fs.exists(c,function(a){return a||(c=path.join(config.root,"server","files","images","userpic.png")),b.sendFile(c)})})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){User.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.userValidation=function(a,b){var c={};c[a.params.field]=a.body.value,User.findAndCountAll({where:c}).then(function(c){return c.count?b.status(200).send({isValid:!1,value:a.body.value}):b.status(200).send({isValid:!0,value:a.body.value})})["catch"](function(a){return handleError(b,a)})},exports.authCallback=function(a,b,c){b.redirect("/")};var user=require("../../models").User;exports.register=function(a){user.afterCreate(function(b){onSave(a,b)}),user.afterUpdate(function(b){onSave(a,b)}),user.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/users",function(){it("should respond with JSON array",function(a){request(app).get("/api/users").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./user_has_chat_queue.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),UserHasChatQueue=require("../../models").UserHasChatQueue;exports.index=function(a,b){UserHasChatQueue.findAll(a.query?{where:a.query}:{}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){UserHasChatQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){UserHasChatQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,UserHasChatQueue.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){UserHasChatQueue.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var UserHasChatQueue=require("../../models").UserHasChatQueue;exports.register=function(a){UserHasChatQueue.afterCreate(function(b){onSave(a,b)}),UserHasChatQueue.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/chat/user_has_queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/chat/user_has_queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./user_has_chat_room.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.put("/:userId/:chatRoomId",controller.update),module.exports=router;var _=require("lodash"),UserHasChatRoom=require("../../models").UserHasChatRoom;exports.index=function(a,b){UserHasChatRoom.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){UserHasChatRoom.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){UserHasChatRoom.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){UserHasChatRoom.findOne({ -where:{UserId:a.params.userId,ChatRoomId:a.params.chatRoomId},limit:1}).then(function(c){return c?void c.updateAttributes(a.body).then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){UserHasChatRoom.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var _=require("lodash"),User=require("../../models").User,ChatRoom=require("../../models").ChatRoom,ChatVisitor=require("../../models").ChatVisitor,UserHasChatRoom=require("../../models").UserHasChatRoom;exports.register=function(a){UserHasChatRoom.afterCreate(function(b){onSave(a,b)}),UserHasChatRoom.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/chat/user_has_rooms",function(){it("should respond with JSON array",function(a){request(app).get("/api/chat/user_has_rooms").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./user_has_fax_queue.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),UserHasFaxQueue=require("../../models").UserHasFaxQueue;exports.index=function(a,b){UserHasFaxQueue.findAll(a.query?{where:a.query}:{}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){UserHasFaxQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){UserHasFaxQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,UserHasFaxQueue.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){UserHasFaxQueue.find({where:{id:a.params.id}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var UserHasFaxQueue=require("../../models").UserHasFaxQueue;exports.register=function(a){UserHasFaxQueue.afterCreate(function(b){onSave(a,b)}),UserHasFaxQueue.afterDestroy(function(b){onRemove(a,b)}),UserHasFaxQueue.afterBulkCreate(function(b){onSave(a,b)}),UserHasFaxQueue.afterBulkDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/fax/user_has_queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/fax/user_has_queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./user_has_mail_queue.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),UserHasMailQueue=require("../../models").UserHasMailQueue;exports.index=function(a,b){UserHasMailQueue.findAll(a.query?{where:a.query}:{}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){UserHasMailQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){UserHasMailQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,UserHasMailQueue.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){UserHasMailQueue.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var UserHasMailQueue=require("../../models").UserHasMailQueue;exports.register=function(a){UserHasMailQueue.afterCreate(function(b){onSave(a,b)}),UserHasMailQueue.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/mail/user_has_queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/mail/user_has_queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./user_has_team.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),UserHasTeam=require("../../models").UserHasTeam;exports.index=function(a,b){console.log(a.query),UserHasTeam.findAll({where:a.query}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){UserHasTeam.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){UserHasTeam.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,UserHasTeam.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){UserHasTeam.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},module["export"]=function(a,b){var c=a.define("UserHasTeam",{name:String,info:String,active:Boolean});return c};var user_has_team=require("../../models").UserHasTeam;exports.register=function(a){user_has_team.afterCreate(function(b){onSave(a,b)}),user_has_team.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/user_has_teams",function(){it("should respond with JSON array",function(a){request(app).get("/api/user_has_teams").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./user_has_voice_queue.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),UserHasVoiceQueue=require("../../models").UserHasVoiceQueue;exports.index=function(a,b){UserHasVoiceQueue.findAll(a.query?{where:a.query}:{}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){UserHasVoiceQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b,c){console.log(a.body),UserHasVoiceQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return console.error(a),c(a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,UserHasVoiceQueue.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){UserHasVoiceQueue.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var UserHasVoiceQueue=require("../../models").UserHasVoiceQueue;exports.register=function(a){UserHasVoiceQueue.afterCreate(function(b){onSave(a,b)}),UserHasVoiceQueue.afterUpdate(function(b){onSave(a,b)}),UserHasVoiceQueue.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/voice/user_has_queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/voice/user_has_queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./variable.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.variableValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),Variable=require("../../models").Variable,util=require("util");exports.index=function(a,b){var c=["name","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),Variable.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.variableValidation=function(a,b){console.log(a.body),Variable.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){Variable.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){Variable.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){Variable.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_VARIABLE"}):(a.body.id&&delete a.body.id,void Variable.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){Variable.findById(a.params.id).then(function(a){return a?void a.getZendeskTexts().then(function(c){return c.length>0?b.status(500).send({message:"MESSAGE_VARIABLE_CONFIGURATION_ASSOCIATED"}):void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){Variable.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var Variable=require("../../models").Variable;exports.register=function(a){Variable.afterCreate(function(b){onSave(a,b)}),Variable.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/variables",function(){it("should respond with JSON array",function(a){request(app).get("/api/variables").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./voice_context.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.contextValidation),router.put("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var VoiceContext=require("../../models").VoiceContext,fs=require("fs"),util=require("util"),path=require("path"),config=require("../../config/environment");exports.register=function(a){VoiceContext.beforeUpdate(function(a){if(a.changed("name"))throw new Error("You can't modify a context name");if(a.defaultEntry)throw new Error("You can't modify a default context")}),VoiceContext.beforeDelete(function(a){if(a.defaultEntry)throw new Error("You can't delete a default context")}),VoiceContext.afterCreate(function(b){rewriteContexts(b,a,!1)}),VoiceContext.afterDelete(function(b){rewriteContexts(b,a,!0)})};var _=require("lodash"),util=require("util"),sequelize=require("../../models").sequelize,VoiceContext=require("../../models").VoiceContext,VoiceExtension=require("../../models").VoiceExtension;exports.index=function(a,b,c){var d=["name","description"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),VoiceContext.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){VoiceContext.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.contextValidation=function(a,b){console.log(a.body),VoiceContext.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){VoiceContext.findAll({where:{name:a.body.name}}).then(function(c){return console.log(c),console.log("Finding app row....."),c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_ROUTE"}):void VoiceContext.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){VoiceContext.findAll({where:{name:a.body.name,id:{$ne:a.body.id}}}).then(function(c){return console.log(c),console.log("Finding app row....."),c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_ROUTE"}):(a.body.id&&delete a.body.id,void VoiceContext.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){VoiceContext.findById(a.params.id).then(function(a){return a?void VoiceExtension.findAll({where:{context:a.name}}).then(function(c){return c.length>0?b.status(500).send({message:"MESSAGE_CONTEXT_ROUTE_ASSOCIATED"}):void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){VoiceContext.findAll({where:{id:a.query.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.pluck(_.pluck(c,"dataValues"),"name");VoiceExtension.findAll({where:{context:d}}).then(function(c){return c.length>0?b.status(500).send({message:"MESSAGE_CONTEXT_ROUTE_ASSOCIATED"}):void VoiceContext.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})};var VoiceContext=require("../../models").VoiceContext;exports.register=function(a){VoiceContext.afterCreate(function(b){onSave(a,b)}),VoiceContext.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/voice/contexts",function(){it("should respond with JSON array",function(a){request(app).get("/api/voice/contexts").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./voice_extension.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/route/:route",auth.isAuthenticated(),controller.showByRoute),router.get("/applications/:id",auth.isAuthenticated(),controller.show),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/applications",auth.isAuthenticated(),controller.showAppsByRoute),router.post("/validate",auth.isAuthenticated(),controller.routeValidation),router.post("/:id/applications",auth.isAuthenticated(),controller.sortAppsByRoute),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.put("/applications/:id",auth.isAuthenticated(),controller.updateApplication),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),VoiceExtension=require("../../models").VoiceExtension,Interval=require("../../models").Interval,sequelize=require("../../models").sequelize,Sequelize=require("../../models").Sequelize,util=require("util"),async=require("async"),Applications={Dial:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"Set",appdata:"CALLERID(all)=%s"},{app:"Dial",appdata:"%s,%s,%s,%s",isApp:!0},{app:"NoOp",appdata:"Dial Application End"}],Queue:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"Answer",appdata:""},{app:"Queue",appdata:"%s,%s,%s,%s,%s",isApp:!0},{app:"NoOp",appdata:"Queue Application End"}],Playback:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"Playback",appdata:"%s,%s",isApp:!0},{app:"NoOp",appdata:"Playback Application End"}],AGI:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"AGI",appdata:"agi://127.0.0.1/square,%s",isApp:!0},{app:"NoOp",appdata:"AGI Application End"}],Goto:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"Goto",appdata:"%s,%s,%d",isApp:!0},{app:"NoOp",appdata:"Goto Application End"}],Hangup:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"Hangup",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Hangup Application End"}],Set:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"Set",appdata:"%s=%s",isApp:!0},{app:"NoOp",appdata:"Set Application End"}],custom:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"custom",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Custom Application End"}],Voicemail:[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"Voicemail",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Voicemail Application End"}]};exports.index=function(a,b){VoiceExtension.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.showByRoute=function(a,b,c){var d=["context","exten","app","appdata"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{type:a.params.route,VoiceExtensionId:null,app:"NoOp"},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),VoiceExtension.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){b.status(500).send({error:"Something blew up!"})})},exports.showAppsByRoute=function(a,b){VoiceExtension.findAll({where:{VoiceExtensionId:a.params.id,isApp:!0}}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){VoiceExtension.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.routeValidation=function(a,b){VoiceExtension.findAll({where:{exten:a.body.exten,context:a.body.context,type:a.body.type}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.sortAppsByRoute=function(a,b,c){VoiceExtension.findAll({where:{appGroup:a.body.applications}}).then(function(c){return sequelize.transaction(function(b){return VoiceExtension.destroy({where:{appGroup:a.body.applications}},{transaction:b}).then(function(){var d=2;a.body.applications.forEach(function(a){var e=_.find(c,function(b){return b.appGroup==a&&b.isApp===!0}),f=_.cloneDeep(Applications[e.app]);(!f||e.customApp)&&(f=[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"custom",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Custom Application End"}]);var g=util.format("%s%s%s",e.context,e.exten,d);e.interval=e.interval||"*,*,*,*";var h=_.filter(c,function(b){return b.appGroup==a&&b.isInterval===!0});return h&&h.length>0&&(f.splice(0,1),h.forEach(function(a,b){f.unshift({app:"GotoIfTimeFromArray",appdata:a.interval+"?%s,${EXTEN},%s:%s,${EXTEN},%s",IntervalId:a.IntervalId?a.IntervalId:null,isInterval:!0,interval:a.interval})})),d=appCreate(f,e,g,h||[],d),VoiceExtension.bulkCreate(f,{transaction:b})})})}).then(function(){return b.sendStatus(201)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return c(a)})},exports.create=function(a,b,c){var d,e;VoiceExtension.max("priority",{where:{VoiceExtensionId:a.body.VoiceExtensionId}}).then(function(c){a.body.VoiceExtensionId?(a.body.priority=c?++c:2,d=_.cloneDeep(Applications[a.body.app]),(!d||a.body.customApp)&&(d=[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"custom",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Custom Application End"}]),e=util.format("%s%s%s",a.body.context,a.body.exten,a.body.priority),a.body.interval=a.body.interval||"*,*,*,*",Interval.findAll({where:{IntervalId:null!==a.body.IntervalId?a.body.IntervalId:0}}).then(function(c){var f,g=[];c&&c.length>0&&(d.splice(0,1),g=_.pluck(c,"dataValues"),g.forEach(function(a,b){d.unshift({app:"GotoIfTimeFromArray",appdata:a.interval+"?%s,${EXTEN},%s:%s,${EXTEN},%s",IntervalId:a.id,interval:f,isInterval:!0})})),appCreate(d,a.body,e,g),VoiceExtension.bulkCreate(d).then(function(a){return b.status(201).send(a)})})):VoiceExtension.findAll({where:{exten:a.body.exten,context:a.body.context,type:a.body.type}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_ROUTE"}):(a.body.priority=1,void VoiceExtension.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return b.handleError(a)})):b.sendStatus(404)})["catch"](function(a){return b.handleError(a)})})["catch"](function(a){c(a)})},exports.update=function(a,b){VoiceExtension.findAll({where:{exten:a.body.exten,context:a.body.context,type:a.body.type,VoiceExtensionId:null,id:{$ne:a.body.id}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_ROUTE"}):(a.body.id&&delete a.body.id,void VoiceExtension.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);return sequelize.transaction(function(a){return d.save({transaction:a}).then(function(c){VoiceExtension.findAll({where:{VoiceExtensionId:c.id,isApp:!0}}).then(function(d){return VoiceExtension.destroy({where:{VoiceExtensionId:c.id}},{transaction:a}).then(function(){d=_.pluck(d,"dataValues");var a=_.filter(_.pluck(d,"IntervalId"),function(a){return null!==a});Interval.findAll({where:{IntervalId:a}}).then(function(a){var e=2;return d.forEach(function(b){var d=_.cloneDeep(Applications[b.app]);(!d||b.customApp)&&(d=[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"custom",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Custom Application End"}]),b.context=c.context,b.exten=c.exten;var f=util.format("%s%s%s",b.context,b.exten,e);b.interval=b.interval||"*,*,*,*";var g=_.filter(a,function(a){return a.IntervalId==b.IntervalId});g&&g.length>0&&(d.splice(0,1),g.forEach(function(a,b){d.unshift({app:"GotoIfTimeFromArray",appdata:a.interval+"?%s,${EXTEN},%s:%s,${EXTEN},%s",IntervalId:a.id,isInterval:!0,interval:a.interval})})),e=appCreate(d,b,f,g||[],e),VoiceExtension.bulkCreate(d)}),b.sendStatus(200)})})})})})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.updateApplication=function(a,b,c){a.body.appdata&&delete a.body.appdata,VoiceExtension.findById(a.body.id).then(function(c){if(!c)return b.sendStatus(404);delete a.body.id;var d=_.merge(c,a.body);return sequelize.transaction(function(b){return d.save({transaction:b}).then(function(){VoiceExtension.findAll({where:{VoiceExtensionId:a.body.VoiceExtensionId,isApp:!0}}).then(function(c){return VoiceExtension.destroy({where:{VoiceExtensionId:a.body.VoiceExtensionId}},{transaction:b}).then(function(){c=_.pluck(c,"dataValues");var a=_.filter(_.pluck(c,"IntervalId"),function(a){return null!==a});return Interval.findAll({where:{IntervalId:a}}).then(function(a){var b=2;c.forEach(function(c){var d=_.cloneDeep(Applications[c.app]);(!d||c.customApp)&&(d=[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"custom",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Custom Application End"}]);var e=util.format("%s%s%s",c.context,c.exten,b);c.interval=c.interval||"*,*,*,*";var f=_.filter(a,function(a){return a.IntervalId==c.IntervalId});f&&f.length>0&&(d.splice(0,1),f.forEach(function(a,b){d.unshift({app:"GotoIfTimeFromArray",appdata:a.interval+"?%s,${EXTEN},%s:%s,${EXTEN},%s",IntervalId:a.id,isInterval:!0,interval:a.interval})})),b=appCreate(d,c,e,f||[],b),VoiceExtension.bulkCreate(d)})})})})})}).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b,c){VoiceExtension.findById(a.params.id).then(function(a){return a?void(a.VoiceExtensionId?VoiceExtension.findAll({where:{appGroup:a.appGroup}}).then(function(d){return d?sequelize.transaction(function(b){return VoiceExtension.destroy({where:{appGroup:a.appGroup}},{transaction:b}).then(function(c){return VoiceExtension.findAll({where:{VoiceExtensionId:a.VoiceExtensionId,priority:{$gt:d[c-1].priority}}}).then(function(e){return VoiceExtension.destroy({where:{VoiceExtensionId:a.VoiceExtensionId,priority:{$gt:d[c-1].priority}}},{transaction:b}).then(function(){var a=_.pluck(_.filter(_.pluck(e,"dataValues"),function(a){return a.isApp===!0}),"appGroup"),b=d[0].priority;a.forEach(function(a){var c=_.find(e,function(b){return b.appGroup==a&&b.isApp===!0}),d=_.cloneDeep(Applications[c.app]);(!d||c.customApp)&&(d=[{app:"GotoIfTime",appdata:"%s?%s,${EXTEN},%s:%s,${EXTEN},%s"},{app:"custom",appdata:"%s",isApp:!0},{app:"NoOp",appdata:"Custom Application End"}]);var f=util.format("%s%s%s",c.context,c.exten,b);c.interval=c.interval||"*,*,*,*";var g=_.filter(e,function(b){return b.appGroup==a&&b.isInterval===!0});g&&g.length>0&&(d.splice(0,1),g.forEach(function(a,b){d.unshift({app:"GotoIfTimeFromArray",appdata:a.interval+"?%s,${EXTEN},%s:%s,${EXTEN},%s",IntervalId:a.IntervalId?a.IntervalId:null,isInterval:!0,interval:a.interval})})),b=appCreate(d,c,f,g||[],b),VoiceExtension.bulkCreate(d)})})})})}).then(function(a){b.sendStatus(201)})["catch"](function(a){return c(a)}):b.sendStatus(404)}):a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return c(a)})},exports.bulkDestroy=function(a,b){VoiceExtension.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})};var VoiceExtension=require("../../models").VoiceExtension;exports.register=function(a){VoiceExtension.afterCreate(function(b){onSave(a,b)}),VoiceExtension.afterDestroy(function(b){onRemove(a,b)}),VoiceExtension.afterBulkDestroy(function(b){onRemove(a,b)}),VoiceExtension.afterUpdate(function(b){onUpdate(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/voice/extensions",function(){it("should respond with JSON array",function(a){request(app).get("/api/voice/extensions").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./voice_musiconhold.controller"),auth=require("../../auth/auth.service"),router=express.Router(); -router.get("/",auth.isAuthenticated(),controller.index),router.get("/stream",auth.isAuthenticated(),controller.stream),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/files",auth.isAuthenticated(),controller.showAudioFiles),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.mohValidation),router.post("/:id/files",auth.isAuthenticated(),controller.addFiles),router.put("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),router["delete"]("/:id/files",auth.isAuthenticated(),controller.deleteAudioFiles),module.exports=router;var _=require("lodash"),VoiceMusicOnHold=require("../../models").VoiceMusicOnHold,fs=require("fs"),remove=require("remove"),Upload=require("../../models").Upload,fse=require("fs-extra"),path=require("path"),config=require("../../config/environment"),sequelize=require("../../models").sequelize,util=require("util"),base64=require("file-base64");exports.index=function(a,b){var c=["name","directory","sort","description"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),VoiceMusicOnHold.findAndCountAll(f).then(function(c){var g=Math.ceil(c.count/d),h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){VoiceMusicOnHold.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.addFiles=function(a,b){VoiceMusicOnHold.findById(a.params.id).then(function(c){return c?void Upload.findAll({where:{id:a.body.sounds}}).then(function(a){var d,e=path.join(config.root,"server/files/sounds/converted");a.forEach(function(a){d=path.join(c.directory,a.display_name+".wav"),fse.copySync(path.join(e,a.save_name+".wav"),d)}),fs.chmodSync(d,parseInt("0777",8)),b.sendStatus(200)})["catch"](function(a){return console.log(a),handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.showAudioFiles=function(a,b){var c={};VoiceMusicOnHold.findById(a.params.id).then(function(a){return a?(c.path=a.directory,void fs.readdir(a.directory,function(a,d){if(a)throw a;return c.files=d,b.send(c)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.deleteAudioFiles=function(a,b){VoiceMusicOnHold.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=c.directory+"/"+a.query.filename;fs.unlink(d,function(a){return a?handleError(b,a):b.sendStatus(204)})})["catch"](function(a){return handleError(b,a)})},exports.mohValidation=function(a,b){console.log(a.body),VoiceMusicOnHold.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){VoiceMusicOnHold.findAll({where:{name:a.body.name}}).then(function(c){return console.log(c),console.log("Finding app row....."),c?c.length>0?(console.log("error2"),b.status(500).send({message:"MESSAGE_EXIST_MOH"})):sequelize.transaction().then(function(c){return a.body.directory=path.join(config.root,"server/files/moh",a.body.name),VoiceMusicOnHold.create(a.body,{transaction:c}).then(function(a){fs.mkdir(a.directory,parseInt("0777",8),function(d){return d?(console.log("file error"),c.rollback(),b.status(500).send({message:"MESSAGE_FILE_CREATION_ERROR"})):(c.commit(),console.log("file created"),b.status(201).send(a))})})["catch"](function(a){c.rollback()})}):(console.log("error1"),b.sendStatus(404))})["catch"](function(a){return console.log("thaterror"),handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,VoiceMusicOnHold.find({where:{id:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){VoiceMusicOnHold.findById(a.params.id).then(function(a){return a?sequelize.transaction(function(c){return a.destroy({transaction:c}).then(function(){remove(a.directory,function(a){return a&&console.log(a),b.sendStatus(204)})})})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){VoiceMusicOnHold.findAll({where:{id:a.query.id}}).then(function(a){return a?sequelize.transaction(function(b){a.forEach(function(a){return a.destroy({transaction:b}).then(function(){remove(a.directory,function(a){if(a)throw console.log(a),a})})})}).then(function(){return b.sendStatus(204)})["catch"](function(a){return console.log(a),handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.stream=function(a,b){var c=decodeURI(a.query.path);base64.encode(c,function(a,c){return a?handleError(b,a):b.status(200).send(c)})};var VoiceMusicOnHold=require("../../models").VoiceMusicOnHold;exports.register=function(a){VoiceMusicOnHold.afterCreate(function(b){onSave(a,b)}),VoiceMusicOnHold.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/voice/musiconhold",function(){it("should respond with JSON array",function(a){request(app).get("/api/voice/musiconhold").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./voice_queue.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.queueValidation),router.post("/:id/agents",auth.isAuthenticated(),controller.addAgents),router.put("/:id",auth.isAuthenticated(),controller.update),router.put("/:id/agents",auth.isAuthenticated(),controller.removeAgents),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:name",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),User=require("../../models").User,VoiceQueue=require("../../models").VoiceQueue,UserHasVoiceQueue=require("../../models").UserHasVoiceQueue,VoiceExtension=require("../../models").VoiceExtension;exports.index=function(a,b){var c=["name","description","strategy","context"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),VoiceQueue.findAndCountAll(f).then(function(c){console.log(c.count);var g=Math.ceil(c.count/d);console.log(g);var h=g>f.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e+1):null,i=e>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,e-1):null;b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:g})})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){VoiceQueue.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.queueValidation=function(a,b){console.log(a.body),VoiceQueue.findAll({where:{name:a.body.name}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){VoiceQueue.findAll({where:{name:a.body.name}}).then(function(c){return console.log(c),console.log("Finding app row....."),c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_QUEUE"}):void VoiceQueue.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){VoiceQueue.find({where:{name:a.params.id}}).then(function(c){if(!c)return b.sendStatus(404);a.body.id&&delete a.body.id;var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.addAgents=function(a,b,c){console.log("addAgents"),console.log(a.params),console.log(a.body),User.findAll({where:{id:{$in:a.body.agents}}}).then(function(d){var e=_.map(d,function(b){return{queue:a.params.id,location:util.format("SIP/%s",b.name),membername:b.name,VoiceQueueName:a.params.id,UserId:b.id}});UserHasVoiceQueue.bulkCreate(e,{individualHooks:!0}).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)})})["catch"](function(a){return c(a)})},exports.removeAgents=function(a,b,c){VoiceQueue.find({where:{name:a.params.id}}).then(function(d){return d?void d.removeUsers(a.body.agents,{individualHooks:!0}).then(function(){return b.sendStatus(200)})["catch"](function(a){return c(a)}):c(new Error("no mail queue found"))})["catch"](function(a){return c(a)})},exports.destroy=function(a,b){VoiceQueue.find({where:{name:a.params.name}}).then(function(a){return a?void VoiceExtension.findAll({where:{queue:a.name}}).then(function(c){return c.length>0?b.status(500).send({message:"MESSAGE_QUEUE_ROUTE_ASSOCIATED"}):void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){VoiceQueue.findAll({where:{name:a.query.name}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.pluck(_.pluck(c,"dataValues"),"name");console.log(d),VoiceExtension.findAll({where:{queue:d}}).then(function(c){return c.length>0?b.status(500).send({message:"MESSAGE_QUEUE_ROUTE_ASSOCIATED"}):void VoiceQueue.destroy({where:{name:a.query.name},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})};var VoiceQueue=require("../../models").VoiceQueue;exports.register=function(a){VoiceQueue.afterCreate(function(b){onSave(a,b)}),VoiceQueue.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/voice/queues",function(){it("should respond with JSON array",function(a){request(app).get("/api/voice/queues").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./voice_voicemail.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:uniqueid",auth.isAuthenticated(),controller.show),router.get("/:uniqueid/messages",auth.isAuthenticated(),controller.getMessages),router.get("/messages/:id/download",auth.isAuthenticated(),controller.downloadMessage),router.post("/",auth.isAuthenticated(),controller.create),router.post("/validate",auth.isAuthenticated(),controller.mailboxValidation),router.put("/:uniqueid",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:uniqueid",auth.isAuthenticated(),controller.destroy),router["delete"]("/messages/:id/delete",auth.isAuthenticated(),controller.destroyMessage),module.exports=router;var _=require("lodash"),VoiceVoicemail=require("../../models").VoiceVoicemail,VoiceVoicemailMessages=require("../../models").VoiceVoicemailMessages,stream=require("stream");exports.index=function(a,b){var c=["mailbox","fullname","email"],d=a.query.per_page?parseInt(a.query.per_page,10):100,e=a.query.page?parseInt(a.query.page,10):0,f={where:{},limit:d,offset:e*d};_.forIn(a.query,function(b,d){switch(d){case"per_page":case"page":break;case"sort_by":f.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":f.where.$or=[],c.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},f.where.$or.push(c)});break;default:f.where[d]={$like:{}},f.where[d].$like="%"+b+"%"}}),VoiceVoicemail.findAndCountAll(f).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){VoiceVoicemail.find({where:{uniqueid:a.params.uniqueid}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.getMessages=function(a,b){VoiceVoicemail.find({where:{uniqueid:a.params.uniqueid}}).then(function(a){VoiceVoicemailMessages.findAll({where:{mailboxcontext:a.context,mailboxuser:a.mailbox}}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.mailboxValidation=function(a,b){console.log(a.body),VoiceVoicemail.findAll({where:{mailbox:a.body.mailbox,context:a.body.context}}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){VoiceVoicemail.findAll({where:{mailbox:a.body.mailbox,context:a.body.context}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_MAILBOX"}):void VoiceVoicemail.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})},exports.update=function(a,b){VoiceVoicemail.findAll({where:{mailbox:a.body.mailbox,context:a.body.context,uniqueid:{$ne:a.body.uniqueid}}}).then(function(c){return c?c.length>0?b.status(500).send({message:"MESSAGE_EXIST_MAILBOX"}):(a.body.uniqueid&&delete a.body.uniqueid,void VoiceVoicemail.find({where:{uniqueid:a.params.uniqueid}}).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){VoiceVoicemail.find({where:{uniqueid:a.params.uniqueid}}).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){VoiceVoicemail.destroy({where:{uniqueid:a.query.uniqueid},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.destroyMessage=function(a,b){VoiceVoicemailMessages.findById(a.params.id).then(function(a){return a?(a.recording=null,void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.downloadMessage=function(a,b){VoiceVoicemailMessages.findById(a.params.id).then(function(a){if(!a)return b.sendStatus(404);var c=a.msg_id+".wav";b.writeHead(200,"OK",{"Content-Type":"audio/wav","Content-Disposition":"attachment; filename="+c,"Content-Length":a.recording.length});var d=new stream.PassThrough;d.end(new Buffer(a.recording)),d.pipe(b)})};var VoiceVoicemail=require("../../models").VoiceVoicemail,VoiceVoicemailMessages=require("../../models").VoiceVoicemailMessages;exports.register=function(a){VoiceVoicemail.afterCreate(function(b){onSave(a,b)}),VoiceVoicemail.afterDestroy(function(b){onRemove(a,b)}),VoiceVoicemailMessages.afterCreate(function(b){onMessageSave(a,b)}),VoiceVoicemailMessages.afterDestroy(function(b){onMessageRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/voice/voicemails",function(){it("should respond with JSON array",function(a){request(app).get("/api/voice/voicemails").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./widget.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/counter",auth.isAuthenticated(),controller.counter),router.get("/table",auth.isAuthenticated(),controller.table),router.get("/piechart",auth.isAuthenticated(),controller.piechart),module.exports=router;var _=require("lodash"),util=require("util"),sequelize=require("../../models").sequelize;exports.counter=function(a,b){var c=util.format("report_%s",a.query.table);sequelize.query(util.format("SELECT COUNT(*) as count FROM %s WHERE %s",c,decodeURIComponent(a.query.condition)),{type:sequelize.QueryTypes.SELECT}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.table=function(a,b){var c,d=[];a.query.fields&&(_.isArray(a.query.fields)?a.query.fields.forEach(function(a){c=JSON.parse(a),c.column&&c.alias&&d.push(c.column+' AS "'+c.alias+'"')}):_.isString(a.query.fields)&&(c=JSON.parse(a.query.fields),c.column&&c.alias&&d.push(c.column+' AS "'+c.alias+'"')));var e=d.length?d.join(","):"*",f=util.format("report_%s",a.query.table);sequelize.query(util.format("SELECT %s FROM %s WHERE %s",e,f,decodeURIComponent(a.query.condition)),{type:sequelize.QueryTypes.SELECT}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.piechart=function(a,b){var c,d=[];a.query.fields&&(_.isArray(a.query.fields)?a.query.fields.forEach(function(a){c=JSON.parse(a),c.column&&c.alias&&d.push(c.column+' AS "'+c.alias+'"')}):_.isString(a.query.fields)&&(c=JSON.parse(a.query.fields),c.column&&c.alias&&d.push(c.column+' AS "'+c.alias+'"')));var e=d.length?d.join(","):"*",f=util.format("report_%s",a.query.table),g="";"undefined"!==a.query.condition&&(g=util.format(" WHERE %s",decodeURIComponent(a.query.condition))),sequelize.query(util.format("SELECT %s FROM %s%s",e,f,g),{type:sequelize.QueryTypes.SELECT}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/widgets",function(){it("should respond with JSON array",function(a){request(app).get("/api/widgets").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./xchatty.controller"),router=express.Router();router.get("/jquery",controller.getJqueryLibrary),router.get("/assets",controller.getAssets),router.get("/status",controller.getStatus),router.get("/signup",controller.signupCustomer),router.get("/read",controller.getMessages),router.get("/send",controller.sendMessage),router.get("/signout",controller.signoutCustomer),router.get("/submit",controller.submitEnquiry),router.get("/unserved",controller.unservedCustomer),router.get("/transcript",controller.getTranscript),router.get("/:id",controller.getJsByWebsite),router.get("/:id/styles",controller.getStyleByWebsite),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),jsmin=require("jsmin").jsmin,Mustache=require("mustache"),querystring=require("querystring"),path=require("path"),md5=require("md5"),fs=require("fs"),UAParser=require("ua-parser-js"),uaParser=new UAParser,languageParser=require("accept-language-parser"),ipaddr=require("ipaddr.js"),geoip=require("geoip-lite"),csv=require("to-csv"),config=require("../../config/environment"),Xchatty=require("../../models").Xchatty,xchatty_components=require("../../components/xchatty"),sequelize=require("../../models").sequelize,User=require("../../models").User,Agent=require("../../models").User,ChatRoom=require("../../models").ChatRoom,ChatEnquiry=require("../../models").ChatEnquiry,ChatVisitor=require("../../models").ChatVisitor,ChatMessage=require("../../models").ChatMessage,ChatWebsite=require("../../models").ChatWebsite,id=1;exports.index=function(a,b,c){Xchatty.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return c(a)})},exports.getJsByWebsite=function(a,b,c){ChatWebsite.findById(a.params.id).then(function(c){b.set({"Content-Type":"application/javascript","x-timestamp":Date.now(),"x-sent":!0});var d=xchatty_components.js,e={websiteId:a.params.id,rootPath:c.remote+"/api/xchatty/",signedUp:"false",windowFocused:"false",isNewPage:"true",processingSignUp:"false",processingEnquiry:"false",processingSend:"false",visitorFullname:'""',visitorAvatar:'""',timerReadMessages:"null",timerCheckStatus:"null",isOnline:"false",decayHistory:0,defaultTimeout:2e3,isInitialStatusCheck:"true",muteNotificationSoundOnce:"false",assetBase:c.remote+"/api/xchatty/assets",hasSessionSaf:"false",restoreOpenState:"false",animateHover:c.animation,hideEmail:"false",hideOffline:"false",headerShape:c.header_shape,HeaderOnline:c.header_online,OnlineMessage:c.online_message,UsernamePlaceholder:c.username_placeholder,EmailPlaceholder:c.email_placeholder,StartChatButtonText:c.start_chat_button,OfflineMessage:c.offline_message,HeaderOffline:c.header_offline,EnquiryMessagePlaceholder:c.enquiry_message_placeholder,EnquiryButtonText:c.enquiry_button,downloadTranscript:c.download_transcript};d=Mustache.render(d,e),b.send(d)})["catch"](function(a){c(a)})},exports.getStyleByWebsite=function(a,b,c){ChatWebsite.findById(a.params.id).then(function(a){b.set({"Content-Type":"text/css","x-timestamp":Date.now(),"x-sent":!0});var c=xchatty_components.css,d={assetBase:a.remote+"/api/xchatty/assets",color:a.color,colorFocus:a.color_focus,colorButton:a.color_button};c=Mustache.render(c,d),b.send(c)})["catch"](function(a){c(a)})},exports.getAssets=function(a,b,c){b.download(path.join(config.root,"server","components","xchatty","assets",a.query.resource))},exports.getJqueryLibrary=function(a,b,c){b.set({"Content-Type":"application/javascript","x-timestamp":Date.now(),"x-sent":!0});var d=xchatty_components.jquery;b.send(d)},exports.getStatus=function(a,b,c){a.session.xchatty||(a.session.xchatty={}),Agent.findAll({where:{online:!0,role:"agent"}}).then(function(d){a.query.data.open_state&&(a.session.xchatty.open_state="true"===a.query.data.open_state?!0:!1);var e={success:!0,has_session_saf:null,signed_up:a.session.xchatty.room_id?!0:!1,fullname:a.session.xchatty.fullname?a.session.xchatty.fullname:"",email:a.session.xchatty.email?a.session.xchatty.email:"",avatar:a.session.xchatty.avatar?a.session.xchatty.avatar:"",open_state:a.session.xchatty.open_state||a.session.xchatty.room_id?!0:!1,online:d.length?!0:!1};a.session.xchatty.visitor_id?ChatRoom.findOne({where:{ChatVisitorId:a.session.xchatty.visitor_id,status:"open"}}).then(function(c){c?(a.session.xchatty.room_id=c.id,e.signed_up=!0):e.signed_up=!1,b.send(a.query.callback+"("+JSON.stringify(e)+")")})["catch"](function(a){c(a)}):b.send(a.query.callback+"("+JSON.stringify(e)+")")})["catch"](function(a){return c(a)})},exports.getMessages=function(a,b,c){var d={where:{ChatRoomId:a.session.xchatty.room_id},include:[{model:User,attributes:["id","name","fullname","email"]},{model:ChatVisitor,attributes:["id","fullname","email"]}]};"false"===a.query.data.is_new_page&&(d.where.id={$gt:a.query.data.last_id}),ChatMessage.findAll(d).then(function(c){var d={success:!0,messages:c,composing:!1,composing_fullname:null};b.send(a.query.callback+"("+JSON.stringify(d)+")")})["catch"](function(a){c(a)})},exports.sendMessage=function(a,b,c){var d={where:{ChatRoomId:a.session.xchatty.room_id},include:[{model:User,attributes:["id","name","fullname","email"]},{model:ChatVisitor,attributes:["id","fullname","email"]}]};"false"===a.query.data.is_new_page&&(d.where.id={$gt:a.query.data.last_id}),ChatMessage.create({body:a.query.data.Message.message,ChatRoomId:a.session.xchatty.room_id,ChatVisitorId:a.session.xchatty.visitor_id}).then(function(e){console.log("chatMessage",e),ChatMessage.findAll(d).then(function(c){var d={errors:[],success:!0,data:e,messages:c};b.send(a.query.callback+"("+JSON.stringify(d)+")")})["catch"](function(a){c(a)})})["catch"](function(a){c(a)})},exports.signoutCustomer=function(a,b,c){ChatRoom.findById(a.session.xchatty.room_id).then(function(d){d.updateAttributes({status:"close"}).then(function(c){var d={success:!0,errors:[]};a.session.xchatty={},b.send(a.query.callback+"("+JSON.stringify(d)+")")})["catch"](function(a){c(a)})})["catch"](function(a){c(a)})},exports.signupCustomer=function(a,b,c){var d=uaParser.setUA(a.headers["user-agent"]).getResult(),e=(languageParser.parse(a.headers["accept-language"]),{fullname:a.query.data.Discussion.fullname,email:a.query.data.Discussion.email,remote_address:a.connection.remoteAddress,user_agent:a.headers["user-agent"],visitor_language:a.headers["accept-language"],referer:a.headers.referer,origin:"webchat",browser:d.browser.name+" "+d.browser.version,engine:d.engine.name+" "+d.engine.version,os:d.os.name+" "+d.os.version,device:d.device.model?d.device.model+" "+d.device.vendor+" "+d.device.type:null,ChatWebsiteId:a.query.chatWebsiteId});return ChatVisitor.create(e).then(function(c){a.session.xchatty.fullname=c.fullname,a.session.xchatty.email=c.email,a.session.xchatty.avatar=md5(c.email).toString("base64"),a.session.xchatty.visitor_id=c.id;var d={success:!0,errors:[],chatVisitor:{id:c.id}};b.send(a.query.callback+"("+JSON.stringify(d)+")")})["catch"](function(a){c(a)})},exports.unservedCustomer=function(a,b,c){ChatVisitor.findById(a.session.xchatty.visitor_id).then(function(d){d.updateAttributes({status:"unserved"}).then(function(){var c={success:!0,errors:[]};a.session.xchatty={},b.send(a.query.callback+"("+JSON.stringify(c)+")")})["catch"](function(a){c(a)})})["catch"](function(a){c(a)})},exports.submitEnquiry=function(a,b,c){var d;return sequelize.transaction().then(function(e){return ChatVisitor.create({fullname:a.query.data.Enquiry.fullname,email:a.query.data.Enquiry.email,remote_address:a.connection.remoteAddress,user_agent:a.headers["user-agent"],visitor_language:a.headers["accept-language"],referer:a.headers.referer,origin:"enquiry",status:"unserved"},{transaction:e}).then(function(b){return d=b,ChatEnquiry.create({username:a.query.data.Enquiry.fullname,email:b.email,text:a.query.data.Enquiry.message,ChatWebsiteId:parseInt(a.query.data.Enquiry.websiteId,10),ChatVisitorId:d.id},{include:[{all:!0,include:[{all:!0}]}],transaction:e})}).then(function(){e.commit(),b.send(a.query.callback+"("+JSON.stringify({success:!0,errors:[]})+")")})["catch"](function(a){e.rollback(),c(a)})})},exports.getTranscript=function(a,b,c){a.session.xchatty&&a.session.xchatty.visitor_id&&a.session.xchatty.room_id&&ChatMessage.findAll({where:{ChatRoomId:a.session.xchatty.room_id}}).then(function(a){var c=[];a.forEach(function(a){var b={name:a.fullname,text:a.body.replace(/(\r\n|\n|\r)/gm," "),date:a.createdAt};c.push(b)});var d=csv(c);b.type("text/csv").status(200).send(d)})["catch"](function(a){c(a)})},exports.show=function(a,b,c){Xchatty.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return c(a)})},exports.create=function(a,b,c){Xchatty.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return c(a)})},exports.update=function(a,b,c){a.body.id&&delete a.body.id,Xchatty.findById(a.params.id).then(function(d){if(!d)return b.sendStatus(404);var e=_.merge(d,a.body);e.save().then(function(){return b.status(200).send(d)})["catch"](function(a){return c(a)})})["catch"](function(a){return c(a)})},exports.destroy=function(a,b,c){Xchatty.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return c(a)}):b.sendStatus(404)})["catch"](function(a){return c(a)})};var xchatty=require("../../models").Xchatty;exports.register=function(a){};var express=require("express"),auth=require("../../auth/auth.service"),controller=require("./zendesk_account.controller"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.get("/:id/check",auth.isAuthenticated(),controller.checkAccount),router.get("/:id/fields",auth.isAuthenticated(),controller.getFields),router.post("/validate/:field",auth.isAuthenticated(),controller.zendeskValidation),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/",auth.isAuthenticated(),controller.bulkDestroy),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),util=require("util"),zendesk=require("node-zendesk"),ZendeskAccount=require("../../models").ZendeskAccount;exports.index=function(a,b,c){var d=["description","name","username","remoteUri"],e=a.query.per_page?parseInt(a.query.per_page,10):100,f=a.query.page?parseInt(a.query.page,10):0,g={where:{},limit:e,offset:f*e};_.forIn(a.query,function(b,c){switch(c){case"per_page":case"page":break;case"sort_by":g.order=util.format("%s %s",a.query.sort_by,a.query.sort_order||"ASC")||null;break;case"sort_order":break;case"$":g.where.$or=[],d.forEach(function(a){var c={};c[a]={$like:"%"+b+"%"},g.where.$or.push(c)});break;default:g.where[c]={$like:{}},g.where[c].$like="%"+b+"%"}}),ZendeskAccount.findAndCountAll(g).then(function(c){var d=Math.ceil(c.count/e),h=d>g.offset+1?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f+1):null,i=f>0?util.format("%s://%s%s?page=%d",a.protocol,a.headers.host,a.baseUrl,f-1):null;return b.status(200).send({count:c.count,rows:c.rows,next_page:h,previous_page:i,total_pages:d})})["catch"](function(a){return b.status(500).send({error:"Something blew up!"})})},exports.show=function(a,b){ZendeskAccount.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ZendeskAccount.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ZendeskAccount.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ZendeskAccount.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.bulkDestroy=function(a,b){ -ZendeskAccount.destroy({where:{id:a.query.id},individualHooks:!0}).then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)})},exports.zendeskValidation=function(a,b){var c={};c[a.params.field]=a.body.value,ZendeskAccount.findAndCountAll({where:c}).then(function(c){return c.count?b.status(200).send({isValid:!1,value:a.body.value}):b.status(200).send({isValid:!0,value:a.body.value})})["catch"](function(a){return handleError(b,a)})},exports.checkAccount=function(a,b){ZendeskAccount.findById(a.params.id).then(function(a){var c={username:a.username,remoteUri:a.remoteUri};"password"===a.authType?c.password=a.password:"token"===a.authType&&(c.token=a.token);var d=zendesk.createClient(c);d.users.auth(function(a,c,d){return a?(console.error(a),handleError(b,a)):d.verified?b.sendStatus(204):b.sendStatus(500)})})["catch"](function(a){return handleError(b,a)})},exports.getFields=function(a,b){ZendeskAccount.findById(a.params.id).then(function(a){var c={username:a.username,remoteUri:a.remoteUri};"password"===a.authType?c.password=a.password:"token"===a.authType&&(c.token=a.token);var d=zendesk.createClient(c);d.ticketfields.list(function(a,c,d){return a?(console.error(a),handleError(b,a)):b.status(200).send(d)})})["catch"](function(a){return handleError(b,a)})};var ZendeskAccount=require("../../models").ZendeskAccount;exports.register=function(a){ZendeskAccount.afterCreate(function(b){onSave(a,b)}),ZendeskAccount.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/zendesk/accounts",function(){it("should respond with JSON array",function(a){request(app).get("/api/zendesk/accounts").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./zendesk_configuration.controller"),auth=require("../../auth/auth.service"),router=express.Router();router.get("/",auth.isAuthenticated(),controller.index),router.get("/:id",auth.isAuthenticated(),controller.show),router.post("/",auth.isAuthenticated(),controller.create),router.put("/:id",auth.isAuthenticated(),controller.update),router.post("/:id/:type",auth.isAuthenticated(),controller.addConfigurationField),router.patch("/:id",auth.isAuthenticated(),controller.update),router["delete"]("/:id",auth.isAuthenticated(),controller.destroy),module.exports=router;var _=require("lodash"),ZendeskConfiguration=require("../../models").ZendeskConfiguration,ZendeskField=require("../../models").ZendeskField;exports.index=function(a,b){ZendeskConfiguration.findAll({where:a.query}).then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ZendeskConfiguration.find({where:{id:a.params.id},include:[{model:ZendeskField,as:"Subject"},{model:ZendeskField,as:"Description"},{model:ZendeskField,as:"Field"}]}).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ZendeskConfiguration.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ZendeskConfiguration.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ZendeskConfiguration.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.addConfigurationField=function(a,b,c){ZendeskConfiguration.findById(a.params.id).then(function(c){return c?void ZendeskField.create(a.body).then(function(d){switch(a.params.type){case"subject":c.addSubject(d).then(function(){return b.status(200).send(d)})["catch"](function(a){return handleError(b,a)});break;case"description":c.addDescription(d).then(function(){return b.status(200).send(d)})["catch"](function(a){return handleError(b,a)});break;case"field":c.addField(d).then(function(){return b.status(200).send(d)})["catch"](function(a){return handleError(b,a)})}})["catch"](function(a){return handleError(b,a)}):b.sendStatus(500)})["catch"](function(a){return handleError(b,a)})};var ZendeskConfiguration=require("../../models").ZendeskConfiguration;exports.register=function(a){ZendeskConfiguration.afterCreate(function(b){onSave(a,b)}),ZendeskConfiguration.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/zendesk/configurations",function(){it("should respond with JSON array",function(a){request(app).get("/api/zendesk/configurations").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})});var express=require("express"),controller=require("./zendesk_field.controller"),router=express.Router();router.get("/",controller.index),router.get("/:id",controller.show),router.post("/",controller.create),router.put("/:id",controller.update),router.patch("/:id",controller.update),router["delete"]("/:id",controller.destroy),module.exports=router;var _=require("lodash"),ZendeskField=require("../../models").ZendeskField;exports.index=function(a,b){ZendeskField.findAll().then(function(a){return b.status(200).send(a)})["catch"](function(a){return handleError(b,a)})},exports.show=function(a,b){ZendeskField.findById(a.params.id).then(function(a){return a?b.send(a):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})},exports.create=function(a,b){ZendeskField.create(a.body).then(function(a){return b.status(201).send(a)})["catch"](function(a){return handleError(b,a)})},exports.update=function(a,b){a.body.id&&delete a.body.id,ZendeskField.findById(a.params.id).then(function(c){if(!c)return b.sendStatus(404);var d=_.merge(c,a.body);d.save().then(function(){return b.status(200).send(c)})["catch"](function(a){return handleError(b,a)})})["catch"](function(a){return handleError(b,a)})},exports.destroy=function(a,b){ZendeskField.findById(a.params.id).then(function(a){return a?void a.destroy().then(function(){return b.sendStatus(204)})["catch"](function(a){return handleError(b,a)}):b.sendStatus(404)})["catch"](function(a){return handleError(b,a)})};var ZendeskField=require("../../models").ZendeskField;exports.register=function(a){ZendeskField.afterCreate(function(b){onSave(a,b)}),ZendeskField.afterDestroy(function(b){onRemove(a,b)})};var should=require("should"),app=require("../../app"),request=require("supertest");describe("GET /api/zendesk/fields",function(){it("should respond with JSON array",function(a){request(app).get("/api/zendesk/fields").expect(200).expect("Content-Type",/json/).end(function(b,c){return b?a(b):(c.body.should.be["instanceof"](Array),void a())})})}); \ No newline at end of file +var _0x44e5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4E\x4F\x44\x45\x5F\x45\x4E\x56","\x65\x6E\x76","\x64\x65\x76\x65\x6C\x6F\x70\x6D\x65\x6E\x74","\x4E\x4F\x44\x45\x5F\x54\x4C\x53\x5F\x52\x45\x4A\x45\x43\x54\x5F\x55\x4E\x41\x55\x54\x48\x4F\x52\x49\x5A\x45\x44","\x75\x6E\x63\x61\x75\x67\x68\x74\x45\x78\x63\x65\x70\x74\x69\x6F\x6E","\x6F\x62\x6A\x65\x63\x74","\x6D\x65\x73\x73\x61\x67\x65","\x0A\x4D\x65\x73\x73\x61\x67\x65\x3A\x20","\x6C\x6F\x67","\x73\x74\x61\x63\x6B","\x0A\x53\x74\x61\x63\x6B\x74\x72\x61\x63\x65\x3A","\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D","\x64\x75\x6D\x70\x45\x72\x72\x6F\x72\x20\x3A\x3A\x20\x61\x72\x67\x75\x6D\x65\x6E\x74\x20\x69\x73\x20\x6E\x6F\x74\x20\x61\x6E\x20\x6F\x62\x6A\x65\x63\x74","\x6F\x6E","\x6F\x73","\x68\x74\x74\x70","\x75\x74\x69\x6C","\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x72\x65\x73\x73","\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x53\x65\x74\x74\x69\x6E\x67","\x63\x72\x65\x61\x74\x65\x53\x65\x72\x76\x65\x72","\x70\x72\x6F\x64\x75\x63\x74\x69\x6F\x6E","\x2F\x73\x6F\x63\x6B\x65\x74\x2E\x69\x6F\x2D\x63\x6C\x69\x65\x6E\x74","\x73\x6F\x63\x6B\x65\x74\x2E\x69\x6F","\x70\x6F\x72\x74","\x61\x73\x74\x65\x72\x69\x73\x6B","\x68\x6F\x73\x74","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x61\x73\x74\x65\x72\x69\x73\x6B\x2D\x6D\x61\x6E\x61\x67\x65\x72","\x6B\x65\x65\x70\x43\x6F\x6E\x6E\x65\x63\x74\x65\x64","\x6B\x75\x65","\x6C\x69\x73\x74\x65\x6E","\x61\x70\x70","\x43\x72\x6F\x6E\x4A\x6F\x62","\x63\x72\x6F\x6E","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x78\x70\x72\x65\x73\x73","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x2E\x2F\x72\x6F\x75\x74\x65\x73","\x73\x65\x65\x64\x44\x42","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x73\x65\x65\x64","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x73\x6F\x63\x6B\x65\x74\x69\x6F","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6B\x75\x65\x2E\x6D\x61\x69\x6C","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6B\x75\x65\x2E\x63\x68\x61\x74","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6B\x75\x65\x2E\x66\x61\x78","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73\x2F\x6D\x61\x69\x6C","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73\x2F\x66\x61\x78","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x74\x72\x69\x67\x67\x65\x72\x73","\x69\x6E\x69\x74","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x69\x6D\x61\x70","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x73\x6D\x74\x70","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x61\x6D\x69","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x61\x67\x69","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x61\x75\x74\x6F\x64\x69\x61\x6C\x65\x72","\x69\x70","\x45\x78\x70\x72\x65\x73\x73\x20\x73\x65\x72\x76\x65\x72\x20\x6C\x69\x73\x74\x65\x6E\x69\x6E\x67\x20\x6F\x6E\x20\x25\x64\x2C\x20\x69\x6E\x20\x25\x73\x20\x6D\x6F\x64\x65","\x67\x65\x74","\x74\x68\x65\x6E","\x73\x79\x6E\x63","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x68\x69\x73\x74\x6F\x72\x79","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65\x5F\x68\x69\x73\x74\x6F\x72\x79","\x65\x78\x70\x6F\x72\x74\x73"];_0x44e5[0];process[_0x44e5[2]][_0x44e5[1]]=process[_0x44e5[2]][_0x44e5[1]]||_0x44e5[3];process[_0x44e5[2]][_0x44e5[4]]=0;process[_0x44e5[14]](_0x44e5[5],function(_0x1d57x1){if( typeof _0x1d57x1===_0x44e5[6]){if(_0x1d57x1[_0x44e5[7]]){console[_0x44e5[9]](_0x44e5[8]+_0x1d57x1[_0x44e5[7]])};if(_0x1d57x1[_0x44e5[10]]){console[_0x44e5[9]](_0x44e5[11]);console[_0x44e5[9]](_0x44e5[12]);console[_0x44e5[9]](_0x1d57x1[_0x44e5[10]]);};}else {console[_0x44e5[9]](_0x44e5[13])}});var os=require(_0x44e5[15]);var http=require(_0x44e5[16]);var util=require(_0x44e5[17]);var crypto=require(_0x44e5[18]);var express=require(_0x44e5[19]);var models=require(_0x44e5[20]);var config=require(_0x44e5[21]);var Setting=models[_0x44e5[22]];var app=express();var server=require(_0x44e5[16])[_0x44e5[23]](app);var io=require(_0x44e5[26])(server,{serveClient:(config[_0x44e5[2]]===_0x44e5[24])?false:true,path:_0x44e5[25]});var ami=require(_0x44e5[32])(config[_0x44e5[28]][_0x44e5[27]],config[_0x44e5[28]][_0x44e5[29]],config[_0x44e5[28]][_0x44e5[30]],config[_0x44e5[28]][_0x44e5[31]],true);ami[_0x44e5[33]]();var kue=require(_0x44e5[34]);kue[_0x44e5[36]][_0x44e5[35]](3001);var cronjob=require(_0x44e5[38])[_0x44e5[37]];require(_0x44e5[39])(app);models[_0x44e5[63]][_0x44e5[62]]()[_0x44e5[61]](function(){require(_0x44e5[42])(app);if(config[_0x44e5[43]]){require(_0x44e5[44])};require(_0x44e5[45])(io);require(_0x44e5[46])(kue);require(_0x44e5[47])(kue);require(_0x44e5[48])(io,kue);require(_0x44e5[49])();require(_0x44e5[50])();require(_0x44e5[51])();require(_0x44e5[53])[_0x44e5[52]]();require(_0x44e5[54])[_0x44e5[52]]();require(_0x44e5[55])(ami);require(_0x44e5[56])();require(_0x44e5[57])(ami);server[_0x44e5[35]](config[_0x44e5[27]],config[_0x44e5[58]],function(){console[_0x44e5[9]](_0x44e5[59],config[_0x44e5[27]],app[_0x44e5[60]](_0x44e5[2]))});})[_0x44e5[41]](function(_0x1d57x1){console[_0x44e5[40]](_0x1d57x1)});models[_0x44e5[65]][_0x44e5[62]]()[_0x44e5[61]](function(){require(_0x44e5[64])(cronjob)})[_0x44e5[41]](function(_0x1d57x1){console[_0x44e5[40]](_0x1d57x1)});exports=module[_0x44e5[66]]=app; \ No newline at end of file diff --git a/server/auth/auth.service.js b/server/auth/auth.service.js index 277a546..45f528a 100644 --- a/server/auth/auth.service.js +++ b/server/auth/auth.service.js @@ -1,90 +1 @@ -'use strict'; - -//var mongoose = require('mongoose'); -var passport = require('passport'); -var config = require('../config/environment'); -var jwt = require('jsonwebtoken'); -var expressJwt = require('express-jwt'); -var compose = require('composable-middleware'); -// var User = require('../api/user/user.model'); -var User = require('../models').User; -var validateJwt = expressJwt({ - secret: config.session.secret -}); - -/** - * Attaches the user object to the request if authenticated - * Otherwise returns 403 - */ -function isAuthenticated() { - return compose() - // Validate jwt - .use(function(req, res, next) { - // allow access_token to be passed through query parameter as well - if (req.query && req.query.hasOwnProperty('access_token')) { - req.headers.authorization = 'Bearer ' + req.query.access_token; - } - validateJwt(req, res, next); - }) - // Attach user to request - .use(function(req, res, next) { - User - .findById(req.user.id) - .then(function(user) { - if (!user) return res.send(401); - req.user = user; - return next(); - }) - .catch(function(err) { - return next(err); - }); - }); -} - -/** - * Checks if the user role meets the minimum requirements of the route - */ -function hasRole(roleRequired) { - if (!roleRequired) throw new Error('Required role needs to be set'); - - return compose() - .use(isAuthenticated()) - .use(function meetsRequirements(req, res, next) { - if (config.userRoles.indexOf(req.user.role) >= config.userRoles.indexOf(roleRequired)) { - return next(); - } else { - return res.send(403); - } - }); -} - -/** - * Returns a jwt token signed by the app secret - */ -function signToken(id, role, remember) { - var expiresIn = 60 * 24 * 365 * 5; //If remember, it expires in 5 years - if (!remember) - expiresIn = "1d"; //Expire in one day - return jwt.sign({ - id: id - }, config.session.secret, { - expiresIn: expiresIn - }); -} - -/** - * Set token cookie directly for oAuth strategies - */ -function setTokenCookie(req, res) { - if (!req.user) return res.json(404, { - message: 'Something went wrong, please try again.' - }); - var token = signToken(req.user.id, req.user.role); - res.cookie('token', JSON.stringify(token)); - res.redirect('/'); -} - -exports.isAuthenticated = isAuthenticated; -exports.hasRole = hasRole; -exports.signToken = signToken; -exports.setTokenCookie = setTokenCookie; +var _0x502d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6A\x73\x6F\x6E\x77\x65\x62\x74\x6F\x6B\x65\x6E","\x65\x78\x70\x72\x65\x73\x73\x2D\x6A\x77\x74","\x63\x6F\x6D\x70\x6F\x73\x61\x62\x6C\x65\x2D\x6D\x69\x64\x64\x6C\x65\x77\x61\x72\x65","\x55\x73\x65\x72","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x63\x72\x65\x74","\x73\x65\x73\x73\x69\x6F\x6E","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x75\x73\x65\x72","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x73\x65","\x71\x75\x65\x72\x79","\x61\x63\x63\x65\x73\x73\x5F\x74\x6F\x6B\x65\x6E","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x61\x75\x74\x68\x6F\x72\x69\x7A\x61\x74\x69\x6F\x6E","\x68\x65\x61\x64\x65\x72\x73","\x42\x65\x61\x72\x65\x72\x20","\x52\x65\x71\x75\x69\x72\x65\x64\x20\x72\x6F\x6C\x65\x20\x6E\x65\x65\x64\x73\x20\x74\x6F\x20\x62\x65\x20\x73\x65\x74","\x72\x6F\x6C\x65","\x69\x6E\x64\x65\x78\x4F\x66","\x75\x73\x65\x72\x52\x6F\x6C\x65\x73","\x31\x64","\x73\x69\x67\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x77\x65\x6E\x74\x20\x77\x72\x6F\x6E\x67\x2C\x20\x70\x6C\x65\x61\x73\x65\x20\x74\x72\x79\x20\x61\x67\x61\x69\x6E\x2E","\x6A\x73\x6F\x6E","\x74\x6F\x6B\x65\x6E","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x63\x6F\x6F\x6B\x69\x65","\x2F","\x72\x65\x64\x69\x72\x65\x63\x74","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x68\x61\x73\x52\x6F\x6C\x65","\x73\x69\x67\x6E\x54\x6F\x6B\x65\x6E","\x73\x65\x74\x54\x6F\x6B\x65\x6E\x43\x6F\x6F\x6B\x69\x65"];_0x502d[0];var passport=require(_0x502d[1]);var config=require(_0x502d[2]);var jwt=require(_0x502d[3]);var expressJwt=require(_0x502d[4]);var compose=require(_0x502d[5]);var User=require(_0x502d[7])[_0x502d[6]];var validateJwt=expressJwt({secret:config[_0x502d[9]][_0x502d[8]]});function isAuthenticated(){return compose()[_0x502d[16]](function(_0x4246x9,_0x4246xa,_0x4246xb){if(_0x4246x9[_0x502d[17]]&&_0x4246x9[_0x502d[17]][_0x502d[19]](_0x502d[18])){_0x4246x9[_0x502d[21]][_0x502d[20]]=_0x502d[22]+_0x4246x9[_0x502d[17]][_0x502d[18]]};validateJwt(_0x4246x9,_0x4246xa,_0x4246xb);})[_0x502d[16]](function(_0x4246x9,_0x4246xa,_0x4246xb){User[_0x502d[15]](_0x4246x9[_0x502d[12]][_0x502d[14]])[_0x502d[13]](function(_0x4246xd){if(!_0x4246xd){return _0x4246xa[_0x502d[11]](401)};_0x4246x9[_0x502d[12]]=_0x4246xd;return _0x4246xb();})[_0x502d[10]](function(_0x4246xc){return _0x4246xb(_0x4246xc)})})}function hasRole(_0x4246xf){if(!_0x4246xf){throw new Error(_0x502d[23])};return compose()[_0x502d[16]](isAuthenticated())[_0x502d[16]](function _0x4246x10(_0x4246x9,_0x4246xa,_0x4246xb){if(config[_0x502d[26]][_0x502d[25]](_0x4246x9[_0x502d[12]][_0x502d[24]])>=config[_0x502d[26]][_0x502d[25]](_0x4246xf)){return _0x4246xb()}else {return _0x4246xa[_0x502d[11]](403)}});}function signToken(_0x4246x12,_0x4246x13,_0x4246x14){var _0x4246x15=60*24*365*5;if(!_0x4246x14){_0x4246x15=_0x502d[27]};return jwt[_0x502d[28]]({id:_0x4246x12},config[_0x502d[9]][_0x502d[8]],{expiresIn:_0x4246x15});}function setTokenCookie(_0x4246x9,_0x4246xa){if(!_0x4246x9[_0x502d[12]]){return _0x4246xa[_0x502d[30]](404,{message:_0x502d[29]})};var _0x4246x17=signToken(_0x4246x9[_0x502d[12]][_0x502d[14]],_0x4246x9[_0x502d[12]][_0x502d[24]]);_0x4246xa[_0x502d[33]](_0x502d[31],JSON[_0x502d[32]](_0x4246x17));_0x4246xa[_0x502d[35]](_0x502d[34]);}exports[_0x502d[36]]=isAuthenticated;exports[_0x502d[37]]=hasRole;exports[_0x502d[38]]=signToken;exports[_0x502d[39]]=setTokenCookie; \ No newline at end of file diff --git a/server/auth/facebook/index.js b/server/auth/facebook/index.js index 4a6f878..7178215 100644 --- a/server/auth/facebook/index.js +++ b/server/auth/facebook/index.js @@ -1,21 +1 @@ -'use strict'; - -var express = require('express'); -var passport = require('passport'); -var auth = require('../auth.service'); - -var router = express.Router(); - -router - .get('/', passport.authenticate('facebook', { - scope: ['email', 'user_about_me'], - failureRedirect: '/signup', - session: false - })) - - .get('/callback', passport.authenticate('facebook', { - failureRedirect: '/signup', - session: false - }), auth.setTokenCookie); - -module.exports = router; \ No newline at end of file +var _0x5123=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2E\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F\x63\x61\x6C\x6C\x62\x61\x63\x6B","\x66\x61\x63\x65\x62\x6F\x6F\x6B","\x2F\x73\x69\x67\x6E\x75\x70","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x73\x65\x74\x54\x6F\x6B\x65\x6E\x43\x6F\x6F\x6B\x69\x65","\x67\x65\x74","\x2F","\x65\x6D\x61\x69\x6C","\x75\x73\x65\x72\x5F\x61\x62\x6F\x75\x74\x5F\x6D\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x5123[0];var express=require(_0x5123[1]);var passport=require(_0x5123[2]);var auth=require(_0x5123[3]);var router=express.Router();router[_0x5123[9]](_0x5123[10],passport[_0x5123[7]](_0x5123[5],{scope:[_0x5123[11],_0x5123[12]],failureRedirect:_0x5123[6],session:false}))[_0x5123[9]](_0x5123[4],passport[_0x5123[7]](_0x5123[5],{failureRedirect:_0x5123[6],session:false}),auth[_0x5123[8]]);module[_0x5123[13]]=router; \ No newline at end of file diff --git a/server/auth/facebook/passport.js b/server/auth/facebook/passport.js index 90ae489..03948df 100644 --- a/server/auth/facebook/passport.js +++ b/server/auth/facebook/passport.js @@ -1,37 +1 @@ -var passport = require('passport'); -var FacebookStrategy = require('passport-facebook').Strategy; - -exports.setup = function (User, config) { - passport.use(new FacebookStrategy({ - clientID: config.facebook.clientID, - clientSecret: config.facebook.clientSecret, - callbackURL: config.facebook.callbackURL - }, - function(accessToken, refreshToken, profile, done) { - User.findOne({ - 'facebook.id': profile.id - }, - function(err, user) { - if (err) { - return done(err); - } - if (!user) { - user = new User({ - name: profile.displayName, - email: profile.emails[0].value, - role: 'user', - username: profile.username, - provider: 'facebook', - facebook: profile._json - }); - user.save(function(err) { - if (err) done(err); - return done(err, user); - }); - } else { - return done(err, user); - } - }) - } - )); -}; \ No newline at end of file +var _0x13f4=["\x70\x61\x73\x73\x70\x6F\x72\x74","\x53\x74\x72\x61\x74\x65\x67\x79","\x70\x61\x73\x73\x70\x6F\x72\x74\x2D\x66\x61\x63\x65\x62\x6F\x6F\x6B","\x73\x65\x74\x75\x70","\x63\x6C\x69\x65\x6E\x74\x49\x44","\x66\x61\x63\x65\x62\x6F\x6F\x6B","\x63\x6C\x69\x65\x6E\x74\x53\x65\x63\x72\x65\x74","\x63\x61\x6C\x6C\x62\x61\x63\x6B\x55\x52\x4C","\x69\x64","\x64\x69\x73\x70\x6C\x61\x79\x4E\x61\x6D\x65","\x76\x61\x6C\x75\x65","\x65\x6D\x61\x69\x6C\x73","\x75\x73\x65\x72","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x5F\x6A\x73\x6F\x6E","\x73\x61\x76\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x73\x65"];var passport=require(_0x13f4[0]);var FacebookStrategy=require(_0x13f4[2])[_0x13f4[1]];exports[_0x13f4[3]]=function(_0x1d45x3,_0x1d45x4){passport[_0x13f4[17]]( new FacebookStrategy({clientID:_0x1d45x4[_0x13f4[5]][_0x13f4[4]],clientSecret:_0x1d45x4[_0x13f4[5]][_0x13f4[6]],callbackURL:_0x1d45x4[_0x13f4[5]][_0x13f4[7]]},function(_0x1d45x5,_0x1d45x6,_0x1d45x7,_0x1d45x8){_0x1d45x3[_0x13f4[16]]({"\x66\x61\x63\x65\x62\x6F\x6F\x6B\x2E\x69\x64":_0x1d45x7[_0x13f4[8]]},function(_0x1d45x9,_0x1d45xa){if(_0x1d45x9){return _0x1d45x8(_0x1d45x9)};if(!_0x1d45xa){_0x1d45xa= new _0x1d45x3({name:_0x1d45x7[_0x13f4[9]],email:_0x1d45x7[_0x13f4[11]][0][_0x13f4[10]],role:_0x13f4[12],username:_0x1d45x7[_0x13f4[13]],provider:_0x13f4[5],facebook:_0x1d45x7[_0x13f4[14]]});_0x1d45xa[_0x13f4[15]](function(_0x1d45x9){if(_0x1d45x9){_0x1d45x8(_0x1d45x9)};return _0x1d45x8(_0x1d45x9,_0x1d45xa);});}else {return _0x1d45x8(_0x1d45x9,_0x1d45xa)};})}))}; \ No newline at end of file diff --git a/server/auth/google/index.js b/server/auth/google/index.js index 9b1ce39..f8d74bf 100644 --- a/server/auth/google/index.js +++ b/server/auth/google/index.js @@ -1,24 +1 @@ -'use strict'; - -var express = require('express'); -var passport = require('passport'); -var auth = require('../auth.service'); - -var router = express.Router(); - -router - .get('/', passport.authenticate('google', { - failureRedirect: '/signup', - scope: [ - 'https://www.googleapis.com/auth/userinfo.profile', - 'https://www.googleapis.com/auth/userinfo.email' - ], - session: false - })) - - .get('/callback', passport.authenticate('google', { - failureRedirect: '/signup', - session: false - }), auth.setTokenCookie); - -module.exports = router; \ No newline at end of file +var _0xf3b0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2E\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F\x63\x61\x6C\x6C\x62\x61\x63\x6B","\x67\x6F\x6F\x67\x6C\x65","\x2F\x73\x69\x67\x6E\x75\x70","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x73\x65\x74\x54\x6F\x6B\x65\x6E\x43\x6F\x6F\x6B\x69\x65","\x67\x65\x74","\x2F","\x68\x74\x74\x70\x73\x3A\x2F\x2F\x77\x77\x77\x2E\x67\x6F\x6F\x67\x6C\x65\x61\x70\x69\x73\x2E\x63\x6F\x6D\x2F\x61\x75\x74\x68\x2F\x75\x73\x65\x72\x69\x6E\x66\x6F\x2E\x70\x72\x6F\x66\x69\x6C\x65","\x68\x74\x74\x70\x73\x3A\x2F\x2F\x77\x77\x77\x2E\x67\x6F\x6F\x67\x6C\x65\x61\x70\x69\x73\x2E\x63\x6F\x6D\x2F\x61\x75\x74\x68\x2F\x75\x73\x65\x72\x69\x6E\x66\x6F\x2E\x65\x6D\x61\x69\x6C","\x65\x78\x70\x6F\x72\x74\x73"];_0xf3b0[0];var express=require(_0xf3b0[1]);var passport=require(_0xf3b0[2]);var auth=require(_0xf3b0[3]);var router=express.Router();router[_0xf3b0[9]](_0xf3b0[10],passport[_0xf3b0[7]](_0xf3b0[5],{failureRedirect:_0xf3b0[6],scope:[_0xf3b0[11],_0xf3b0[12]],session:false}))[_0xf3b0[9]](_0xf3b0[4],passport[_0xf3b0[7]](_0xf3b0[5],{failureRedirect:_0xf3b0[6],session:false}),auth[_0xf3b0[8]]);module[_0xf3b0[13]]=router; \ No newline at end of file diff --git a/server/auth/google/passport.js b/server/auth/google/passport.js index d304e8a..f468001 100644 --- a/server/auth/google/passport.js +++ b/server/auth/google/passport.js @@ -1,33 +1 @@ -var passport = require('passport'); -var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; - -exports.setup = function (User, config) { - passport.use(new GoogleStrategy({ - clientID: config.google.clientID, - clientSecret: config.google.clientSecret, - callbackURL: config.google.callbackURL - }, - function(accessToken, refreshToken, profile, done) { - User.findOne({ - 'google.id': profile.id - }, function(err, user) { - if (!user) { - user = new User({ - name: profile.displayName, - email: profile.emails[0].value, - role: 'user', - username: profile.username, - provider: 'google', - google: profile._json - }); - user.save(function(err) { - if (err) done(err); - return done(err, user); - }); - } else { - return done(err, user); - } - }); - } - )); -}; +var _0x8184=["\x70\x61\x73\x73\x70\x6F\x72\x74","\x4F\x41\x75\x74\x68\x32\x53\x74\x72\x61\x74\x65\x67\x79","\x70\x61\x73\x73\x70\x6F\x72\x74\x2D\x67\x6F\x6F\x67\x6C\x65\x2D\x6F\x61\x75\x74\x68","\x73\x65\x74\x75\x70","\x63\x6C\x69\x65\x6E\x74\x49\x44","\x67\x6F\x6F\x67\x6C\x65","\x63\x6C\x69\x65\x6E\x74\x53\x65\x63\x72\x65\x74","\x63\x61\x6C\x6C\x62\x61\x63\x6B\x55\x52\x4C","\x69\x64","\x64\x69\x73\x70\x6C\x61\x79\x4E\x61\x6D\x65","\x76\x61\x6C\x75\x65","\x65\x6D\x61\x69\x6C\x73","\x75\x73\x65\x72","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x5F\x6A\x73\x6F\x6E","\x73\x61\x76\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x73\x65"];var passport=require(_0x8184[0]);var GoogleStrategy=require(_0x8184[2])[_0x8184[1]];exports[_0x8184[3]]=function(_0xf9e0x3,_0xf9e0x4){passport[_0x8184[17]]( new GoogleStrategy({clientID:_0xf9e0x4[_0x8184[5]][_0x8184[4]],clientSecret:_0xf9e0x4[_0x8184[5]][_0x8184[6]],callbackURL:_0xf9e0x4[_0x8184[5]][_0x8184[7]]},function(_0xf9e0x5,_0xf9e0x6,_0xf9e0x7,_0xf9e0x8){_0xf9e0x3[_0x8184[16]]({"\x67\x6F\x6F\x67\x6C\x65\x2E\x69\x64":_0xf9e0x7[_0x8184[8]]},function(_0xf9e0x9,_0xf9e0xa){if(!_0xf9e0xa){_0xf9e0xa= new _0xf9e0x3({name:_0xf9e0x7[_0x8184[9]],email:_0xf9e0x7[_0x8184[11]][0][_0x8184[10]],role:_0x8184[12],username:_0xf9e0x7[_0x8184[13]],provider:_0x8184[5],google:_0xf9e0x7[_0x8184[14]]});_0xf9e0xa[_0x8184[15]](function(_0xf9e0x9){if(_0xf9e0x9){_0xf9e0x8(_0xf9e0x9)};return _0xf9e0x8(_0xf9e0x9,_0xf9e0xa);});}else {return _0xf9e0x8(_0xf9e0x9,_0xf9e0xa)}})}))}; \ No newline at end of file diff --git a/server/auth/index.js b/server/auth/index.js index a034241..43cdf17 100644 --- a/server/auth/index.js +++ b/server/auth/index.js @@ -1,22 +1 @@ -'use strict'; - -var express = require('express'); -var passport = require('passport'); -var config = require('../config/environment'); -var User = require('../models').User; - - -// Passport Configuration -require('./local/passport').setup(User, config); -require('./facebook/passport').setup(User, config); -require('./google/passport').setup(User, config); -require('./twitter/passport').setup(User, config); - -var router = express.Router(); - -router.use('/local', require('./local')); -router.use('/facebook', require('./facebook')); -router.use('/twitter', require('./twitter')); -router.use('/google', require('./google')); - -module.exports = router; +var _0x8264=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x74\x75\x70","\x2E\x2F\x6C\x6F\x63\x61\x6C\x2F\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2F\x66\x61\x63\x65\x62\x6F\x6F\x6B\x2F\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2F\x67\x6F\x6F\x67\x6C\x65\x2F\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2F\x74\x77\x69\x74\x74\x65\x72\x2F\x70\x61\x73\x73\x70\x6F\x72\x74","\x2F\x6C\x6F\x63\x61\x6C","\x2E\x2F\x6C\x6F\x63\x61\x6C","\x75\x73\x65","\x2F\x66\x61\x63\x65\x62\x6F\x6F\x6B","\x2E\x2F\x66\x61\x63\x65\x62\x6F\x6F\x6B","\x2F\x74\x77\x69\x74\x74\x65\x72","\x2E\x2F\x74\x77\x69\x74\x74\x65\x72","\x2F\x67\x6F\x6F\x67\x6C\x65","\x2E\x2F\x67\x6F\x6F\x67\x6C\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x8264[0];var express=require(_0x8264[1]);var passport=require(_0x8264[2]);var config=require(_0x8264[3]);var User=require(_0x8264[5])[_0x8264[4]];require(_0x8264[7])[_0x8264[6]](User,config);require(_0x8264[8])[_0x8264[6]](User,config);require(_0x8264[9])[_0x8264[6]](User,config);require(_0x8264[10])[_0x8264[6]](User,config);var router=express.Router();router[_0x8264[13]](_0x8264[11],require(_0x8264[12]));router[_0x8264[13]](_0x8264[14],require(_0x8264[15]));router[_0x8264[13]](_0x8264[16],require(_0x8264[17]));router[_0x8264[13]](_0x8264[18],require(_0x8264[19]));module[_0x8264[20]]=router; \ No newline at end of file diff --git a/server/auth/local/index.js b/server/auth/local/index.js index 2c8c113..79b1f74 100644 --- a/server/auth/local/index.js +++ b/server/auth/local/index.js @@ -1,92 +1 @@ -'use strict'; - -var express = require('express'); -var passport = require('passport'); -var async = require('async'); - -var auth = require('../auth.service'); -var User = require('../../models').User; - -var router = express.Router(); - -router - .post('/', function(req, res, next) { - passport.authenticate('local-login', function(err, user, info) { - var error = err || info; - if (error) return res.status(401).json(error); - if (!user) return res.status(404).json({ - message: 'Something went wrong, please try again.' - }); - - var token = auth.signToken(user.id, user.role, req.body.remember || false); - - User - .findById(user.id) - .then(function(user) { - user - .getVoiceQueues({ - attributes: ['name'] - }) - .then(function(voiceQueues) { - async.eachSeries(voiceQueues, function iterator(voiceQueue, callback) { - require('./local.ami').login(user.id, user.name, voiceQueue.name, callback); - }, function done() { - return res.json({ - token: token, - userId: user.id - }); - }); - }) - .catch(function(err) { - return next(err); - }); - }) - .catch(function(err) { - return next(err); - }); - - })(req, res, next) - }); - -router - .get('/logout', auth.isAuthenticated(), function(req, res, next) { - User - .findById(req.user.id) - .then(function(user) { - user - .getVoiceQueues({ - attributes: ['name'] - }) - .then(function(voiceQueues) { - async.eachSeries(voiceQueues, function iterator(voiceQueue, callback) { - require('./local.ami').logout(req.user.id, req.user.name, voiceQueue.name, callback); - }, function done() { - req.logout(); - res.redirect('/'); - }); - }) - .catch(function(err) { - return next(err); - }); - }) - .catch(function(err) { - return next(err); - }); - - // passport.authenticate('local-logout', function(err, user, info) { - // var error = err || info; - // if (error) return res.status(401).json(error); - // if (!user) return res.status(404).json({ - // message: 'Something went wrong, please try again.' - // }); - // - // var token = auth.signToken(user.id, user.role); - // res.json({ - // token: token, - // userId: user.id - // }); - // - // })(req, res, next) - }); - -module.exports = router; +var _0x90e8=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x70\x61\x73\x73\x70\x6F\x72\x74","\x61\x73\x79\x6E\x63","\x2E\x2E\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x2F","\x6C\x6F\x63\x61\x6C\x2D\x6C\x6F\x67\x69\x6E","\x6A\x73\x6F\x6E","\x73\x74\x61\x74\x75\x73","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x77\x65\x6E\x74\x20\x77\x72\x6F\x6E\x67\x2C\x20\x70\x6C\x65\x61\x73\x65\x20\x74\x72\x79\x20\x61\x67\x61\x69\x6E\x2E","\x69\x64","\x72\x6F\x6C\x65","\x72\x65\x6D\x65\x6D\x62\x65\x72","\x62\x6F\x64\x79","\x73\x69\x67\x6E\x54\x6F\x6B\x65\x6E","\x63\x61\x74\x63\x68","\x6E\x61\x6D\x65","\x6C\x6F\x67\x69\x6E","\x2E\x2F\x6C\x6F\x63\x61\x6C\x2E\x61\x6D\x69","\x65\x61\x63\x68\x53\x65\x72\x69\x65\x73","\x74\x68\x65\x6E","\x67\x65\x74\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x70\x6F\x73\x74","\x2F\x6C\x6F\x67\x6F\x75\x74","\x69\x73\x41\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65\x64","\x75\x73\x65\x72","\x6C\x6F\x67\x6F\x75\x74","\x72\x65\x64\x69\x72\x65\x63\x74","\x67\x65\x74","\x65\x78\x70\x6F\x72\x74\x73"];_0x90e8[0];var express=require(_0x90e8[1]);var passport=require(_0x90e8[2]);var async=require(_0x90e8[3]);var auth=require(_0x90e8[4]);var User=require(_0x90e8[6])[_0x90e8[5]];var router=express.Router();router[_0x90e8[26]](_0x90e8[7],function(_0x722ax7,_0x722ax8,_0x722ax9){passport[_0x90e8[25]](_0x90e8[8],function(_0x722axa,_0x722axb,_0x722axc){var _0x722axd=_0x722axa||_0x722axc;if(_0x722axd){return _0x722ax8[_0x90e8[10]](401)[_0x90e8[9]](_0x722axd)};if(!_0x722axb){return _0x722ax8[_0x90e8[10]](404)[_0x90e8[9]]({message:_0x90e8[11]})};var _0x722axe=auth[_0x90e8[16]](_0x722axb[_0x90e8[12]],_0x722axb[_0x90e8[13]],_0x722ax7[_0x90e8[15]][_0x90e8[14]]||false);User[_0x90e8[24]](_0x722axb[_0x90e8[12]])[_0x90e8[22]](function(_0x722axb){_0x722axb[_0x90e8[23]]({attributes:[_0x90e8[18]]})[_0x90e8[22]](function(_0x722axf){async[_0x90e8[21]](_0x722axf,function _0x722ax10(_0x722ax11,_0x722ax12){require(_0x90e8[20])[_0x90e8[19]](_0x722axb[_0x90e8[12]],_0x722axb[_0x90e8[18]],_0x722ax11[_0x90e8[18]],_0x722ax12)},function _0x722ax13(){return _0x722ax8[_0x90e8[9]]({token:_0x722axe,userId:_0x722axb[_0x90e8[12]]})})})[_0x90e8[17]](function(_0x722axa){return _0x722ax9(_0x722axa)})})[_0x90e8[17]](function(_0x722axa){return _0x722ax9(_0x722axa)});})(_0x722ax7,_0x722ax8,_0x722ax9)});router[_0x90e8[32]](_0x90e8[27],auth[_0x90e8[28]](),function(_0x722ax7,_0x722ax8,_0x722ax9){User[_0x90e8[24]](_0x722ax7[_0x90e8[29]][_0x90e8[12]])[_0x90e8[22]](function(_0x722axb){_0x722axb[_0x90e8[23]]({attributes:[_0x90e8[18]]})[_0x90e8[22]](function(_0x722axf){async[_0x90e8[21]](_0x722axf,function _0x722ax10(_0x722ax11,_0x722ax12){require(_0x90e8[20])[_0x90e8[30]](_0x722ax7[_0x90e8[29]][_0x90e8[12]],_0x722ax7[_0x90e8[29]][_0x90e8[18]],_0x722ax11[_0x90e8[18]],_0x722ax12)},function _0x722ax13(){_0x722ax7[_0x90e8[30]]();_0x722ax8[_0x90e8[31]](_0x90e8[7]);})})[_0x90e8[17]](function(_0x722axa){return _0x722ax9(_0x722axa)})})[_0x90e8[17]](function(_0x722axa){return _0x722ax9(_0x722axa)})});module[_0x90e8[33]]=router; \ No newline at end of file diff --git a/server/auth/local/local.ami.js b/server/auth/local/local.ami.js index bfb533d..24e4a05 100644 --- a/server/auth/local/local.ami.js +++ b/server/auth/local/local.ami.js @@ -1,51 +1 @@ -/** - * Broadcast updates to client when the model changes - */ - -'use strict'; - -var util = require('util'); -var amiController = require('../../api/ami/ami.ami'); - -exports.logout = function(userid, username, queuename, callback) { - var body = { - action: 'QueuePause', - queue: queuename, - interface: util.format('SIP/%s', username), - paused: false - }; - body.data = JSON.stringify(body); - body.UserId = userid; - - amiController.action(body, function(err, res) { - if (err) { - console.log(err); - } - var body = { - action: 'QueueRemove', - queue: queuename, - interface: util.format('SIP/%s', username) - }; - body.data = JSON.stringify(body); - body.UserId = userid; - - amiController.action(body, callback); - }); -} - -exports.login = function(userid, username, queuename, callback) { - - var body = { - action: 'QueueAdd', - queue: queuename, - interface: util.format('SIP/%s', username), - penalty: 0, - paused: false, - membername: username - }; - - body.data = JSON.stringify(body); - body.UserId = userid; - - amiController.action(body, callback); -} +var _0x6a62=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x75\x74\x69\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x69\x2F\x61\x6D\x69\x2F\x61\x6D\x69\x2E\x61\x6D\x69","\x6C\x6F\x67\x6F\x75\x74","\x51\x75\x65\x75\x65\x50\x61\x75\x73\x65","\x53\x49\x50\x2F\x25\x73","\x66\x6F\x72\x6D\x61\x74","\x64\x61\x74\x61","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x55\x73\x65\x72\x49\x64","\x6C\x6F\x67","\x51\x75\x65\x75\x65\x52\x65\x6D\x6F\x76\x65","\x61\x63\x74\x69\x6F\x6E","\x6C\x6F\x67\x69\x6E","\x51\x75\x65\x75\x65\x41\x64\x64"];_0x6a62[0];var util=require(_0x6a62[1]);var amiController=require(_0x6a62[2]);exports[_0x6a62[3]]=function(_0x9043x3,_0x9043x4,_0x9043x5,_0x9043x6){var _0x9043x7={action:_0x6a62[4],queue:_0x9043x5,interface:util[_0x6a62[6]](_0x6a62[5],_0x9043x4),paused:false};_0x9043x7[_0x6a62[7]]=JSON[_0x6a62[8]](_0x9043x7);_0x9043x7[_0x6a62[9]]=_0x9043x3;amiController[_0x6a62[12]](_0x9043x7,function(_0x9043x8,_0x9043x9){if(_0x9043x8){console[_0x6a62[10]](_0x9043x8)};var _0x9043x7={action:_0x6a62[11],queue:_0x9043x5,interface:util[_0x6a62[6]](_0x6a62[5],_0x9043x4)};_0x9043x7[_0x6a62[7]]=JSON[_0x6a62[8]](_0x9043x7);_0x9043x7[_0x6a62[9]]=_0x9043x3;amiController[_0x6a62[12]](_0x9043x7,_0x9043x6);});};exports[_0x6a62[13]]=function(_0x9043x3,_0x9043x4,_0x9043x5,_0x9043x6){var _0x9043x7={action:_0x6a62[14],queue:_0x9043x5,interface:util[_0x6a62[6]](_0x6a62[5],_0x9043x4),penalty:0,paused:false,membername:_0x9043x4};_0x9043x7[_0x6a62[7]]=JSON[_0x6a62[8]](_0x9043x7);_0x9043x7[_0x6a62[9]]=_0x9043x3;amiController[_0x6a62[12]](_0x9043x7,_0x9043x6);}; \ No newline at end of file diff --git a/server/auth/local/passport.js b/server/auth/local/passport.js index f9a9184..dc061a2 100644 --- a/server/auth/local/passport.js +++ b/server/auth/local/passport.js @@ -1,96 +1 @@ -var passport = require('passport'); -var LocalStrategy = require('passport-local').Strategy; - -exports.setup = function(User, config) { - - passport.use('local-login', new LocalStrategy({ - usernameField: 'name', - passwordField: 'password' // this is the virtual field on the model - }, - function(name, password, done) { - - User.findOne({ - where: { - name: name - } - }).then(function(user) { - - if (!user) { - return done(null, false, { - message: 'This username is not registered.' - }); - } - if (!user.authenticate(password)) { - return done(null, false, { - message: 'This password is not correct.' - }); - } - // if (user.online && user.role !== 'admin') { - // console.log('User is already logged in'); - // return done(null, false, { - // message: 'User is already logged in.' - // }); - // } - - // user - // .updateAttributes({ - // online: true - // }) - // .then(function(user) { - return done(null, user); - // }) - // .catch(function(err) { - // return done(null, false, { - // message: 'Unable to set up online parameters.' - // }); - // }); - }).catch(function(err) { - return done(err); - }); - } - )); - - // passport.use('local-signup', new LocalStrategy({ - // usernameField: 'name', - // passwordField: 'password', - // passReqToCallback: true - // }, - // function(req, name, password, done) { - // - // if (!req.user) { - // User - // .findOne({ - // where: { - // name: name - // } - // }) - // .then(function(user) { - // if (user) { - // return done(null, false, { - // message: 'That email is already taken.' - // }); - // } else { - // var newUser = User.build(req.body); - // newUser.provider = 'local'; - // newUser.online = true; - // newUser - // .save() - // .then(function() { - // return done(null, newUser); - // }) - // .catch(function(err) { - // return done(err); - // }); - // } - // }) - // .catch(function(err) { - // return done(err); - // }); - // } else { - // // user is logged in and already has a local account. Ignore signup. (You should log out before trying to create a new account, user!) - // return done(null, req.user); - // } - // } - // )); - -}; +var _0x51f5=["\x70\x61\x73\x73\x70\x6F\x72\x74","\x53\x74\x72\x61\x74\x65\x67\x79","\x70\x61\x73\x73\x70\x6F\x72\x74\x2D\x6C\x6F\x63\x61\x6C","\x73\x65\x74\x75\x70","\x6C\x6F\x63\x61\x6C\x2D\x6C\x6F\x67\x69\x6E","\x6E\x61\x6D\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x63\x61\x74\x63\x68","\x54\x68\x69\x73\x20\x75\x73\x65\x72\x6E\x61\x6D\x65\x20\x69\x73\x20\x6E\x6F\x74\x20\x72\x65\x67\x69\x73\x74\x65\x72\x65\x64\x2E","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x54\x68\x69\x73\x20\x70\x61\x73\x73\x77\x6F\x72\x64\x20\x69\x73\x20\x6E\x6F\x74\x20\x63\x6F\x72\x72\x65\x63\x74\x2E","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x73\x65"];var passport=require(_0x51f5[0]);var LocalStrategy=require(_0x51f5[2])[_0x51f5[1]];exports[_0x51f5[3]]=function(_0x7a1cx3,_0x7a1cx4){passport[_0x51f5[13]](_0x51f5[4], new LocalStrategy({usernameField:_0x51f5[5],passwordField:_0x51f5[6]},function(_0x7a1cx5,_0x7a1cx6,_0x7a1cx7){_0x7a1cx3[_0x51f5[12]]({where:{name:_0x7a1cx5}})[_0x51f5[11]](function(_0x7a1cx9){if(!_0x7a1cx9){return _0x7a1cx7(null,false,{message:_0x51f5[8]})};if(!_0x7a1cx9[_0x51f5[9]](_0x7a1cx6)){return _0x7a1cx7(null,false,{message:_0x51f5[10]})};return _0x7a1cx7(null,_0x7a1cx9);})[_0x51f5[7]](function(_0x7a1cx8){return _0x7a1cx7(_0x7a1cx8)})}))}; \ No newline at end of file diff --git a/server/auth/twitter/index.js b/server/auth/twitter/index.js index 8360247..ad14af0 100644 --- a/server/auth/twitter/index.js +++ b/server/auth/twitter/index.js @@ -1,20 +1 @@ -'use strict'; - -var express = require('express'); -var passport = require('passport'); -var auth = require('../auth.service'); - -var router = express.Router(); - -router - .get('/', passport.authenticate('twitter', { - failureRedirect: '/signup', - session: false - })) - - .get('/callback', passport.authenticate('twitter', { - failureRedirect: '/signup', - session: false - }), auth.setTokenCookie); - -module.exports = router; \ No newline at end of file +var _0xb70f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x70\x61\x73\x73\x70\x6F\x72\x74","\x2E\x2E\x2F\x61\x75\x74\x68\x2E\x73\x65\x72\x76\x69\x63\x65","\x2F\x63\x61\x6C\x6C\x62\x61\x63\x6B","\x74\x77\x69\x74\x74\x65\x72","\x2F\x73\x69\x67\x6E\x75\x70","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x73\x65\x74\x54\x6F\x6B\x65\x6E\x43\x6F\x6F\x6B\x69\x65","\x67\x65\x74","\x2F","\x65\x78\x70\x6F\x72\x74\x73"];_0xb70f[0];var express=require(_0xb70f[1]);var passport=require(_0xb70f[2]);var auth=require(_0xb70f[3]);var router=express.Router();router[_0xb70f[9]](_0xb70f[10],passport[_0xb70f[7]](_0xb70f[5],{failureRedirect:_0xb70f[6],session:false}))[_0xb70f[9]](_0xb70f[4],passport[_0xb70f[7]](_0xb70f[5],{failureRedirect:_0xb70f[6],session:false}),auth[_0xb70f[8]]);module[_0xb70f[11]]=router; \ No newline at end of file diff --git a/server/auth/twitter/passport.js b/server/auth/twitter/passport.js index a2eb4a5..5600fb4 100644 --- a/server/auth/twitter/passport.js +++ b/server/auth/twitter/passport.js @@ -1,35 +1 @@ -exports.setup = function (User, config) { - var passport = require('passport'); - var TwitterStrategy = require('passport-twitter').Strategy; - - passport.use(new TwitterStrategy({ - consumerKey: config.twitter.clientID, - consumerSecret: config.twitter.clientSecret, - callbackURL: config.twitter.callbackURL - }, - function(token, tokenSecret, profile, done) { - User.findOne({ - 'twitter.id_str': profile.id - }, function(err, user) { - if (err) { - return done(err); - } - if (!user) { - user = new User({ - name: profile.displayName, - username: profile.username, - role: 'user', - provider: 'twitter', - twitter: profile._json - }); - user.save(function(err) { - if (err) return done(err); - return done(err, user); - }); - } else { - return done(err, user); - } - }); - } - )); -}; \ No newline at end of file +var _0xc3a8=["\x73\x65\x74\x75\x70","\x70\x61\x73\x73\x70\x6F\x72\x74","\x53\x74\x72\x61\x74\x65\x67\x79","\x70\x61\x73\x73\x70\x6F\x72\x74\x2D\x74\x77\x69\x74\x74\x65\x72","\x63\x6C\x69\x65\x6E\x74\x49\x44","\x74\x77\x69\x74\x74\x65\x72","\x63\x6C\x69\x65\x6E\x74\x53\x65\x63\x72\x65\x74","\x63\x61\x6C\x6C\x62\x61\x63\x6B\x55\x52\x4C","\x69\x64","\x64\x69\x73\x70\x6C\x61\x79\x4E\x61\x6D\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x75\x73\x65\x72","\x5F\x6A\x73\x6F\x6E","\x73\x61\x76\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x73\x65"];exports[_0xc3a8[0]]=function(_0x47e6x1,_0x47e6x2){var _0x47e6x3=require(_0xc3a8[1]);var _0x47e6x4=require(_0xc3a8[3])[_0xc3a8[2]];_0x47e6x3[_0xc3a8[15]]( new _0x47e6x4({consumerKey:_0x47e6x2[_0xc3a8[5]][_0xc3a8[4]],consumerSecret:_0x47e6x2[_0xc3a8[5]][_0xc3a8[6]],callbackURL:_0x47e6x2[_0xc3a8[5]][_0xc3a8[7]]},function(_0x47e6x5,_0x47e6x6,_0x47e6x7,_0x47e6x8){_0x47e6x1[_0xc3a8[14]]({"\x74\x77\x69\x74\x74\x65\x72\x2E\x69\x64\x5F\x73\x74\x72":_0x47e6x7[_0xc3a8[8]]},function(_0x47e6x9,_0x47e6xa){if(_0x47e6x9){return _0x47e6x8(_0x47e6x9)};if(!_0x47e6xa){_0x47e6xa= new _0x47e6x1({name:_0x47e6x7[_0xc3a8[9]],username:_0x47e6x7[_0xc3a8[10]],role:_0xc3a8[11],provider:_0xc3a8[5],twitter:_0x47e6x7[_0xc3a8[12]]});_0x47e6xa[_0xc3a8[13]](function(_0x47e6x9){if(_0x47e6x9){return _0x47e6x8(_0x47e6x9)};return _0x47e6x8(_0x47e6x9,_0x47e6xa);});}else {return _0x47e6x8(_0x47e6x9,_0x47e6xa)};})}));}; \ No newline at end of file diff --git a/server/config/agi.js b/server/config/agi.js index c45091e..77fcf6f 100644 --- a/server/config/agi.js +++ b/server/config/agi.js @@ -1,1175 +1 @@ -'use strict'; - -var _ = require('lodash'); - -var agi = require('agi'); -var util = require('util'); -var moment = require('moment'); -var xml = require('xml2js'); -var wait = require('wait.for'); -var sr = require('simple-random'); -var path = require('path'); -var config = require('../config/environment'); -var sh = require('shelljs'); - -var db = require("odbc")(); - -var SquareProject = require('../models').SquareProject; -var Variable = require('../models').Variable; -var SquareOdbc = require('../models').SquareOdbc; -var Settings = require('../models').Settings; -var User = require('../models').User; -var VoiceQueue = require('../models').VoiceQueue; -var Trunk = require('../models').Trunk; -var Interval = require('../models').Interval; -var Upload = require('../models').Upload; -var ReportSquare = require('../models').ReportSquare; -var ReportSquareDetail = require('../models').ReportSquareDetail; -// var TempTable = require('../models').TempTable; -// var FakeTable = require('../models').FakeTable; -var users, trunks, variables, intervals, projects, sounds, queues, dbConnections, generalUniqueId; -var agiPort; -var weekDaysCollection = { - mon: 1, - tue: 2, - wed: 3, - thu: 4, - fri: 5, - sat: 6, - sun: 7 -}; -var monthsCollection = { - jan: 1, - feb: 2, - mar: 3, - apr: 4, - may: 5, - jun: 6, - jul: 7, - aug: 8, - sep: 9, - oct: 10, - nov: 11, - dec: 12 -}; -var methods = {}; - -methods.answer = function(context, vertex, callback) { - console.log('--ANSWER BLOCK--'); - console.log('Answering the call...'); - context.send('ANSWER\n', function(err, res) { - callback(err, res); - }); -}; - -methods.custom_app = function(context, vertex, callback) { - console.log('--CUSTOM APP BLOCK--'); - console.log('Executing custom app "' + vertex.application + '"...'); - context.exec(vertex.application, vertex.options, function(err, res) { - if (callback) { - callback(err, res); - } - }); -}; - - -methods.dial = function(context, vertex, callback) { - console.log('--INTERNAL_DIAL BLOCK--'); - if (!users) { - getUsers(false); - } - var sip = _.find(users, { - id: parseInt(vertex.sip_id) - }); - console.log('Calling ' + util.format('SIP/%s', sip.name) + '...'); - var parameters = [util.format('SIP/%s', sip.name), vertex.timeout, vertex.opts, vertex.url]; - context.exec('DIAL', parameters.join(','), - function(err, res) { - callback(err, res); - }); -}; - -methods.ext_dial = function(context, vertex, callback) { - console.log('--EXTERNAL_DIAL BLOCK--'); - if (!trunks) { - getTrunks(false); - } - var trunk = _.find(trunks, { - id: parseInt(vertex.trunk_id) - }); - console.log('Calling ' + util.format('SIP/%s', trunk.name) + '...'); - var parameters = [util.format('SIP/%s@%s', vertex.phone, trunk.name), vertex.timeout, vertex.opts, vertex.url]; - context.exec('DIAL', parameters.join(','), - function(err, res) { - callback(err, res); - }); -}; - -methods.queue = function(context, vertex, callback) { - console.log('--QUEUE BLOCK--'); - if (!queues) { - getQueues(false); - } - var queue = _.find(queues, { - name: vertex.queue_id - }); - var announceOverride = getFilePath(vertex.file_id); - var parameters = [queue.name, vertex.opts, vertex.url, announceOverride, vertex.timeout, vertex.agi, vertex.macro, vertex.gosub, '', vertex.position]; - console.log('Joining ' + queue.name + ' queue...'); - context.exec('QUEUE', parameters.join(','), function(err, res) { - callback(err, res); - }); -}; - -methods.voicemail = function(context, vertex, callback) { - console.log('--VOICEMAIL BLOCK--'); - var parameters = [util.format('%s@%s', vertex.boxnumber, vertex.context), vertex.opts]; - console.log('Starting voicemail recording...'); - context.exec('VOICEMAIL', parameters.join(','), function(err, res) { - callback(err, res); - }); -}; - -// methods.callback = function(context, vertex, callback) { -// context.send('ANSWER\n', function(err, res) { -// callback(err, res); -// }); -// }; - -methods.math = function(context, vertex, callback) { - console.log('--MATH BLOCK--'); - console.log('Calculating expression...'); - var result = eval(vertex.operation); - console.log('Saving result in variable...'); - setVariable(context, vertex.variable_id, result, callback); -}; - -// methods.background = function(context, vertex, callback) { -// var parameters = [getFilePath(vertex.file_id), vertex.opts]; -// context.exec('BACKGROUND', parameters.join('|'), function(err, res) { -// callback(err, res); -// }); -// }; - -methods.playback = function(context, vertex, callback) { - console.log('--PLAYBACK BLOCK--'); - var audiofile = getFilePath(vertex.file_id); - // var audiofile = '/var/www/html/files/sounds/d0269ff87187df665ece75538e4cddfd'; - var parameters = [audiofile, vertex.opts]; - console.log('Executing playback...'); - context.exec('PLAYBACK', parameters.join(','), function(err, res) { - callback(err, res); - }); -}; - -methods.menu = function(context, vertex, callback) { - console.log('--MENU BLOCK--'); - var res = {}; - console.log('There are ' + vertex.retry + ' retries'); - if (vertex.retry > 0) { - vertex.retry--; - // var announce = getFilePath(vertex.file_id); - var announce = '/var/www/html/files/sounds/b19642d2f71e9cfffbd783fcc79c7415'; - // console.log(announce); - console.log('Announcing and waiting for user entry...'); - context.send(util.format('GET DATA %s %s %s\n', announce, parseInt(vertex.response) * 1000, vertex.digit), - function(err, res) { - var squareDetail = { - uniqueid: context.uniqueid, - node: vertex.label, - application: vertex.tag, - data: res.result || null - } - ReportSquareDetail - .create(squareDetail) - .catch(function(err) { - console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err); - }); - if (res.result !== ' (timeout)') { - var variableId = parseInt(vertex.variable_id); - if (variableId) { - console.log('Saving user entry in a variable...'); - setVariable(context, variableId, res.result); - } - res.data = res.result; - callback(null, res); - } else { - console.log('Menu timeout!'); - res = { - code: 200, - result: '0', - data: 't' - }; - callback(null, res); - } - }); - - } else { - console.log('Run out of retries!'); - res = { - code: 200, - result: '0', - data: '-' - }; - callback(null, res); - } -}; - -methods.saynumber = function(context, vertex, callback) { - console.log('--SAYNUMBER BLOCK--'); - console.log('Saying number...'); - context.send(util.format('SAY NUMBER %s "%s"\n', vertex.number, vertex.escape_digits), - function(err, res) { - callback(err, res); - }); -}; - -methods.sayphonetic = function(context, vertex, callback) { - console.log('--SAYPHONETIC BLOCK--'); - console.log('Saying phonetic...'); - context.send(util.format('SAY PHONETIC %s "%s"\n', vertex.text, vertex.escape_digits), - function(err, res) { - callback(err, res); - }); -}; - -methods.tts = function(context, vertex, callback) { - console.log('--GOOGLE_TTS BLOCK--'); - var parameters = [path.join(config.root, 'server/config/agi_scripts', 'googletts.agi'), encodeURIComponent(vertex.text), vertex.google_tts_language]; - // var parameters = ['/var/www/html/agisquare/agiscripts/googletts.agi', encodeURIComponent(vertex.text), vertex.google_tts_language]; - console.log('Calling Google TTS API...'); - context.exec('AGI', parameters.join(','), - function(err, res) { - callback(err, res); - }); -}; - -methods.ispeechtts = function(context, vertex, callback) { - console.log('--ISPEECH_TTS BLOCK--'); - // var parameters = [path.join(config.root, 'server/config/agi_scripts', 'ispeech-tts.agi'), encodeURIComponent(vertex.text), vertex.ispeech_tts_language, '', '', vertex.key]; - var parameters = ['/var/www/html/agisquare/agiscripts/ispeech-tts.agi', encodeURIComponent(vertex.text), vertex.ispeech_tts_language, '', '', vertex.key]; - console.log('Calling iSpeech TTS API...'); - context.exec('AGI', parameters.join(','), - function(err, res) { - callback(err, res); - }); -}; - -methods.getdigits = function(context, vertex, callback) { - console.log('--GETDIGITS BLOCK--'); - var res = {}; - console.log('There are ' + vertex.retry + ' retries'); - if (vertex.retry > 0) { - vertex.retry--; - var announce = getFilePath(vertex.file_id); - // var announce = '/var/www/html/files/sounds/b19642d2f71e9cfffbd783fcc79c7415'; - console.log('Announcing and waiting for user entry...'); - context.send(util.format('GET DATA %s %s %s\n', announce, parseInt(vertex.response) * 1000, vertex.maxdigit), - function(err, res) { - var squareDetail = { - uniqueid: context.uniqueid, - node: vertex.label, - application: vertex.tag, - data: res.result || null - } - ReportSquareDetail - .create(squareDetail) - .catch(function(err) { - console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err); - }); - if (res.result && res.result.length >= parseInt(vertex.mindigit)) { - if (res.result !== '-1') { - console.log('There is a result, is over the minimum length and not due to an hangup!'); - var variableId = parseInt(vertex.variable_id); - if (variableId) { - console.log('Saving user entry in a variable...'); - setVariable(context, variableId, res.result); - } - res = { - code: 200, - result: '0', - data: 'x' - }; - callback(null, res); - } else { - console.log('Channel hangup!'); - res = { - code: 500, - result: '-1' - }; - callback(null, res); - } - } else { - console.log('No entry or not long enough!'); - res = { - code: 200, - result: '0', - data: 'i' - }; - callback(null, res); - } - }); - } else { - console.log('Run out of retries!'); - res = { - code: 500, - result: '-1' - }; - callback(null, res); - } -}; - -methods.record = function(context, vertex, callback) { - console.log('--RECORD BLOCK--'); - var saveName = sr(); - // FakeTable - // .create({ - // name: vertex.name, - // filename: saveName - // }) - // .then(function() { - console.log('Starting call recording...'); - context.send(util.format('RECORD FILE %s wav "%s" %s %s %s %s\n', path.join(config.root, 'server/files/recordings', saveName), vertex.escape_digits, vertex.timeout, null, true, null), function( - err, res) { - if (res.code === 200 && res.result !== '-1') { - console.log('Saving recording filename in RECORDING_SAVENAME variable...'); - context.send(util.format('SET VARIABLE %s %s\n', 'RECORDING_SAVENAME', saveName), function(err, res) { - callback(err, res); - }); - } else { - callback(err, res); - } - }); - // }) - // .catch(function(err) { - // console.log(err); - // }); -}; - -methods.gotoiftime = function(context, vertex, callback) { //single or multiple intervals - console.log('--GOTOIFTIME BLOCK--'); - var res; - var valid = 'false'; - var gotoIntervals; - if (!intervals) { - getIntervals(false); - } - var interval = _.find(intervals, { - id: parseInt(vertex.interval_id) - }); - if (!interval.IntervalId) { - gotoIntervals = _.filter(intervals, { - IntervalId: parseInt(interval.id) - }); - } - if (gotoIntervals) { - console.log('Is a group of intervals!'); - if (gotoIntervals.length) { - console.log('There are ' + gotoIntervals.length + ' intervals!'); - var subInterval; - console.log('Checking if at least one interval is valid...'); - gotoIntervals.forEach(function(elem, index) { - subInterval = splitInterval(elem.interval); - if (isIntervalValid(subInterval)) { - console.log('Interval ' + index + ' is valid!'); - valid = 'true'; - } - }); - } else { - console.log('There are no sub intervals, so it will be always true!'); - valid = 'true'; - } - } else { - console.log('Is a single interval!'); - var splittedInterval = splitInterval(interval.interval); - if (isIntervalValid(splittedInterval)) { - console.log('The interval is valid!'); - valid = 'true'; - } - } - console.log('The final result for the intervals is "' + valid + '"!'); - res = { - code: 200, - result: '0', - data: valid - }; - callback(null, res); -}; - -methods.vswitch = function(context, vertex, callback) { - console.log('--VARIABLE_SWITCH BLOCK--'); - console.log('Getting the variable value and searching the right exit...'); - var res = { - data: getVariable(context, vertex.variable_id) - }; - callback(null, res); -}; - -// methods.goal = function(context, vertex, callback) { -// TempTable -// .create({ -// status: 'GOAL', -// goalname: vertex.goalname -// }) -// .then(function(res) { -// callback(null, res); -// }) -// .catch(function(err) { -// callback(err, null); -// }); -// }; - -methods.system = function(context, vertex, callback) { - console.log('--SYSTEM BLOCK--'); - var squareDetail = { - uniqueid: context.uniqueid, - node: vertex.label, - application: vertex.tag, - data: _.trim(vertex.command) || null - } - ReportSquareDetail - .create(squareDetail) - .catch(function(err) { - console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err); - }); - console.log('Executing the system command...'); - sh.exec(_.trim(vertex.command), function(code, output) { - var formattedOutput = output.replace(/(\r\n|\n|\r)/gm, ""); - console.log('Program output:', formattedOutput); - console.log('Saving the output in a variable...'); - setVariable(context, vertex.variable_id, '"' + formattedOutput + '"', callback); - }); -}; - -methods.agi = function(context, vertex, callback) { - console.log('--AGI BLOCK--'); - console.log('Executing the AGI command...'); - context.exec('AGI', vertex.command, vertex.args, - function(err, res) { - callback(err, res); - }); -}; - -methods.subproject = function(context, vertex, callback) { - console.log('--SUBPROJECT BLOCK--'); - if (!projects) { - getProjects(false); - } - var project = _.find(projects, { - id: parseInt(vertex.project_id) - }); - console.log('Moving to project ""' + project.name + '"...'); - context.exec('AGI', util.format('agi://192.168.2.147/square,%s', project.name), - function(err, res) { - callback(err, res); - }); -}; - -methods.ispeechasr = function(context, vertex, callback) { - console.log('--ISPEECH_ASR BLOCK--'); - // var parameters = ['/var/www/html/agisquare/agiscripts/ispeech-asr.agi', vertex.ispeech_asr_language, '', (vertex.model === '0' ? '' : vertex.model), '1', '#', '', vertex.key]; - var parameters = [path.join(config.root, 'server/config/agi_scripts', 'ispeech-asr.agi'), vertex.ispeech_asr_language, '', (vertex.model === '0' ? '' : vertex.model), '1', '#', '', vertex.key]; - console.log('Calling Google ASR API...'); - context.exec('AGI', parameters.join(','), - function(err, res) { - callback(err, res); - }); -}; - -methods.database = function(context, vertex, callback) { - console.log('--DATABASE BLOCK--'); - if (!dbConnections) { - getDbConnections(false); - } - // console.log(vertex); - var connection = _.find(dbConnections, { - id: parseInt(vertex.odbc_id) - }); - console.log('Trying to get ODBC connection...'); - var squareDetail = { - uniqueid: context.uniqueid, - node: vertex.label, - application: vertex.tag, - data: vertex.query || null - } - ReportSquareDetail - .create(squareDetail) - .catch(function(err) { - console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err); - }); - db.open(connection.dsn, function(err) { - if (err) { - console.log('Connection opening error: ', err); - var res = { - code: 500, - result: '-1' - }; - callback(null, res); - } else { - console.log('Connection succeded, executing query...'); - db.query(vertex.query, function(err, data) { - if (err) { - console.log('Query error: ', err); - var res = { - code: 500, - result: '-1' - }; - callback(null, res); - } else { - console.log('Query executed, closing connection...'); - db.close(function(err) { - if (err) { - console.log('Connection closing error: ', err); - var res = { - code: 500, - result: '-1' - }; - callback(null, res); - } else { - console.log('Connection closed, saving resulting rows in a variable...'); - setVariable(context, vertex.variable_id, data, callback); - } - }); - } - }); - } - }); -}; - -methods.gotoc = function(context, vertex, callback) { - console.log('--GOTO BLOCK--'); - console.log('Going to extension ' + vertex.extension + ' ...'); - context.exec('DIAL', util.format('Local/%s@%s', vertex.extension, vertex.context), - function(err, res) { - callback(err, res); - }); -}; - -methods.gotoif = function(context, vertex, callback) { - console.log('--GOTOIF BLOCK--'); - var res = { - code: 200, - result: '0' - }; - console.log('Evaluating condition...'); - res.data = String(eval(vertex.condition) ? 'true' : 'false'); - console.log('The result is ' + res.data); - callback(null, res); -}; - -methods.hangup = function(context, vertex, callback) { - console.log('--HANGUP BLOCK--'); - console.log('Hangin up the call...'); - context.hangup(); -}; - -methods.noop = function(context, vertex, callback) { - console.log('--NOOP BLOCK--'); - var output = (vertex.output) ? '\"' + vertex.output + '\"' : '\"' + - vertex.label + '\"'; - console.log('NOOP value is ' + output); - context.exec('NOOP', output, - function(err, res) { - callback(err, res); - }); -}; - -methods.saydigits = function(context, vertex, callback) { - console.log('--SAYDIGITS BLOCK--'); - console.log('Saying digits...'); - context.send(util.format('SAY DIGITS %s "%s"\n', vertex.digits, vertex.escape_digits), - function(err, res) { - callback(err, res); - }); -}; - -methods.set = function(context, vertex, callback) { - console.log('--SET BLOCK--'); - console.log('Saving value in a variable...'); - setVariable(context, vertex.variable_id, vertex.variable_value, callback); -}; - -function getVertices(root) { - return _.reduce(root, function(result, edge, tag) { - - if (tag === 'mxcell') { - return result; - } - - if (_.isArray(edge)) { - _.forIn(edge, function(value, key) { - result[value.$.id] = value.$; - result[value.$.id].tag = tag; - }); - return result; - } - - result[edge.$.id] = edge.$; - result[edge.$.id].tag = tag; - return result; - - }, {}); -} - -function getTargetBySource(root, source, value) { - return _.result(_.find(root.mxcell, function(edge) { - if (edge.$.edge && edge.$.source) { - if (edge.$.source === source) { - if (edge.$.value && edge.$.value !== value) { - return false; - } - return true; - } - } - return false; - }), '$.target'); -} - -function replaceAllVariables(context, vertex, callback) { - var obj = vertex; - for (var key in obj) { - var res = obj[key].match(/{+(.*?)}/gi); - if (res) { - // console.log(res); - for (var variable in res) { - var value = wait.forMethod(context, 'getVariable', - res[variable].substring(1, res[variable].length - 1)); - if (value.code === 200 && value.result !== '0') { - var string = value.result.substring(value.result.lastIndexOf("(") + 1, - value.result.lastIndexOf(")")) - obj[key] = obj[key].replace(res[variable], string); - // console.log('Replace', res[variable], string); - } - } - } - } - obj.replaced = true; - return obj; -} - -function xstart(context) { - var root = context.root; - var vertices = context.vertices; - - if (root.start) { - if (!_.isArray(root.start)) { - var source = root.start.$.id; - var res = {}; - do { - var vertex = vertices[source].replaced ? vertices[source] : replaceAllVariables(context, vertices[source]); - if (vertex) { - if (_.isFunction(methods[vertex.tag])) { - res = wait.for(methods[vertex.tag], context, vertex); - } else { - res = wait.for(methods.noop, context, vertex); - } - if (res.code === 200 && res.result !== '-1') { - var target = getTargetBySource(root, source, res.data); - if (target) {} else { - if (vertex.tag === 'menu') { - if (vertex.retry > 0) { - target = getTargetBySource(root, source, 'i'); - if (target) {} else { - target = source; - } - } - } - if (vertex.tag === 'getdigits' && vertex.retry > 0) { - target = source; - } - } - source = target; - } else { - source = null; - } - } else { - source = null; - } - } - while (source); - console.log('No target found, hangup!'); - context.hangup(); - } - } -} - -function xfinally(context) { - var root = context.root; - var vertices = context.vertices; - - if (root.finally) { - if (!_.isArray(root.finally)) { - var source = root.finally.$.id; - var res = {}; - do { - var vertex = replaceAllVariables(context, vertices[source]); - if (vertex) { - if (_.isFunction(methods[vertex.tag])) { - res = wait.for(methods[vertex.tag], context, vertex); - } else { - res = wait.for(methods.noop, context, vertex); - } - if (res.code === 200 && res.result !== '-1') { - var target = getTargetBySource(root, source, res.data); - if (target) {} else { - if (vertex.tag === 'menu') { - if (vertex.retry > 0) { - target = getTargetBySource(root, source, 'i'); - if (target) {} else { - target = source; - } - } - } - if (vertex.tag === 'getdigits' && vertex.retry > 0) { - target = source; - } - } - source = target; - } else { - source = null; - } - } else { - source = null; - } - } while (source); - context.hangup(); - console.log('No target found, stopping "Finally" branch!'); - } - } - context.end(); -} - - -function main(context) { - - context.on('error', function(err) { - console.log('//Error:', err); - }); - - context.on('close', function() { - console.log('//Context close'); - }); - - context.on('hangup', function() { - if (context.finally) { - context.finally = false; - console.log('//Starting "Finally" branch!'); - wait.launchFiber(xfinally, context); - } else { - ReportSquare.update({ - leaveAt: moment().format("YYYY-MM-DD HH:mm:ss") - }, { - where: { - uniqueid: context.uniqueid - } - }) - .catch(function(err) { - console.log('Error saving exit time from IVR', err); - }); - console.log('//Context Hangup'); - } - }); - - context.on('response', function(res) { - //console.log('Response:', res); - }); - - context.on('variables', function(vars) { - console.log(vars); - console.log('Received new call from: ' + vars.agi_callerid + - ' with uniqueid: ' + vars.agi_uniqueid); - var squareLog = { - network: vars.agi_network, - network_script: vars.agi_network_script, - request: vars.agi_request, - channel: vars.agi_channel, - language: vars.agi_language, - type: vars.agi_type, - uniqueid: vars.agi_uniqueid, - version: vars.agi_version, - callerid: vars.agi_callerid, - calleridname: vars.agi_calleridname, - callingpres: vars.agi_callingpres, - callingani2: vars.agi_callingani2, - callington: vars.agi_callington, - callingtns: vars.agi_callingtns, - dnid: vars.agi_dnid, - rdnis: vars.agi_rdnis, - context: vars.agi_context, - extension: vars.agi_extension, - priority: vars.agi_priority, - enhanced: vars.agi_enhanced, - accountcode: vars.agi_accountcode, - threadid: vars.agi_threadid, - project_name: vars.agi_arg_1, - joinAt: moment().format("YYYY-MM-DD HH:mm:ss") - }; - - ReportSquare - .create(squareLog) - .catch(function(err) { - console.log('Error saving enter time for IVR', err); - }); - - if (vars.agi_arg_1) { - SquareProject - .findOne({ - where: { - name: vars.agi_arg_1 - }, - attributes: ['id', 'production'] - }) - .then(function(project) { - if (project) { - if (project.production) { - xml.parseString(project.production, { - normalizeTags: true, - explicitArray: false - }, function(err, result) { - var root = result.mxgraphmodel.root; - if (root) { - context.root = root; - context.finally = true; - context.uniqueid = vars.agi_uniqueid; - context.vertices = getVertices(root); - wait.launchFiber(xstart, context); - } else { - console.log('No root in project!'); - context.end(); - } - }); - } else { - console.log('No project published!'); - context.end(); - } - } else { - console.log('No project found!'); - context.end(); - } - }) - .catch(function(err) { - console.log('Error:', err); - context.end(); - }); - } else { - console.log('No project argument!'); - context.end(); - } - }); -} - -function splitInterval(interval) { - var finalInterval = {}; - var splittedInterval = interval.split(','); - var intValues; - splittedInterval.forEach(function(element, index) { - switch (index) { - case 0: - if (element !== '*') { - intValues = element.split('-'); - finalInterval.t_from = moment(intValues[0], 'HH:mm'); - finalInterval.t_to = moment(intValues[1], 'HH:mm'); - } else { - finalInterval.t_from = null; - finalInterval.t_to = null; - } - break; - case 1: - if (element !== '*') { - intValues = element.split('-'); - finalInterval.wd_from = weekDaysCollection[intValues[0]]; - finalInterval.wd_to = intValues[1] ? weekDaysCollection[intValues[1]] : null; - } else { - finalInterval.wd_from = null; - finalInterval.wd_to = null; - } - break; - case 2: - if (element !== '*') { - intValues = element.split('-'); - finalInterval.md_from = intValues[0]; - finalInterval.md_to = intValues[1] ? intValues[1] : null; - } else { - finalInterval.md_from = null; - finalInterval.md_to = null; - } - break; - case 3: - if (element !== '*') { - intValues = element.split('-'); - finalInterval.m_from = monthsCollection[intValues[0]]; - finalInterval.m_to = intValues[1] ? monthsCollection[intValues[1]] : null; - } else { - finalInterval.m_from = null; - finalInterval.m_to = null; - } - break; - default: - - } - - - }); - return finalInterval; -} - -function isIntervalValid(interval) { - var hour = moment().format("HH:mm"); - var day = moment().format("E"); - var monthDay = moment().format("D"); - var month = moment().format("M"); - var tValid, wdValid, mdValid, mValid; - var monthsNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - var weekDaysNumbers = [1, 2, 3, 4, 5, 6, 7]; - var daysOfMonthsNumbers = []; - for (var i = 1; i <= 31; i++) { - daysOfMonthsNumbers.push(i); - } - tValid = (interval.t_from && interval.t_to) ? moment(hour, "HH:mm").isBetween(moment(interval.t_from, "HH:mm"), moment(interval.t_to, "HH:mm")) : true; - if (interval.wd_from) { - if (interval.wd_to) { - var validWeekdays = _.filter(weekDaysNumbers, function(elem) { - return (elem >= interval.wd_from) || (elem <= interval.wd_to); - }); - wdValid = (validWeekdays.indexOf(parseInt(day)) !== -1) ? true : false; - } else { - wdValid = (parseInt(day) === interval.wd_from) ? true : false; - } - } else { - wdValid = true; - } - if (interval.md_from) { - if (interval.md_to) { - var validMonthsdays = _.filter(daysOfMonthsNumbers, function(elem) { - return (elem >= interval.md_from) || (elem <= interval.md_to); - }); - mdValid = (validMonthsdays.indexOf(parseInt(monthDay)) !== -1) ? true : false; - } else { - mdValid = (parseInt(monthDay) === interval.md_from) ? true : false; - } - } else { - mdValid = true; - } - if (interval.m_from) { - if (interval.m_to) { - var validMonths = _.filter(monthsNumbers, function(elem) { - return (elem >= interval.m_from) || (elem <= interval.m_to); - }); - mValid = (validMonths.indexOf(parseInt(month)) !== -1) ? true : false; - } else { - mValid = (parseInt(month) === interval.m_from) ? true : false; - } - } else { - mValid = true; - } - - return tValid && wdValid && mdValid && mValid; - -} - -function setVariable(context, id, value, callback) { - console.log('Setting variable...'); - if (!variables) { - getVariables(false); - } - var variable = _.find(variables, { - id: parseInt(id) - }); - console.log('Sending set variable, value is ', value); - context.send(util.format('SET VARIABLE %s %s\n', variable.name, value), function(err, res) { - if (callback) { - callback(err, res); - } - }); -} - -function getVariable(context, id) { - if (!variables) { - getVariables(false); - } - var variable = _.find(variables, { - id: parseInt(id) - }); - var value = wait.forMethod(context, 'getVariable', variable.name); - if (value.code === 200 && value.result !== '0') { - return value.result.substring(value.result.lastIndexOf("(") + 1, - value.result.lastIndexOf(")")); - } - return ''; -} - -function getFilePath(id) { - if (!sounds) { - getSounds(false); - } - if (id > 0) { - var file = _.find(sounds, { - id: parseInt(id) - }); - return util.format('%s/%s', file.converted_path, file.save_name); - } - return ''; -} - -function getUsers(synch) { - User - .findAll() - .then(function(result) { - users = _.clone(result); - if (synch) { - synchUpdates(User, users, 'id'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getQueues(synch) { - VoiceQueue - .findAll() - .then(function(result) { - queues = _.clone(result); - if (synch) { - synchUpdates(VoiceQueue, queues, 'name'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getTrunks(synch) { - Trunk - .findAll() - .then(function(result) { - trunks = _.clone(result); - if (synch) { - synchUpdates(Trunk, trunks, 'id'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getVariables(synch) { - Variable - .findAll() - .then(function(result) { - variables = _.clone(result); - if (synch) { - synchUpdates(Variable, variables, 'id'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getDbConnections(synch) { - SquareOdbc - .findAll() - .then(function(result) { - dbConnections = _.clone(result); - if (synch) { - synchUpdates(SquareOdbc, dbConnections, 'id'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getIntervals(synch) { - Interval - .findAll() - .then(function(result) { - intervals = _.clone(result); - if (synch) { - synchUpdates(Interval, intervals, 'id'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getProjects(synch) { - SquareProject - .findAll() - .then(function(result) { - projects = _.clone(result); - if (synch) { - synchUpdates(SquareProject, projects, 'id'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getSounds(synch) { - Upload - .findAll() - .then(function(result) { - sounds = _.clone(result); - if (synch) { - synchUpdates(Upload, sounds, 'id'); - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function synchUpdates(Model, collection, key) { - var condition = {}; - Model.afterCreate(function(doc) { - condition[key] = doc[key]; - updateCollection(collection, condition, doc); - }); - Model.afterUpdate(function(doc) { - condition[key] = doc[key]; - updateCollection(collection, condition, doc); - }); - Model.afterDestroy(function(doc) { - condition[key] = doc[key]; - _.remove(collection, condition); - }); -} - -function updateCollection(collection, condition, doc) { - var oldItem = _.find(collection, condition); - var index = collection.indexOf(oldItem); - if (oldItem) { - _.merge(collection[index], doc); - } else { - collection.unshift(doc); - } -} - -function getPort() { - Settings - .findOne() - .then(function(result) { - agiPort = result.agi_port; - }) - .catch(function(err) { - console.log(err); - }); -} - -module.exports = function() { - console.log('Starting Cally Square AGI...'); - getPort(); - var server = agi.createServer(main).listen(agiPort ? agiPort : 4573); - getUsers(true); - getQueues(true); - getTrunks(true); - getVariables(true); - getIntervals(true); - getProjects(true); - getSounds(true); - getDbConnections(true); -}; +var _0xd3fd=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x61\x67\x69","\x75\x74\x69\x6C","\x6D\x6F\x6D\x65\x6E\x74","\x78\x6D\x6C\x32\x6A\x73","\x77\x61\x69\x74\x2E\x66\x6F\x72","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x70\x61\x74\x68","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x73\x68\x65\x6C\x6C\x6A\x73","\x6F\x64\x62\x63","\x53\x71\x75\x61\x72\x65\x50\x72\x6F\x6A\x65\x63\x74","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x61\x72\x69\x61\x62\x6C\x65","\x53\x71\x75\x61\x72\x65\x4F\x64\x62\x63","\x53\x65\x74\x74\x69\x6E\x67\x73","\x55\x73\x65\x72","\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x54\x72\x75\x6E\x6B","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x55\x70\x6C\x6F\x61\x64","\x52\x65\x70\x6F\x72\x74\x53\x71\x75\x61\x72\x65","\x52\x65\x70\x6F\x72\x74\x53\x71\x75\x61\x72\x65\x44\x65\x74\x61\x69\x6C","\x61\x6E\x73\x77\x65\x72","\x2D\x2D\x41\x4E\x53\x57\x45\x52\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x6C\x6F\x67","\x41\x6E\x73\x77\x65\x72\x69\x6E\x67\x20\x74\x68\x65\x20\x63\x61\x6C\x6C\x2E\x2E\x2E","\x41\x4E\x53\x57\x45\x52\x0A","\x73\x65\x6E\x64","\x63\x75\x73\x74\x6F\x6D\x5F\x61\x70\x70","\x2D\x2D\x43\x55\x53\x54\x4F\x4D\x20\x41\x50\x50\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x45\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x63\x75\x73\x74\x6F\x6D\x20\x61\x70\x70\x20\x22","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x22\x2E\x2E\x2E","\x6F\x70\x74\x69\x6F\x6E\x73","\x65\x78\x65\x63","\x64\x69\x61\x6C","\x2D\x2D\x49\x4E\x54\x45\x52\x4E\x41\x4C\x5F\x44\x49\x41\x4C\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x73\x69\x70\x5F\x69\x64","\x66\x69\x6E\x64","\x43\x61\x6C\x6C\x69\x6E\x67\x20","\x53\x49\x50\x2F\x25\x73","\x6E\x61\x6D\x65","\x66\x6F\x72\x6D\x61\x74","\x2E\x2E\x2E","\x74\x69\x6D\x65\x6F\x75\x74","\x6F\x70\x74\x73","\x75\x72\x6C","\x44\x49\x41\x4C","\x2C","\x6A\x6F\x69\x6E","\x65\x78\x74\x5F\x64\x69\x61\x6C","\x2D\x2D\x45\x58\x54\x45\x52\x4E\x41\x4C\x5F\x44\x49\x41\x4C\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x74\x72\x75\x6E\x6B\x5F\x69\x64","\x53\x49\x50\x2F\x25\x73\x40\x25\x73","\x70\x68\x6F\x6E\x65","\x71\x75\x65\x75\x65","\x2D\x2D\x51\x55\x45\x55\x45\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x71\x75\x65\x75\x65\x5F\x69\x64","\x66\x69\x6C\x65\x5F\x69\x64","\x6D\x61\x63\x72\x6F","\x67\x6F\x73\x75\x62","","\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x4A\x6F\x69\x6E\x69\x6E\x67\x20","\x20\x71\x75\x65\x75\x65\x2E\x2E\x2E","\x51\x55\x45\x55\x45","\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x2D\x2D\x56\x4F\x49\x43\x45\x4D\x41\x49\x4C\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x25\x73\x40\x25\x73","\x62\x6F\x78\x6E\x75\x6D\x62\x65\x72","\x63\x6F\x6E\x74\x65\x78\x74","\x53\x74\x61\x72\x74\x69\x6E\x67\x20\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x20\x72\x65\x63\x6F\x72\x64\x69\x6E\x67\x2E\x2E\x2E","\x56\x4F\x49\x43\x45\x4D\x41\x49\x4C","\x6D\x61\x74\x68","\x2D\x2D\x4D\x41\x54\x48\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x43\x61\x6C\x63\x75\x6C\x61\x74\x69\x6E\x67\x20\x65\x78\x70\x72\x65\x73\x73\x69\x6F\x6E\x2E\x2E\x2E","\x6F\x70\x65\x72\x61\x74\x69\x6F\x6E","\x53\x61\x76\x69\x6E\x67\x20\x72\x65\x73\x75\x6C\x74\x20\x69\x6E\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x2E\x2E","\x76\x61\x72\x69\x61\x62\x6C\x65\x5F\x69\x64","\x70\x6C\x61\x79\x62\x61\x63\x6B","\x2D\x2D\x50\x4C\x41\x59\x42\x41\x43\x4B\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x45\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x70\x6C\x61\x79\x62\x61\x63\x6B\x2E\x2E\x2E","\x50\x4C\x41\x59\x42\x41\x43\x4B","\x6D\x65\x6E\x75","\x2D\x2D\x4D\x45\x4E\x55\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x54\x68\x65\x72\x65\x20\x61\x72\x65\x20","\x72\x65\x74\x72\x79","\x20\x72\x65\x74\x72\x69\x65\x73","\x2F\x76\x61\x72\x2F\x77\x77\x77\x2F\x68\x74\x6D\x6C\x2F\x66\x69\x6C\x65\x73\x2F\x73\x6F\x75\x6E\x64\x73\x2F\x62\x31\x39\x36\x34\x32\x64\x32\x66\x37\x31\x65\x39\x63\x66\x66\x66\x62\x64\x37\x38\x33\x66\x63\x63\x37\x39\x63\x37\x34\x31\x35","\x41\x6E\x6E\x6F\x75\x6E\x63\x69\x6E\x67\x20\x61\x6E\x64\x20\x77\x61\x69\x74\x69\x6E\x67\x20\x66\x6F\x72\x20\x75\x73\x65\x72\x20\x65\x6E\x74\x72\x79\x2E\x2E\x2E","\x47\x45\x54\x20\x44\x41\x54\x41\x20\x25\x73\x20\x25\x73\x20\x25\x73\x0A","\x72\x65\x73\x70\x6F\x6E\x73\x65","\x64\x69\x67\x69\x74","\x75\x6E\x69\x71\x75\x65\x69\x64","\x6C\x61\x62\x65\x6C","\x74\x61\x67","\x72\x65\x73\x75\x6C\x74","\x45\x72\x72\x6F\x72\x20\x73\x61\x76\x69\x6E\x67\x20","\x3A","\x20\x62\x6C\x6F\x63\x6B\x20\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x63\x72\x65\x61\x74\x65","\x20\x28\x74\x69\x6D\x65\x6F\x75\x74\x29","\x53\x61\x76\x69\x6E\x67\x20\x75\x73\x65\x72\x20\x65\x6E\x74\x72\x79\x20\x69\x6E\x20\x61\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x2E\x2E","\x64\x61\x74\x61","\x4D\x65\x6E\x75\x20\x74\x69\x6D\x65\x6F\x75\x74\x21","\x30","\x74","\x52\x75\x6E\x20\x6F\x75\x74\x20\x6F\x66\x20\x72\x65\x74\x72\x69\x65\x73\x21","\x2D","\x73\x61\x79\x6E\x75\x6D\x62\x65\x72","\x2D\x2D\x53\x41\x59\x4E\x55\x4D\x42\x45\x52\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x53\x61\x79\x69\x6E\x67\x20\x6E\x75\x6D\x62\x65\x72\x2E\x2E\x2E","\x53\x41\x59\x20\x4E\x55\x4D\x42\x45\x52\x20\x25\x73\x20\x22\x25\x73\x22\x0A","\x6E\x75\x6D\x62\x65\x72","\x65\x73\x63\x61\x70\x65\x5F\x64\x69\x67\x69\x74\x73","\x73\x61\x79\x70\x68\x6F\x6E\x65\x74\x69\x63","\x2D\x2D\x53\x41\x59\x50\x48\x4F\x4E\x45\x54\x49\x43\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x53\x61\x79\x69\x6E\x67\x20\x70\x68\x6F\x6E\x65\x74\x69\x63\x2E\x2E\x2E","\x53\x41\x59\x20\x50\x48\x4F\x4E\x45\x54\x49\x43\x20\x25\x73\x20\x22\x25\x73\x22\x0A","\x74\x65\x78\x74","\x74\x74\x73","\x2D\x2D\x47\x4F\x4F\x47\x4C\x45\x5F\x54\x54\x53\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x61\x67\x69\x5F\x73\x63\x72\x69\x70\x74\x73","\x67\x6F\x6F\x67\x6C\x65\x74\x74\x73\x2E\x61\x67\x69","\x67\x6F\x6F\x67\x6C\x65\x5F\x74\x74\x73\x5F\x6C\x61\x6E\x67\x75\x61\x67\x65","\x43\x61\x6C\x6C\x69\x6E\x67\x20\x47\x6F\x6F\x67\x6C\x65\x20\x54\x54\x53\x20\x41\x50\x49\x2E\x2E\x2E","\x41\x47\x49","\x69\x73\x70\x65\x65\x63\x68\x74\x74\x73","\x2D\x2D\x49\x53\x50\x45\x45\x43\x48\x5F\x54\x54\x53\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x2F\x76\x61\x72\x2F\x77\x77\x77\x2F\x68\x74\x6D\x6C\x2F\x61\x67\x69\x73\x71\x75\x61\x72\x65\x2F\x61\x67\x69\x73\x63\x72\x69\x70\x74\x73\x2F\x69\x73\x70\x65\x65\x63\x68\x2D\x74\x74\x73\x2E\x61\x67\x69","\x69\x73\x70\x65\x65\x63\x68\x5F\x74\x74\x73\x5F\x6C\x61\x6E\x67\x75\x61\x67\x65","\x6B\x65\x79","\x43\x61\x6C\x6C\x69\x6E\x67\x20\x69\x53\x70\x65\x65\x63\x68\x20\x54\x54\x53\x20\x41\x50\x49\x2E\x2E\x2E","\x67\x65\x74\x64\x69\x67\x69\x74\x73","\x2D\x2D\x47\x45\x54\x44\x49\x47\x49\x54\x53\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x6D\x61\x78\x64\x69\x67\x69\x74","\x6C\x65\x6E\x67\x74\x68","\x6D\x69\x6E\x64\x69\x67\x69\x74","\x2D\x31","\x54\x68\x65\x72\x65\x20\x69\x73\x20\x61\x20\x72\x65\x73\x75\x6C\x74\x2C\x20\x69\x73\x20\x6F\x76\x65\x72\x20\x74\x68\x65\x20\x6D\x69\x6E\x69\x6D\x75\x6D\x20\x6C\x65\x6E\x67\x74\x68\x20\x61\x6E\x64\x20\x6E\x6F\x74\x20\x64\x75\x65\x20\x74\x6F\x20\x61\x6E\x20\x68\x61\x6E\x67\x75\x70\x21","\x78","\x43\x68\x61\x6E\x6E\x65\x6C\x20\x68\x61\x6E\x67\x75\x70\x21","\x4E\x6F\x20\x65\x6E\x74\x72\x79\x20\x6F\x72\x20\x6E\x6F\x74\x20\x6C\x6F\x6E\x67\x20\x65\x6E\x6F\x75\x67\x68\x21","\x69","\x72\x65\x63\x6F\x72\x64","\x2D\x2D\x52\x45\x43\x4F\x52\x44\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x53\x74\x61\x72\x74\x69\x6E\x67\x20\x63\x61\x6C\x6C\x20\x72\x65\x63\x6F\x72\x64\x69\x6E\x67\x2E\x2E\x2E","\x52\x45\x43\x4F\x52\x44\x20\x46\x49\x4C\x45\x20\x25\x73\x20\x77\x61\x76\x20\x22\x25\x73\x22\x20\x25\x73\x20\x25\x73\x20\x25\x73\x20\x25\x73\x0A","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x72\x65\x63\x6F\x72\x64\x69\x6E\x67\x73","\x63\x6F\x64\x65","\x53\x61\x76\x69\x6E\x67\x20\x72\x65\x63\x6F\x72\x64\x69\x6E\x67\x20\x66\x69\x6C\x65\x6E\x61\x6D\x65\x20\x69\x6E\x20\x52\x45\x43\x4F\x52\x44\x49\x4E\x47\x5F\x53\x41\x56\x45\x4E\x41\x4D\x45\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x2E\x2E","\x53\x45\x54\x20\x56\x41\x52\x49\x41\x42\x4C\x45\x20\x25\x73\x20\x25\x73\x0A","\x52\x45\x43\x4F\x52\x44\x49\x4E\x47\x5F\x53\x41\x56\x45\x4E\x41\x4D\x45","\x67\x6F\x74\x6F\x69\x66\x74\x69\x6D\x65","\x2D\x2D\x47\x4F\x54\x4F\x49\x46\x54\x49\x4D\x45\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x66\x61\x6C\x73\x65","\x69\x6E\x74\x65\x72\x76\x61\x6C\x5F\x69\x64","\x49\x6E\x74\x65\x72\x76\x61\x6C\x49\x64","\x69\x64","\x66\x69\x6C\x74\x65\x72","\x49\x73\x20\x61\x20\x67\x72\x6F\x75\x70\x20\x6F\x66\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x73\x21","\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x73\x21","\x43\x68\x65\x63\x6B\x69\x6E\x67\x20\x69\x66\x20\x61\x74\x20\x6C\x65\x61\x73\x74\x20\x6F\x6E\x65\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x20\x69\x73\x20\x76\x61\x6C\x69\x64\x2E\x2E\x2E","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x49\x6E\x74\x65\x72\x76\x61\x6C\x20","\x20\x69\x73\x20\x76\x61\x6C\x69\x64\x21","\x74\x72\x75\x65","\x66\x6F\x72\x45\x61\x63\x68","\x54\x68\x65\x72\x65\x20\x61\x72\x65\x20\x6E\x6F\x20\x73\x75\x62\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x73\x2C\x20\x73\x6F\x20\x69\x74\x20\x77\x69\x6C\x6C\x20\x62\x65\x20\x61\x6C\x77\x61\x79\x73\x20\x74\x72\x75\x65\x21","\x49\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x21","\x54\x68\x65\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x20\x69\x73\x20\x76\x61\x6C\x69\x64\x21","\x54\x68\x65\x20\x66\x69\x6E\x61\x6C\x20\x72\x65\x73\x75\x6C\x74\x20\x66\x6F\x72\x20\x74\x68\x65\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x73\x20\x69\x73\x20\x22","\x22\x21","\x76\x73\x77\x69\x74\x63\x68","\x2D\x2D\x56\x41\x52\x49\x41\x42\x4C\x45\x5F\x53\x57\x49\x54\x43\x48\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x47\x65\x74\x74\x69\x6E\x67\x20\x74\x68\x65\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x20\x76\x61\x6C\x75\x65\x20\x61\x6E\x64\x20\x73\x65\x61\x72\x63\x68\x69\x6E\x67\x20\x74\x68\x65\x20\x72\x69\x67\x68\x74\x20\x65\x78\x69\x74\x2E\x2E\x2E","\x73\x79\x73\x74\x65\x6D","\x2D\x2D\x53\x59\x53\x54\x45\x4D\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x63\x6F\x6D\x6D\x61\x6E\x64","\x74\x72\x69\x6D","\x45\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x74\x68\x65\x20\x73\x79\x73\x74\x65\x6D\x20\x63\x6F\x6D\x6D\x61\x6E\x64\x2E\x2E\x2E","\x72\x65\x70\x6C\x61\x63\x65","\x50\x72\x6F\x67\x72\x61\x6D\x20\x6F\x75\x74\x70\x75\x74\x3A","\x53\x61\x76\x69\x6E\x67\x20\x74\x68\x65\x20\x6F\x75\x74\x70\x75\x74\x20\x69\x6E\x20\x61\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x2E\x2E","\x22","\x2D\x2D\x41\x47\x49\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x45\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x74\x68\x65\x20\x41\x47\x49\x20\x63\x6F\x6D\x6D\x61\x6E\x64\x2E\x2E\x2E","\x61\x72\x67\x73","\x73\x75\x62\x70\x72\x6F\x6A\x65\x63\x74","\x2D\x2D\x53\x55\x42\x50\x52\x4F\x4A\x45\x43\x54\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x70\x72\x6F\x6A\x65\x63\x74\x5F\x69\x64","\x4D\x6F\x76\x69\x6E\x67\x20\x74\x6F\x20\x70\x72\x6F\x6A\x65\x63\x74\x20\x22\x22","\x61\x67\x69\x3A\x2F\x2F\x31\x39\x32\x2E\x31\x36\x38\x2E\x32\x2E\x31\x34\x37\x2F\x73\x71\x75\x61\x72\x65\x2C\x25\x73","\x69\x73\x70\x65\x65\x63\x68\x61\x73\x72","\x2D\x2D\x49\x53\x50\x45\x45\x43\x48\x5F\x41\x53\x52\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x69\x73\x70\x65\x65\x63\x68\x2D\x61\x73\x72\x2E\x61\x67\x69","\x69\x73\x70\x65\x65\x63\x68\x5F\x61\x73\x72\x5F\x6C\x61\x6E\x67\x75\x61\x67\x65","\x6D\x6F\x64\x65\x6C","\x31","\x23","\x43\x61\x6C\x6C\x69\x6E\x67\x20\x47\x6F\x6F\x67\x6C\x65\x20\x41\x53\x52\x20\x41\x50\x49\x2E\x2E\x2E","\x64\x61\x74\x61\x62\x61\x73\x65","\x2D\x2D\x44\x41\x54\x41\x42\x41\x53\x45\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x6F\x64\x62\x63\x5F\x69\x64","\x54\x72\x79\x69\x6E\x67\x20\x74\x6F\x20\x67\x65\x74\x20\x4F\x44\x42\x43\x20\x63\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E\x2E\x2E\x2E","\x71\x75\x65\x72\x79","\x64\x73\x6E","\x43\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E\x20\x6F\x70\x65\x6E\x69\x6E\x67\x20\x65\x72\x72\x6F\x72\x3A\x20","\x43\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E\x20\x73\x75\x63\x63\x65\x64\x65\x64\x2C\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x71\x75\x65\x72\x79\x2E\x2E\x2E","\x51\x75\x65\x72\x79\x20\x65\x72\x72\x6F\x72\x3A\x20","\x51\x75\x65\x72\x79\x20\x65\x78\x65\x63\x75\x74\x65\x64\x2C\x20\x63\x6C\x6F\x73\x69\x6E\x67\x20\x63\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E\x2E\x2E\x2E","\x43\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E\x20\x63\x6C\x6F\x73\x69\x6E\x67\x20\x65\x72\x72\x6F\x72\x3A\x20","\x43\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E\x20\x63\x6C\x6F\x73\x65\x64\x2C\x20\x73\x61\x76\x69\x6E\x67\x20\x72\x65\x73\x75\x6C\x74\x69\x6E\x67\x20\x72\x6F\x77\x73\x20\x69\x6E\x20\x61\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x2E\x2E","\x63\x6C\x6F\x73\x65","\x6F\x70\x65\x6E","\x67\x6F\x74\x6F\x63","\x2D\x2D\x47\x4F\x54\x4F\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x47\x6F\x69\x6E\x67\x20\x74\x6F\x20\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x20","\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x20\x2E\x2E\x2E","\x4C\x6F\x63\x61\x6C\x2F\x25\x73\x40\x25\x73","\x67\x6F\x74\x6F\x69\x66","\x2D\x2D\x47\x4F\x54\x4F\x49\x46\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x45\x76\x61\x6C\x75\x61\x74\x69\x6E\x67\x20\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x2E\x2E\x2E","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x54\x68\x65\x20\x72\x65\x73\x75\x6C\x74\x20\x69\x73\x20","\x68\x61\x6E\x67\x75\x70","\x2D\x2D\x48\x41\x4E\x47\x55\x50\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x48\x61\x6E\x67\x69\x6E\x20\x75\x70\x20\x74\x68\x65\x20\x63\x61\x6C\x6C\x2E\x2E\x2E","\x6E\x6F\x6F\x70","\x2D\x2D\x4E\x4F\x4F\x50\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x6F\x75\x74\x70\x75\x74","\x4E\x4F\x4F\x50\x20\x76\x61\x6C\x75\x65\x20\x69\x73\x20","\x4E\x4F\x4F\x50","\x73\x61\x79\x64\x69\x67\x69\x74\x73","\x2D\x2D\x53\x41\x59\x44\x49\x47\x49\x54\x53\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x53\x61\x79\x69\x6E\x67\x20\x64\x69\x67\x69\x74\x73\x2E\x2E\x2E","\x53\x41\x59\x20\x44\x49\x47\x49\x54\x53\x20\x25\x73\x20\x22\x25\x73\x22\x0A","\x64\x69\x67\x69\x74\x73","\x73\x65\x74","\x2D\x2D\x53\x45\x54\x20\x42\x4C\x4F\x43\x4B\x2D\x2D","\x53\x61\x76\x69\x6E\x67\x20\x76\x61\x6C\x75\x65\x20\x69\x6E\x20\x61\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x2E\x2E","\x76\x61\x72\x69\x61\x62\x6C\x65\x5F\x76\x61\x6C\x75\x65","\x6D\x78\x63\x65\x6C\x6C","\x69\x73\x41\x72\x72\x61\x79","\x24","\x66\x6F\x72\x49\x6E","\x72\x65\x64\x75\x63\x65","\x65\x64\x67\x65","\x73\x6F\x75\x72\x63\x65","\x76\x61\x6C\x75\x65","\x24\x2E\x74\x61\x72\x67\x65\x74","\x6D\x61\x74\x63\x68","\x67\x65\x74\x56\x61\x72\x69\x61\x62\x6C\x65","\x73\x75\x62\x73\x74\x72\x69\x6E\x67","\x66\x6F\x72\x4D\x65\x74\x68\x6F\x64","\x28","\x6C\x61\x73\x74\x49\x6E\x64\x65\x78\x4F\x66","\x29","\x72\x65\x70\x6C\x61\x63\x65\x64","\x76\x65\x72\x74\x69\x63\x65\x73","\x73\x74\x61\x72\x74","\x69\x73\x46\x75\x6E\x63\x74\x69\x6F\x6E","\x66\x6F\x72","\x4E\x6F\x20\x74\x61\x72\x67\x65\x74\x20\x66\x6F\x75\x6E\x64\x2C\x20\x68\x61\x6E\x67\x75\x70\x21","\x66\x69\x6E\x61\x6C\x6C\x79","\x4E\x6F\x20\x74\x61\x72\x67\x65\x74\x20\x66\x6F\x75\x6E\x64\x2C\x20\x73\x74\x6F\x70\x70\x69\x6E\x67\x20\x22\x46\x69\x6E\x61\x6C\x6C\x79\x22\x20\x62\x72\x61\x6E\x63\x68\x21","\x65\x6E\x64","\x65\x72\x72\x6F\x72","\x2F\x2F\x45\x72\x72\x6F\x72\x3A","\x6F\x6E","\x2F\x2F\x43\x6F\x6E\x74\x65\x78\x74\x20\x63\x6C\x6F\x73\x65","\x2F\x2F\x53\x74\x61\x72\x74\x69\x6E\x67\x20\x22\x46\x69\x6E\x61\x6C\x6C\x79\x22\x20\x62\x72\x61\x6E\x63\x68\x21","\x6C\x61\x75\x6E\x63\x68\x46\x69\x62\x65\x72","\x45\x72\x72\x6F\x72\x20\x73\x61\x76\x69\x6E\x67\x20\x65\x78\x69\x74\x20\x74\x69\x6D\x65\x20\x66\x72\x6F\x6D\x20\x49\x56\x52","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x75\x70\x64\x61\x74\x65","\x2F\x2F\x43\x6F\x6E\x74\x65\x78\x74\x20\x48\x61\x6E\x67\x75\x70","\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x52\x65\x63\x65\x69\x76\x65\x64\x20\x6E\x65\x77\x20\x63\x61\x6C\x6C\x20\x66\x72\x6F\x6D\x3A\x20","\x61\x67\x69\x5F\x63\x61\x6C\x6C\x65\x72\x69\x64","\x20\x77\x69\x74\x68\x20\x75\x6E\x69\x71\x75\x65\x69\x64\x3A\x20","\x61\x67\x69\x5F\x75\x6E\x69\x71\x75\x65\x69\x64","\x61\x67\x69\x5F\x6E\x65\x74\x77\x6F\x72\x6B","\x61\x67\x69\x5F\x6E\x65\x74\x77\x6F\x72\x6B\x5F\x73\x63\x72\x69\x70\x74","\x61\x67\x69\x5F\x72\x65\x71\x75\x65\x73\x74","\x61\x67\x69\x5F\x63\x68\x61\x6E\x6E\x65\x6C","\x61\x67\x69\x5F\x6C\x61\x6E\x67\x75\x61\x67\x65","\x61\x67\x69\x5F\x74\x79\x70\x65","\x61\x67\x69\x5F\x76\x65\x72\x73\x69\x6F\x6E","\x61\x67\x69\x5F\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x61\x6D\x65","\x61\x67\x69\x5F\x63\x61\x6C\x6C\x69\x6E\x67\x70\x72\x65\x73","\x61\x67\x69\x5F\x63\x61\x6C\x6C\x69\x6E\x67\x61\x6E\x69\x32","\x61\x67\x69\x5F\x63\x61\x6C\x6C\x69\x6E\x67\x74\x6F\x6E","\x61\x67\x69\x5F\x63\x61\x6C\x6C\x69\x6E\x67\x74\x6E\x73","\x61\x67\x69\x5F\x64\x6E\x69\x64","\x61\x67\x69\x5F\x72\x64\x6E\x69\x73","\x61\x67\x69\x5F\x63\x6F\x6E\x74\x65\x78\x74","\x61\x67\x69\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x61\x67\x69\x5F\x70\x72\x69\x6F\x72\x69\x74\x79","\x61\x67\x69\x5F\x65\x6E\x68\x61\x6E\x63\x65\x64","\x61\x67\x69\x5F\x61\x63\x63\x6F\x75\x6E\x74\x63\x6F\x64\x65","\x61\x67\x69\x5F\x74\x68\x72\x65\x61\x64\x69\x64","\x61\x67\x69\x5F\x61\x72\x67\x5F\x31","\x45\x72\x72\x6F\x72\x20\x73\x61\x76\x69\x6E\x67\x20\x65\x6E\x74\x65\x72\x20\x74\x69\x6D\x65\x20\x66\x6F\x72\x20\x49\x56\x52","\x45\x72\x72\x6F\x72\x3A","\x70\x72\x6F\x64\x75\x63\x74\x69\x6F\x6E","\x6D\x78\x67\x72\x61\x70\x68\x6D\x6F\x64\x65\x6C","\x4E\x6F\x20\x72\x6F\x6F\x74\x20\x69\x6E\x20\x70\x72\x6F\x6A\x65\x63\x74\x21","\x70\x61\x72\x73\x65\x53\x74\x72\x69\x6E\x67","\x4E\x6F\x20\x70\x72\x6F\x6A\x65\x63\x74\x20\x70\x75\x62\x6C\x69\x73\x68\x65\x64\x21","\x4E\x6F\x20\x70\x72\x6F\x6A\x65\x63\x74\x20\x66\x6F\x75\x6E\x64\x21","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x4F\x6E\x65","\x4E\x6F\x20\x70\x72\x6F\x6A\x65\x63\x74\x20\x61\x72\x67\x75\x6D\x65\x6E\x74\x21","\x73\x70\x6C\x69\x74","\x2A","\x74\x5F\x66\x72\x6F\x6D","\x48\x48\x3A\x6D\x6D","\x74\x5F\x74\x6F","\x77\x64\x5F\x66\x72\x6F\x6D","\x77\x64\x5F\x74\x6F","\x6D\x64\x5F\x66\x72\x6F\x6D","\x6D\x64\x5F\x74\x6F","\x6D\x5F\x66\x72\x6F\x6D","\x6D\x5F\x74\x6F","\x45","\x44","\x4D","\x70\x75\x73\x68","\x69\x73\x42\x65\x74\x77\x65\x65\x6E","\x69\x6E\x64\x65\x78\x4F\x66","\x53\x65\x74\x74\x69\x6E\x67\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x2E\x2E","\x53\x65\x6E\x64\x69\x6E\x67\x20\x73\x65\x74\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x2C\x20\x76\x61\x6C\x75\x65\x20\x69\x73\x20","\x25\x73\x2F\x25\x73","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x70\x61\x74\x68","\x73\x61\x76\x65\x5F\x6E\x61\x6D\x65","\x63\x6C\x6F\x6E\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x72\x65\x6D\x6F\x76\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x65\x72\x67\x65","\x75\x6E\x73\x68\x69\x66\x74","\x61\x67\x69\x5F\x70\x6F\x72\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x74\x61\x72\x74\x69\x6E\x67\x20\x43\x61\x6C\x6C\x79\x20\x53\x71\x75\x61\x72\x65\x20\x41\x47\x49\x2E\x2E\x2E","\x6C\x69\x73\x74\x65\x6E","\x63\x72\x65\x61\x74\x65\x53\x65\x72\x76\x65\x72"];_0xd3fd[0];var _=require(_0xd3fd[1]);var agi=require(_0xd3fd[2]);var util=require(_0xd3fd[3]);var moment=require(_0xd3fd[4]);var xml=require(_0xd3fd[5]);var wait=require(_0xd3fd[6]);var sr=require(_0xd3fd[7]);var path=require(_0xd3fd[8]);var config=require(_0xd3fd[9]);var sh=require(_0xd3fd[10]);var db=require(_0xd3fd[11])();var SquareProject=require(_0xd3fd[13])[_0xd3fd[12]];var Variable=require(_0xd3fd[13])[_0xd3fd[14]];var SquareOdbc=require(_0xd3fd[13])[_0xd3fd[15]];var Settings=require(_0xd3fd[13])[_0xd3fd[16]];var User=require(_0xd3fd[13])[_0xd3fd[17]];var VoiceQueue=require(_0xd3fd[13])[_0xd3fd[18]];var Trunk=require(_0xd3fd[13])[_0xd3fd[19]];var Interval=require(_0xd3fd[13])[_0xd3fd[20]];var Upload=require(_0xd3fd[13])[_0xd3fd[21]];var ReportSquare=require(_0xd3fd[13])[_0xd3fd[22]];var ReportSquareDetail=require(_0xd3fd[13])[_0xd3fd[23]];var users,trunks,variables,intervals,projects,sounds,queues,dbConnections,generalUniqueId;var agiPort;var weekDaysCollection={mon:1,tue:2,wed:3,thu:4,fri:5,sat:6,sun:7};var monthsCollection={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12};var methods={};methods[_0xd3fd[24]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[25]);console[_0xd3fd[26]](_0xd3fd[27]);_0xad3ex24[_0xd3fd[29]](_0xd3fd[28],function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[30]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[31]);console[_0xd3fd[26]](_0xd3fd[32]+_0xad3ex25[_0xd3fd[33]]+_0xd3fd[34]);_0xad3ex24[_0xd3fd[36]](_0xad3ex25[_0xd3fd[33]],_0xad3ex25[_0xd3fd[35]],function(_0xad3ex27,_0xad3ex28){if(_0xad3ex26){_0xad3ex26(_0xad3ex27,_0xad3ex28)}});};methods[_0xd3fd[37]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[38]);if(!users){getUsers(false)};var _0xad3ex29=_[_0xd3fd[40]](users,{id:parseInt(_0xad3ex25[_0xd3fd[39]])});console[_0xd3fd[26]](_0xd3fd[41]+util[_0xd3fd[44]](_0xd3fd[42],_0xad3ex29[_0xd3fd[43]])+_0xd3fd[45]);var _0xad3ex2a=[util[_0xd3fd[44]](_0xd3fd[42],_0xad3ex29[_0xd3fd[43]]),_0xad3ex25[_0xd3fd[46]],_0xad3ex25[_0xd3fd[47]],_0xad3ex25[_0xd3fd[48]]];_0xad3ex24[_0xd3fd[36]](_0xd3fd[49],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[52]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[53]);if(!trunks){getTrunks(false)};var _0xad3ex2b=_[_0xd3fd[40]](trunks,{id:parseInt(_0xad3ex25[_0xd3fd[54]])});console[_0xd3fd[26]](_0xd3fd[41]+util[_0xd3fd[44]](_0xd3fd[42],_0xad3ex2b[_0xd3fd[43]])+_0xd3fd[45]);var _0xad3ex2a=[util[_0xd3fd[44]](_0xd3fd[55],_0xad3ex25[_0xd3fd[56]],_0xad3ex2b[_0xd3fd[43]]),_0xad3ex25[_0xd3fd[46]],_0xad3ex25[_0xd3fd[47]],_0xad3ex25[_0xd3fd[48]]];_0xad3ex24[_0xd3fd[36]](_0xd3fd[49],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[57]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[58]);if(!queues){getQueues(false)};var _0xad3ex2c=_[_0xd3fd[40]](queues,{name:_0xad3ex25[_0xd3fd[59]]});var _0xad3ex2d=getFilePath(_0xad3ex25[_0xd3fd[60]]);var _0xad3ex2a=[_0xad3ex2c[_0xd3fd[43]],_0xad3ex25[_0xd3fd[47]],_0xad3ex25[_0xd3fd[48]],_0xad3ex2d,_0xad3ex25[_0xd3fd[46]],_0xad3ex25[_0xd3fd[2]],_0xad3ex25[_0xd3fd[61]],_0xad3ex25[_0xd3fd[62]],_0xd3fd[63],_0xad3ex25[_0xd3fd[64]]];console[_0xd3fd[26]](_0xd3fd[65]+_0xad3ex2c[_0xd3fd[43]]+_0xd3fd[66]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[67],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[68]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[69]);var _0xad3ex2a=[util[_0xd3fd[44]](_0xd3fd[70],_0xad3ex25[_0xd3fd[71]],_0xad3ex25[_0xd3fd[72]]),_0xad3ex25[_0xd3fd[47]]];console[_0xd3fd[26]](_0xd3fd[73]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[74],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[75]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[76]);console[_0xd3fd[26]](_0xd3fd[77]);var _0xad3ex2e=eval(_0xad3ex25[_0xd3fd[78]]);console[_0xd3fd[26]](_0xd3fd[79]);setVariable(_0xad3ex24,_0xad3ex25[_0xd3fd[80]],_0xad3ex2e,_0xad3ex26);};methods[_0xd3fd[81]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[82]);var _0xad3ex2f=getFilePath(_0xad3ex25[_0xd3fd[60]]);var _0xad3ex2a=[_0xad3ex2f,_0xad3ex25[_0xd3fd[47]]];console[_0xd3fd[26]](_0xd3fd[83]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[84],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[85]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[86]);var _0xad3ex28={};console[_0xd3fd[26]](_0xd3fd[87]+_0xad3ex25[_0xd3fd[88]]+_0xd3fd[89]);if(_0xad3ex25[_0xd3fd[88]]>0){_0xad3ex25[_0xd3fd[88]]--;var _0xad3ex30=_0xd3fd[90];console[_0xd3fd[26]](_0xd3fd[91]);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[92],_0xad3ex30,parseInt(_0xad3ex25[_0xd3fd[93]])*1000,_0xad3ex25[_0xd3fd[94]]),function(_0xad3ex27,_0xad3ex28){var _0xad3ex31={uniqueid:_0xad3ex24[_0xd3fd[95]],node:_0xad3ex25[_0xd3fd[96]],application:_0xad3ex25[_0xd3fd[97]],data:_0xad3ex28[_0xd3fd[98]]||null};ReportSquareDetail[_0xd3fd[103]](_0xad3ex31)[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[99]+_0xad3ex25[_0xd3fd[97]]+_0xd3fd[100]+_0xad3ex25[_0xd3fd[96]]+_0xd3fd[101],_0xad3ex27)});if(_0xad3ex28[_0xd3fd[98]]!==_0xd3fd[104]){var _0xad3ex32=parseInt(_0xad3ex25[_0xd3fd[80]]);if(_0xad3ex32){console[_0xd3fd[26]](_0xd3fd[105]);setVariable(_0xad3ex24,_0xad3ex32,_0xad3ex28[_0xd3fd[98]]);};_0xad3ex28[_0xd3fd[106]]=_0xad3ex28[_0xd3fd[98]];_0xad3ex26(null,_0xad3ex28);}else {console[_0xd3fd[26]](_0xd3fd[107]);_0xad3ex28={code:200,result:_0xd3fd[108],data:_0xd3fd[109]};_0xad3ex26(null,_0xad3ex28);};});}else {console[_0xd3fd[26]](_0xd3fd[110]);_0xad3ex28={code:200,result:_0xd3fd[108],data:_0xd3fd[111]};_0xad3ex26(null,_0xad3ex28);};};methods[_0xd3fd[112]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[113]);console[_0xd3fd[26]](_0xd3fd[114]);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[115],_0xad3ex25[_0xd3fd[116]],_0xad3ex25[_0xd3fd[117]]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[118]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[119]);console[_0xd3fd[26]](_0xd3fd[120]);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[121],_0xad3ex25[_0xd3fd[122]],_0xad3ex25[_0xd3fd[117]]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[123]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[124]);var _0xad3ex2a=[path[_0xd3fd[51]](config[_0xd3fd[125]],_0xd3fd[126],_0xd3fd[127]),encodeURIComponent(_0xad3ex25[_0xd3fd[122]]),_0xad3ex25[_0xd3fd[128]]];console[_0xd3fd[26]](_0xd3fd[129]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[130],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[131]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[132]);var _0xad3ex2a=[_0xd3fd[133],encodeURIComponent(_0xad3ex25[_0xd3fd[122]]),_0xad3ex25[_0xd3fd[134]],_0xd3fd[63],_0xd3fd[63],_0xad3ex25[_0xd3fd[135]]];console[_0xd3fd[26]](_0xd3fd[136]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[130],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[137]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[138]);var _0xad3ex28={};console[_0xd3fd[26]](_0xd3fd[87]+_0xad3ex25[_0xd3fd[88]]+_0xd3fd[89]);if(_0xad3ex25[_0xd3fd[88]]>0){_0xad3ex25[_0xd3fd[88]]--;var _0xad3ex30=getFilePath(_0xad3ex25[_0xd3fd[60]]);console[_0xd3fd[26]](_0xd3fd[91]);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[92],_0xad3ex30,parseInt(_0xad3ex25[_0xd3fd[93]])*1000,_0xad3ex25[_0xd3fd[139]]),function(_0xad3ex27,_0xad3ex28){var _0xad3ex31={uniqueid:_0xad3ex24[_0xd3fd[95]],node:_0xad3ex25[_0xd3fd[96]],application:_0xad3ex25[_0xd3fd[97]],data:_0xad3ex28[_0xd3fd[98]]||null};ReportSquareDetail[_0xd3fd[103]](_0xad3ex31)[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[99]+_0xad3ex25[_0xd3fd[97]]+_0xd3fd[100]+_0xad3ex25[_0xd3fd[96]]+_0xd3fd[101],_0xad3ex27)});if(_0xad3ex28[_0xd3fd[98]]&&_0xad3ex28[_0xd3fd[98]][_0xd3fd[140]]>=parseInt(_0xad3ex25[_0xd3fd[141]])){if(_0xad3ex28[_0xd3fd[98]]!==_0xd3fd[142]){console[_0xd3fd[26]](_0xd3fd[143]);var _0xad3ex32=parseInt(_0xad3ex25[_0xd3fd[80]]);if(_0xad3ex32){console[_0xd3fd[26]](_0xd3fd[105]);setVariable(_0xad3ex24,_0xad3ex32,_0xad3ex28[_0xd3fd[98]]);};_0xad3ex28={code:200,result:_0xd3fd[108],data:_0xd3fd[144]};_0xad3ex26(null,_0xad3ex28);}else {console[_0xd3fd[26]](_0xd3fd[145]);_0xad3ex28={code:500,result:_0xd3fd[142]};_0xad3ex26(null,_0xad3ex28);}}else {console[_0xd3fd[26]](_0xd3fd[146]);_0xad3ex28={code:200,result:_0xd3fd[108],data:_0xd3fd[147]};_0xad3ex26(null,_0xad3ex28);};});}else {console[_0xd3fd[26]](_0xd3fd[110]);_0xad3ex28={code:500,result:_0xd3fd[142]};_0xad3ex26(null,_0xad3ex28);};};methods[_0xd3fd[148]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[149]);var _0xad3ex33=sr();console[_0xd3fd[26]](_0xd3fd[150]);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[151],path[_0xd3fd[51]](config[_0xd3fd[125]],_0xd3fd[152],_0xad3ex33),_0xad3ex25[_0xd3fd[117]],_0xad3ex25[_0xd3fd[46]],null,true,null),function(_0xad3ex27,_0xad3ex28){if(_0xad3ex28[_0xd3fd[153]]===200&&_0xad3ex28[_0xd3fd[98]]!==_0xd3fd[142]){console[_0xd3fd[26]](_0xd3fd[154]);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[155],_0xd3fd[156],_0xad3ex33),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});}else {_0xad3ex26(_0xad3ex27,_0xad3ex28)}});};methods[_0xd3fd[157]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[158]);var _0xad3ex28;var _0xad3ex34=_0xd3fd[159];var _0xad3ex35;if(!intervals){getIntervals(false)};var _0xad3ex36=_[_0xd3fd[40]](intervals,{id:parseInt(_0xad3ex25[_0xd3fd[160]])});if(!_0xad3ex36[_0xd3fd[161]]){_0xad3ex35=_[_0xd3fd[163]](intervals,{IntervalId:parseInt(_0xad3ex36[_0xd3fd[162]])})};if(_0xad3ex35){console[_0xd3fd[26]](_0xd3fd[164]);if(_0xad3ex35[_0xd3fd[140]]){console[_0xd3fd[26]](_0xd3fd[87]+_0xad3ex35[_0xd3fd[140]]+_0xd3fd[165]);var _0xad3ex37;console[_0xd3fd[26]](_0xd3fd[166]);_0xad3ex35[_0xd3fd[171]](function(_0xad3ex38,_0xad3ex39){_0xad3ex37=splitInterval(_0xad3ex38[_0xd3fd[167]]);if(isIntervalValid(_0xad3ex37)){console[_0xd3fd[26]](_0xd3fd[168]+_0xad3ex39+_0xd3fd[169]);_0xad3ex34=_0xd3fd[170];};});}else {console[_0xd3fd[26]](_0xd3fd[172]);_0xad3ex34=_0xd3fd[170];};}else {console[_0xd3fd[26]](_0xd3fd[173]);var _0xad3ex3a=splitInterval(_0xad3ex36[_0xd3fd[167]]);if(isIntervalValid(_0xad3ex3a)){console[_0xd3fd[26]](_0xd3fd[174]);_0xad3ex34=_0xd3fd[170];};};console[_0xd3fd[26]](_0xd3fd[175]+_0xad3ex34+_0xd3fd[176]);_0xad3ex28={code:200,result:_0xd3fd[108],data:_0xad3ex34};_0xad3ex26(null,_0xad3ex28);};methods[_0xd3fd[177]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[178]);console[_0xd3fd[26]](_0xd3fd[179]);var _0xad3ex28={data:getVariable(_0xad3ex24,_0xad3ex25[_0xd3fd[80]])};_0xad3ex26(null,_0xad3ex28);};methods[_0xd3fd[180]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[181]);var _0xad3ex31={uniqueid:_0xad3ex24[_0xd3fd[95]],node:_0xad3ex25[_0xd3fd[96]],application:_0xad3ex25[_0xd3fd[97]],data:_[_0xd3fd[183]](_0xad3ex25[_0xd3fd[182]])||null};ReportSquareDetail[_0xd3fd[103]](_0xad3ex31)[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[99]+_0xad3ex25[_0xd3fd[97]]+_0xd3fd[100]+_0xad3ex25[_0xd3fd[96]]+_0xd3fd[101],_0xad3ex27)});console[_0xd3fd[26]](_0xd3fd[184]);sh[_0xd3fd[36]](_[_0xd3fd[183]](_0xad3ex25[_0xd3fd[182]]),function(_0xad3ex3b,_0xad3ex3c){var _0xad3ex3d=_0xad3ex3c[_0xd3fd[185]](/(\r\n|\n|\r)/gm,_0xd3fd[63]);console[_0xd3fd[26]](_0xd3fd[186],_0xad3ex3d);console[_0xd3fd[26]](_0xd3fd[187]);setVariable(_0xad3ex24,_0xad3ex25[_0xd3fd[80]],_0xd3fd[188]+_0xad3ex3d+_0xd3fd[188],_0xad3ex26);});};methods[_0xd3fd[2]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[189]);console[_0xd3fd[26]](_0xd3fd[190]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[130],_0xad3ex25[_0xd3fd[182]],_0xad3ex25[_0xd3fd[191]],function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[192]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[193]);if(!projects){getProjects(false)};var _0xad3ex3e=_[_0xd3fd[40]](projects,{id:parseInt(_0xad3ex25[_0xd3fd[194]])});console[_0xd3fd[26]](_0xd3fd[195]+_0xad3ex3e[_0xd3fd[43]]+_0xd3fd[34]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[130],util[_0xd3fd[44]](_0xd3fd[196],_0xad3ex3e[_0xd3fd[43]]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[197]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[198]);var _0xad3ex2a=[path[_0xd3fd[51]](config[_0xd3fd[125]],_0xd3fd[126],_0xd3fd[199]),_0xad3ex25[_0xd3fd[200]],_0xd3fd[63],(_0xad3ex25[_0xd3fd[201]]===_0xd3fd[108]?_0xd3fd[63]:_0xad3ex25[_0xd3fd[201]]),_0xd3fd[202],_0xd3fd[203],_0xd3fd[63],_0xad3ex25[_0xd3fd[135]]];console[_0xd3fd[26]](_0xd3fd[204]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[130],_0xad3ex2a[_0xd3fd[51]](_0xd3fd[50]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[205]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[206]);if(!dbConnections){getDbConnections(false)};var _0xad3ex3f=_[_0xd3fd[40]](dbConnections,{id:parseInt(_0xad3ex25[_0xd3fd[207]])});console[_0xd3fd[26]](_0xd3fd[208]);var _0xad3ex31={uniqueid:_0xad3ex24[_0xd3fd[95]],node:_0xad3ex25[_0xd3fd[96]],application:_0xad3ex25[_0xd3fd[97]],data:_0xad3ex25[_0xd3fd[209]]||null};ReportSquareDetail[_0xd3fd[103]](_0xad3ex31)[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[99]+_0xad3ex25[_0xd3fd[97]]+_0xd3fd[100]+_0xad3ex25[_0xd3fd[96]]+_0xd3fd[101],_0xad3ex27)});db[_0xd3fd[218]](_0xad3ex3f[_0xd3fd[210]],function(_0xad3ex27){if(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[211],_0xad3ex27);var _0xad3ex28={code:500,result:_0xd3fd[142]};_0xad3ex26(null,_0xad3ex28);}else {console[_0xd3fd[26]](_0xd3fd[212]);db[_0xd3fd[209]](_0xad3ex25[_0xd3fd[209]],function(_0xad3ex27,_0xad3ex40){if(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[213],_0xad3ex27);var _0xad3ex28={code:500,result:_0xd3fd[142]};_0xad3ex26(null,_0xad3ex28);}else {console[_0xd3fd[26]](_0xd3fd[214]);db[_0xd3fd[217]](function(_0xad3ex27){if(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[215],_0xad3ex27);var _0xad3ex28={code:500,result:_0xd3fd[142]};_0xad3ex26(null,_0xad3ex28);}else {console[_0xd3fd[26]](_0xd3fd[216]);setVariable(_0xad3ex24,_0xad3ex25[_0xd3fd[80]],_0xad3ex40,_0xad3ex26);}});}});}});};methods[_0xd3fd[219]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[220]);console[_0xd3fd[26]](_0xd3fd[221]+_0xad3ex25[_0xd3fd[222]]+_0xd3fd[223]);_0xad3ex24[_0xd3fd[36]](_0xd3fd[49],util[_0xd3fd[44]](_0xd3fd[224],_0xad3ex25[_0xd3fd[222]],_0xad3ex25[_0xd3fd[72]]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[225]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[226]);var _0xad3ex28={code:200,result:_0xd3fd[108]};console[_0xd3fd[26]](_0xd3fd[227]);_0xad3ex28[_0xd3fd[106]]=String(eval(_0xad3ex25[_0xd3fd[228]])?_0xd3fd[170]:_0xd3fd[159]);console[_0xd3fd[26]](_0xd3fd[229]+_0xad3ex28[_0xd3fd[106]]);_0xad3ex26(null,_0xad3ex28);};methods[_0xd3fd[230]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[231]);console[_0xd3fd[26]](_0xd3fd[232]);_0xad3ex24[_0xd3fd[230]]();};methods[_0xd3fd[233]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[234]);var _0xad3ex3c=(_0xad3ex25[_0xd3fd[235]])?_0xd3fd[188]+_0xad3ex25[_0xd3fd[235]]+_0xd3fd[188]:_0xd3fd[188]+_0xad3ex25[_0xd3fd[96]]+_0xd3fd[188];console[_0xd3fd[26]](_0xd3fd[236]+_0xad3ex3c);_0xad3ex24[_0xd3fd[36]](_0xd3fd[237],_0xad3ex3c,function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[238]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[239]);console[_0xd3fd[26]](_0xd3fd[240]);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[241],_0xad3ex25[_0xd3fd[242]],_0xad3ex25[_0xd3fd[117]]),function(_0xad3ex27,_0xad3ex28){_0xad3ex26(_0xad3ex27,_0xad3ex28)});};methods[_0xd3fd[243]]=function(_0xad3ex24,_0xad3ex25,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[244]);console[_0xd3fd[26]](_0xd3fd[245]);setVariable(_0xad3ex24,_0xad3ex25[_0xd3fd[80]],_0xad3ex25[_0xd3fd[246]],_0xad3ex26);};function getVertices(_0xad3ex42){return _[_0xd3fd[251]](_0xad3ex42,function(_0xad3ex2e,_0xad3ex43,_0xad3ex44){if(_0xad3ex44===_0xd3fd[247]){return _0xad3ex2e};if(_[_0xd3fd[248]](_0xad3ex43)){_[_0xd3fd[250]](_0xad3ex43,function(_0xad3ex45,_0xad3ex46){_0xad3ex2e[_0xad3ex45[_0xd3fd[249]][_0xd3fd[162]]]=_0xad3ex45[_0xd3fd[249]];_0xad3ex2e[_0xad3ex45[_0xd3fd[249]][_0xd3fd[162]]][_0xd3fd[97]]=_0xad3ex44;});return _0xad3ex2e;};_0xad3ex2e[_0xad3ex43[_0xd3fd[249]][_0xd3fd[162]]]=_0xad3ex43[_0xd3fd[249]];_0xad3ex2e[_0xad3ex43[_0xd3fd[249]][_0xd3fd[162]]][_0xd3fd[97]]=_0xad3ex44;return _0xad3ex2e;},{})}function getTargetBySource(_0xad3ex42,_0xad3ex48,_0xad3ex45){return _[_0xd3fd[98]](_[_0xd3fd[40]](_0xad3ex42[_0xd3fd[247]],function(_0xad3ex43){if(_0xad3ex43[_0xd3fd[249]][_0xd3fd[252]]&&_0xad3ex43[_0xd3fd[249]][_0xd3fd[253]]){if(_0xad3ex43[_0xd3fd[249]][_0xd3fd[253]]===_0xad3ex48){if(_0xad3ex43[_0xd3fd[249]][_0xd3fd[254]]&&_0xad3ex43[_0xd3fd[249]][_0xd3fd[254]]!==_0xad3ex45){return false};return true;}};return false;}),_0xd3fd[255])}function replaceAllVariables(_0xad3ex24,_0xad3ex25,_0xad3ex26){var _0xad3ex4a=_0xad3ex25;for(var _0xad3ex46 in _0xad3ex4a){var _0xad3ex28=_0xad3ex4a[_0xad3ex46][_0xd3fd[256]](/{+(.*?)}/gi);if(_0xad3ex28){for(var _0xad3ex4b in _0xad3ex28){var _0xad3ex45=wait[_0xd3fd[259]](_0xad3ex24,_0xd3fd[257],_0xad3ex28[_0xad3ex4b][_0xd3fd[258]](1,_0xad3ex28[_0xad3ex4b][_0xd3fd[140]]-1));if(_0xad3ex45[_0xd3fd[153]]===200&&_0xad3ex45[_0xd3fd[98]]!==_0xd3fd[108]){var _0xad3ex4c=_0xad3ex45[_0xd3fd[98]][_0xd3fd[258]](_0xad3ex45[_0xd3fd[98]][_0xd3fd[261]](_0xd3fd[260])+1,_0xad3ex45[_0xd3fd[98]][_0xd3fd[261]](_0xd3fd[262]));_0xad3ex4a[_0xad3ex46]=_0xad3ex4a[_0xad3ex46][_0xd3fd[185]](_0xad3ex28[_0xad3ex4b],_0xad3ex4c);};}};};_0xad3ex4a[_0xd3fd[263]]=true;return _0xad3ex4a;}function xstart(_0xad3ex24){var _0xad3ex42=_0xad3ex24[_0xd3fd[125]];var _0xad3ex4e=_0xad3ex24[_0xd3fd[264]];if(_0xad3ex42[_0xd3fd[265]]){if(!_[_0xd3fd[248]](_0xad3ex42[_0xd3fd[265]])){var _0xad3ex48=_0xad3ex42[_0xd3fd[265]][_0xd3fd[249]][_0xd3fd[162]];var _0xad3ex28={};do{var _0xad3ex25=_0xad3ex4e[_0xad3ex48][_0xd3fd[263]]?_0xad3ex4e[_0xad3ex48]:replaceAllVariables(_0xad3ex24,_0xad3ex4e[_0xad3ex48]);if(_0xad3ex25){if(_[_0xd3fd[266]](methods[_0xad3ex25[_0xd3fd[97]]])){_0xad3ex28=wait[_0xd3fd[267]](methods[_0xad3ex25[_0xd3fd[97]]],_0xad3ex24,_0xad3ex25)}else {_0xad3ex28=wait[_0xd3fd[267]](methods[_0xd3fd[233]],_0xad3ex24,_0xad3ex25)};if(_0xad3ex28[_0xd3fd[153]]===200&&_0xad3ex28[_0xd3fd[98]]!==_0xd3fd[142]){var _0xad3ex4f=getTargetBySource(_0xad3ex42,_0xad3ex48,_0xad3ex28[_0xd3fd[106]]);if(_0xad3ex4f){}else {if(_0xad3ex25[_0xd3fd[97]]===_0xd3fd[85]){if(_0xad3ex25[_0xd3fd[88]]>0){_0xad3ex4f=getTargetBySource(_0xad3ex42,_0xad3ex48,_0xd3fd[147]);if(_0xad3ex4f){}else {_0xad3ex4f=_0xad3ex48};}};if(_0xad3ex25[_0xd3fd[97]]===_0xd3fd[137]&&_0xad3ex25[_0xd3fd[88]]>0){_0xad3ex4f=_0xad3ex48};};_0xad3ex48=_0xad3ex4f;}else {_0xad3ex48=null};}else {_0xad3ex48=null};}while(_0xad3ex48);;console[_0xd3fd[26]](_0xd3fd[268]);_0xad3ex24[_0xd3fd[230]]();}};}function xfinally(_0xad3ex24){var _0xad3ex42=_0xad3ex24[_0xd3fd[125]];var _0xad3ex4e=_0xad3ex24[_0xd3fd[264]];if(_0xad3ex42[_0xd3fd[269]]){if(!_[_0xd3fd[248]](_0xad3ex42[_0xd3fd[269]])){var _0xad3ex48=_0xad3ex42[_0xd3fd[269]][_0xd3fd[249]][_0xd3fd[162]];var _0xad3ex28={};do{var _0xad3ex25=replaceAllVariables(_0xad3ex24,_0xad3ex4e[_0xad3ex48]);if(_0xad3ex25){if(_[_0xd3fd[266]](methods[_0xad3ex25[_0xd3fd[97]]])){_0xad3ex28=wait[_0xd3fd[267]](methods[_0xad3ex25[_0xd3fd[97]]],_0xad3ex24,_0xad3ex25)}else {_0xad3ex28=wait[_0xd3fd[267]](methods[_0xd3fd[233]],_0xad3ex24,_0xad3ex25)};if(_0xad3ex28[_0xd3fd[153]]===200&&_0xad3ex28[_0xd3fd[98]]!==_0xd3fd[142]){var _0xad3ex4f=getTargetBySource(_0xad3ex42,_0xad3ex48,_0xad3ex28[_0xd3fd[106]]);if(_0xad3ex4f){}else {if(_0xad3ex25[_0xd3fd[97]]===_0xd3fd[85]){if(_0xad3ex25[_0xd3fd[88]]>0){_0xad3ex4f=getTargetBySource(_0xad3ex42,_0xad3ex48,_0xd3fd[147]);if(_0xad3ex4f){}else {_0xad3ex4f=_0xad3ex48};}};if(_0xad3ex25[_0xd3fd[97]]===_0xd3fd[137]&&_0xad3ex25[_0xd3fd[88]]>0){_0xad3ex4f=_0xad3ex48};};_0xad3ex48=_0xad3ex4f;}else {_0xad3ex48=null};}else {_0xad3ex48=null};}while(_0xad3ex48);;_0xad3ex24[_0xd3fd[230]]();console[_0xd3fd[26]](_0xd3fd[270]);}};_0xad3ex24[_0xd3fd[271]]();}function main(_0xad3ex24){_0xad3ex24[_0xd3fd[274]](_0xd3fd[272],function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[273],_0xad3ex27)});_0xad3ex24[_0xd3fd[274]](_0xd3fd[217],function(){console[_0xd3fd[26]](_0xd3fd[275])});_0xad3ex24[_0xd3fd[274]](_0xd3fd[230],function(){if(_0xad3ex24[_0xd3fd[269]]){_0xad3ex24[_0xd3fd[269]]=false;console[_0xd3fd[26]](_0xd3fd[276]);wait[_0xd3fd[277]](xfinally,_0xad3ex24);}else {ReportSquare[_0xd3fd[280]]({leaveAt:moment()[_0xd3fd[44]](_0xd3fd[279])},{where:{uniqueid:_0xad3ex24[_0xd3fd[95]]}})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[278],_0xad3ex27)});console[_0xd3fd[26]](_0xd3fd[281]);}});_0xad3ex24[_0xd3fd[274]](_0xd3fd[93],function(_0xad3ex28){});_0xad3ex24[_0xd3fd[274]](_0xd3fd[282],function(_0xad3ex52){console[_0xd3fd[26]](_0xad3ex52);console[_0xd3fd[26]](_0xd3fd[283]+_0xad3ex52[_0xd3fd[284]]+_0xd3fd[285]+_0xad3ex52[_0xd3fd[286]]);var _0xad3ex53={network:_0xad3ex52[_0xd3fd[287]],network_script:_0xad3ex52[_0xd3fd[288]],request:_0xad3ex52[_0xd3fd[289]],channel:_0xad3ex52[_0xd3fd[290]],language:_0xad3ex52[_0xd3fd[291]],type:_0xad3ex52[_0xd3fd[292]],uniqueid:_0xad3ex52[_0xd3fd[286]],version:_0xad3ex52[_0xd3fd[293]],callerid:_0xad3ex52[_0xd3fd[284]],calleridname:_0xad3ex52[_0xd3fd[294]],callingpres:_0xad3ex52[_0xd3fd[295]],callingani2:_0xad3ex52[_0xd3fd[296]],callington:_0xad3ex52[_0xd3fd[297]],callingtns:_0xad3ex52[_0xd3fd[298]],dnid:_0xad3ex52[_0xd3fd[299]],rdnis:_0xad3ex52[_0xd3fd[300]],context:_0xad3ex52[_0xd3fd[301]],extension:_0xad3ex52[_0xd3fd[302]],priority:_0xad3ex52[_0xd3fd[303]],enhanced:_0xad3ex52[_0xd3fd[304]],accountcode:_0xad3ex52[_0xd3fd[305]],threadid:_0xad3ex52[_0xd3fd[306]],project_name:_0xad3ex52[_0xd3fd[307]],joinAt:moment()[_0xd3fd[44]](_0xd3fd[279])};ReportSquare[_0xd3fd[103]](_0xad3ex53)[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[308],_0xad3ex27)});if(_0xad3ex52[_0xd3fd[307]]){SquareProject[_0xd3fd[317]]({where:{name:_0xad3ex52[_0xd3fd[307]]},attributes:[_0xd3fd[162],_0xd3fd[310]]})[_0xd3fd[316]](function(_0xad3ex3e){if(_0xad3ex3e){if(_0xad3ex3e[_0xd3fd[310]]){xml[_0xd3fd[313]](_0xad3ex3e[_0xd3fd[310]],{normalizeTags:true,explicitArray:false},function(_0xad3ex27,_0xad3ex2e){var _0xad3ex42=_0xad3ex2e[_0xd3fd[311]][_0xd3fd[125]];if(_0xad3ex42){_0xad3ex24[_0xd3fd[125]]=_0xad3ex42;_0xad3ex24[_0xd3fd[269]]=true;_0xad3ex24[_0xd3fd[95]]=_0xad3ex52[_0xd3fd[286]];_0xad3ex24[_0xd3fd[264]]=getVertices(_0xad3ex42);wait[_0xd3fd[277]](xstart,_0xad3ex24);}else {console[_0xd3fd[26]](_0xd3fd[312]);_0xad3ex24[_0xd3fd[271]]();};})}else {console[_0xd3fd[26]](_0xd3fd[314]);_0xad3ex24[_0xd3fd[271]]();}}else {console[_0xd3fd[26]](_0xd3fd[315]);_0xad3ex24[_0xd3fd[271]]();}})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xd3fd[309],_0xad3ex27);_0xad3ex24[_0xd3fd[271]]();})}else {console[_0xd3fd[26]](_0xd3fd[318]);_0xad3ex24[_0xd3fd[271]]();};});}function splitInterval(_0xad3ex36){var _0xad3ex55={};var _0xad3ex3a=_0xad3ex36[_0xd3fd[319]](_0xd3fd[50]);var _0xad3ex56;_0xad3ex3a[_0xd3fd[171]](function(_0xad3ex57,_0xad3ex39){switch(_0xad3ex39){case 0:if(_0xad3ex57!==_0xd3fd[320]){_0xad3ex56=_0xad3ex57[_0xd3fd[319]](_0xd3fd[111]);_0xad3ex55[_0xd3fd[321]]=moment(_0xad3ex56[0],_0xd3fd[322]);_0xad3ex55[_0xd3fd[323]]=moment(_0xad3ex56[1],_0xd3fd[322]);}else {_0xad3ex55[_0xd3fd[321]]=null;_0xad3ex55[_0xd3fd[323]]=null;};break ;;case 1:if(_0xad3ex57!==_0xd3fd[320]){_0xad3ex56=_0xad3ex57[_0xd3fd[319]](_0xd3fd[111]);_0xad3ex55[_0xd3fd[324]]=weekDaysCollection[_0xad3ex56[0]];_0xad3ex55[_0xd3fd[325]]=_0xad3ex56[1]?weekDaysCollection[_0xad3ex56[1]]:null;}else {_0xad3ex55[_0xd3fd[324]]=null;_0xad3ex55[_0xd3fd[325]]=null;};break ;;case 2:if(_0xad3ex57!==_0xd3fd[320]){_0xad3ex56=_0xad3ex57[_0xd3fd[319]](_0xd3fd[111]);_0xad3ex55[_0xd3fd[326]]=_0xad3ex56[0];_0xad3ex55[_0xd3fd[327]]=_0xad3ex56[1]?_0xad3ex56[1]:null;}else {_0xad3ex55[_0xd3fd[326]]=null;_0xad3ex55[_0xd3fd[327]]=null;};break ;;case 3:if(_0xad3ex57!==_0xd3fd[320]){_0xad3ex56=_0xad3ex57[_0xd3fd[319]](_0xd3fd[111]);_0xad3ex55[_0xd3fd[328]]=monthsCollection[_0xad3ex56[0]];_0xad3ex55[_0xd3fd[329]]=_0xad3ex56[1]?monthsCollection[_0xad3ex56[1]]:null;}else {_0xad3ex55[_0xd3fd[328]]=null;_0xad3ex55[_0xd3fd[329]]=null;};break ;;default:;}});return _0xad3ex55;}function isIntervalValid(_0xad3ex36){var _0xad3ex59=moment()[_0xd3fd[44]](_0xd3fd[322]);var _0xad3ex5a=moment()[_0xd3fd[44]](_0xd3fd[330]);var _0xad3ex5b=moment()[_0xd3fd[44]](_0xd3fd[331]);var _0xad3ex5c=moment()[_0xd3fd[44]](_0xd3fd[332]);var _0xad3ex5d,_0xad3ex5e,_0xad3ex5f,_0xad3ex60;var _0xad3ex61=[1,2,3,4,5,6,7,8,9,10,11,12];var _0xad3ex62=[1,2,3,4,5,6,7];var _0xad3ex63=[];for(var _0xad3ex64=1;_0xad3ex64<=31;_0xad3ex64++){_0xad3ex63[_0xd3fd[333]](_0xad3ex64)};_0xad3ex5d=(_0xad3ex36[_0xd3fd[321]]&&_0xad3ex36[_0xd3fd[323]])?moment(_0xad3ex59,_0xd3fd[322])[_0xd3fd[334]](moment(_0xad3ex36[_0xd3fd[321]],_0xd3fd[322]),moment(_0xad3ex36[_0xd3fd[323]],_0xd3fd[322])):true;if(_0xad3ex36[_0xd3fd[324]]){if(_0xad3ex36[_0xd3fd[325]]){var _0xad3ex65=_[_0xd3fd[163]](_0xad3ex62,function(_0xad3ex38){return (_0xad3ex38>=_0xad3ex36[_0xd3fd[324]])||(_0xad3ex38<=_0xad3ex36[_0xd3fd[325]])});_0xad3ex5e=(_0xad3ex65[_0xd3fd[335]](parseInt(_0xad3ex5a))!== -1)?true:false;}else {_0xad3ex5e=(parseInt(_0xad3ex5a)===_0xad3ex36[_0xd3fd[324]])?true:false}}else {_0xad3ex5e=true};if(_0xad3ex36[_0xd3fd[326]]){if(_0xad3ex36[_0xd3fd[327]]){var _0xad3ex66=_[_0xd3fd[163]](_0xad3ex63,function(_0xad3ex38){return (_0xad3ex38>=_0xad3ex36[_0xd3fd[326]])||(_0xad3ex38<=_0xad3ex36[_0xd3fd[327]])});_0xad3ex5f=(_0xad3ex66[_0xd3fd[335]](parseInt(_0xad3ex5b))!== -1)?true:false;}else {_0xad3ex5f=(parseInt(_0xad3ex5b)===_0xad3ex36[_0xd3fd[326]])?true:false}}else {_0xad3ex5f=true};if(_0xad3ex36[_0xd3fd[328]]){if(_0xad3ex36[_0xd3fd[329]]){var _0xad3ex67=_[_0xd3fd[163]](_0xad3ex61,function(_0xad3ex38){return (_0xad3ex38>=_0xad3ex36[_0xd3fd[328]])||(_0xad3ex38<=_0xad3ex36[_0xd3fd[329]])});_0xad3ex60=(_0xad3ex67[_0xd3fd[335]](parseInt(_0xad3ex5c))!== -1)?true:false;}else {_0xad3ex60=(parseInt(_0xad3ex5c)===_0xad3ex36[_0xd3fd[328]])?true:false}}else {_0xad3ex60=true};return _0xad3ex5d&&_0xad3ex5e&&_0xad3ex5f&&_0xad3ex60;}function setVariable(_0xad3ex24,_0xad3ex69,_0xad3ex45,_0xad3ex26){console[_0xd3fd[26]](_0xd3fd[336]);if(!variables){getVariables(false)};var _0xad3ex4b=_[_0xd3fd[40]](variables,{id:parseInt(_0xad3ex69)});console[_0xd3fd[26]](_0xd3fd[337],_0xad3ex45);_0xad3ex24[_0xd3fd[29]](util[_0xd3fd[44]](_0xd3fd[155],_0xad3ex4b[_0xd3fd[43]],_0xad3ex45),function(_0xad3ex27,_0xad3ex28){if(_0xad3ex26){_0xad3ex26(_0xad3ex27,_0xad3ex28)}});}function getVariable(_0xad3ex24,_0xad3ex69){if(!variables){getVariables(false)};var _0xad3ex4b=_[_0xd3fd[40]](variables,{id:parseInt(_0xad3ex69)});var _0xad3ex45=wait[_0xd3fd[259]](_0xad3ex24,_0xd3fd[257],_0xad3ex4b[_0xd3fd[43]]);if(_0xad3ex45[_0xd3fd[153]]===200&&_0xad3ex45[_0xd3fd[98]]!==_0xd3fd[108]){return _0xad3ex45[_0xd3fd[98]][_0xd3fd[258]](_0xad3ex45[_0xd3fd[98]][_0xd3fd[261]](_0xd3fd[260])+1,_0xad3ex45[_0xd3fd[98]][_0xd3fd[261]](_0xd3fd[262]))};return _0xd3fd[63];}function getFilePath(_0xad3ex69){if(!sounds){getSounds(false)};if(_0xad3ex69>0){var _0xad3ex6c=_[_0xd3fd[40]](sounds,{id:parseInt(_0xad3ex69)});return util[_0xd3fd[44]](_0xd3fd[338],_0xad3ex6c[_0xd3fd[339]],_0xad3ex6c[_0xd3fd[340]]);};return _0xd3fd[63];}function getUsers(_0xad3ex6e){User[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){users=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(User,users,_0xd3fd[162])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function getQueues(_0xad3ex6e){VoiceQueue[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){queues=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(VoiceQueue,queues,_0xd3fd[43])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function getTrunks(_0xad3ex6e){Trunk[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){trunks=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(Trunk,trunks,_0xd3fd[162])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function getVariables(_0xad3ex6e){Variable[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){variables=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(Variable,variables,_0xd3fd[162])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function getDbConnections(_0xad3ex6e){SquareOdbc[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){dbConnections=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(SquareOdbc,dbConnections,_0xd3fd[162])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function getIntervals(_0xad3ex6e){Interval[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){intervals=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(Interval,intervals,_0xd3fd[162])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function getProjects(_0xad3ex6e){SquareProject[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){projects=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(SquareProject,projects,_0xd3fd[162])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function getSounds(_0xad3ex6e){Upload[_0xd3fd[342]]()[_0xd3fd[316]](function(_0xad3ex2e){sounds=_[_0xd3fd[341]](_0xad3ex2e);if(_0xad3ex6e){synchUpdates(Upload,sounds,_0xd3fd[162])};})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}function synchUpdates(_0xad3ex77,_0xad3ex78,_0xad3ex46){var _0xad3ex79={};_0xad3ex77[_0xd3fd[343]](function(_0xad3ex7a){_0xad3ex79[_0xad3ex46]=_0xad3ex7a[_0xad3ex46];updateCollection(_0xad3ex78,_0xad3ex79,_0xad3ex7a);});_0xad3ex77[_0xd3fd[344]](function(_0xad3ex7a){_0xad3ex79[_0xad3ex46]=_0xad3ex7a[_0xad3ex46];updateCollection(_0xad3ex78,_0xad3ex79,_0xad3ex7a);});_0xad3ex77[_0xd3fd[346]](function(_0xad3ex7a){_0xad3ex79[_0xad3ex46]=_0xad3ex7a[_0xad3ex46];_[_0xd3fd[345]](_0xad3ex78,_0xad3ex79);});}function updateCollection(_0xad3ex78,_0xad3ex79,_0xad3ex7a){var _0xad3ex7c=_[_0xd3fd[40]](_0xad3ex78,_0xad3ex79);var _0xad3ex39=_0xad3ex78[_0xd3fd[335]](_0xad3ex7c);if(_0xad3ex7c){_[_0xd3fd[347]](_0xad3ex78[_0xad3ex39],_0xad3ex7a)}else {_0xad3ex78[_0xd3fd[348]](_0xad3ex7a)};}function getPort(){Settings[_0xd3fd[317]]()[_0xd3fd[316]](function(_0xad3ex2e){agiPort=_0xad3ex2e[_0xd3fd[349]]})[_0xd3fd[102]](function(_0xad3ex27){console[_0xd3fd[26]](_0xad3ex27)})}module[_0xd3fd[350]]=function(){console[_0xd3fd[26]](_0xd3fd[351]);getPort();var _0xad3ex7e=agi[_0xd3fd[353]](main)[_0xd3fd[352]](agiPort?agiPort:4573);getUsers(true);getQueues(true);getTrunks(true);getVariables(true);getIntervals(true);getProjects(true);getSounds(true);getDbConnections(true);}; \ No newline at end of file diff --git a/server/config/ami/acw.js b/server/config/ami/acw.js index c34be0d..d9b372f 100644 --- a/server/config/ami/acw.js +++ b/server/config/ami/acw.js @@ -1,118 +1 @@ -var moment = require('moment'); -var asteriskManager = null; - - -function ACW(ami) { - console.log('ACW Initialization...'); - asteriskManager = ami; -} - -ACW.prototype.agentcomplete = function(evt) { - if (asteriskManager && asteriskManager.isConnected()) { - if (evt.interface === 'SIP/massimiliano.bungaro') { - asteriskManager.action({ - action: 'QueuePause', - interface: evt.interface, - paused: true, - reason: 'UNAVAILABLE BY ACW' - }, function(err, res) { - if (err) { - console.error(err); - return; - } - console.log('PAUSE ACW in all queue for the agent ' + evt.interface); - asteriskManager.action({ - action: 'QueuePause', - interface: evt.interface, - queue: evt.queue, - paused: true, - reason: 'ACW' - }, function(err, res) { - if (err) { - console.error(err); - return; - } - console.log('SINGLE PAUSE ACW in ' + evt.queue + ' for the agent ' + evt.interface); - findAndUpdateFlag(evt); - setTimeout(function() { - asteriskManager.action({ - action: 'QueuePause', - interface: evt.interface, - paused: false, - }, function(err, res) { - if (err) { - console.error(err) - } - console.log('UNPAUSE ACW in all queue for the agent ' + evt.interface); - }); - }, 5000); - }); - }); - } - } -} - -ACW.prototype.agentpause = function(evt) { - if ((evt.reason === 'ACW' || evt.reason === 'UNAVAILABLE BY ACW') && evt.paused === '1') { - return; - } - - // findAndUpdateTime(evt); -} - -function findAndUpdateTime(evt) { - var agent = require('../../models').ReportAgent; - agent - .findAll({ - where: { - agentcomplete: true, - agentacw: true, - acwtime: null, - queue: evt.queue, - interface: evt.interface - } - }) - .then(function(agents) { - if (agents.length > 0) { - var agent = agents[agents.length - 1]; // get last inserted agent - var diff = moment().diff(agent.agentcompleteAt, 'seconds'); // diff seconds now - completeAt - agent - .updateAttributes({ - acwtime: diff - }) - .then(function(res) { - console.log('[acw] agent acw ' + res.membername + ' updated seconds ' + diff + ' ACW in queue ' + res.queue); - }) - .catch(function(err) { - console.error('[acw] agent acw ' + err); - }); - } else { - console.error(new Error('[acw] agent acw not found!')); - } - }) - .catch(function(err) { - console.error('[acw] agent acw ' + err); - }); -} - -function findAndUpdateFlag(evt) { - - var agent = require('../../models').ReportAgent; - agent - .update({ - agentacw: true - }, { - where: { - uniqueid: evt.uniqueid, - destuniqueid: evt.destuniqueid - } - }) - .then(function(agent) { - console.log('[acw] agent acw updated'); - }) - .catch(function(err) { - console.error('[acw] agent acw update error: ' + err); - }); -} - -module.exports = ACW; +var _0x4f7c=["\x6D\x6F\x6D\x65\x6E\x74","\x41\x43\x57\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x61\x67\x65\x6E\x74\x63\x6F\x6D\x70\x6C\x65\x74\x65","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x69\x73\x43\x6F\x6E\x6E\x65\x63\x74\x65\x64","\x69\x6E\x74\x65\x72\x66\x61\x63\x65","\x53\x49\x50\x2F\x6D\x61\x73\x73\x69\x6D\x69\x6C\x69\x61\x6E\x6F\x2E\x62\x75\x6E\x67\x61\x72\x6F","\x51\x75\x65\x75\x65\x50\x61\x75\x73\x65","\x55\x4E\x41\x56\x41\x49\x4C\x41\x42\x4C\x45\x20\x42\x59\x20\x41\x43\x57","\x65\x72\x72\x6F\x72","\x50\x41\x55\x53\x45\x20\x41\x43\x57\x20\x69\x6E\x20\x61\x6C\x6C\x20\x71\x75\x65\x75\x65\x20\x66\x6F\x72\x20\x74\x68\x65\x20\x61\x67\x65\x6E\x74\x20","\x71\x75\x65\x75\x65","\x41\x43\x57","\x53\x49\x4E\x47\x4C\x45\x20\x50\x41\x55\x53\x45\x20\x41\x43\x57\x20\x69\x6E\x20","\x20\x66\x6F\x72\x20\x74\x68\x65\x20\x61\x67\x65\x6E\x74\x20","\x55\x4E\x50\x41\x55\x53\x45\x20\x41\x43\x57\x20\x69\x6E\x20\x61\x6C\x6C\x20\x71\x75\x65\x75\x65\x20\x66\x6F\x72\x20\x74\x68\x65\x20\x61\x67\x65\x6E\x74\x20","\x61\x63\x74\x69\x6F\x6E","\x61\x67\x65\x6E\x74\x70\x61\x75\x73\x65","\x72\x65\x61\x73\x6F\x6E","\x70\x61\x75\x73\x65\x64","\x31","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5B\x61\x63\x77\x5D\x20\x61\x67\x65\x6E\x74\x20\x61\x63\x77\x20\x20","\x63\x61\x74\x63\x68","\x6C\x65\x6E\x67\x74\x68","\x61\x67\x65\x6E\x74\x63\x6F\x6D\x70\x6C\x65\x74\x65\x41\x74","\x73\x65\x63\x6F\x6E\x64\x73","\x64\x69\x66\x66","\x5B\x61\x63\x77\x5D\x20\x61\x67\x65\x6E\x74\x20\x61\x63\x77\x20","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x20\x75\x70\x64\x61\x74\x65\x64\x20\x73\x65\x63\x6F\x6E\x64\x73\x20","\x20\x41\x43\x57\x20\x69\x6E\x20\x71\x75\x65\x75\x65\x20","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x5B\x61\x63\x77\x5D\x20\x61\x67\x65\x6E\x74\x20\x61\x63\x77\x20\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x21","\x66\x69\x6E\x64\x41\x6C\x6C","\x5B\x61\x63\x77\x5D\x20\x61\x67\x65\x6E\x74\x20\x61\x63\x77\x20\x75\x70\x64\x61\x74\x65\x20\x65\x72\x72\x6F\x72\x3A\x20\x20","\x5B\x61\x63\x77\x5D\x20\x61\x67\x65\x6E\x74\x20\x61\x63\x77\x20\x75\x70\x64\x61\x74\x65\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x64\x65\x73\x74\x75\x6E\x69\x71\x75\x65\x69\x64","\x75\x70\x64\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];var moment=require(_0x4f7c[0]);var asteriskManager=null;function ACW(_0xf39fx4){console[_0x4f7c[2]](_0x4f7c[1]);asteriskManager=_0xf39fx4;}ACW[_0x4f7c[4]][_0x4f7c[3]]=function(_0xf39fx5){if(asteriskManager&&asteriskManager[_0x4f7c[5]]()){if(_0xf39fx5[_0x4f7c[6]]===_0x4f7c[7]){asteriskManager[_0x4f7c[17]]({action:_0x4f7c[8],interface:_0xf39fx5[_0x4f7c[6]],paused:true,reason:_0x4f7c[9]},function(_0xf39fx6,_0xf39fx7){if(_0xf39fx6){console[_0x4f7c[10]](_0xf39fx6);return ;};console[_0x4f7c[2]](_0x4f7c[11]+_0xf39fx5[_0x4f7c[6]]);asteriskManager[_0x4f7c[17]]({action:_0x4f7c[8],interface:_0xf39fx5[_0x4f7c[6]],queue:_0xf39fx5[_0x4f7c[12]],paused:true,reason:_0x4f7c[13]},function(_0xf39fx6,_0xf39fx7){if(_0xf39fx6){console[_0x4f7c[10]](_0xf39fx6);return ;};console[_0x4f7c[2]](_0x4f7c[14]+_0xf39fx5[_0x4f7c[12]]+_0x4f7c[15]+_0xf39fx5[_0x4f7c[6]]);findAndUpdateFlag(_0xf39fx5);setTimeout(function(){asteriskManager[_0x4f7c[17]]({action:_0x4f7c[8],interface:_0xf39fx5[_0x4f7c[6]],paused:false},function(_0xf39fx6,_0xf39fx7){if(_0xf39fx6){console[_0x4f7c[10]](_0xf39fx6)};console[_0x4f7c[2]](_0x4f7c[16]+_0xf39fx5[_0x4f7c[6]]);})},5000);});})}}};ACW[_0x4f7c[4]][_0x4f7c[18]]=function(_0xf39fx5){if((_0xf39fx5[_0x4f7c[19]]===_0x4f7c[13]||_0xf39fx5[_0x4f7c[19]]===_0x4f7c[9])&&_0xf39fx5[_0x4f7c[20]]===_0x4f7c[21]){return }};function findAndUpdateTime(_0xf39fx5){var _0xf39fx9=require(_0x4f7c[23])[_0x4f7c[22]];_0xf39fx9[_0x4f7c[37]]({where:{agentcomplete:true,agentacw:true,acwtime:null,queue:_0xf39fx5[_0x4f7c[12]],interface:_0xf39fx5[_0x4f7c[6]]}})[_0x4f7c[34]](function(_0xf39fxa){if(_0xf39fxa[_0x4f7c[26]]>0){var _0xf39fx9=_0xf39fxa[_0xf39fxa[_0x4f7c[26]]-1];var _0xf39fxb=moment()[_0x4f7c[29]](_0xf39fx9[_0x4f7c[27]],_0x4f7c[28]);_0xf39fx9[_0x4f7c[35]]({acwtime:_0xf39fxb})[_0x4f7c[34]](function(_0xf39fx7){console[_0x4f7c[2]](_0x4f7c[30]+_0xf39fx7[_0x4f7c[31]]+_0x4f7c[32]+_0xf39fxb+_0x4f7c[33]+_0xf39fx7[_0x4f7c[12]])})[_0x4f7c[25]](function(_0xf39fx6){console[_0x4f7c[10]](_0x4f7c[24]+_0xf39fx6)});}else {console[_0x4f7c[10]]( new Error(_0x4f7c[36]))}})[_0x4f7c[25]](function(_0xf39fx6){console[_0x4f7c[10]](_0x4f7c[24]+_0xf39fx6)});}function findAndUpdateFlag(_0xf39fx5){var _0xf39fx9=require(_0x4f7c[23])[_0x4f7c[22]];_0xf39fx9[_0x4f7c[42]]({agentacw:true},{where:{uniqueid:_0xf39fx5[_0x4f7c[40]],destuniqueid:_0xf39fx5[_0x4f7c[41]]}})[_0x4f7c[34]](function(_0xf39fx9){console[_0x4f7c[2]](_0x4f7c[39])})[_0x4f7c[25]](function(_0xf39fx6){console[_0x4f7c[10]](_0x4f7c[38]+_0xf39fx6)});}module[_0x4f7c[43]]=ACW; \ No newline at end of file diff --git a/server/config/ami/agent.js b/server/config/ami/agent.js index 20173ab..da2d5e5 100644 --- a/server/config/ami/agent.js +++ b/server/config/ami/agent.js @@ -1,95 +1 @@ -var moment = require('moment'); - -function Agent() { - console.log('Agent Initialization...'); -} - -Agent.prototype.called = function(evt) { - evt.lastevent = 'called'; - evt.agentcalledAt = moment().format("YYYY-MM-DD HH:mm:ss"); - createAgent(evt); -} - -Agent.prototype.connect = function(evt) { - evt.lastevent = 'connect'; - evt.agentconnectAt = moment().format("YYYY-MM-DD HH:mm:ss"); - updateAgents(evt); - updateAgents({ - agentringnoanswer: true, - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss"), - reason: 'answered_elsewhere', - lastevent: 'answered_elsewhere' - }, { - uniqueid: evt.uniqueid, - destuniqueid: { - $ne: evt.destuniqueid - }, - reason: null - }) -} - -Agent.prototype.complete = function(evt) { - evt.lastevent = 'complete'; - evt.agentcomplete = true; - evt.agentcompleteAt = moment().format("YYYY-MM-DD HH:mm:ss"); - updateAgents(evt); -} - -Agent.prototype.dump = function(evt) { - evt.lastevent = 'dump'; - - evt.agentdump = true; - evt.agentdumpAt = moment().format("YYYY-MM-DD HH:mm:ss"); - updateAgents(evt); -} - -Agent.prototype.ringnoanswer = function(evt) { - evt.lastevent = 'rejected'; - evt.agentringnoanswer = true; - evt.agentringnoanswerAt = moment().format("YYYY-MM-DD HH:mm:ss"); - evt.reason = 'rejected'; - updateAgents(evt); -} - -Agent.prototype.callerabandon = function(evt) { - evt.lastevent = 'abandoned'; - evt.agentringnoanswer = true; - evt.agentringnoanswerAt = moment().format("YYYY-MM-DD HH:mm:ss"); - evt.reason = 'abandoned'; - updateAgents(evt, { - uniqueid: evt.uniqueid, - reason: null - }); -} - -function createAgent(evt) { - var agent = require('../../models').ReportAgent; - agent - .create(evt) - .then(function(agent) { - console.log('[report] agent begin created'); - }) - .catch(function(err) { - console.error('[report] agent ' + err); - }); -} - -function updateAgents(evt, where) { - var agent = require('../../models').ReportAgent; - agent - .update(evt, { - where: (where) ? where : { - uniqueid: evt.uniqueid, - destuniqueid: evt.destuniqueid - }, - individualHooks: true - }) - .then(function(agent) { - console.log('[agent] agent') - }) - .catch(function(err) { - console.error('[agent] agent error: ' + err); - }); -} - -module.exports = Agent; +var _0xf6c6=["\x6D\x6F\x6D\x65\x6E\x74","\x41\x67\x65\x6E\x74\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x63\x61\x6C\x6C\x65\x64","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x6C\x61\x73\x74\x65\x76\x65\x6E\x74","\x61\x67\x65\x6E\x74\x63\x61\x6C\x6C\x65\x64\x41\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x63\x6F\x6E\x6E\x65\x63\x74","\x61\x67\x65\x6E\x74\x63\x6F\x6E\x6E\x65\x63\x74\x41\x74","\x61\x6E\x73\x77\x65\x72\x65\x64\x5F\x65\x6C\x73\x65\x77\x68\x65\x72\x65","\x75\x6E\x69\x71\x75\x65\x69\x64","\x64\x65\x73\x74\x75\x6E\x69\x71\x75\x65\x69\x64","\x63\x6F\x6D\x70\x6C\x65\x74\x65","\x61\x67\x65\x6E\x74\x63\x6F\x6D\x70\x6C\x65\x74\x65","\x61\x67\x65\x6E\x74\x63\x6F\x6D\x70\x6C\x65\x74\x65\x41\x74","\x64\x75\x6D\x70","\x61\x67\x65\x6E\x74\x64\x75\x6D\x70","\x61\x67\x65\x6E\x74\x64\x75\x6D\x70\x41\x74","\x72\x69\x6E\x67\x6E\x6F\x61\x6E\x73\x77\x65\x72","\x72\x65\x6A\x65\x63\x74\x65\x64","\x61\x67\x65\x6E\x74\x72\x69\x6E\x67\x6E\x6F\x61\x6E\x73\x77\x65\x72","\x61\x67\x65\x6E\x74\x72\x69\x6E\x67\x6E\x6F\x61\x6E\x73\x77\x65\x72\x41\x74","\x72\x65\x61\x73\x6F\x6E","\x63\x61\x6C\x6C\x65\x72\x61\x62\x61\x6E\x64\x6F\x6E","\x61\x62\x61\x6E\x64\x6F\x6E\x65\x64","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5B\x72\x65\x70\x6F\x72\x74\x5D\x20\x61\x67\x65\x6E\x74\x20","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x5B\x72\x65\x70\x6F\x72\x74\x5D\x20\x61\x67\x65\x6E\x74\x20\x62\x65\x67\x69\x6E\x20\x63\x72\x65\x61\x74\x65\x64","\x74\x68\x65\x6E","\x63\x72\x65\x61\x74\x65","\x5B\x61\x67\x65\x6E\x74\x5D\x20\x61\x67\x65\x6E\x74\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x61\x67\x65\x6E\x74\x5D\x20\x61\x67\x65\x6E\x74","\x75\x70\x64\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];var moment=require(_0xf6c6[0]);function Agent(){console[_0xf6c6[2]](_0xf6c6[1])}Agent[_0xf6c6[4]][_0xf6c6[3]]=function(_0x3258x3){_0x3258x3[_0xf6c6[5]]=_0xf6c6[3];_0x3258x3[_0xf6c6[6]]=moment()[_0xf6c6[8]](_0xf6c6[7]);createAgent(_0x3258x3);};Agent[_0xf6c6[4]][_0xf6c6[9]]=function(_0x3258x3){_0x3258x3[_0xf6c6[5]]=_0xf6c6[9];_0x3258x3[_0xf6c6[10]]=moment()[_0xf6c6[8]](_0xf6c6[7]);updateAgents(_0x3258x3);updateAgents({agentringnoanswer:true,agentringnoanswerAt:moment()[_0xf6c6[8]](_0xf6c6[7]),reason:_0xf6c6[11],lastevent:_0xf6c6[11]},{uniqueid:_0x3258x3[_0xf6c6[12]],destuniqueid:{$ne:_0x3258x3[_0xf6c6[13]]},reason:null});};Agent[_0xf6c6[4]][_0xf6c6[14]]=function(_0x3258x3){_0x3258x3[_0xf6c6[5]]=_0xf6c6[14];_0x3258x3[_0xf6c6[15]]=true;_0x3258x3[_0xf6c6[16]]=moment()[_0xf6c6[8]](_0xf6c6[7]);updateAgents(_0x3258x3);};Agent[_0xf6c6[4]][_0xf6c6[17]]=function(_0x3258x3){_0x3258x3[_0xf6c6[5]]=_0xf6c6[17];_0x3258x3[_0xf6c6[18]]=true;_0x3258x3[_0xf6c6[19]]=moment()[_0xf6c6[8]](_0xf6c6[7]);updateAgents(_0x3258x3);};Agent[_0xf6c6[4]][_0xf6c6[20]]=function(_0x3258x3){_0x3258x3[_0xf6c6[5]]=_0xf6c6[21];_0x3258x3[_0xf6c6[22]]=true;_0x3258x3[_0xf6c6[23]]=moment()[_0xf6c6[8]](_0xf6c6[7]);_0x3258x3[_0xf6c6[24]]=_0xf6c6[21];updateAgents(_0x3258x3);};Agent[_0xf6c6[4]][_0xf6c6[25]]=function(_0x3258x3){_0x3258x3[_0xf6c6[5]]=_0xf6c6[26];_0x3258x3[_0xf6c6[22]]=true;_0x3258x3[_0xf6c6[23]]=moment()[_0xf6c6[8]](_0xf6c6[7]);_0x3258x3[_0xf6c6[24]]=_0xf6c6[26];updateAgents(_0x3258x3,{uniqueid:_0x3258x3[_0xf6c6[12]],reason:null});};function createAgent(_0x3258x3){var _0x3258x5=require(_0xf6c6[28])[_0xf6c6[27]];_0x3258x5[_0xf6c6[34]](_0x3258x3)[_0xf6c6[33]](function(_0x3258x5){console[_0xf6c6[2]](_0xf6c6[32])})[_0xf6c6[31]](function(_0x3258x6){console[_0xf6c6[30]](_0xf6c6[29]+_0x3258x6)});}function updateAgents(_0x3258x3,_0x3258x8){var _0x3258x5=require(_0xf6c6[28])[_0xf6c6[27]];_0x3258x5[_0xf6c6[37]](_0x3258x3,{where:(_0x3258x8)?_0x3258x8:{uniqueid:_0x3258x3[_0xf6c6[12]],destuniqueid:_0x3258x3[_0xf6c6[13]]},individualHooks:true})[_0xf6c6[33]](function(_0x3258x5){console[_0xf6c6[2]](_0xf6c6[36])})[_0xf6c6[31]](function(_0x3258x6){console[_0xf6c6[30]](_0xf6c6[35]+_0x3258x6)});}module[_0xf6c6[38]]=Agent; \ No newline at end of file diff --git a/server/config/ami/call.js b/server/config/ami/call.js index e32a772..3ab27b4 100644 --- a/server/config/ami/call.js +++ b/server/config/ami/call.js @@ -1,21 +1 @@ -function Call() { - console.log('Call Initialization...'); -} - -Call.prototype.add = function(evt) { - create(evt); -} - -function create(evt) { - var call = require('../../models').ReportCall; - call - .create(evt) - .then(function(call) { - console.log('[report] call created'); - }) - .catch(function(err) { - console.error('[report] call ' + err); - }); -} - -module.exports = Call; +var _0xb7d4=["\x43\x61\x6C\x6C\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x61\x64\x64","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5B\x72\x65\x70\x6F\x72\x74\x5D\x20\x63\x61\x6C\x6C\x20","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x5B\x72\x65\x70\x6F\x72\x74\x5D\x20\x63\x61\x6C\x6C\x20\x63\x72\x65\x61\x74\x65\x64","\x74\x68\x65\x6E","\x63\x72\x65\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];function Call(){console[_0xb7d4[1]](_0xb7d4[0])}Call[_0xb7d4[3]][_0xb7d4[2]]=function(_0x23e9x2){create(_0x23e9x2)};function create(_0x23e9x2){var _0x23e9x4=require(_0xb7d4[5])[_0xb7d4[4]];_0x23e9x4[_0xb7d4[11]](_0x23e9x2)[_0xb7d4[10]](function(_0x23e9x4){console[_0xb7d4[1]](_0xb7d4[9])})[_0xb7d4[8]](function(_0x23e9x5){console[_0xb7d4[7]](_0xb7d4[6]+_0x23e9x5)});}module[_0xb7d4[12]]=Call; \ No newline at end of file diff --git a/server/config/ami/dial.js b/server/config/ami/dial.js index 4d1c98d..1b59cb0 100644 --- a/server/config/ami/dial.js +++ b/server/config/ami/dial.js @@ -1,41 +1 @@ -function Dial() { - console.log('Dial Initialization...'); -} - -Dial.prototype.begin = function(evt) { - create(evt); -} - -Dial.prototype.end = function(evt) { - findAndUpdate(evt); -} - -function create(evt) { - var dial = require('../../models').ReportDial; - dial - .create(evt) - .then(function(dial) { - console.log('[dial] dial begin created'); - }) - .catch(function(err) { - console.error('[dial] dial begin error: ' + err); - }); -} - -function findAndUpdate(evt) { - var dial = require('../../models').ReportDial; - dial - .update(evt, { - where: { - uniqueid: evt.uniqueid - } - }) - .then(function() { - console.info('[dial] dial end updated'); - }) - .catch(function(err) { - console.error('[dial] dial end error: ' + err); - }); -} - -module.exports = Dial; +var _0x9be9=["\x44\x69\x61\x6C\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x62\x65\x67\x69\x6E","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x65\x6E\x64","\x52\x65\x70\x6F\x72\x74\x44\x69\x61\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5B\x64\x69\x61\x6C\x5D\x20\x64\x69\x61\x6C\x20\x62\x65\x67\x69\x6E\x20\x65\x72\x72\x6F\x72\x3A\x20","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x5B\x64\x69\x61\x6C\x5D\x20\x64\x69\x61\x6C\x20\x62\x65\x67\x69\x6E\x20\x63\x72\x65\x61\x74\x65\x64","\x74\x68\x65\x6E","\x63\x72\x65\x61\x74\x65","\x5B\x64\x69\x61\x6C\x5D\x20\x64\x69\x61\x6C\x20\x65\x6E\x64\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x64\x69\x61\x6C\x5D\x20\x64\x69\x61\x6C\x20\x65\x6E\x64\x20\x75\x70\x64\x61\x74\x65\x64","\x69\x6E\x66\x6F","\x75\x6E\x69\x71\x75\x65\x69\x64","\x75\x70\x64\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];function Dial(){console[_0x9be9[1]](_0x9be9[0])}Dial[_0x9be9[3]][_0x9be9[2]]=function(_0x57bex2){create(_0x57bex2)};Dial[_0x9be9[3]][_0x9be9[4]]=function(_0x57bex2){findAndUpdate(_0x57bex2)};function create(_0x57bex2){var _0x57bex4=require(_0x9be9[6])[_0x9be9[5]];_0x57bex4[_0x9be9[12]](_0x57bex2)[_0x9be9[11]](function(_0x57bex4){console[_0x9be9[1]](_0x9be9[10])})[_0x9be9[9]](function(_0x57bex5){console[_0x9be9[8]](_0x9be9[7]+_0x57bex5)});}function findAndUpdate(_0x57bex2){var _0x57bex4=require(_0x9be9[6])[_0x9be9[5]];_0x57bex4[_0x9be9[17]](_0x57bex2,{where:{uniqueid:_0x57bex2[_0x9be9[16]]}})[_0x9be9[11]](function(){console[_0x9be9[15]](_0x9be9[14])})[_0x9be9[9]](function(_0x57bex5){console[_0x9be9[8]](_0x9be9[13]+_0x57bex5)});}module[_0x9be9[18]]=Dial; \ No newline at end of file diff --git a/server/config/ami/index.js b/server/config/ami/index.js index c8d1a15..85d7531 100644 --- a/server/config/ami/index.js +++ b/server/config/ami/index.js @@ -1,171 +1 @@ -'use strict'; - -var Agent = require('./agent'); -var Call = require('./call'); -var Dial = require('./dial'); -var Member = require('./member'); -var QueueCaller = require('./queue_caller'); -var QueueMember = require('./queue_member'); -var ACW = require('./acw'); - -// When the ami disconnects.. perform this -function onDisconnect(ami) {} - -// When the ami connects.. perform this -function onConnect(ami) {} - -module.exports = function(ami) { - - var agent = new Agent(); - var call = new Call(); - var dial = new Dial(); - var member = new Member(); - var queuemember = new QueueMember(); - var queuecaller = new QueueCaller(); - - var acw = new ACW(ami); - - // Asterisk Status Connect - - // Raised when asterisk is connected - ami.on('connect', function() { - console.info('[%s:%s] AMI CONNECTED', ami.options.host, ami.options.port); - ami.options.connectedAt = new Date(); - // Call onConnect. - onConnect(ami); - }); - - // Raised when asterisk is disconnected - ami.on('disconnect', function() { - // Call onDisconnect. - onDisconnect(ami); - console.info('[%s:%s] AMI DISCONNECTED', ami.options.host, ami.options.port); - }); - - // Raised when asterisk is closed - ami.on('close', function(flag) { - console.log('[%s:%s] AMI CLOSE: %s', ami.options.host, ami.options.port, flag); - }); - - // Raised when asterisk has an error - ami.on('error', function(err) { - console.log('[%s:%s] AMI ERROR: %s', ami.options.host, ami.options.port, err); - }); - - ami.on('managerevent', function(evt) { - //console.log(evt); - }); - - // Agent Status Events - - // Raised when an Agent is notified of a member in the queue. - ami.on('agentcalled', function(evt) { - agent.called(evt); - }); - - // Raised when an agent has finished servicing a member in the queue. - ami.on('agentcomplete', function(evt) { - acw.agentcomplete(evt); - agent.complete(evt); - queuecaller.complete(evt); - }); - - // Raised when an agent answers and is bridged to a member in the queue. - ami.on('agentconnect', function(evt) { - agent.connect(evt); - }); - - // Raised when an agent hangs up on a member in the queue. - ami.on('agentdump', function(evt) { - agent.dump(evt); - }); - - // Raised when an agent is notified of a member in the queue and fails to answer. - ami.on('agentringnoanswer', function(evt) { - agent.ringnoanswer(evt); - }); - - // Member Status Events in Queue - - // Raised when a member is added to the queue. - ami.on('queuememberadded', function(evt) { - member.login(evt); - queuemember.added(evt); - }); - - // Raised when a member is paused/unpaused in the queue with a reason. - ami.on('queuememberpause', function(evt) { - acw.agentpause(evt); - member.pause(evt); - queuemember.pause(evt); - }); - - // Raised when a member's penalty is changed. - ami.on('queuememberpenalty', function(evt) { - queuemember.penalty(evt); - }); - - // Raised when a member is removed from the queue. - ami.on('queuememberremoved', function(evt) { - member.logout(evt); - queuemember.removed(evt); - }); - - // Raised when a member's ringinuse setting is changed. - ami.on('queuememberringinuse', function(evt) { - queuemember.ringinuse(evt); - }); - - // Raised when a Queue member's status has changed. - ami.on('queuememberstatus', function(evt) { - queuemember.status(evt); - }); - - // Dial Status Events - - // Raised when a dial action has started. - ami.on('dialbegin', function(evt) { - dial.begin(evt); - }); - - // Raised when a dial action has completed. - ami.on('dialend', function(evt) { - dial.end(evt); - }); - - // Queue Status Events - - // Raised when a caller joins a Queue. - ami.on('queuecallerjoin', function(evt) { - queuecaller.join(evt); - }); - - // Raised when a caller abandons the queue. - ami.on('queuecallerabandon', function(evt) { - queuecaller.abandon(evt); - //queuemember.callerabandon(evt); - agent.callerabandon(evt); - }); - - // Raised when a caller leaves a Queue. - ami.on('queuecallerleave', function(evt) { - queuecaller.leave(evt); - }); - - // Cdr Status Events - - // Raised when a CDR is generated. - ami.on('cdr', function(evt) { - call.add(evt); - }); - - // Hangup Status Events - ami.on('hangup', function(evt) { - //agent.hangup(evt); - }); - - require('./../fax').register(ami); - require('../../api/user/user.ami').register(ami); - require('../../api/voice_context/voice_context.ami').register(ami); - require('../../api/ami/ami.ami').register(ami); -}; +var _0x7bc5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x2E\x2F\x61\x67\x65\x6E\x74","\x2E\x2F\x63\x61\x6C\x6C","\x2E\x2F\x64\x69\x61\x6C","\x2E\x2F\x6D\x65\x6D\x62\x65\x72","\x2E\x2F\x71\x75\x65\x75\x65\x5F\x63\x61\x6C\x6C\x65\x72","\x2E\x2F\x71\x75\x65\x75\x65\x5F\x6D\x65\x6D\x62\x65\x72","\x2E\x2F\x61\x63\x77","\x65\x78\x70\x6F\x72\x74\x73","\x63\x6F\x6E\x6E\x65\x63\x74","\x5B\x25\x73\x3A\x25\x73\x5D\x20\x41\x4D\x49\x20\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x68\x6F\x73\x74","\x6F\x70\x74\x69\x6F\x6E\x73","\x70\x6F\x72\x74","\x69\x6E\x66\x6F","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x41\x74","\x6F\x6E","\x64\x69\x73\x63\x6F\x6E\x6E\x65\x63\x74","\x5B\x25\x73\x3A\x25\x73\x5D\x20\x41\x4D\x49\x20\x44\x49\x53\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x63\x6C\x6F\x73\x65","\x5B\x25\x73\x3A\x25\x73\x5D\x20\x41\x4D\x49\x20\x43\x4C\x4F\x53\x45\x3A\x20\x25\x73","\x6C\x6F\x67","\x65\x72\x72\x6F\x72","\x5B\x25\x73\x3A\x25\x73\x5D\x20\x41\x4D\x49\x20\x45\x52\x52\x4F\x52\x3A\x20\x25\x73","\x6D\x61\x6E\x61\x67\x65\x72\x65\x76\x65\x6E\x74","\x61\x67\x65\x6E\x74\x63\x61\x6C\x6C\x65\x64","\x63\x61\x6C\x6C\x65\x64","\x61\x67\x65\x6E\x74\x63\x6F\x6D\x70\x6C\x65\x74\x65","\x63\x6F\x6D\x70\x6C\x65\x74\x65","\x61\x67\x65\x6E\x74\x63\x6F\x6E\x6E\x65\x63\x74","\x61\x67\x65\x6E\x74\x64\x75\x6D\x70","\x64\x75\x6D\x70","\x61\x67\x65\x6E\x74\x72\x69\x6E\x67\x6E\x6F\x61\x6E\x73\x77\x65\x72","\x72\x69\x6E\x67\x6E\x6F\x61\x6E\x73\x77\x65\x72","\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x61\x64\x64\x65\x64","\x6C\x6F\x67\x69\x6E","\x61\x64\x64\x65\x64","\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x70\x61\x75\x73\x65","\x61\x67\x65\x6E\x74\x70\x61\x75\x73\x65","\x70\x61\x75\x73\x65","\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x70\x65\x6E\x61\x6C\x74\x79","\x70\x65\x6E\x61\x6C\x74\x79","\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x72\x65\x6D\x6F\x76\x65\x64","\x6C\x6F\x67\x6F\x75\x74","\x72\x65\x6D\x6F\x76\x65\x64","\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x72\x69\x6E\x67\x69\x6E\x75\x73\x65","\x72\x69\x6E\x67\x69\x6E\x75\x73\x65","\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x73\x74\x61\x74\x75\x73","\x73\x74\x61\x74\x75\x73","\x64\x69\x61\x6C\x62\x65\x67\x69\x6E","\x62\x65\x67\x69\x6E","\x64\x69\x61\x6C\x65\x6E\x64","\x65\x6E\x64","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x6A\x6F\x69\x6E","\x6A\x6F\x69\x6E","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x61\x62\x61\x6E\x64\x6F\x6E","\x61\x62\x61\x6E\x64\x6F\x6E","\x63\x61\x6C\x6C\x65\x72\x61\x62\x61\x6E\x64\x6F\x6E","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x6C\x65\x61\x76\x65","\x6C\x65\x61\x76\x65","\x63\x64\x72","\x61\x64\x64","\x68\x61\x6E\x67\x75\x70","\x72\x65\x67\x69\x73\x74\x65\x72","\x2E\x2F\x2E\x2E\x2F\x66\x61\x78","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x2F\x75\x73\x65\x72\x2E\x61\x6D\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x2F\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x2E\x61\x6D\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x61\x70\x69\x2F\x61\x6D\x69\x2F\x61\x6D\x69\x2E\x61\x6D\x69"];_0x7bc5[0];var Agent=require(_0x7bc5[1]);var Call=require(_0x7bc5[2]);var Dial=require(_0x7bc5[3]);var Member=require(_0x7bc5[4]);var QueueCaller=require(_0x7bc5[5]);var QueueMember=require(_0x7bc5[6]);var ACW=require(_0x7bc5[7]);function onDisconnect(_0xdba2x9){}function onConnect(_0xdba2x9){}module[_0x7bc5[8]]=function(_0xdba2x9){var _0xdba2xb= new Agent();var _0xdba2xc= new Call();var _0xdba2xd= new Dial();var _0xdba2xe= new Member();var _0xdba2xf= new QueueMember();var _0xdba2x10= new QueueCaller();var _0xdba2x11= new ACW(_0xdba2x9);_0xdba2x9[_0x7bc5[16]](_0x7bc5[9],function(){console[_0x7bc5[14]](_0x7bc5[10],_0xdba2x9[_0x7bc5[12]][_0x7bc5[11]],_0xdba2x9[_0x7bc5[12]][_0x7bc5[13]]);_0xdba2x9[_0x7bc5[12]][_0x7bc5[15]]= new Date();onConnect(_0xdba2x9);});_0xdba2x9[_0x7bc5[16]](_0x7bc5[17],function(){onDisconnect(_0xdba2x9);console[_0x7bc5[14]](_0x7bc5[18],_0xdba2x9[_0x7bc5[12]][_0x7bc5[11]],_0xdba2x9[_0x7bc5[12]][_0x7bc5[13]]);});_0xdba2x9[_0x7bc5[16]](_0x7bc5[19],function(_0xdba2x12){console[_0x7bc5[21]](_0x7bc5[20],_0xdba2x9[_0x7bc5[12]][_0x7bc5[11]],_0xdba2x9[_0x7bc5[12]][_0x7bc5[13]],_0xdba2x12)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[22],function(_0xdba2x13){console[_0x7bc5[21]](_0x7bc5[23],_0xdba2x9[_0x7bc5[12]][_0x7bc5[11]],_0xdba2x9[_0x7bc5[12]][_0x7bc5[13]],_0xdba2x13)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[24],function(_0xdba2x14){});_0xdba2x9[_0x7bc5[16]](_0x7bc5[25],function(_0xdba2x14){_0xdba2xb[_0x7bc5[26]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[27],function(_0xdba2x14){_0xdba2x11[_0x7bc5[27]](_0xdba2x14);_0xdba2xb[_0x7bc5[28]](_0xdba2x14);_0xdba2x10[_0x7bc5[28]](_0xdba2x14);});_0xdba2x9[_0x7bc5[16]](_0x7bc5[29],function(_0xdba2x14){_0xdba2xb[_0x7bc5[9]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[30],function(_0xdba2x14){_0xdba2xb[_0x7bc5[31]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[32],function(_0xdba2x14){_0xdba2xb[_0x7bc5[33]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[34],function(_0xdba2x14){_0xdba2xe[_0x7bc5[35]](_0xdba2x14);_0xdba2xf[_0x7bc5[36]](_0xdba2x14);});_0xdba2x9[_0x7bc5[16]](_0x7bc5[37],function(_0xdba2x14){_0xdba2x11[_0x7bc5[38]](_0xdba2x14);_0xdba2xe[_0x7bc5[39]](_0xdba2x14);_0xdba2xf[_0x7bc5[39]](_0xdba2x14);});_0xdba2x9[_0x7bc5[16]](_0x7bc5[40],function(_0xdba2x14){_0xdba2xf[_0x7bc5[41]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[42],function(_0xdba2x14){_0xdba2xe[_0x7bc5[43]](_0xdba2x14);_0xdba2xf[_0x7bc5[44]](_0xdba2x14);});_0xdba2x9[_0x7bc5[16]](_0x7bc5[45],function(_0xdba2x14){_0xdba2xf[_0x7bc5[46]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[47],function(_0xdba2x14){_0xdba2xf[_0x7bc5[48]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[49],function(_0xdba2x14){_0xdba2xd[_0x7bc5[50]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[51],function(_0xdba2x14){_0xdba2xd[_0x7bc5[52]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[53],function(_0xdba2x14){_0xdba2x10[_0x7bc5[54]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[55],function(_0xdba2x14){_0xdba2x10[_0x7bc5[56]](_0xdba2x14);_0xdba2xb[_0x7bc5[57]](_0xdba2x14);});_0xdba2x9[_0x7bc5[16]](_0x7bc5[58],function(_0xdba2x14){_0xdba2x10[_0x7bc5[59]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[60],function(_0xdba2x14){_0xdba2xc[_0x7bc5[61]](_0xdba2x14)});_0xdba2x9[_0x7bc5[16]](_0x7bc5[62],function(_0xdba2x14){});require(_0x7bc5[64])[_0x7bc5[63]](_0xdba2x9);require(_0x7bc5[65])[_0x7bc5[63]](_0xdba2x9);require(_0x7bc5[66])[_0x7bc5[63]](_0xdba2x9);require(_0x7bc5[67])[_0x7bc5[63]](_0xdba2x9);}; \ No newline at end of file diff --git a/server/config/ami/member.js b/server/config/ami/member.js index 638a0f0..58cabd0 100644 --- a/server/config/ami/member.js +++ b/server/config/ami/member.js @@ -1,106 +1 @@ -var moment = require('moment'); - -function Member() { - console.log('Member Initialization...'); -} - -Member.prototype.login = function(evt) { - evt.state = 0; - evt.statedesc = 'LOGIN'; - - evt.enterdate = moment().format("YYYY-MM-DD HH:mm:ss"); - - findOrCreate(evt); -} - -Member.prototype.logout = function(evt) { - evt.state = 0; - evt.statedesc = 'LOGIN'; - - evt.exitdate = moment().format("YYYY-MM-DD HH:mm:ss"); - findAndUpdate(evt); -} - -Member.prototype.pause = function(evt) { - evt.state = 1; - evt.statedesc = 'PAUSE'; - - var paused = parseInt(evt.paused, 10); - if (paused) { - evt.enterdate = moment().format("YYYY-MM-DD HH:mm:ss"); - findOrCreate(evt); - } else { - if (evt.reason) { - delete evt.reason; - } - - evt.exitdate = moment().format("YYYY-MM-DD HH:mm:ss"); - findAndUpdate(evt); - } -} - -function findOrCreate(evt) { - var member = require('../../models').ReportMember; - // member. - // findOne({ - // where: { - // queue: evt.queue, - // membername: evt.membername, - // state: evt.state, - // } - // }); - - member - .findOrCreate({ - where: { - queue: evt.queue, - membername: evt.membername, - state: evt.state, - enterdate: { - $ne: null - }, - exitdate: null - }, - defaults: evt - }) - .spread(function(mem, created) { - if (created) { - console.log('[member] member created'); - } else { - console.log('[member] member exist'); - mem - .updateAttributes({ - exitdate: moment().format("YYYY-MM-DD HH:mm:ss") - }) - .then(function(res) { - console.log('[member] member updated'); - findOrCreate(evt); - }); - } - }); -} - -function findAndUpdate(evt) { - var member = require('../../models').ReportMember; - member - .update(evt, { - where: { - queue: evt.queue, - membername: evt.membername, - state: evt.state, - enterdate: { - $ne: null - }, - exitdate: null, - reason: null - } - }) - .then(function(member) { - console.log('[member] member updated'); - }) - .catch(function(err) { - console.error('[member] member error: ' + err); - }); -} - -module.exports = Member; +var _0xf722=["\x6D\x6F\x6D\x65\x6E\x74","\x4D\x65\x6D\x62\x65\x72\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x6C\x6F\x67\x69\x6E","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x73\x74\x61\x74\x65","\x73\x74\x61\x74\x65\x64\x65\x73\x63","\x4C\x4F\x47\x49\x4E","\x65\x6E\x74\x65\x72\x64\x61\x74\x65","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x6C\x6F\x67\x6F\x75\x74","\x65\x78\x69\x74\x64\x61\x74\x65","\x70\x61\x75\x73\x65","\x50\x41\x55\x53\x45","\x70\x61\x75\x73\x65\x64","\x72\x65\x61\x73\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x4D\x65\x6D\x62\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5B\x6D\x65\x6D\x62\x65\x72\x5D\x20\x6D\x65\x6D\x62\x65\x72\x20\x63\x72\x65\x61\x74\x65\x64","\x5B\x6D\x65\x6D\x62\x65\x72\x5D\x20\x6D\x65\x6D\x62\x65\x72\x20\x65\x78\x69\x73\x74","\x5B\x6D\x65\x6D\x62\x65\x72\x5D\x20\x6D\x65\x6D\x62\x65\x72\x20\x75\x70\x64\x61\x74\x65\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x73\x70\x72\x65\x61\x64","\x71\x75\x65\x75\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x5B\x6D\x65\x6D\x62\x65\x72\x5D\x20\x6D\x65\x6D\x62\x65\x72\x20\x65\x72\x72\x6F\x72\x3A\x20","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x75\x70\x64\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];var moment=require(_0xf722[0]);function Member(){console[_0xf722[2]](_0xf722[1])}Member[_0xf722[4]][_0xf722[3]]=function(_0xad94x3){_0xad94x3[_0xf722[5]]=0;_0xad94x3[_0xf722[6]]=_0xf722[7];_0xad94x3[_0xf722[8]]=moment()[_0xf722[10]](_0xf722[9]);findOrCreate(_0xad94x3);};Member[_0xf722[4]][_0xf722[11]]=function(_0xad94x3){_0xad94x3[_0xf722[5]]=0;_0xad94x3[_0xf722[6]]=_0xf722[7];_0xad94x3[_0xf722[12]]=moment()[_0xf722[10]](_0xf722[9]);findAndUpdate(_0xad94x3);};Member[_0xf722[4]][_0xf722[13]]=function(_0xad94x3){_0xad94x3[_0xf722[5]]=1;_0xad94x3[_0xf722[6]]=_0xf722[14];var _0xad94x4=parseInt(_0xad94x3[_0xf722[15]],10);if(_0xad94x4){_0xad94x3[_0xf722[8]]=moment()[_0xf722[10]](_0xf722[9]);findOrCreate(_0xad94x3);}else {if(_0xad94x3[_0xf722[16]]){delete _0xad94x3[_0xf722[16]]};_0xad94x3[_0xf722[12]]=moment()[_0xf722[10]](_0xf722[9]);findAndUpdate(_0xad94x3);};};function findOrCreate(_0xad94x3){var _0xad94x6=require(_0xf722[18])[_0xf722[17]];_0xad94x6[_0xf722[27]]({where:{queue:_0xad94x3[_0xf722[25]],membername:_0xad94x3[_0xf722[26]],state:_0xad94x3[_0xf722[5]],enterdate:{$ne:null},exitdate:null},defaults:_0xad94x3})[_0xf722[24]](function(_0xad94x7,_0xad94x8){if(_0xad94x8){console[_0xf722[2]](_0xf722[19])}else {console[_0xf722[2]](_0xf722[20]);_0xad94x7[_0xf722[23]]({exitdate:moment()[_0xf722[10]](_0xf722[9])})[_0xf722[22]](function(_0xad94x9){console[_0xf722[2]](_0xf722[21]);findOrCreate(_0xad94x3);});}});}function findAndUpdate(_0xad94x3){var _0xad94x6=require(_0xf722[18])[_0xf722[17]];_0xad94x6[_0xf722[31]](_0xad94x3,{where:{queue:_0xad94x3[_0xf722[25]],membername:_0xad94x3[_0xf722[26]],state:_0xad94x3[_0xf722[5]],enterdate:{$ne:null},exitdate:null,reason:null}})[_0xf722[22]](function(_0xad94x6){console[_0xf722[2]](_0xf722[21])})[_0xf722[30]](function(_0xad94xb){console[_0xf722[29]](_0xf722[28]+_0xad94xb)});}module[_0xf722[32]]=Member; \ No newline at end of file diff --git a/server/config/ami/queue_caller.js b/server/config/ami/queue_caller.js index f28c26a..61db4d4 100644 --- a/server/config/ami/queue_caller.js +++ b/server/config/ami/queue_caller.js @@ -1,57 +1 @@ -var moment = require('moment'); - -function QueueCaller() { - console.log('QueueCaller Initialization...'); -} - -QueueCaller.prototype.join = function(evt) { - evt.queuecallerjoinAt = moment().format("YYYY-MM-DD HH:mm:ss"); - create(evt); -} - -QueueCaller.prototype.leave = function(evt) { - evt.queuecallerleaveAt = moment().format("YYYY-MM-DD HH:mm:ss"); - findAndUpdate(evt); -} - -QueueCaller.prototype.abandon = function(evt) { - evt.queuecallerabandon = true; - evt.queuecallerabandonAt = moment().format("YYYY-MM-DD HH:mm:ss"); - findAndUpdate(evt); -} - -QueueCaller.prototype.complete = function(evt) { - evt.queuecallercompleteAt = moment().format("YYYY-MM-DD HH:mm:ss"); - findAndUpdate(evt); -} - -function create(evt) { - var queue = require('../../models').ReportQueue; - queue - .create(evt) - .then(function(queue) { - console.log('[report] queue created'); - }) - .catch(function(err) { - console.error('[report] queue ' + err); - }); -} - -function findAndUpdate(evt) { - var queue = require('../../models').ReportQueue; - queue - .update(evt, { - where: { - uniqueid: evt.uniqueid - }, - individualHooks: true - }) - .then(function(queue) { - console.info('[queue_caller] queue_caller updated'); - }) - .catch(function(err) { - console.error('[queue_caller] queue_caller error: ' + err); - }); -} - -module.exports = QueueCaller; +var _0xe789=["\x6D\x6F\x6D\x65\x6E\x74","\x51\x75\x65\x75\x65\x43\x61\x6C\x6C\x65\x72\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x6A\x6F\x69\x6E","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x6A\x6F\x69\x6E\x41\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x6C\x65\x61\x76\x65","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x6C\x65\x61\x76\x65\x41\x74","\x61\x62\x61\x6E\x64\x6F\x6E","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x61\x62\x61\x6E\x64\x6F\x6E","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x61\x62\x61\x6E\x64\x6F\x6E\x41\x74","\x63\x6F\x6D\x70\x6C\x65\x74\x65","\x71\x75\x65\x75\x65\x63\x61\x6C\x6C\x65\x72\x63\x6F\x6D\x70\x6C\x65\x74\x65\x41\x74","\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5B\x72\x65\x70\x6F\x72\x74\x5D\x20\x71\x75\x65\x75\x65\x20","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x5B\x72\x65\x70\x6F\x72\x74\x5D\x20\x71\x75\x65\x75\x65\x20\x63\x72\x65\x61\x74\x65\x64","\x74\x68\x65\x6E","\x63\x72\x65\x61\x74\x65","\x5B\x71\x75\x65\x75\x65\x5F\x63\x61\x6C\x6C\x65\x72\x5D\x20\x71\x75\x65\x75\x65\x5F\x63\x61\x6C\x6C\x65\x72\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x71\x75\x65\x75\x65\x5F\x63\x61\x6C\x6C\x65\x72\x5D\x20\x71\x75\x65\x75\x65\x5F\x63\x61\x6C\x6C\x65\x72\x20\x75\x70\x64\x61\x74\x65\x64","\x69\x6E\x66\x6F","\x75\x6E\x69\x71\x75\x65\x69\x64","\x75\x70\x64\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];var moment=require(_0xe789[0]);function QueueCaller(){console[_0xe789[2]](_0xe789[1])}QueueCaller[_0xe789[4]][_0xe789[3]]=function(_0xc1cfx3){_0xc1cfx3[_0xe789[5]]=moment()[_0xe789[7]](_0xe789[6]);create(_0xc1cfx3);};QueueCaller[_0xe789[4]][_0xe789[8]]=function(_0xc1cfx3){_0xc1cfx3[_0xe789[9]]=moment()[_0xe789[7]](_0xe789[6]);findAndUpdate(_0xc1cfx3);};QueueCaller[_0xe789[4]][_0xe789[10]]=function(_0xc1cfx3){_0xc1cfx3[_0xe789[11]]=true;_0xc1cfx3[_0xe789[12]]=moment()[_0xe789[7]](_0xe789[6]);findAndUpdate(_0xc1cfx3);};QueueCaller[_0xe789[4]][_0xe789[13]]=function(_0xc1cfx3){_0xc1cfx3[_0xe789[14]]=moment()[_0xe789[7]](_0xe789[6]);findAndUpdate(_0xc1cfx3);};function create(_0xc1cfx3){var _0xc1cfx5=require(_0xe789[16])[_0xe789[15]];_0xc1cfx5[_0xe789[22]](_0xc1cfx3)[_0xe789[21]](function(_0xc1cfx5){console[_0xe789[2]](_0xe789[20])})[_0xe789[19]](function(_0xc1cfx6){console[_0xe789[18]](_0xe789[17]+_0xc1cfx6)});}function findAndUpdate(_0xc1cfx3){var _0xc1cfx5=require(_0xe789[16])[_0xe789[15]];_0xc1cfx5[_0xe789[27]](_0xc1cfx3,{where:{uniqueid:_0xc1cfx3[_0xe789[26]]},individualHooks:true})[_0xe789[21]](function(_0xc1cfx5){console[_0xe789[25]](_0xe789[24])})[_0xe789[19]](function(_0xc1cfx6){console[_0xe789[18]](_0xe789[23]+_0xc1cfx6)});}module[_0xe789[28]]=QueueCaller; \ No newline at end of file diff --git a/server/config/ami/queue_member.js b/server/config/ami/queue_member.js index 59ea80b..b8e6470 100644 --- a/server/config/ami/queue_member.js +++ b/server/config/ami/queue_member.js @@ -1,59 +1 @@ -var moment = require('moment'); - -function QueueMember() { - console.log('QueueMember Initialization...'); -} - -QueueMember.prototype.added = function(evt) { - evt.logged = true; - evt.loggedAt = moment().format("YYYY-MM-DD HH:mm:ss"); - findAndUpdate(evt); -} - -QueueMember.prototype.pause = function(evt) { - var paused = parseInt(evt.paused, 10); - if (paused) { - evt.pausedAt = moment().format("YYYY-MM-DD HH:mm:ss"); - } else { - evt.pausedAt = null; - } - findAndUpdate(evt); -} - -QueueMember.prototype.penalty = function(evt) { - findAndUpdate(evt); -} - -QueueMember.prototype.removed = function(evt) { - evt.logged = false; - evt.loggedAt = null; - findAndUpdate(evt); -} - -QueueMember.prototype.ringinuse = function(evt) { - findAndUpdate(evt); -} - -QueueMember.prototype.status = function(evt) { - findAndUpdate(evt); -} - -function findAndUpdate(evt, options) { - var queueMember = require('../../models').UserHasVoiceQueue; - queueMember - .update(evt, { - where: { - queue: evt.queue, - membername: evt.membername - }, - individualHooks: true - }) - .then(function(member) { - console.log('[queuemember] update member'); - }) - .catch(function(err) { - console.error('[queuemember] update member error: ' + err); - }); -} - -module.exports = QueueMember; +var _0x81da=["\x6D\x6F\x6D\x65\x6E\x74","\x51\x75\x65\x75\x65\x4D\x65\x6D\x62\x65\x72\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x61\x64\x64\x65\x64","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x6C\x6F\x67\x67\x65\x64","\x6C\x6F\x67\x67\x65\x64\x41\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x70\x61\x75\x73\x65","\x70\x61\x75\x73\x65\x64","\x70\x61\x75\x73\x65\x64\x41\x74","\x70\x65\x6E\x61\x6C\x74\x79","\x72\x65\x6D\x6F\x76\x65\x64","\x72\x69\x6E\x67\x69\x6E\x75\x73\x65","\x73\x74\x61\x74\x75\x73","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x5B\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x5D\x20\x75\x70\x64\x61\x74\x65\x20\x6D\x65\x6D\x62\x65\x72\x20\x65\x72\x72\x6F\x72\x3A\x20","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x5B\x71\x75\x65\x75\x65\x6D\x65\x6D\x62\x65\x72\x5D\x20\x75\x70\x64\x61\x74\x65\x20\x6D\x65\x6D\x62\x65\x72","\x74\x68\x65\x6E","\x71\x75\x65\x75\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x75\x70\x64\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];var moment=require(_0x81da[0]);function QueueMember(){console[_0x81da[2]](_0x81da[1])}QueueMember[_0x81da[4]][_0x81da[3]]=function(_0x2337x3){_0x2337x3[_0x81da[5]]=true;_0x2337x3[_0x81da[6]]=moment()[_0x81da[8]](_0x81da[7]);findAndUpdate(_0x2337x3);};QueueMember[_0x81da[4]][_0x81da[9]]=function(_0x2337x3){var _0x2337x4=parseInt(_0x2337x3[_0x81da[10]],10);if(_0x2337x4){_0x2337x3[_0x81da[11]]=moment()[_0x81da[8]](_0x81da[7])}else {_0x2337x3[_0x81da[11]]=null};findAndUpdate(_0x2337x3);};QueueMember[_0x81da[4]][_0x81da[12]]=function(_0x2337x3){findAndUpdate(_0x2337x3)};QueueMember[_0x81da[4]][_0x81da[13]]=function(_0x2337x3){_0x2337x3[_0x81da[5]]=false;_0x2337x3[_0x81da[6]]=null;findAndUpdate(_0x2337x3);};QueueMember[_0x81da[4]][_0x81da[14]]=function(_0x2337x3){findAndUpdate(_0x2337x3)};QueueMember[_0x81da[4]][_0x81da[15]]=function(_0x2337x3){findAndUpdate(_0x2337x3)};function findAndUpdate(_0x2337x3,_0x2337x6){var _0x2337x7=require(_0x81da[17])[_0x81da[16]];_0x2337x7[_0x81da[25]](_0x2337x3,{where:{queue:_0x2337x3[_0x81da[23]],membername:_0x2337x3[_0x81da[24]]},individualHooks:true})[_0x81da[22]](function(_0x2337x9){console[_0x81da[2]](_0x81da[21])})[_0x81da[20]](function(_0x2337x8){console[_0x81da[19]](_0x81da[18]+_0x2337x8)});}module[_0x81da[26]]=QueueMember; \ No newline at end of file diff --git a/server/config/analytics.js b/server/config/analytics.js index e69de29..bd8f9a2 100644 --- a/server/config/analytics.js +++ b/server/config/analytics.js @@ -0,0 +1 @@ +var _0xfd4f=[]; \ No newline at end of file diff --git a/server/config/autodialer/index.js b/server/config/autodialer/index.js index a47295f..857fdf2 100644 --- a/server/config/autodialer/index.js +++ b/server/config/autodialer/index.js @@ -1,125 +1 @@ -'use strict'; -var util = require('util'); -var Process = require('./process'); - -module.exports = function(ami) { - - console.log('Autodialer Starting...'); - var proc = new Process(); - - proc.getProcesses(function(res, err) { - if(err) - { - console.log(err); - return; - } - // console.log(res.Contacts); - // if (util.isArray(res.Contacts)) - // { - // var contact = res.Contacts; - // console.log(contact); - // } - // else - // { - // var contacts = res.Contacts; - // if (contacts.length) - // { - // contacts.forEach(function(contact) { - // console.log(contact); - // }) - // } - // } - - - - }); - -} - -// var _ = require('lodash'); -// -// var agents = ['SIP/massimiliano.bungaro', 'SIP/daniele.cinti']; -// var channels = []; -// var peers = []; -// var contacts = ['600', '600', '600']; -// -// var ami; -// -// function coreshow() { -// channels = []; -// if (contacts.length > 0) { -// ami.action({ -// action: 'CoreShowChannels' -// }, function(err, res) { -// if (err) { -// console.log(err); -// } -// console.log(res); -// }); -// } -// -// } -// -// function peerstatus() { -// peers = []; -// if (contacts.length > 0) { -// ami.action({ -// action: 'SIPpeerstatus' -// }, function(err, res) { -// if (err) { -// console.log(err); -// } -// console.log(res); -// }) -// } -// } -// -// module.exports = function(asterisk_manager) { -// -// ami = asterisk_manager; -// -// peerstatus(); -// -// ami.on('peerstatus', function(evt) { -// if (evt.peerstatus == 'Reachable') { -// peers.push(evt.peer); -// } -// }); -// -// ami.on('coreshowchannel', function(evt) { -// channels.push(evt.channel.split('-')[0]); -// }); -// -// ami.on('sippeerstatuscomplete', function(evt) { -// coreshow(); -// }); -// -// ami.on('coreshowchannelscomplete', function(evt) { -// console.log('Agents registered ', peers); -// console.log('Agents in call ', channels); -// -// -// var agent = _.find(agents, function(agent) { -// return !_.includes(channels, agent); -// }); -// -// if (agent) { -// if (_.includes(peers, agent)) { -// ami.action({ -// action: 'originate', -// channel: agent, -// exten: contacts.pop(), -// context: 'demo', -// priority: 1, -// async: true -// }, function(err, res) { -// if (err) { -// console.log(err); -// } -// console.log(res); -// }); -// } -// } -// peerstatus(); -// }); -// }; +var _0x82b6=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x75\x74\x69\x6C","\x2E\x2F\x70\x72\x6F\x63\x65\x73\x73","\x65\x78\x70\x6F\x72\x74\x73","\x41\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x20\x53\x74\x61\x72\x74\x69\x6E\x67\x2E\x2E\x2E","\x6C\x6F\x67","\x67\x65\x74\x50\x72\x6F\x63\x65\x73\x73\x65\x73"];_0x82b6[0];var util=require(_0x82b6[1]);var Process=require(_0x82b6[2]);module[_0x82b6[3]]=function(_0xfdb2x3){console[_0x82b6[5]](_0x82b6[4]);var _0xfdb2x4= new Process();_0xfdb2x4[_0x82b6[6]](function(_0xfdb2x5,_0xfdb2x6){if(_0xfdb2x6){console[_0x82b6[5]](_0xfdb2x6);return ;}});}; \ No newline at end of file diff --git a/server/config/autodialer/process.js b/server/config/autodialer/process.js index 7974168..676666b 100644 --- a/server/config/autodialer/process.js +++ b/server/config/autodialer/process.js @@ -1,26 +1 @@ -var AutodialerProcess = require('../../models').AutodialerProcess; -var Contact = require('../../models').Contact; - -function Process() { - console.log('Process Initialization...'); -} - -Process.prototype.getProcesses = function(callback) { - - AutodialerProcess - .findAll({ - where: { - enable: true - }, - include: [Contact] - }) - .then(function(res) { - callback(res); - }) - .catch(function(err) { - callback(null, err); - }); - -} - -module.exports = Process; +var _0x8b41=["\x41\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x50\x72\x6F\x63\x65\x73\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x6F\x6E\x74\x61\x63\x74","\x50\x72\x6F\x63\x65\x73\x73\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x67\x65\x74\x50\x72\x6F\x63\x65\x73\x73\x65\x73","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x65\x78\x70\x6F\x72\x74\x73"];var AutodialerProcess=require(_0x8b41[1])[_0x8b41[0]];var Contact=require(_0x8b41[1])[_0x8b41[2]];function Process(){console[_0x8b41[4]](_0x8b41[3])}Process[_0x8b41[6]][_0x8b41[5]]=function(_0xc53cx4){AutodialerProcess[_0x8b41[9]]({where:{enable:true},include:[Contact]})[_0x8b41[8]](function(_0xc53cx6){_0xc53cx4(_0xc53cx6)})[_0x8b41[7]](function(_0xc53cx5){_0xc53cx4(null,_0xc53cx5)})};module[_0x8b41[10]]=Process; \ No newline at end of file diff --git a/server/config/automations/fax.js b/server/config/automations/fax.js index 8acb5a8..6c86c13 100644 --- a/server/config/automations/fax.js +++ b/server/config/automations/fax.js @@ -1,171 +1 @@ -'use strict'; - -var _ = require('lodash'); -var config = require('../environment'); -var moment = require('moment'); -// var stringifyObject = require('stringify-object'); - -var sequelize = require('../../models').sequelize; -var Automation = require('../../models').Automation; -var FaxRoom = require('../../models').FaxRoom; -var Settings = require('../../models').Settings; -var automationTimeout; -var activeAutomations = {}; - -function getTimeout() { - Settings - .findOne() - .then(function(result) { - automationTimeout = result.automation_timeout; - }) - .catch(function(err) { - // console.log(err); - }); -} - -function executeAutomation(faxAutomation) { - var query = { - where: {} - }; - var actions = {}; - var conditionsGroup = JSON.parse(faxAutomation.conditions).group; - var actionsGroup = JSON.parse(faxAutomation.actions).group; - var subConditions = {}; - var mainOp = conditionsGroup.boolean === 'AND' ? '$and' : '$or'; - query.where[mainOp] = []; - conditionsGroup.rules.forEach(function(rule) { - if (rule.operator) { - // console.log('normal rule'); - query.where[mainOp].push(getCondition(rule)); - } else if (rule.group) { - // console.log('subgroup'); - var subOp = rule.group.boolean === 'AND' ? '$and' : '$or'; - var tempGroup = {}; - tempGroup[subOp] = []; - rule.group.rules.forEach(function(subRule) { - // console.log('subgroup rule'); - tempGroup[subOp].push(getCondition(subRule)); - }); - query.where[mainOp].push(tempGroup); - } - }); - - // - FaxRoom - .findAll(query) - .then(function(res) { - res.forEach(function(fax) { - actionsGroup.rules.forEach(function(rule) { - switch (rule.field.value) { - case 'status': - setStatus(fax.id, rule.data); - break; - default: - } - }); - }); - }) - .catch(function(err) { - console.log(err); - }); -} - -function setStatus(ticketId, newStatus) { - FaxRoom.update({ - status: newStatus, - }, { - where: { - id: ticketId - } - }) - .catch(function(err) { - console.log(err); - }); -} - -function getCondition(rule) { - var result = {}; - switch (rule.field.value) { - case 'status': - switch (rule.operator) { - case '=': - result[rule.field.value] = rule.data; - break; - case '<>': - result[rule.field.value] = { - $ne: rule.data - }; - break; - default: - } - break; - case 'createdAt': - var compareDate = moment().subtract(parseInt(rule.data, 10), 'hours').format("YYYY-MM-DD HH:mm:ss"); - switch (rule.operator) { - case '>': - result[rule.field.value] = { - lt: compareDate - }; - break; - case '>=': - result[rule.field.value] = { - $lte: compareDate - }; - break; - case '<': - result[rule.field.value] = { - $gt: compareDate - }; - break; - case '<=': - result[rule.field.value] = { - $gte: compareDate - }; - break; - default: - } - break; - default: - } - return result; -} - -function createInterval(faxAutomation) { - activeAutomations['interval' + faxAutomation.id] = setInterval(function() { - executeAutomation(faxAutomation); - }, automationTimeout * 1000); -} - -module.exports = function() { - getTimeout(); - - Automation.afterCreate(function(doc, options) { - createInterval(doc); - }); - - Automation.afterUpdate(function(doc, options) { - clearInterval(activeAutomations['interval' + doc.id]); - createInterval(doc); - }); - - Automation.afterDelete(function(doc, options) { - clearInterval(activeAutomations['interval' + doc.id]); - }); - - Automation - .findAll({ - where: { - status: true, - channel: 'fax' - } - }) - .then(function(faxAutomations) { - - faxAutomations.forEach(function(faxAutomation) { - createInterval(faxAutomation); - }); - }) - .catch(function(err) { - console.error(err); - }); -}; +var _0x41e1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6D\x6F\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x46\x61\x78\x52\x6F\x6F\x6D","\x53\x65\x74\x74\x69\x6E\x67\x73","\x63\x61\x74\x63\x68","\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x5F\x74\x69\x6D\x65\x6F\x75\x74","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x4F\x6E\x65","\x67\x72\x6F\x75\x70","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x70\x61\x72\x73\x65","\x61\x63\x74\x69\x6F\x6E\x73","\x62\x6F\x6F\x6C\x65\x61\x6E","\x41\x4E\x44","\x24\x61\x6E\x64","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x6F\x70\x65\x72\x61\x74\x6F\x72","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x72\x75\x6C\x65\x73","\x6C\x6F\x67","\x69\x64","\x64\x61\x74\x61","\x73\x74\x61\x74\x75\x73","\x76\x61\x6C\x75\x65","\x66\x69\x65\x6C\x64","\x66\x69\x6E\x64\x41\x6C\x6C","\x75\x70\x64\x61\x74\x65","\x3D","\x3C\x3E","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x68\x6F\x75\x72\x73","\x73\x75\x62\x74\x72\x61\x63\x74","\x3E","\x3E\x3D","\x3C","\x3C\x3D","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x65\x78\x70\x6F\x72\x74\x73","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","\x65\x72\x72\x6F\x72","\x66\x61\x78"];_0x41e1[0];var _=require(_0x41e1[1]);var config=require(_0x41e1[2]);var moment=require(_0x41e1[3]);var sequelize=require(_0x41e1[5])[_0x41e1[4]];var Automation=require(_0x41e1[5])[_0x41e1[6]];var FaxRoom=require(_0x41e1[5])[_0x41e1[7]];var Settings=require(_0x41e1[5])[_0x41e1[8]];var automationTimeout;var activeAutomations={};function getTimeout(){Settings[_0x41e1[12]]()[_0x41e1[11]](function(_0xaad7xc){automationTimeout=_0xaad7xc[_0x41e1[10]]})[_0x41e1[9]](function(_0xaad7xb){})}function executeAutomation(_0xaad7xe){var _0xaad7xf={where:{}};var _0xaad7x10={};var _0xaad7x11=JSON[_0x41e1[15]](_0xaad7xe[_0x41e1[14]])[_0x41e1[13]];var _0xaad7x12=JSON[_0x41e1[15]](_0xaad7xe[_0x41e1[16]])[_0x41e1[13]];var _0xaad7x13={};var _0xaad7x14=_0xaad7x11[_0x41e1[17]]===_0x41e1[18]?_0x41e1[19]:_0x41e1[20];_0xaad7xf[_0x41e1[21]][_0xaad7x14]=[];_0xaad7x11[_0x41e1[25]][_0x41e1[24]](function(_0xaad7x15){if(_0xaad7x15[_0x41e1[22]]){_0xaad7xf[_0x41e1[21]][_0xaad7x14][_0x41e1[23]](getCondition(_0xaad7x15))}else {if(_0xaad7x15[_0x41e1[13]]){var _0xaad7x16=_0xaad7x15[_0x41e1[13]][_0x41e1[17]]===_0x41e1[18]?_0x41e1[19]:_0x41e1[20];var _0xaad7x17={};_0xaad7x17[_0xaad7x16]=[];_0xaad7x15[_0x41e1[13]][_0x41e1[25]][_0x41e1[24]](function(_0xaad7x18){_0xaad7x17[_0xaad7x16][_0x41e1[23]](getCondition(_0xaad7x18))});_0xaad7xf[_0x41e1[21]][_0xaad7x14][_0x41e1[23]](_0xaad7x17);}}});FaxRoom[_0x41e1[32]](_0xaad7xf)[_0x41e1[11]](function(_0xaad7x19){_0xaad7x19[_0x41e1[24]](function(_0xaad7x1a){_0xaad7x12[_0x41e1[25]][_0x41e1[24]](function(_0xaad7x15){switch(_0xaad7x15[_0x41e1[31]][_0x41e1[30]]){case _0x41e1[29]:setStatus(_0xaad7x1a[_0x41e1[27]],_0xaad7x15[_0x41e1[28]]);break ;;default:;}})})})[_0x41e1[9]](function(_0xaad7xb){console[_0x41e1[26]](_0xaad7xb)});}function setStatus(_0xaad7x1c,_0xaad7x1d){FaxRoom[_0x41e1[33]]({status:_0xaad7x1d},{where:{id:_0xaad7x1c}})[_0x41e1[9]](function(_0xaad7xb){console[_0x41e1[26]](_0xaad7xb)})}function getCondition(_0xaad7x15){var _0xaad7xc={};switch(_0xaad7x15[_0x41e1[31]][_0x41e1[30]]){case _0x41e1[29]:switch(_0xaad7x15[_0x41e1[22]]){case _0x41e1[34]:_0xaad7xc[_0xaad7x15[_0x41e1[31]][_0x41e1[30]]]=_0xaad7x15[_0x41e1[28]];break ;;case _0x41e1[35]:_0xaad7xc[_0xaad7x15[_0x41e1[31]][_0x41e1[30]]]={$ne:_0xaad7x15[_0x41e1[28]]};break ;;default:;};break ;;case _0x41e1[44]:var _0xaad7x1f=moment()[_0x41e1[39]](parseInt(_0xaad7x15[_0x41e1[28]],10),_0x41e1[38])[_0x41e1[37]](_0x41e1[36]);switch(_0xaad7x15[_0x41e1[22]]){case _0x41e1[40]:_0xaad7xc[_0xaad7x15[_0x41e1[31]][_0x41e1[30]]]={lt:_0xaad7x1f};break ;;case _0x41e1[41]:_0xaad7xc[_0xaad7x15[_0x41e1[31]][_0x41e1[30]]]={$lte:_0xaad7x1f};break ;;case _0x41e1[42]:_0xaad7xc[_0xaad7x15[_0x41e1[31]][_0x41e1[30]]]={$gt:_0xaad7x1f};break ;;case _0x41e1[43]:_0xaad7xc[_0xaad7x15[_0x41e1[31]][_0x41e1[30]]]={$gte:_0xaad7x1f};break ;;default:;};break ;;default:;};return _0xaad7xc;}function createInterval(_0xaad7xe){activeAutomations[_0x41e1[45]+_0xaad7xe[_0x41e1[27]]]=setInterval(function(){executeAutomation(_0xaad7xe)},automationTimeout*1000)}module[_0x41e1[46]]=function(){getTimeout();Automation[_0x41e1[47]](function(_0xaad7x21,_0xaad7x22){createInterval(_0xaad7x21)});Automation[_0x41e1[48]](function(_0xaad7x21,_0xaad7x22){clearInterval(activeAutomations[_0x41e1[45]+_0xaad7x21[_0x41e1[27]]]);createInterval(_0xaad7x21);});Automation[_0x41e1[49]](function(_0xaad7x21,_0xaad7x22){clearInterval(activeAutomations[_0x41e1[45]+_0xaad7x21[_0x41e1[27]]])});Automation[_0x41e1[32]]({where:{status:true,channel:_0x41e1[51]}})[_0x41e1[11]](function(_0xaad7x23){_0xaad7x23[_0x41e1[24]](function(_0xaad7xe){createInterval(_0xaad7xe)})})[_0x41e1[9]](function(_0xaad7xb){console[_0x41e1[50]](_0xaad7xb)});}; \ No newline at end of file diff --git a/server/config/automations/mail.js b/server/config/automations/mail.js index ea76e97..cd448aa 100644 --- a/server/config/automations/mail.js +++ b/server/config/automations/mail.js @@ -1,169 +1 @@ -'use strict'; - -var _ = require('lodash'); -var config = require('../environment'); -var moment = require('moment'); -// var stringifyObject = require('stringify-object'); - -var sequelize = require('../../models').sequelize; -var Automation = require('../../models').Automation; -var MailRoom = require('../../models').MailRoom; -var Settings = require('../../models').Settings; -var automationTimeout; -var activeAutomations = {}; - -function getTimeout() { - return Settings - .findOne() - .then(function (result) { - automationTimeout = result.automation_timeout; - return; - }); -} - -function executeAutomation(mailAutomation) { - var query = { - where: {} - }; - var actions = {}; - var conditionsGroup = JSON.parse(mailAutomation.conditions).group; - var actionsGroup = JSON.parse(mailAutomation.actions).group; - var subConditions = {}; - var mainOp = conditionsGroup.boolean === 'AND' ? '$and' : '$or'; - query.where[mainOp] = []; - conditionsGroup.rules.forEach(function (rule) { - if (rule.operator) { - // console.log('normal rule'); - query.where[mainOp].push(getCondition(rule)); - } else if (rule.group) { - // console.log('subgroup'); - var subOp = rule.group.boolean === 'AND' ? '$and' : '$or'; - var tempGroup = {}; - tempGroup[subOp] = []; - rule.group.rules.forEach(function (subRule) { - // console.log('subgroup rule'); - tempGroup[subOp].push(getCondition(subRule)); - }); - query.where[mainOp].push(tempGroup); - } - }); - - // - MailRoom - .findAll(query) - .then(function (res) { - res.forEach(function (mail) { - actionsGroup.rules.forEach(function (rule) { - switch (rule.field.value) { - case 'status': - setStatus(mail.id, rule.data); - break; - default: - } - }); - }); - }) - .catch(function (err) { - console.log(err); - }); -} - -function setStatus(ticketId, newStatus) { - MailRoom.update({ - status: newStatus, - }, { - where: { - id: ticketId - } - }) - .catch(function (err) { - console.log(err); - }); -} - -function getCondition(rule) { - var result = {}; - switch (rule.field.value) { - case 'status': - switch (rule.operator) { - case '=': - result[rule.field.value] = rule.data; - break; - case '<>': - result[rule.field.value] = { - $ne: rule.data - }; - break; - default: - } - break; - case 'createdAt': - var compareDate = moment().subtract(parseInt(rule.data, 10), 'hours').format("YYYY-MM-DD HH:mm:ss"); - switch (rule.operator) { - case '>': - result[rule.field.value] = { - lt: compareDate - }; - break; - case '>=': - result[rule.field.value] = { - $lte: compareDate - }; - break; - case '<': - result[rule.field.value] = { - $gt: compareDate - }; - break; - case '<=': - result[rule.field.value] = { - $gte: compareDate - }; - break; - default: - } - break; - default: - } - return result; -} - -function createInterval(mailAutomation) { - activeAutomations['interval' + mailAutomation.id] = setInterval(function () { - executeAutomation(mailAutomation); - }, automationTimeout * 1000); -} - -module.exports = function () { - getTimeout(); - - Automation.afterCreate(function (doc, options) { - createInterval(doc); - }); - - Automation.afterUpdate(function (doc, options) { - clearInterval(activeAutomations['interval' + doc.id]); - createInterval(doc); - }); - - Automation.afterDelete(function (doc, options) { - clearInterval(activeAutomations['interval' + doc.id]); - }); - - Automation - .findAll({ - where: { - status: true, - channel: 'mail' - } - }) - .then(function (mailAutomations) { - - mailAutomations.forEach(function (mailAutomation) { - createInterval(mailAutomation); - }); - }) - .catch(function (err) { - console.error(err); - }); -}; +var _0x3f40=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6D\x6F\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x53\x65\x74\x74\x69\x6E\x67\x73","\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x5F\x74\x69\x6D\x65\x6F\x75\x74","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x4F\x6E\x65","\x67\x72\x6F\x75\x70","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x70\x61\x72\x73\x65","\x61\x63\x74\x69\x6F\x6E\x73","\x62\x6F\x6F\x6C\x65\x61\x6E","\x41\x4E\x44","\x24\x61\x6E\x64","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x6F\x70\x65\x72\x61\x74\x6F\x72","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x72\x75\x6C\x65\x73","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x69\x64","\x64\x61\x74\x61","\x73\x74\x61\x74\x75\x73","\x76\x61\x6C\x75\x65","\x66\x69\x65\x6C\x64","\x66\x69\x6E\x64\x41\x6C\x6C","\x75\x70\x64\x61\x74\x65","\x3D","\x3C\x3E","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x68\x6F\x75\x72\x73","\x73\x75\x62\x74\x72\x61\x63\x74","\x3E","\x3E\x3D","\x3C","\x3C\x3D","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x65\x78\x70\x6F\x72\x74\x73","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","\x65\x72\x72\x6F\x72","\x6D\x61\x69\x6C"];_0x3f40[0];var _=require(_0x3f40[1]);var config=require(_0x3f40[2]);var moment=require(_0x3f40[3]);var sequelize=require(_0x3f40[5])[_0x3f40[4]];var Automation=require(_0x3f40[5])[_0x3f40[6]];var MailRoom=require(_0x3f40[5])[_0x3f40[7]];var Settings=require(_0x3f40[5])[_0x3f40[8]];var automationTimeout;var activeAutomations={};function getTimeout(){return Settings[_0x3f40[11]]()[_0x3f40[10]](function(_0xc2d8xb){automationTimeout=_0xc2d8xb[_0x3f40[9]];return ;})}function executeAutomation(_0xc2d8xd){var _0xc2d8xe={where:{}};var _0xc2d8xf={};var _0xc2d8x10=JSON[_0x3f40[14]](_0xc2d8xd[_0x3f40[13]])[_0x3f40[12]];var _0xc2d8x11=JSON[_0x3f40[14]](_0xc2d8xd[_0x3f40[15]])[_0x3f40[12]];var _0xc2d8x12={};var _0xc2d8x13=_0xc2d8x10[_0x3f40[16]]===_0x3f40[17]?_0x3f40[18]:_0x3f40[19];_0xc2d8xe[_0x3f40[20]][_0xc2d8x13]=[];_0xc2d8x10[_0x3f40[24]][_0x3f40[23]](function(_0xc2d8x14){if(_0xc2d8x14[_0x3f40[21]]){_0xc2d8xe[_0x3f40[20]][_0xc2d8x13][_0x3f40[22]](getCondition(_0xc2d8x14))}else {if(_0xc2d8x14[_0x3f40[12]]){var _0xc2d8x15=_0xc2d8x14[_0x3f40[12]][_0x3f40[16]]===_0x3f40[17]?_0x3f40[18]:_0x3f40[19];var _0xc2d8x16={};_0xc2d8x16[_0xc2d8x15]=[];_0xc2d8x14[_0x3f40[12]][_0x3f40[24]][_0x3f40[23]](function(_0xc2d8x17){_0xc2d8x16[_0xc2d8x15][_0x3f40[22]](getCondition(_0xc2d8x17))});_0xc2d8xe[_0x3f40[20]][_0xc2d8x13][_0x3f40[22]](_0xc2d8x16);}}});MailRoom[_0x3f40[32]](_0xc2d8xe)[_0x3f40[10]](function(_0xc2d8x19){_0xc2d8x19[_0x3f40[23]](function(_0xc2d8x1a){_0xc2d8x11[_0x3f40[24]][_0x3f40[23]](function(_0xc2d8x14){switch(_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]){case _0x3f40[29]:setStatus(_0xc2d8x1a[_0x3f40[27]],_0xc2d8x14[_0x3f40[28]]);break ;;default:;}})})})[_0x3f40[26]](function(_0xc2d8x18){console[_0x3f40[25]](_0xc2d8x18)});}function setStatus(_0xc2d8x1c,_0xc2d8x1d){MailRoom[_0x3f40[33]]({status:_0xc2d8x1d},{where:{id:_0xc2d8x1c}})[_0x3f40[26]](function(_0xc2d8x18){console[_0x3f40[25]](_0xc2d8x18)})}function getCondition(_0xc2d8x14){var _0xc2d8xb={};switch(_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]){case _0x3f40[29]:switch(_0xc2d8x14[_0x3f40[21]]){case _0x3f40[34]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]=_0xc2d8x14[_0x3f40[28]];break ;;case _0x3f40[35]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$ne:_0xc2d8x14[_0x3f40[28]]};break ;;default:;};break ;;case _0x3f40[44]:var _0xc2d8x1f=moment()[_0x3f40[39]](parseInt(_0xc2d8x14[_0x3f40[28]],10),_0x3f40[38])[_0x3f40[37]](_0x3f40[36]);switch(_0xc2d8x14[_0x3f40[21]]){case _0x3f40[40]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={lt:_0xc2d8x1f};break ;;case _0x3f40[41]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$lte:_0xc2d8x1f};break ;;case _0x3f40[42]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$gt:_0xc2d8x1f};break ;;case _0x3f40[43]:_0xc2d8xb[_0xc2d8x14[_0x3f40[31]][_0x3f40[30]]]={$gte:_0xc2d8x1f};break ;;default:;};break ;;default:;};return _0xc2d8xb;}function createInterval(_0xc2d8xd){activeAutomations[_0x3f40[45]+_0xc2d8xd[_0x3f40[27]]]=setInterval(function(){executeAutomation(_0xc2d8xd)},automationTimeout*1000)}module[_0x3f40[46]]=function(){getTimeout();Automation[_0x3f40[47]](function(_0xc2d8x21,_0xc2d8x22){createInterval(_0xc2d8x21)});Automation[_0x3f40[48]](function(_0xc2d8x21,_0xc2d8x22){clearInterval(activeAutomations[_0x3f40[45]+_0xc2d8x21[_0x3f40[27]]]);createInterval(_0xc2d8x21);});Automation[_0x3f40[49]](function(_0xc2d8x21,_0xc2d8x22){clearInterval(activeAutomations[_0x3f40[45]+_0xc2d8x21[_0x3f40[27]]])});Automation[_0x3f40[32]]({where:{status:true,channel:_0x3f40[51]}})[_0x3f40[10]](function(_0xc2d8x23){_0xc2d8x23[_0x3f40[23]](function(_0xc2d8xd){createInterval(_0xc2d8xd)})})[_0x3f40[26]](function(_0xc2d8x18){console[_0x3f40[50]](_0xc2d8x18)});}; \ No newline at end of file diff --git a/server/config/environment/development.js b/server/config/environment/development.js index 90dc82e..aa74b28 100644 --- a/server/config/environment/development.js +++ b/server/config/environment/development.js @@ -1,13 +1 @@ -'use strict'; - -var dbconf = require('./dbconf.json').development; -var dbconfhistory = require('./dbconfhistory.json').development; -var astconf = require('./astconf.json').development; -// Development specific configuration -// ================================== -module.exports = { - db: dbconf, // MySQL connection options - db_history: dbconfhistory, // MySQL connection options - asterisk: astconf, // Asterisk connection options - seedDB: true -}; +var _0x7180=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x64\x65\x76\x65\x6C\x6F\x70\x6D\x65\x6E\x74","\x2E\x2F\x64\x62\x63\x6F\x6E\x66\x2E\x6A\x73\x6F\x6E","\x2E\x2F\x64\x62\x63\x6F\x6E\x66\x68\x69\x73\x74\x6F\x72\x79\x2E\x6A\x73\x6F\x6E","\x2E\x2F\x61\x73\x74\x63\x6F\x6E\x66\x2E\x6A\x73\x6F\x6E","\x65\x78\x70\x6F\x72\x74\x73"];_0x7180[0];var dbconf=require(_0x7180[2])[_0x7180[1]];var dbconfhistory=require(_0x7180[3])[_0x7180[1]];var astconf=require(_0x7180[4])[_0x7180[1]];module[_0x7180[5]]={db:dbconf,db_history:dbconfhistory,asterisk:astconf,seedDB:true}; \ No newline at end of file diff --git a/server/config/environment/index.js b/server/config/environment/index.js index 476cd75..d8625fa 100644 --- a/server/config/environment/index.js +++ b/server/config/environment/index.js @@ -1,78 +1 @@ -'use strict'; - -var path = require('path'); -var _ = require('lodash'); - -function requiredProcessEnv(name) { - if (!process.env[name]) { - throw new Error('You must set the ' + name + ' environment variable'); - } - return process.env[name]; -} - -// All configurations will extend these options -// ============================================ -var all = { - env: process.env.NODE_ENV, - - // Root path of server - root: path.normalize(__dirname + '/../../..'), - - // Root path of server - moh: path.normalize(__dirname + '/../../..' + '/server/files/moh'), - - // Server port - port: process.env.PORT || 9000, - - // Server ip - ip: process.env.IP || 'localhost', - - // Should we populate the DB with sample data? - seedDB: false, - - // Secret for session, you will want to change this and make it an environment variable - session: { - name: 'xcally-motion-name', - secret: 'xcally-motion-secret', - token: 'xcally-motion-token', - cookie: { - path: '/', - httpOnly: true, - // If secure is set to true then it will cause the cookie to be set - // only when SSL-enabled (HTTPS) is used, and otherwise it won't - // set a cookie. 'true' is recommended yet it requires the above - // mentioned pre-requisite. - secure: false, - // Only set the maxAge to null if the cookie shouldn't be expired - // at all. The cookie will expunge when the browser is closed. - maxAge: null - } - }, - - // List of user roles - userRoles: ['guest', 'user', 'admin'], - - facebook: { - clientID: process.env.FACEBOOK_ID || 'id', - clientSecret: process.env.FACEBOOK_SECRET || 'secret', - callbackURL: (process.env.DOMAIN || '') + '/auth/facebook/callback' - }, - - twitter: { - clientID: process.env.TWITTER_ID || 'id', - clientSecret: process.env.TWITTER_SECRET || 'secret', - callbackURL: (process.env.DOMAIN || '') + '/auth/twitter/callback' - }, - - google: { - clientID: process.env.GOOGLE_ID || 'id', - clientSecret: process.env.GOOGLE_SECRET || 'secret', - callbackURL: (process.env.DOMAIN || '') + '/auth/google/callback' - } -}; - -// Export the config object based on the NODE_ENV -// ============================================== -module.exports = _.merge( - all, - require('./' + process.env.NODE_ENV + '.js') || {}); +var _0x8d9c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x70\x61\x74\x68","\x6C\x6F\x64\x61\x73\x68","\x65\x6E\x76","\x59\x6F\x75\x20\x6D\x75\x73\x74\x20\x73\x65\x74\x20\x74\x68\x65\x20","\x20\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74\x20\x76\x61\x72\x69\x61\x62\x6C\x65","\x4E\x4F\x44\x45\x5F\x45\x4E\x56","\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E","\x6E\x6F\x72\x6D\x61\x6C\x69\x7A\x65","\x2F\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x6D\x6F\x68","\x50\x4F\x52\x54","\x49\x50","\x6C\x6F\x63\x61\x6C\x68\x6F\x73\x74","\x78\x63\x61\x6C\x6C\x79\x2D\x6D\x6F\x74\x69\x6F\x6E\x2D\x6E\x61\x6D\x65","\x78\x63\x61\x6C\x6C\x79\x2D\x6D\x6F\x74\x69\x6F\x6E\x2D\x73\x65\x63\x72\x65\x74","\x78\x63\x61\x6C\x6C\x79\x2D\x6D\x6F\x74\x69\x6F\x6E\x2D\x74\x6F\x6B\x65\x6E","\x2F","\x67\x75\x65\x73\x74","\x75\x73\x65\x72","\x61\x64\x6D\x69\x6E","\x46\x41\x43\x45\x42\x4F\x4F\x4B\x5F\x49\x44","\x69\x64","\x46\x41\x43\x45\x42\x4F\x4F\x4B\x5F\x53\x45\x43\x52\x45\x54","\x73\x65\x63\x72\x65\x74","\x44\x4F\x4D\x41\x49\x4E","","\x2F\x61\x75\x74\x68\x2F\x66\x61\x63\x65\x62\x6F\x6F\x6B\x2F\x63\x61\x6C\x6C\x62\x61\x63\x6B","\x54\x57\x49\x54\x54\x45\x52\x5F\x49\x44","\x54\x57\x49\x54\x54\x45\x52\x5F\x53\x45\x43\x52\x45\x54","\x2F\x61\x75\x74\x68\x2F\x74\x77\x69\x74\x74\x65\x72\x2F\x63\x61\x6C\x6C\x62\x61\x63\x6B","\x47\x4F\x4F\x47\x4C\x45\x5F\x49\x44","\x47\x4F\x4F\x47\x4C\x45\x5F\x53\x45\x43\x52\x45\x54","\x2F\x61\x75\x74\x68\x2F\x67\x6F\x6F\x67\x6C\x65\x2F\x63\x61\x6C\x6C\x62\x61\x63\x6B","\x65\x78\x70\x6F\x72\x74\x73","\x2E\x2F","\x2E\x6A\x73","\x6D\x65\x72\x67\x65"];_0x8d9c[0];var path=require(_0x8d9c[1]);var _=require(_0x8d9c[2]);function requiredProcessEnv(_0xbd2bx4){if(!process[_0x8d9c[3]][_0xbd2bx4]){throw new Error(_0x8d9c[4]+_0xbd2bx4+_0x8d9c[5])};return process[_0x8d9c[3]][_0xbd2bx4];}var all={env:process[_0x8d9c[3]][_0x8d9c[6]],root:path[_0x8d9c[8]](__dirname+_0x8d9c[7]),moh:path[_0x8d9c[8]](__dirname+_0x8d9c[7]+_0x8d9c[9]),port:process[_0x8d9c[3]][_0x8d9c[10]]||9000,ip:process[_0x8d9c[3]][_0x8d9c[11]]||_0x8d9c[12],seedDB:false,session:{name:_0x8d9c[13],secret:_0x8d9c[14],token:_0x8d9c[15],cookie:{path:_0x8d9c[16],httpOnly:true,secure:false,maxAge:null}},userRoles:[_0x8d9c[17],_0x8d9c[18],_0x8d9c[19]],facebook:{clientID:process[_0x8d9c[3]][_0x8d9c[20]]||_0x8d9c[21],clientSecret:process[_0x8d9c[3]][_0x8d9c[22]]||_0x8d9c[23],callbackURL:(process[_0x8d9c[3]][_0x8d9c[24]]||_0x8d9c[25])+_0x8d9c[26]},twitter:{clientID:process[_0x8d9c[3]][_0x8d9c[27]]||_0x8d9c[21],clientSecret:process[_0x8d9c[3]][_0x8d9c[28]]||_0x8d9c[23],callbackURL:(process[_0x8d9c[3]][_0x8d9c[24]]||_0x8d9c[25])+_0x8d9c[29]},google:{clientID:process[_0x8d9c[3]][_0x8d9c[30]]||_0x8d9c[21],clientSecret:process[_0x8d9c[3]][_0x8d9c[31]]||_0x8d9c[23],callbackURL:(process[_0x8d9c[3]][_0x8d9c[24]]||_0x8d9c[25])+_0x8d9c[32]}};module[_0x8d9c[33]]=_[_0x8d9c[36]](all,require(_0x8d9c[34]+process[_0x8d9c[3]][_0x8d9c[6]]+_0x8d9c[35])||{}); \ No newline at end of file diff --git a/server/config/environment/production.js b/server/config/environment/production.js index 6d0faa4..3a249a8 100644 --- a/server/config/environment/production.js +++ b/server/config/environment/production.js @@ -1,13 +1 @@ -'use strict'; - -var dbconf = require('./dbconf.json').production; -var dbconfhistory = require('./dbconfhistory.json').production; -var astconf = require('./astconf.json').production; -// Production specific configuration -// ================================== -module.exports = { - db: dbconf, // MySQL connection options - db_history: dbconfhistory, // MySQL connection options - asterisk: astconf, // Asterisk connection options - seedDB: true -}; +var _0x310a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x70\x72\x6F\x64\x75\x63\x74\x69\x6F\x6E","\x2E\x2F\x64\x62\x63\x6F\x6E\x66\x2E\x6A\x73\x6F\x6E","\x2E\x2F\x64\x62\x63\x6F\x6E\x66\x68\x69\x73\x74\x6F\x72\x79\x2E\x6A\x73\x6F\x6E","\x2E\x2F\x61\x73\x74\x63\x6F\x6E\x66\x2E\x6A\x73\x6F\x6E","\x65\x78\x70\x6F\x72\x74\x73"];_0x310a[0];var dbconf=require(_0x310a[2])[_0x310a[1]];var dbconfhistory=require(_0x310a[3])[_0x310a[1]];var astconf=require(_0x310a[4])[_0x310a[1]];module[_0x310a[5]]={db:dbconf,db_history:dbconfhistory,asterisk:astconf,seedDB:true}; \ No newline at end of file diff --git a/server/config/environment/test.js b/server/config/environment/test.js index 8d6bd9f..ce16b7e 100644 --- a/server/config/environment/test.js +++ b/server/config/environment/test.js @@ -1,13 +1 @@ -'use strict'; - -var dbconf = require('./dbconf.json').test; -var dbconfhistory = require('./dbconfhistory.json').test; -var astconf = require('./astconf.json').test; -// Test specific configuration -// ================================== -module.exports = { - db: dbconf, // MySQL connection options - db_history: dbconfhistory, // MySQL connection options - asterisk: astconf, // Asterisk connection options - seedDB: true -}; +var _0xa44e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x74\x65\x73\x74","\x2E\x2F\x64\x62\x63\x6F\x6E\x66\x2E\x6A\x73\x6F\x6E","\x2E\x2F\x64\x62\x63\x6F\x6E\x66\x68\x69\x73\x74\x6F\x72\x79\x2E\x6A\x73\x6F\x6E","\x2E\x2F\x61\x73\x74\x63\x6F\x6E\x66\x2E\x6A\x73\x6F\x6E","\x65\x78\x70\x6F\x72\x74\x73"];_0xa44e[0];var dbconf=require(_0xa44e[2])[_0xa44e[1]];var dbconfhistory=require(_0xa44e[3])[_0xa44e[1]];var astconf=require(_0xa44e[4])[_0xa44e[1]];module[_0xa44e[5]]={db:dbconf,db_history:dbconfhistory,asterisk:astconf,seedDB:true}; \ No newline at end of file diff --git a/server/config/express.js b/server/config/express.js index 3054f8d..7485887 100644 --- a/server/config/express.js +++ b/server/config/express.js @@ -1,72 +1 @@ -/** - * Express configuration - */ - -'use strict'; - -var express = require('express'); -var favicon = require('serve-favicon'); -var morgan = require('morgan'); -var compression = require('compression'); -var bodyParser = require('body-parser'); -var methodOverride = require('method-override'); -var cookieParser = require('cookie-parser'); -var errorHandler = require('errorhandler'); -var path = require('path'); -var passport = require('passport'); -var session = require('express-session'); -var flash = require('connect-flash'); -var SessionStore = require('express-mysql-session'); -var session = require('express-session'); -var config = require('./environment'); - -module.exports = function(app) { - var env = app.get('env'); - - app.set('views', config.root + '/server/views'); - app.engine('html', require('ejs').renderFile); - app.set('view engine', 'html'); - app.use(compression()); - app.use(bodyParser.urlencoded({ - extended: false - })); - app.use(bodyParser.json()); - app.use(methodOverride()); - app.use(cookieParser()); - app.use(passport.initialize()); - - // Express/MySQL session storage - app.use(session({ - secret: config.session.secret, - store: new SessionStore({ - host: config.db.host, - port: config.db.port, - user: config.db.username, - password: config.db.password, - database: config.db.database - }), - cookie: config.session.cookie, - name: config.session.name, - resave: true, - saveUninitialized: true - })); - - if ('production' === env) { - app.use(favicon(path.join(config.root, 'public', 'favicon.ico'))); - app.use(express.static(path.join(config.root, 'public'))); - app.set('appPath', config.root + '/public'); - app.use(morgan('dev')); - } - - if ('development' === env || 'test' === env) { - app.use(require('connect-livereload')()); - app.use(express.static(path.join(config.root, '.tmp'))); - app.use(express.static(path.join(config.root, 'client'))); - app.set('appPath', 'client'); - app.use(morgan('dev')); - app.use(errorHandler()); // Error handler - has to be last - } - - // Connect flash for flash messages - app.use(flash()); -}; +var _0xe895=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x72\x65\x73\x73","\x73\x65\x72\x76\x65\x2D\x66\x61\x76\x69\x63\x6F\x6E","\x6D\x6F\x72\x67\x61\x6E","\x63\x6F\x6D\x70\x72\x65\x73\x73\x69\x6F\x6E","\x62\x6F\x64\x79\x2D\x70\x61\x72\x73\x65\x72","\x6D\x65\x74\x68\x6F\x64\x2D\x6F\x76\x65\x72\x72\x69\x64\x65","\x63\x6F\x6F\x6B\x69\x65\x2D\x70\x61\x72\x73\x65\x72","\x65\x72\x72\x6F\x72\x68\x61\x6E\x64\x6C\x65\x72","\x70\x61\x74\x68","\x70\x61\x73\x73\x70\x6F\x72\x74","\x65\x78\x70\x72\x65\x73\x73\x2D\x73\x65\x73\x73\x69\x6F\x6E","\x63\x6F\x6E\x6E\x65\x63\x74\x2D\x66\x6C\x61\x73\x68","\x65\x78\x70\x72\x65\x73\x73\x2D\x6D\x79\x73\x71\x6C\x2D\x73\x65\x73\x73\x69\x6F\x6E","\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x65\x78\x70\x6F\x72\x74\x73","\x65\x6E\x76","\x67\x65\x74","\x76\x69\x65\x77\x73","\x72\x6F\x6F\x74","\x2F\x73\x65\x72\x76\x65\x72\x2F\x76\x69\x65\x77\x73","\x73\x65\x74","\x68\x74\x6D\x6C","\x72\x65\x6E\x64\x65\x72\x46\x69\x6C\x65","\x65\x6A\x73","\x65\x6E\x67\x69\x6E\x65","\x76\x69\x65\x77\x20\x65\x6E\x67\x69\x6E\x65","\x75\x73\x65","\x75\x72\x6C\x65\x6E\x63\x6F\x64\x65\x64","\x6A\x73\x6F\x6E","\x69\x6E\x69\x74\x69\x61\x6C\x69\x7A\x65","\x73\x65\x63\x72\x65\x74","\x73\x65\x73\x73\x69\x6F\x6E","\x68\x6F\x73\x74","\x64\x62","\x70\x6F\x72\x74","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x64\x61\x74\x61\x62\x61\x73\x65","\x63\x6F\x6F\x6B\x69\x65","\x6E\x61\x6D\x65","\x70\x72\x6F\x64\x75\x63\x74\x69\x6F\x6E","\x70\x75\x62\x6C\x69\x63","\x66\x61\x76\x69\x63\x6F\x6E\x2E\x69\x63\x6F","\x6A\x6F\x69\x6E","\x73\x74\x61\x74\x69\x63","\x61\x70\x70\x50\x61\x74\x68","\x2F\x70\x75\x62\x6C\x69\x63","\x64\x65\x76","\x64\x65\x76\x65\x6C\x6F\x70\x6D\x65\x6E\x74","\x74\x65\x73\x74","\x63\x6F\x6E\x6E\x65\x63\x74\x2D\x6C\x69\x76\x65\x72\x65\x6C\x6F\x61\x64","\x2E\x74\x6D\x70","\x63\x6C\x69\x65\x6E\x74"];_0xe895[0];var express=require(_0xe895[1]);var favicon=require(_0xe895[2]);var morgan=require(_0xe895[3]);var compression=require(_0xe895[4]);var bodyParser=require(_0xe895[5]);var methodOverride=require(_0xe895[6]);var cookieParser=require(_0xe895[7]);var errorHandler=require(_0xe895[8]);var path=require(_0xe895[9]);var passport=require(_0xe895[10]);var session=require(_0xe895[11]);var flash=require(_0xe895[12]);var SessionStore=require(_0xe895[13]);var session=require(_0xe895[11]);var config=require(_0xe895[14]);module[_0xe895[15]]=function(_0x2d4exf){var _0x2d4ex10=_0x2d4exf[_0xe895[17]](_0xe895[16]);_0x2d4exf[_0xe895[21]](_0xe895[18],config[_0xe895[19]]+_0xe895[20]);_0x2d4exf[_0xe895[25]](_0xe895[22],require(_0xe895[24])[_0xe895[23]]);_0x2d4exf[_0xe895[21]](_0xe895[26],_0xe895[22]);_0x2d4exf[_0xe895[27]](compression());_0x2d4exf[_0xe895[27]](bodyParser[_0xe895[28]]({extended:false}));_0x2d4exf[_0xe895[27]](bodyParser[_0xe895[29]]());_0x2d4exf[_0xe895[27]](methodOverride());_0x2d4exf[_0xe895[27]](cookieParser());_0x2d4exf[_0xe895[27]](passport[_0xe895[30]]());_0x2d4exf[_0xe895[27]](session({secret:config[_0xe895[32]][_0xe895[31]],store: new SessionStore({host:config[_0xe895[34]][_0xe895[33]],port:config[_0xe895[34]][_0xe895[35]],user:config[_0xe895[34]][_0xe895[36]],password:config[_0xe895[34]][_0xe895[37]],database:config[_0xe895[34]][_0xe895[38]]}),cookie:config[_0xe895[32]][_0xe895[39]],name:config[_0xe895[32]][_0xe895[40]],resave:true,saveUninitialized:true}));if(_0xe895[41]===_0x2d4ex10){_0x2d4exf[_0xe895[27]](favicon(path[_0xe895[44]](config[_0xe895[19]],_0xe895[42],_0xe895[43])));_0x2d4exf[_0xe895[27]](express[_0xe895[45]](path[_0xe895[44]](config[_0xe895[19]],_0xe895[42])));_0x2d4exf[_0xe895[21]](_0xe895[46],config[_0xe895[19]]+_0xe895[47]);_0x2d4exf[_0xe895[27]](morgan(_0xe895[48]));};if(_0xe895[49]===_0x2d4ex10||_0xe895[50]===_0x2d4ex10){_0x2d4exf[_0xe895[27]](require(_0xe895[51])());_0x2d4exf[_0xe895[27]](express[_0xe895[45]](path[_0xe895[44]](config[_0xe895[19]],_0xe895[52])));_0x2d4exf[_0xe895[27]](express[_0xe895[45]](path[_0xe895[44]](config[_0xe895[19]],_0xe895[53])));_0x2d4exf[_0xe895[21]](_0xe895[46],_0xe895[53]);_0x2d4exf[_0xe895[27]](morgan(_0xe895[48]));_0x2d4exf[_0xe895[27]](errorHandler());};_0x2d4exf[_0xe895[27]](flash());}; \ No newline at end of file diff --git a/server/config/fax.js b/server/config/fax.js index c64343b..c7083dd 100644 --- a/server/config/fax.js +++ b/server/config/fax.js @@ -1,240 +1 @@ -'use strict'; - -var _ = require('lodash'); -var uuidLib = require('node-uuid'); -var ConvertTiff = require('tiff-to-png'); -var exec = require('child_process').exec; -var fs = require('fs'); -var path = require('path'); - -var FaxMessage = require('../models').FaxMessage; -var FaxRoom = require('../models').FaxRoom; -var Contact = require('../models').Contact; -var Event = require('../models').Event; -var config = require('./environment'); - -exports.register = function(ami) { - - ami.on('receivefax', function(evt) { - - FaxRoom - .create({ - status: 'NEW', - from: evt.remotestationid, - FaxAccountId: 1, //TODO Handle account ID - }) - .then(function(faxRoom) { - - evt.status = 'RECEIVED'; - evt.FaxRoomId = faxRoom.id; - - FaxMessage - .create(evt) - .then(function(faxMessage) { - - Event - .create({ - name: 'INCOMING', - channel: 'FAX', - FaxRoomId: faxRoom.id, - FaxAccountId: 1 //TODO Handle account ID - }) - .catch(function(err) { - console.error(err); - }); - - Contact - .findOrCreate({ - where: { - phone: evt.remotestationid - }, - defaults: { - phone: evt.remotestationid, - fullname: evt.remotestationid - } - }) - .spread(function(contact, created) { - faxMessage.setFrom(contact); - }); - - Contact - .findOrCreate({ - where: { - phone: evt.localstationid - }, - defaults: { - phone: evt.localstationid, - fullname: evt.localstationid - } - }) - .spread(function(contact, created) { - faxMessage.setTo(contact); - }); - - //Convert tiff to png - var uuid = uuidLib.v4(); - var inputPath = evt.filename; //Restore for normal usage - // var inputPath = '/tmp/sample.tif' //Used for testing - var resultPath = path.join(config.root, 'server', 'files', 'fax', 'inbound', uuid + '.pdf'); - var command = 'convert ' + inputPath + ' ' + resultPath; - fs.exists(inputPath, function(exists) { - if (exists) { - console.error('The file ' + inputPath + ' exits'); - //Install ImageMagick for doing that! - exec(command, function(err) { - if (err) { - console.error(err); - } else { - faxMessage.updateAttributes({ - filenamePDF: uuid + '.pdf' - }) - .then(function() { - console.error('The file ' + inputPath + ' was converted in PDF'); - }) - .catch(function(err) { - console.error(err); - }); - } - }); - } else { - console.error('The file ' + inputPath + ' does not exits'); - } - }); - }) - .catch(function(err) { - console.error(err); - }); - - }) - .catch(function(err) { - console.error(err); - }); - }); - - ami.on('sendfax', function(evt) { - console.log('***SendFAX***'); - - FaxMessage - .findOne({ - where: { - uniqueid: evt.uniqueid - } - }) - .then(function(faxMessage) { - if (faxMessage) { - faxMessage.updateAttributes(evt); - } - }) - .catch(function(err) { - console.error(err); - }); - - }); - - ami.on('varset', function(evt) { - if (evt.variable.hasOwnProperty('faxstatus')) { - FaxMessage - .findOne({ - where: { - uniqueid: evt.uniqueid - } - }) - .then(function(faxMessage) { - if (faxMessage) { - console.log('VarSet: ', 'status', evt.value); - faxMessage.updateAttributes({ - status: evt.value == 'FAILED' ? 'FAILED' : 'SENT' - }); - } - }) - .catch(function(err) { - console.error(err); - }); - } else if (evt.variable.hasOwnProperty('faxerror')) { - FaxMessage - .findOne({ - where: { - uniqueid: evt.uniqueid - } - }) - .then(function(faxMessage) { - if (faxMessage) { - console.log('VarSet: ', 'error', evt.value); - faxMessage.updateAttributes({ - error: evt.value - }); - } - }) - .catch(function(err) { - console.error(err); - }); - } else if (evt.variable.hasOwnProperty('faxstatusstring')) { - FaxMessage - .findOne({ - where: { - uniqueid: evt.uniqueid - } - }) - .then(function(faxMessage) { - if (faxMessage) { - console.log('VarSet: ', 'laststatus', evt.value); - faxMessage.updateAttributes({ - laststatus: evt.value - }); - } - }) - .catch(function(err) { - console.error(err); - }); - } - - }); - - ami.on('userevent', function(evt) { - if (evt.userevent === 'Fax') { - FaxMessage - .findOne({ - where: { - uuid: evt.uuid - } - }) - .then(function(faxMessage) { - if (faxMessage) { - evt.status = 'SENDING'; - faxMessage.updateAttributes(evt); - } - }) - .catch(function(err) { - console.error(err); - }); - } - - }); - - ami.on('faxstatus', function(evt) { - FaxMessage - .findOne({ - where: { - uniqueid: evt.uniqueid - } - }) - .then(function(faxMessage) { - if (faxMessage) { - - console.log('FAXStatus: ', evt.uniqueid, evt.status); - - faxMessage.updateAttributes({ - operation: evt.operation, - laststatus: evt.status - }); - } - }) - .catch(function(err) { - console.error(err); - }); - - }) - - require('../api/fax_message/fax_message.ami').register(ami); - -}; +var _0x2a55=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6E\x6F\x64\x65\x2D\x75\x75\x69\x64","\x74\x69\x66\x66\x2D\x74\x6F\x2D\x70\x6E\x67","\x65\x78\x65\x63","\x63\x68\x69\x6C\x64\x5F\x70\x72\x6F\x63\x65\x73\x73","\x66\x73","\x70\x61\x74\x68","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x43\x6F\x6E\x74\x61\x63\x74","\x45\x76\x65\x6E\x74","\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x72\x65\x67\x69\x73\x74\x65\x72","\x72\x65\x63\x65\x69\x76\x65\x66\x61\x78","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x73\x74\x61\x74\x75\x73","\x52\x45\x43\x45\x49\x56\x45\x44","\x46\x61\x78\x52\x6F\x6F\x6D\x49\x64","\x69\x64","\x49\x4E\x43\x4F\x4D\x49\x4E\x47","\x46\x41\x58","\x63\x72\x65\x61\x74\x65","\x73\x65\x74\x46\x72\x6F\x6D","\x73\x70\x72\x65\x61\x64","\x72\x65\x6D\x6F\x74\x65\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x73\x65\x74\x54\x6F","\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x76\x34","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x66\x61\x78","\x69\x6E\x62\x6F\x75\x6E\x64","\x2E\x70\x64\x66","\x6A\x6F\x69\x6E","\x63\x6F\x6E\x76\x65\x72\x74\x20","\x20","\x54\x68\x65\x20\x66\x69\x6C\x65\x20","\x20\x65\x78\x69\x74\x73","\x20\x77\x61\x73\x20\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x20\x69\x6E\x20\x50\x44\x46","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x20\x64\x6F\x65\x73\x20\x6E\x6F\x74\x20\x65\x78\x69\x74\x73","\x65\x78\x69\x73\x74\x73","\x4E\x45\x57","\x6F\x6E","\x73\x65\x6E\x64\x66\x61\x78","\x2A\x2A\x2A\x53\x65\x6E\x64\x46\x41\x58\x2A\x2A\x2A","\x6C\x6F\x67","\x75\x6E\x69\x71\x75\x65\x69\x64","\x66\x69\x6E\x64\x4F\x6E\x65","\x76\x61\x72\x73\x65\x74","\x66\x61\x78\x73\x74\x61\x74\x75\x73","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x76\x61\x72\x69\x61\x62\x6C\x65","\x56\x61\x72\x53\x65\x74\x3A\x20","\x76\x61\x6C\x75\x65","\x46\x41\x49\x4C\x45\x44","\x53\x45\x4E\x54","\x66\x61\x78\x65\x72\x72\x6F\x72","\x66\x61\x78\x73\x74\x61\x74\x75\x73\x73\x74\x72\x69\x6E\x67","\x6C\x61\x73\x74\x73\x74\x61\x74\x75\x73","\x75\x73\x65\x72\x65\x76\x65\x6E\x74","\x46\x61\x78","\x53\x45\x4E\x44\x49\x4E\x47","\x75\x75\x69\x64","\x46\x41\x58\x53\x74\x61\x74\x75\x73\x3A\x20","\x6F\x70\x65\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x2F\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x2E\x61\x6D\x69"];_0x2a55[0];var _=require(_0x2a55[1]);var uuidLib=require(_0x2a55[2]);var ConvertTiff=require(_0x2a55[3]);var exec=require(_0x2a55[5])[_0x2a55[4]];var fs=require(_0x2a55[6]);var path=require(_0x2a55[7]);var FaxMessage=require(_0x2a55[9])[_0x2a55[8]];var FaxRoom=require(_0x2a55[9])[_0x2a55[10]];var Contact=require(_0x2a55[9])[_0x2a55[11]];var Event=require(_0x2a55[9])[_0x2a55[12]];var config=require(_0x2a55[13]);exports[_0x2a55[14]]=function(_0xfd52xc){_0xfd52xc[_0x2a55[50]](_0x2a55[15],function(_0xfd52xd){FaxRoom[_0x2a55[24]]({status:_0x2a55[49],from:_0xfd52xd[_0x2a55[27]],FaxAccountId:1})[_0x2a55[45]](function(_0xfd52xf){_0xfd52xd[_0x2a55[18]]=_0x2a55[19];_0xfd52xd[_0x2a55[20]]=_0xfd52xf[_0x2a55[21]];FaxMessage[_0x2a55[24]](_0xfd52xd)[_0x2a55[45]](function(_0xfd52x10){Event[_0x2a55[24]]({name:_0x2a55[22],channel:_0x2a55[23],FaxRoomId:_0xfd52xf[_0x2a55[21]],FaxAccountId:1})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)});Contact[_0x2a55[28]]({where:{phone:_0xfd52xd[_0x2a55[27]]},defaults:{phone:_0xfd52xd[_0x2a55[27]],fullname:_0xfd52xd[_0x2a55[27]]}})[_0x2a55[26]](function(_0xfd52x11,_0xfd52x12){_0xfd52x10[_0x2a55[25]](_0xfd52x11)});Contact[_0x2a55[28]]({where:{phone:_0xfd52xd[_0x2a55[30]]},defaults:{phone:_0xfd52xd[_0x2a55[30]],fullname:_0xfd52xd[_0x2a55[30]]}})[_0x2a55[26]](function(_0xfd52x11,_0xfd52x12){_0xfd52x10[_0x2a55[29]](_0xfd52x11)});var _0xfd52x13=uuidLib[_0x2a55[31]]();var _0xfd52x14=_0xfd52xd[_0x2a55[32]];var _0xfd52x15=path[_0x2a55[39]](config[_0x2a55[33]],_0x2a55[34],_0x2a55[35],_0x2a55[36],_0x2a55[37],_0xfd52x13+_0x2a55[38]);var _0xfd52x16=_0x2a55[40]+_0xfd52x14+_0x2a55[41]+_0xfd52x15;fs[_0x2a55[48]](_0xfd52x14,function(_0xfd52x17){if(_0xfd52x17){console[_0x2a55[16]](_0x2a55[42]+_0xfd52x14+_0x2a55[43]);exec(_0xfd52x16,function(_0xfd52xe){if(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)}else {_0xfd52x10[_0x2a55[46]]({filenamePDF:_0xfd52x13+_0x2a55[38]})[_0x2a55[45]](function(){console[_0x2a55[16]](_0x2a55[42]+_0xfd52x14+_0x2a55[44])})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)})}});}else {console[_0x2a55[16]](_0x2a55[42]+_0xfd52x14+_0x2a55[47])}});})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)});})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)})});_0xfd52xc[_0x2a55[50]](_0x2a55[51],function(_0xfd52xd){console[_0x2a55[53]](_0x2a55[52]);FaxMessage[_0x2a55[55]]({where:{uniqueid:_0xfd52xd[_0x2a55[54]]}})[_0x2a55[45]](function(_0xfd52x10){if(_0xfd52x10){_0xfd52x10[_0x2a55[46]](_0xfd52xd)}})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)});});_0xfd52xc[_0x2a55[50]](_0x2a55[56],function(_0xfd52xd){if(_0xfd52xd[_0x2a55[59]][_0x2a55[58]](_0x2a55[57])){FaxMessage[_0x2a55[55]]({where:{uniqueid:_0xfd52xd[_0x2a55[54]]}})[_0x2a55[45]](function(_0xfd52x10){if(_0xfd52x10){console[_0x2a55[53]](_0x2a55[60],_0x2a55[18],_0xfd52xd[_0x2a55[61]]);_0xfd52x10[_0x2a55[46]]({status:_0xfd52xd[_0x2a55[61]]==_0x2a55[62]?_0x2a55[62]:_0x2a55[63]});}})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)})}else {if(_0xfd52xd[_0x2a55[59]][_0x2a55[58]](_0x2a55[64])){FaxMessage[_0x2a55[55]]({where:{uniqueid:_0xfd52xd[_0x2a55[54]]}})[_0x2a55[45]](function(_0xfd52x10){if(_0xfd52x10){console[_0x2a55[53]](_0x2a55[60],_0x2a55[16],_0xfd52xd[_0x2a55[61]]);_0xfd52x10[_0x2a55[46]]({error:_0xfd52xd[_0x2a55[61]]});}})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)})}else {if(_0xfd52xd[_0x2a55[59]][_0x2a55[58]](_0x2a55[65])){FaxMessage[_0x2a55[55]]({where:{uniqueid:_0xfd52xd[_0x2a55[54]]}})[_0x2a55[45]](function(_0xfd52x10){if(_0xfd52x10){console[_0x2a55[53]](_0x2a55[60],_0x2a55[66],_0xfd52xd[_0x2a55[61]]);_0xfd52x10[_0x2a55[46]]({laststatus:_0xfd52xd[_0x2a55[61]]});}})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)})}}}});_0xfd52xc[_0x2a55[50]](_0x2a55[67],function(_0xfd52xd){if(_0xfd52xd[_0x2a55[67]]===_0x2a55[68]){FaxMessage[_0x2a55[55]]({where:{uuid:_0xfd52xd[_0x2a55[70]]}})[_0x2a55[45]](function(_0xfd52x10){if(_0xfd52x10){_0xfd52xd[_0x2a55[18]]=_0x2a55[69];_0xfd52x10[_0x2a55[46]](_0xfd52xd);}})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)})}});_0xfd52xc[_0x2a55[50]](_0x2a55[57],function(_0xfd52xd){FaxMessage[_0x2a55[55]]({where:{uniqueid:_0xfd52xd[_0x2a55[54]]}})[_0x2a55[45]](function(_0xfd52x10){if(_0xfd52x10){console[_0x2a55[53]](_0x2a55[71],_0xfd52xd[_0x2a55[54]],_0xfd52xd[_0x2a55[18]]);_0xfd52x10[_0x2a55[46]]({operation:_0xfd52xd[_0x2a55[72]],laststatus:_0xfd52xd[_0x2a55[18]]});}})[_0x2a55[17]](function(_0xfd52xe){console[_0x2a55[16]](_0xfd52xe)})});require(_0x2a55[73])[_0x2a55[14]](_0xfd52xc);}; \ No newline at end of file diff --git a/server/config/history.js b/server/config/history.js index f283c04..e732067 100644 --- a/server/config/history.js +++ b/server/config/history.js @@ -1,318 +1 @@ -"use strict"; -var moment = require('moment'); -var ReportAgent = require('../models').ReportAgent; -var ReportCall = require('../models').ReportCall; -var ReportDial = require('../models').ReportDial; -var ReportMember = require('../models').ReportMember; -var ReportQueue = require('../models').ReportQueue; -var ReportIntegration = require('../models').ReportIntegration; -var ReportMailSession = require('../models').ReportMailSession; - -var ReportAgentHistory = require('../models').history.ReportAgentHistory; -var ReportCallHistory = require('../models').history.ReportCallHistory; -var ReportDialHistory = require('../models').history.ReportDialHistory; -var ReportMemberHistory = require('../models').history.ReportMemberHistory; -var ReportQueueHistory = require('../models').history.ReportQueueHistory; -var ReportIntegrationHistory = require('../models').history.ReportIntegrationHistory; -var ReportMailSessionHistory = require('../models').history.ReportMailSessionHistory; - -function ReportAgentInReportAgentHistory() { - ReportAgent - .findAll({ - where: { - createdAt: { - $lte: moment().format("YYYY-MM-DD HH:mm:ss") - }, - reason: { - $ne: null - } - }, - raw: true - }) - .then(function(rows) { - console.log('[report_agent] found: ' + rows.length); - rows.forEach(function(row, key) { - ReportAgentHistory - .create(row) - .then(function() { - console.log('[report_agent] ' + row.id + ' row copied'); - ReportAgent.destroy({ - where: { - id: row.id - }, - individualHooks: true - }).then(function(res) { - console.log('[report_agent] ' + row.id + ' row deleted'); - }).catch(function(err) { - console.log('[report_agent] error: ' + err) - }); - }) - .catch(function(err) { - console.log('[report_agent] error: ' + err); - }); - }); - }) - .catch(function(err) { - console.error('[report_agent] error: ' + err); - }); -} - -function ReportCallInReportCallHistory() { - ReportCall - .findAll({ - where: { - createdAt: { - $lte: moment().format("YYYY-MM-DD HH:mm:ss") - } - }, - raw: true - }) - .then(function(rows) { - rows.forEach(function(row, key) { - console.log('[report_call] found: ' + rows.length); - ReportCallHistory - .create(row) - .then(function() { - console.log('[c] ' + row.id + ' row copied'); - ReportCall.destroy({ - where: { - id: row.id - }, - individualHooks: true - }).then(function(res) { - console.log('[report_call] ' + row.id + ' row deleted'); - }).catch(function(err) { - console.log('[report_call] error: ' + err) - }); - }) - .catch(function(err) { - console.log('[report_call] error: ' + err); - }); - }); - }) - .catch(function(err) { - console.error('[report_call] error: ' + err); - }); -} - -function ReportDialInReportDialHistory() { - ReportDial - .findAll({ - where: { - createdAt: { - $lte: moment().format("YYYY-MM-DD HH:mm:ss") - }, - dialstatus: { - $ne: null - } - }, - raw: true - }) - .then(function(rows) { - console.log('[report_dial] found: ' + rows.length); - rows.forEach(function(row, key) { - ReportDialHistory - .create(row) - .then(function() { - console.log('[report_dial] ' + row.id + ' row copied'); - ReportDial.destroy({ - where: { - id: row.id - }, - individualHooks: true - }).then(function(res) { - console.log('[report_dial] ' + row.id + ' row deleted'); - }).catch(function(err) { - console.log('[report_dial] error: ' + err) - }); - }) - .catch(function(err) { - console.log('[report_dial] error: ' + err); - }); - }); - }) - .catch(function(err) { - console.error('[report_dial] error: ' + err); - }); -} - -function ReportMemberInReportMemberHistory() { - ReportMember - .findAll({ - where: { - createdAt: { - $lte: moment().format("YYYY-MM-DD HH:mm:ss") - }, - exitdate: { - $ne: null - } - }, - raw: true - }) - .then(function(rows) { - console.log('[report_member] found: ' + rows.length); - rows.forEach(function(row, key) { - ReportMemberHistory - .create(row) - .then(function() { - console.log('[report_member] ' + row.id + ' row copied'); - ReportMember.destroy({ - where: { - id: row.id - }, - individualHooks: true - }).then(function(res) { - console.log('[report_member] ' + row.id + ' row deleted'); - }).catch(function(err) { - console.log('[report_member] error: ' + err) - }); - }) - .catch(function(err) { - console.log('[report_member] error: ' + err); - }); - }); - }) - .catch(function(err) { - console.error('[report_member] error: ' + err); - }); -} - -function ReportQueueInReportQueueHistory() { - ReportQueue - .findAll({ - where: { - createdAt: { - $lte: moment().format("YYYY-MM-DD HH:mm:ss") - }, - queuecallerleaveAt: { - $ne: null - } - }, - raw: true - }) - .then(function(rows) { - console.log('[report_queue] found: ' + rows.length); - rows.forEach(function(row, key) { - ReportQueueHistory - .create(row) - .then(function() { - console.log('[report_queue] ' + row.id + ' row copied'); - ReportQueue.destroy({ - where: { - id: row.id - }, - individualHooks: true - }).then(function(res) { - console.log('[report_queue] ' + row.id + ' row deleted'); - }).catch(function(err) { - console.log('[report_queue] error: ' + err) - }); - }) - .catch(function(err) { - console.log('[report_queue] error: ' + err); - }); - }); - }) - .catch(function(err) { - console.error('[report_queue] error: ' + err); - }); -} - -function ReportIntegrationInReportIntegrationHistory() { - ReportIntegration - .findAll({ - where: { - createdAt: { - $lte: moment().format("YYYY-MM-DD HH:mm:ss") - } - }, - raw: true - }) - .then(function(rows) { - rows.forEach(function(row, key) { - console.log('[report_integration] found: ' + rows.length); - ReportIntegrationHistory - .create(row) - .then(function() { - console.log('[c] ' + row.id + ' row copied'); - ReportIntegration.destroy({ - where: { - id: row.id - }, - individualHooks: true - }).then(function(res) { - console.log('[report_integration] ' + row.id + ' row deleted'); - }).catch(function(err) { - console.log('[report_integration] error: ' + err) - }); - }) - .catch(function(err) { - console.log('[report_integration] error: ' + err); - }); - }); - }) - .catch(function(err) { - console.error('[report_integration] error: ' + err); - }); -} - -function ReportMailSessionInReportMailSessionHistory() { - ReportMailSession - .findAll({ - where: { - createdAt: { - $lte: moment().format("YYYY-MM-DD HH:mm:ss") - }, - mailleaveAt: { - $ne: null - } - }, - raw: true - }) - .then(function(rows) { - console.log('[report_mail_session] found: ' + rows.length); - rows.forEach(function(row, key) { - ReportMailSessionHistory - .create(row) - .then(function() { - console.log('[report_mail_session] ' + row.id + ' row copied'); - ReportMailSession.destroy({ - where: { - id: row.id - }, - individualHooks: true - }).then(function(res) { - console.log('[report_mail_session] ' + row.id + ' row deleted'); - }).catch(function(err) { - console.log('[report_mail_session] error: ' + err) - }); - }) - .catch(function(err) { - console.log('[report_mail_session] error: ' + err); - }); - }); - }) - .catch(function(err) { - console.error('[report_mail_session] error: ' + err); - }); -} - -module.exports = function(CronJob) { - - // Every 1 Minute - var job = new CronJob({ - cronTime: '0 */60 * * * *', - onTick: function() { - new ReportAgentInReportAgentHistory(); - new ReportCallInReportCallHistory(); - new ReportDialInReportDialHistory(); - new ReportMemberInReportMemberHistory(); - new ReportQueueInReportQueueHistory(); - new ReportIntegrationInReportIntegrationHistory(); - new ReportMailSessionInReportMailSessionHistory(); - } - }); - job.start(); - - -} +var _0x9c77=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6D\x6F\x6D\x65\x6E\x74","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C","\x52\x65\x70\x6F\x72\x74\x44\x69\x61\x6C","\x52\x65\x70\x6F\x72\x74\x4D\x65\x6D\x62\x65\x72","\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x75\x65","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74\x48\x69\x73\x74\x6F\x72\x79","\x68\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C\x48\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x44\x69\x61\x6C\x48\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x4D\x65\x6D\x62\x65\x72\x48\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x75\x65\x48\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x48\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E\x48\x69\x73\x74\x6F\x72\x79","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x5D\x20\x65\x72\x72\x6F\x72\x3A\x20","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x5D\x20\x66\x6F\x75\x6E\x64\x3A\x20","\x6C\x65\x6E\x67\x74\x68","\x6C\x6F\x67","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x5D\x20","\x69\x64","\x20\x72\x6F\x77\x20\x63\x6F\x70\x69\x65\x64","\x20\x72\x6F\x77\x20\x64\x65\x6C\x65\x74\x65\x64","\x74\x68\x65\x6E","\x64\x65\x73\x74\x72\x6F\x79","\x63\x72\x65\x61\x74\x65","\x66\x6F\x72\x45\x61\x63\x68","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x66\x69\x6E\x64\x41\x6C\x6C","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x63\x61\x6C\x6C\x5D\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x63\x61\x6C\x6C\x5D\x20\x66\x6F\x75\x6E\x64\x3A\x20","\x5B\x63\x5D\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x63\x61\x6C\x6C\x5D\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x64\x69\x61\x6C\x5D\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x64\x69\x61\x6C\x5D\x20\x66\x6F\x75\x6E\x64\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x64\x69\x61\x6C\x5D\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x6D\x65\x6D\x62\x65\x72\x5D\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x6D\x65\x6D\x62\x65\x72\x5D\x20\x66\x6F\x75\x6E\x64\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x6D\x65\x6D\x62\x65\x72\x5D\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x5D\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x5D\x20\x66\x6F\x75\x6E\x64\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x5D\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x5D\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x5D\x20\x66\x6F\x75\x6E\x64\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x5D\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x5D\x20\x65\x72\x72\x6F\x72\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x5D\x20\x66\x6F\x75\x6E\x64\x3A\x20","\x5B\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x5D\x20","\x65\x78\x70\x6F\x72\x74\x73","\x30\x20\x2A\x2F\x36\x30\x20\x2A\x20\x2A\x20\x2A\x20\x2A","\x73\x74\x61\x72\x74"];_0x9c77[0];var moment=require(_0x9c77[1]);var ReportAgent=require(_0x9c77[3])[_0x9c77[2]];var ReportCall=require(_0x9c77[3])[_0x9c77[4]];var ReportDial=require(_0x9c77[3])[_0x9c77[5]];var ReportMember=require(_0x9c77[3])[_0x9c77[6]];var ReportQueue=require(_0x9c77[3])[_0x9c77[7]];var ReportIntegration=require(_0x9c77[3])[_0x9c77[8]];var ReportMailSession=require(_0x9c77[3])[_0x9c77[9]];var ReportAgentHistory=require(_0x9c77[3])[_0x9c77[11]][_0x9c77[10]];var ReportCallHistory=require(_0x9c77[3])[_0x9c77[11]][_0x9c77[12]];var ReportDialHistory=require(_0x9c77[3])[_0x9c77[11]][_0x9c77[13]];var ReportMemberHistory=require(_0x9c77[3])[_0x9c77[11]][_0x9c77[14]];var ReportQueueHistory=require(_0x9c77[3])[_0x9c77[11]][_0x9c77[15]];var ReportIntegrationHistory=require(_0x9c77[3])[_0x9c77[11]][_0x9c77[16]];var ReportMailSessionHistory=require(_0x9c77[3])[_0x9c77[11]][_0x9c77[17]];function ReportAgentInReportAgentHistory(){ReportAgent[_0x9c77[34]]({where:{createdAt:{$lte:moment()[_0x9c77[33]](_0x9c77[32])},reason:{$ne:null}},raw:true})[_0x9c77[28]](function(_0x9e8fx12){console[_0x9c77[23]](_0x9c77[21]+_0x9e8fx12[_0x9c77[22]]);_0x9e8fx12[_0x9c77[31]](function(_0x9e8fx13,_0x9e8fx14){ReportAgentHistory[_0x9c77[30]](_0x9e8fx13)[_0x9c77[28]](function(){console[_0x9c77[23]](_0x9c77[24]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[26]);ReportAgent[_0x9c77[29]]({where:{id:_0x9e8fx13[_0x9c77[25]]},individualHooks:true})[_0x9c77[28]](function(_0x9e8fx15){console[_0x9c77[23]](_0x9c77[24]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[27])})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[18]+_0x9e8fx11)});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[18]+_0x9e8fx11)})});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[19]](_0x9c77[18]+_0x9e8fx11)})}function ReportCallInReportCallHistory(){ReportCall[_0x9c77[34]]({where:{createdAt:{$lte:moment()[_0x9c77[33]](_0x9c77[32])}},raw:true})[_0x9c77[28]](function(_0x9e8fx12){_0x9e8fx12[_0x9c77[31]](function(_0x9e8fx13,_0x9e8fx14){console[_0x9c77[23]](_0x9c77[36]+_0x9e8fx12[_0x9c77[22]]);ReportCallHistory[_0x9c77[30]](_0x9e8fx13)[_0x9c77[28]](function(){console[_0x9c77[23]](_0x9c77[37]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[26]);ReportCall[_0x9c77[29]]({where:{id:_0x9e8fx13[_0x9c77[25]]},individualHooks:true})[_0x9c77[28]](function(_0x9e8fx15){console[_0x9c77[23]](_0x9c77[38]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[27])})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[35]+_0x9e8fx11)});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[35]+_0x9e8fx11)});})})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[19]](_0x9c77[35]+_0x9e8fx11)})}function ReportDialInReportDialHistory(){ReportDial[_0x9c77[34]]({where:{createdAt:{$lte:moment()[_0x9c77[33]](_0x9c77[32])},dialstatus:{$ne:null}},raw:true})[_0x9c77[28]](function(_0x9e8fx12){console[_0x9c77[23]](_0x9c77[40]+_0x9e8fx12[_0x9c77[22]]);_0x9e8fx12[_0x9c77[31]](function(_0x9e8fx13,_0x9e8fx14){ReportDialHistory[_0x9c77[30]](_0x9e8fx13)[_0x9c77[28]](function(){console[_0x9c77[23]](_0x9c77[41]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[26]);ReportDial[_0x9c77[29]]({where:{id:_0x9e8fx13[_0x9c77[25]]},individualHooks:true})[_0x9c77[28]](function(_0x9e8fx15){console[_0x9c77[23]](_0x9c77[41]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[27])})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[39]+_0x9e8fx11)});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[39]+_0x9e8fx11)})});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[19]](_0x9c77[39]+_0x9e8fx11)})}function ReportMemberInReportMemberHistory(){ReportMember[_0x9c77[34]]({where:{createdAt:{$lte:moment()[_0x9c77[33]](_0x9c77[32])},exitdate:{$ne:null}},raw:true})[_0x9c77[28]](function(_0x9e8fx12){console[_0x9c77[23]](_0x9c77[43]+_0x9e8fx12[_0x9c77[22]]);_0x9e8fx12[_0x9c77[31]](function(_0x9e8fx13,_0x9e8fx14){ReportMemberHistory[_0x9c77[30]](_0x9e8fx13)[_0x9c77[28]](function(){console[_0x9c77[23]](_0x9c77[44]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[26]);ReportMember[_0x9c77[29]]({where:{id:_0x9e8fx13[_0x9c77[25]]},individualHooks:true})[_0x9c77[28]](function(_0x9e8fx15){console[_0x9c77[23]](_0x9c77[44]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[27])})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[42]+_0x9e8fx11)});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[42]+_0x9e8fx11)})});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[19]](_0x9c77[42]+_0x9e8fx11)})}function ReportQueueInReportQueueHistory(){ReportQueue[_0x9c77[34]]({where:{createdAt:{$lte:moment()[_0x9c77[33]](_0x9c77[32])},queuecallerleaveAt:{$ne:null}},raw:true})[_0x9c77[28]](function(_0x9e8fx12){console[_0x9c77[23]](_0x9c77[46]+_0x9e8fx12[_0x9c77[22]]);_0x9e8fx12[_0x9c77[31]](function(_0x9e8fx13,_0x9e8fx14){ReportQueueHistory[_0x9c77[30]](_0x9e8fx13)[_0x9c77[28]](function(){console[_0x9c77[23]](_0x9c77[47]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[26]);ReportQueue[_0x9c77[29]]({where:{id:_0x9e8fx13[_0x9c77[25]]},individualHooks:true})[_0x9c77[28]](function(_0x9e8fx15){console[_0x9c77[23]](_0x9c77[47]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[27])})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[45]+_0x9e8fx11)});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[45]+_0x9e8fx11)})});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[19]](_0x9c77[45]+_0x9e8fx11)})}function ReportIntegrationInReportIntegrationHistory(){ReportIntegration[_0x9c77[34]]({where:{createdAt:{$lte:moment()[_0x9c77[33]](_0x9c77[32])}},raw:true})[_0x9c77[28]](function(_0x9e8fx12){_0x9e8fx12[_0x9c77[31]](function(_0x9e8fx13,_0x9e8fx14){console[_0x9c77[23]](_0x9c77[49]+_0x9e8fx12[_0x9c77[22]]);ReportIntegrationHistory[_0x9c77[30]](_0x9e8fx13)[_0x9c77[28]](function(){console[_0x9c77[23]](_0x9c77[37]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[26]);ReportIntegration[_0x9c77[29]]({where:{id:_0x9e8fx13[_0x9c77[25]]},individualHooks:true})[_0x9c77[28]](function(_0x9e8fx15){console[_0x9c77[23]](_0x9c77[50]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[27])})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[48]+_0x9e8fx11)});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[48]+_0x9e8fx11)});})})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[19]](_0x9c77[48]+_0x9e8fx11)})}function ReportMailSessionInReportMailSessionHistory(){ReportMailSession[_0x9c77[34]]({where:{createdAt:{$lte:moment()[_0x9c77[33]](_0x9c77[32])},mailleaveAt:{$ne:null}},raw:true})[_0x9c77[28]](function(_0x9e8fx12){console[_0x9c77[23]](_0x9c77[52]+_0x9e8fx12[_0x9c77[22]]);_0x9e8fx12[_0x9c77[31]](function(_0x9e8fx13,_0x9e8fx14){ReportMailSessionHistory[_0x9c77[30]](_0x9e8fx13)[_0x9c77[28]](function(){console[_0x9c77[23]](_0x9c77[53]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[26]);ReportMailSession[_0x9c77[29]]({where:{id:_0x9e8fx13[_0x9c77[25]]},individualHooks:true})[_0x9c77[28]](function(_0x9e8fx15){console[_0x9c77[23]](_0x9c77[53]+_0x9e8fx13[_0x9c77[25]]+_0x9c77[27])})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[51]+_0x9e8fx11)});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[23]](_0x9c77[51]+_0x9e8fx11)})});})[_0x9c77[20]](function(_0x9e8fx11){console[_0x9c77[19]](_0x9c77[51]+_0x9e8fx11)})}module[_0x9c77[54]]=function(_0x9e8fx1c){var _0x9e8fx1d= new _0x9e8fx1c({cronTime:_0x9c77[55],onTick:function(){ new ReportAgentInReportAgentHistory(); new ReportCallInReportCallHistory(); new ReportDialInReportDialHistory(); new ReportMemberInReportMemberHistory(); new ReportQueueInReportQueueHistory(); new ReportIntegrationInReportIntegrationHistory(); new ReportMailSessionInReportMailSessionHistory();}});_0x9e8fx1d[_0x9c77[56]]();}; \ No newline at end of file diff --git a/server/config/imap/imap.js b/server/config/imap/imap.js index a894bad..b5654ed 100644 --- a/server/config/imap/imap.js +++ b/server/config/imap/imap.js @@ -1,551 +1 @@ -'use strict'; - -var _ = require('lodash'); -var path = require('path'); -var config = require('../environment'); -var ImapListener = require("mail-listener2"); -var MailServerIn = require('../../models').MailServerIn; -var MailMessage = require('../../models').MailMessage; -var MailRoom = require('../../models').MailRoom; -var Contact = require('../../models').Contact; -var ContactEmail = require('../../models').ContactEmail; -var sequelize = require('../../models').sequelize; - -// Public -module.exports = { - create: function (doc) { - - var imap; - - function onUpdate(doc) { - if (!doc.changed('state') && !doc.changed('source') && doc.username === imap.imap._config.user) { - console.log("MAIL - Account " + doc.username + " IMAP UPDATED"); - imap.stop(); - onSave(doc); - } - } - - function onRemove(doc) { - if (doc.username === imap.imap._config.user) { - console.log("MAIL - Account " + doc.username + " IMAP DESTROY"); - imap.stop(); - imap = null; - } - } - - function onSave(doc) { - - if (imap) { - imap.stop(doc); - imap = null; - } - - imap = new ImapListener({ - username: doc.username, - password: doc.password, - host: doc.host, - port: doc.port, - tls: doc.ssl, - tlsOptions: { - rejectUnauthorized: false - }, - mailbox: doc.mailbox, // mailbox to monitor - searchFilter: [doc.filter], // the search filter being used after an IDLE notification has been retrieved - markSeen: true, // all fetched email willbe marked as seen and not fetched next time - fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,, - mailParserOptions: { - streamAttachments: false - }, // options to be passed to mailParser lib. - attachments: true, // download attachments as they are encountered to the project directory - attachmentOptions: { - directory: path.join(config.root, 'server', 'files', 'attachments', '/') - } // specify a download directory for attachments - }); - - imap.start(); - - imap.on("server:connected", function () { - console.log("MAIL - Account " + doc.username + " IMAP CONNECTED"); - // SETUP CONNECTED STATUS - return MailServerIn - .findById(doc.id) - .then(function (msi) { - return msi - .update({ - state: 'CONNECTED' - }); - }) - .catch(function (err) { - console.error(err); - }); - }); - - imap.on("server:disconnected", function () { - console.log("MAIL - Account " + doc.MailAccountId + " IMAP DISCONNECTED"); - MailServerIn - .findById(doc.id) - .then(function (msi) { - msi - .updateAttributes({ - state: 'DISCONNECTED' - }); - }) - .catch(function (err) { - console.error(err); - }); - }); - - imap.on("error", function (err) { - console.log("MAIL - Account " + doc.MailAccountId + " IMAP ERROR", err); - MailServerIn - .findById(doc.id) - .then(function (msi) { - msi - .updateAttributes({ - state: 'ERROR', - source: err.source - }); - }) - .catch(function (err) { - console.error(err); - }); - }); - - imap.on("mail", function (msg, seqno, attributes) { - var _mRoom; - var _mMessage; - var _mFrom, _mTo, _mCc, _mBcc; - - function createMailMessage(mailRoom) { - _mRoom = mailRoom; - - return MailMessage - .create({ - messageId: msg.messageId, - subject: msg.subject, - from: _.pluck(msg.from, 'address').join(';'), - to: msg.to ? _.pluck(msg.to, 'address').join(';') : null, - cc: msg.cc ? _.pluck(msg.cc, 'address').join(';') : null, - bcc: msg.cc ? _.pluck(msg.bcc, 'address').join(';') : null, - status: 'RECEIVED', - html: msg.html || null, - text: msg.text || null, - MailAttachments: msg.attachments || [], - MailRoomId: mailRoom.id, - }); - } - - function createFrom(mailMessage) { - _mMessage = mailMessage; - - return ContactEmail - .findOrCreate({ - where: { - email: _mMessage.from - }, - defaults: { - email: _mMessage.from - } - }); - } - - function createTo(mFrom, created) { - var promises = []; - var tos = _mMessage.to ? _.pluck(msg.to, 'address') : []; - _mFrom = mFrom; - - tos.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - } - })); - }); - - return promises; - } - - function createCc(mTo) { - var promises = []; - var ccs = _mMessage.cc ? _.pluck(msg.cc, 'address') : []; - _mTo = _.map(mTo, function (elm) { - return elm[0]; - }); - - ccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - } - })); - }); - - return promises; - } - - function createBcc(mCc) { - var promises = []; - var bccs = _mMessage.bcc ? _.pluck(msg.bcc, 'address') : []; - _mCc = _.map(mCc, function (elm) { - return elm[0]; - }); - - bccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - } - })); - }); - - return promises; - } - - function setBcc(mBcc) { - _mBcc = _.map(mBcc, function (elm) { - return elm[0]; - }); - - return; - } - - return sequelize.transaction(function (t) { - if (msg.inReplyTo) { - console.log('msg', msg); - return MailMessage - .findOne({ - where: { - messageId: msg.inReplyTo[0] - }, - include: [{ - all: true - }] - }) - .then(function (mailMessageParent) { - return mailMessageParent - .getMailRoom(); - }) - .then(function (mailRoom) { - _mRoom = mailRoom; - - return MailMessage - .create({ - messageId: msg.messageId, - subject: msg.subject, - from: _.pluck(msg.from, 'address').join(';'), - to: msg.to ? _.pluck(msg.to, 'address').join(';') : null, - cc: msg.cc ? _.pluck(msg.cc, 'address').join(';') : null, - bcc: msg.cc ? _.pluck(msg.bcc, 'address').join(';') : null, - status: 'RECEIVED', - html: msg.html || null, - text: msg.text || null, - MailAttachments: msg.attachments || [], - MailRoomId: mailRoom.id, - }, { - include: [{ - all: true - }], - transaction: t - }); - }) - .then(function (mailMessage) { - _mMessage = mailMessage; - - return ContactEmail - .findOrCreate({ - where: { - email: _mMessage.from - }, - defaults: { - email: _mMessage.from - }, - transaction: t - }); - }) - .spread(function (mFrom, created) { - var promises = []; - var tos = _mMessage.to ? _.pluck(msg.to, 'address') : []; - _mFrom = mFrom; - - tos.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: t - })); - }); - - return promises; - }) - .all() - .then(function (mTo) { - var promises = []; - var ccs = _mMessage.cc ? _.pluck(msg.cc, 'address') : []; - _mTo = _.map(mTo, function (elm) { - return elm[0]; - }); - - ccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: t - })); - }); - - return promises; - }) - .all() - .then(function (mCc) { - var promises = []; - var bccs = _mMessage.bcc ? _.pluck(msg.bcc, 'address') : []; - _mCc = _.map(mCc, function (elm) { - return elm[0]; - }); - - bccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: t - })); - }); - - return promises; - }) - .all() - .then(function (mBcc) { - _mBcc = _.map(mBcc, function (elm) { - return elm[0]; - }); - - return; - }) - .then(function () { - return _mMessage - .setFrom(_mFrom, { - transaction: t - }); - }) - .then(function () { - return _mMessage - .setTo(_mTo, { - transaction: t - }); - }) - .then(function () { - return _mMessage - .setCc(_mCc, { - transaction: t - }); - }) - .then(function () { - return _mMessage - .setBcc(_mBcc, { - transaction: t - }); - }); - - } else { - return MailRoom - .create({ - roomId: msg.messageId, - subject: msg.subject, - from: _.pluck(msg.from, 'address').join(';'), - MailAccountId: doc.MailAccountId - }, { - transaction: t - }) - .then(function (mailRoom) { - _mRoom = mailRoom; - - return MailMessage - .create({ - messageId: msg.messageId, - subject: msg.subject, - from: _.pluck(msg.from, 'address').join(';'), - to: msg.to ? _.pluck(msg.to, 'address').join(';') : null, - cc: msg.cc ? _.pluck(msg.cc, 'address').join(';') : null, - bcc: msg.cc ? _.pluck(msg.bcc, 'address').join(';') : null, - status: 'RECEIVED', - html: msg.html || null, - text: msg.text || null, - MailAttachments: msg.attachments || [], - MailRoomId: mailRoom.id, - }, { - include: [{ - all: true - }], - transaction: t - }); - }) - .then(function (mailMessage) { - _mMessage = mailMessage; - - return ContactEmail - .findOrCreate({ - where: { - email: _mMessage.from - }, - defaults: { - email: _mMessage.from - }, - transaction: t - }); - }) - .spread(function (mFrom, created) { - var promises = []; - var tos = _mMessage.to ? _.pluck(msg.to, 'address') : []; - _mFrom = mFrom; - - tos.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: t - })); - }); - - return promises; - }) - .all() - .then(function (mTo) { - var promises = []; - var ccs = _mMessage.cc ? _.pluck(msg.cc, 'address') : []; - _mTo = _.map(mTo, function (elm) { - return elm[0]; - }); - - ccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCrredieate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: t - })); - }); - - return promises; - }) - .all() - .then(function (mCc) { - var promises = []; - var bccs = _mMessage.bcc ? _.pluck(msg.bcc, 'address') : []; - _mCc = _.map(mCc, function (elm) { - return elm[0]; - }); - - bccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: t - })); - }); - - return promises; - }) - .all() - .then(function (mBcc) { - _mBcc = _.map(mBcc, function (elm) { - return elm[0]; - }); - - return; - }) - .then(function () { - return _mMessage - .setFrom(_mFrom, { - transaction: t - }); - }) - .then(function () { - return _mMessage - .setTo(_mTo, { - transaction: t - }); - }) - .then(function () { - return _mMessage - .setCc(_mCc, { - transaction: t - }); - }) - .then(function () { - return _mMessage - .setBcc(_mBcc, { - transaction: t - }); - }); - } - }).then(function (result) { - // Transaction has been committed - // result is whatever the result of the promise chain returned to the transaction callback - console.log(result); - }).catch(function (err) { - // Transaction has been rolled back - // err is whatever rejected the promise chain returned to the transaction callback - console.error(err); - }); - }); - - imap.on("attachment", function (attachment) { - console.log(attachment.path); - }); - } - - onSave(doc); - - MailServerIn.afterCreate(function (doc) { - onSave(doc); - }); - // HANDLE ACCOUNT UPDATE/DELETE - MailServerIn.afterUpdate(function (doc) { - onUpdate(doc); - }); - MailServerIn.afterDestroy(function (doc) { - onRemove(doc); - }); - } -}; +var _0x1c39=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x70\x61\x74\x68","\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6D\x61\x69\x6C\x2D\x6C\x69\x73\x74\x65\x6E\x65\x72\x32","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x43\x6F\x6E\x74\x61\x63\x74","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x65\x78\x70\x6F\x72\x74\x73","\x73\x74\x61\x74\x65","\x63\x68\x61\x6E\x67\x65\x64","\x73\x6F\x75\x72\x63\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x75\x73\x65\x72","\x5F\x63\x6F\x6E\x66\x69\x67","\x69\x6D\x61\x70","\x4D\x41\x49\x4C\x20\x2D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20","\x20\x49\x4D\x41\x50\x20\x55\x50\x44\x41\x54\x45\x44","\x6C\x6F\x67","\x73\x74\x6F\x70","\x20\x49\x4D\x41\x50\x20\x44\x45\x53\x54\x52\x4F\x59","\x70\x61\x73\x73\x77\x6F\x72\x64","\x68\x6F\x73\x74","\x70\x6F\x72\x74","\x73\x73\x6C","\x6D\x61\x69\x6C\x62\x6F\x78","\x66\x69\x6C\x74\x65\x72","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x2F","\x6A\x6F\x69\x6E","\x73\x74\x61\x72\x74","\x73\x65\x72\x76\x65\x72\x3A\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64","\x20\x49\x4D\x41\x50\x20\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x75\x70\x64\x61\x74\x65","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x6F\x6E","\x73\x65\x72\x76\x65\x72\x3A\x64\x69\x73\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x20\x49\x4D\x41\x50\x20\x44\x49\x53\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x44\x49\x53\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x20\x49\x4D\x41\x50\x20\x45\x52\x52\x4F\x52","\x45\x52\x52\x4F\x52","\x6D\x61\x69\x6C","\x6D\x65\x73\x73\x61\x67\x65\x49\x64","\x73\x75\x62\x6A\x65\x63\x74","\x3B","\x66\x72\x6F\x6D","\x61\x64\x64\x72\x65\x73\x73","\x70\x6C\x75\x63\x6B","\x74\x6F","\x63\x63","\x62\x63\x63","\x52\x45\x43\x45\x49\x56\x45\x44","\x68\x74\x6D\x6C","\x74\x65\x78\x74","\x63\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x6D\x61\x70","\x69\x6E\x52\x65\x70\x6C\x79\x54\x6F","\x6D\x73\x67","\x73\x65\x74\x42\x63\x63","\x73\x65\x74\x43\x63","\x73\x65\x74\x54\x6F","\x73\x65\x74\x46\x72\x6F\x6D","\x61\x6C\x6C","\x73\x70\x72\x65\x61\x64","\x67\x65\x74\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x66\x69\x6E\x64\x4F\x6E\x65","\x66\x69\x6E\x64\x4F\x72\x43\x72\x72\x65\x64\x69\x65\x61\x74\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79"];_0x1c39[0];var _=require(_0x1c39[1]);var path=require(_0x1c39[2]);var config=require(_0x1c39[3]);var ImapListener=require(_0x1c39[4]);var MailServerIn=require(_0x1c39[6])[_0x1c39[5]];var MailMessage=require(_0x1c39[6])[_0x1c39[7]];var MailRoom=require(_0x1c39[6])[_0x1c39[8]];var Contact=require(_0x1c39[6])[_0x1c39[9]];var ContactEmail=require(_0x1c39[6])[_0x1c39[10]];var sequelize=require(_0x1c39[6])[_0x1c39[11]];module[_0x1c39[12]]={create:function(_0xebfaxb){var _0xebfaxc;function _0xebfaxd(_0xebfaxb){if(!_0xebfaxb[_0x1c39[14]](_0x1c39[13])&&!_0xebfaxb[_0x1c39[14]](_0x1c39[15])&&_0xebfaxb[_0x1c39[16]]===_0xebfaxc[_0x1c39[19]][_0x1c39[18]][_0x1c39[17]]){console[_0x1c39[22]](_0x1c39[20]+_0xebfaxb[_0x1c39[16]]+_0x1c39[21]);_0xebfaxc[_0x1c39[23]]();_0xebfaxf(_0xebfaxb);}}function _0xebfaxe(_0xebfaxb){if(_0xebfaxb[_0x1c39[16]]===_0xebfaxc[_0x1c39[19]][_0x1c39[18]][_0x1c39[17]]){console[_0x1c39[22]](_0x1c39[20]+_0xebfaxb[_0x1c39[16]]+_0x1c39[24]);_0xebfaxc[_0x1c39[23]]();_0xebfaxc=null;}}function _0xebfaxf(_0xebfaxb){if(_0xebfaxc){_0xebfaxc[_0x1c39[23]](_0xebfaxb);_0xebfaxc=null;};_0xebfaxc= new ImapListener({username:_0xebfaxb[_0x1c39[16]],password:_0xebfaxb[_0x1c39[25]],host:_0xebfaxb[_0x1c39[26]],port:_0xebfaxb[_0x1c39[27]],tls:_0xebfaxb[_0x1c39[28]],tlsOptions:{rejectUnauthorized:false},mailbox:_0xebfaxb[_0x1c39[29]],searchFilter:[_0xebfaxb[_0x1c39[30]]],markSeen:true,fetchUnreadOnStart:true,mailParserOptions:{streamAttachments:false},attachments:true,attachmentOptions:{directory:path[_0x1c39[36]](config[_0x1c39[31]],_0x1c39[32],_0x1c39[33],_0x1c39[34],_0x1c39[35])}});_0xebfaxc[_0x1c39[37]]();_0xebfaxc[_0x1c39[47]](_0x1c39[38],function(){console[_0x1c39[22]](_0x1c39[20]+_0xebfaxb[_0x1c39[16]]+_0x1c39[39]);return MailServerIn[_0x1c39[46]](_0xebfaxb[_0x1c39[45]])[_0x1c39[44]](function(_0xebfax11){return _0xebfax11[_0x1c39[43]]({state:_0x1c39[42]})})[_0x1c39[41]](function(_0xebfax10){console[_0x1c39[40]](_0xebfax10)});});_0xebfaxc[_0x1c39[47]](_0x1c39[48],function(){console[_0x1c39[22]](_0x1c39[20]+_0xebfaxb[_0x1c39[49]]+_0x1c39[50]);MailServerIn[_0x1c39[46]](_0xebfaxb[_0x1c39[45]])[_0x1c39[44]](function(_0xebfax11){_0xebfax11[_0x1c39[52]]({state:_0x1c39[51]})})[_0x1c39[41]](function(_0xebfax10){console[_0x1c39[40]](_0xebfax10)});});_0xebfaxc[_0x1c39[47]](_0x1c39[40],function(_0xebfax10){console[_0x1c39[22]](_0x1c39[20]+_0xebfaxb[_0x1c39[49]]+_0x1c39[53],_0xebfax10);MailServerIn[_0x1c39[46]](_0xebfaxb[_0x1c39[45]])[_0x1c39[44]](function(_0xebfax11){_0xebfax11[_0x1c39[52]]({state:_0x1c39[54],source:_0xebfax10[_0x1c39[15]]})})[_0x1c39[41]](function(_0xebfax10){console[_0x1c39[40]](_0xebfax10)});});_0xebfaxc[_0x1c39[47]](_0x1c39[55],function(_0xebfax12,_0xebfax13,_0xebfax14){var _0xebfax15;var _0xebfax16;var _0xebfax17,_0xebfax18,_0xebfax19,_0xebfax1a;function _0xebfax1b(_0xebfax1c){_0xebfax15=_0xebfax1c;return MailMessage[_0x1c39[68]]({messageId:_0xebfax12[_0x1c39[56]],subject:_0xebfax12[_0x1c39[57]],from:_[_0x1c39[61]](_0xebfax12[_0x1c39[59]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]),to:_0xebfax12[_0x1c39[62]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[62]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,cc:_0xebfax12[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[63]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,bcc:_0xebfax12[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[64]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,status:_0x1c39[65],html:_0xebfax12[_0x1c39[66]]||null,text:_0xebfax12[_0x1c39[67]]||null,MailAttachments:_0xebfax12[_0x1c39[34]]||[],MailRoomId:_0xebfax1c[_0x1c39[45]]});}function _0xebfax1d(_0xebfax1e){_0xebfax16=_0xebfax1e;return ContactEmail[_0x1c39[69]]({where:{email:_0xebfax16[_0x1c39[59]]},defaults:{email:_0xebfax16[_0x1c39[59]]}});}function _0xebfax1f(_0xebfax20,_0xebfax21){var _0xebfax22=[];var _0xebfax23=_0xebfax16[_0x1c39[62]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[62]],_0x1c39[60]):[];_0xebfax17=_0xebfax20;_0xebfax23[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24}}))});return _0xebfax22;}function _0xebfax25(_0xebfax26){var _0xebfax22=[];var _0xebfax27=_0xebfax16[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[63]],_0x1c39[60]):[];_0xebfax18=_[_0x1c39[72]](_0xebfax26,function(_0xebfax28){return _0xebfax28[0]});_0xebfax27[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24}}))});return _0xebfax22;}function _0xebfax29(_0xebfax2a){var _0xebfax22=[];var _0xebfax2b=_0xebfax16[_0x1c39[64]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[64]],_0x1c39[60]):[];_0xebfax19=_[_0x1c39[72]](_0xebfax2a,function(_0xebfax28){return _0xebfax28[0]});_0xebfax2b[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24}}))});return _0xebfax22;}function _0xebfax2c(_0xebfax2d){_0xebfax1a=_[_0x1c39[72]](_0xebfax2d,function(_0xebfax28){return _0xebfax28[0]});return ;}return sequelize[_0x1c39[84]](function(_0xebfax2f){if(_0xebfax12[_0x1c39[73]]){console[_0x1c39[22]](_0x1c39[74],_0xebfax12);return MailMessage[_0x1c39[82]]({where:{messageId:_0xebfax12[_0x1c39[73]][0]},include:[{all:true}]})[_0x1c39[44]](function(_0xebfax30){return _0xebfax30[_0x1c39[81]]()})[_0x1c39[44]](function(_0xebfax1c){_0xebfax15=_0xebfax1c;return MailMessage[_0x1c39[68]]({messageId:_0xebfax12[_0x1c39[56]],subject:_0xebfax12[_0x1c39[57]],from:_[_0x1c39[61]](_0xebfax12[_0x1c39[59]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]),to:_0xebfax12[_0x1c39[62]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[62]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,cc:_0xebfax12[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[63]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,bcc:_0xebfax12[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[64]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,status:_0x1c39[65],html:_0xebfax12[_0x1c39[66]]||null,text:_0xebfax12[_0x1c39[67]]||null,MailAttachments:_0xebfax12[_0x1c39[34]]||[],MailRoomId:_0xebfax1c[_0x1c39[45]]},{include:[{all:true}],transaction:_0xebfax2f});})[_0x1c39[44]](function(_0xebfax1e){_0xebfax16=_0xebfax1e;return ContactEmail[_0x1c39[69]]({where:{email:_0xebfax16[_0x1c39[59]]},defaults:{email:_0xebfax16[_0x1c39[59]]},transaction:_0xebfax2f});})[_0x1c39[80]](function(_0xebfax20,_0xebfax21){var _0xebfax22=[];var _0xebfax23=_0xebfax16[_0x1c39[62]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[62]],_0x1c39[60]):[];_0xebfax17=_0xebfax20;_0xebfax23[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24},transaction:_0xebfax2f}))});return _0xebfax22;})[_0x1c39[79]]()[_0x1c39[44]](function(_0xebfax26){var _0xebfax22=[];var _0xebfax27=_0xebfax16[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[63]],_0x1c39[60]):[];_0xebfax18=_[_0x1c39[72]](_0xebfax26,function(_0xebfax28){return _0xebfax28[0]});_0xebfax27[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24},transaction:_0xebfax2f}))});return _0xebfax22;})[_0x1c39[79]]()[_0x1c39[44]](function(_0xebfax2a){var _0xebfax22=[];var _0xebfax2b=_0xebfax16[_0x1c39[64]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[64]],_0x1c39[60]):[];_0xebfax19=_[_0x1c39[72]](_0xebfax2a,function(_0xebfax28){return _0xebfax28[0]});_0xebfax2b[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24},transaction:_0xebfax2f}))});return _0xebfax22;})[_0x1c39[79]]()[_0x1c39[44]](function(_0xebfax2d){_0xebfax1a=_[_0x1c39[72]](_0xebfax2d,function(_0xebfax28){return _0xebfax28[0]});return ;})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[78]](_0xebfax17,{transaction:_0xebfax2f})})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[77]](_0xebfax18,{transaction:_0xebfax2f})})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[76]](_0xebfax19,{transaction:_0xebfax2f})})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[75]](_0xebfax1a,{transaction:_0xebfax2f})});}else {return MailRoom[_0x1c39[68]]({roomId:_0xebfax12[_0x1c39[56]],subject:_0xebfax12[_0x1c39[57]],from:_[_0x1c39[61]](_0xebfax12[_0x1c39[59]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]),MailAccountId:_0xebfaxb[_0x1c39[49]]},{transaction:_0xebfax2f})[_0x1c39[44]](function(_0xebfax1c){_0xebfax15=_0xebfax1c;return MailMessage[_0x1c39[68]]({messageId:_0xebfax12[_0x1c39[56]],subject:_0xebfax12[_0x1c39[57]],from:_[_0x1c39[61]](_0xebfax12[_0x1c39[59]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]),to:_0xebfax12[_0x1c39[62]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[62]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,cc:_0xebfax12[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[63]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,bcc:_0xebfax12[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[64]],_0x1c39[60])[_0x1c39[36]](_0x1c39[58]):null,status:_0x1c39[65],html:_0xebfax12[_0x1c39[66]]||null,text:_0xebfax12[_0x1c39[67]]||null,MailAttachments:_0xebfax12[_0x1c39[34]]||[],MailRoomId:_0xebfax1c[_0x1c39[45]]},{include:[{all:true}],transaction:_0xebfax2f});})[_0x1c39[44]](function(_0xebfax1e){_0xebfax16=_0xebfax1e;return ContactEmail[_0x1c39[69]]({where:{email:_0xebfax16[_0x1c39[59]]},defaults:{email:_0xebfax16[_0x1c39[59]]},transaction:_0xebfax2f});})[_0x1c39[80]](function(_0xebfax20,_0xebfax21){var _0xebfax22=[];var _0xebfax23=_0xebfax16[_0x1c39[62]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[62]],_0x1c39[60]):[];_0xebfax17=_0xebfax20;_0xebfax23[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24},transaction:_0xebfax2f}))});return _0xebfax22;})[_0x1c39[79]]()[_0x1c39[44]](function(_0xebfax26){var _0xebfax22=[];var _0xebfax27=_0xebfax16[_0x1c39[63]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[63]],_0x1c39[60]):[];_0xebfax18=_[_0x1c39[72]](_0xebfax26,function(_0xebfax28){return _0xebfax28[0]});_0xebfax27[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[83]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24},transaction:_0xebfax2f}))});return _0xebfax22;})[_0x1c39[79]]()[_0x1c39[44]](function(_0xebfax2a){var _0xebfax22=[];var _0xebfax2b=_0xebfax16[_0x1c39[64]]?_[_0x1c39[61]](_0xebfax12[_0x1c39[64]],_0x1c39[60]):[];_0xebfax19=_[_0x1c39[72]](_0xebfax2a,function(_0xebfax28){return _0xebfax28[0]});_0xebfax2b[_0x1c39[71]](function(_0xebfax24){_0xebfax22[_0x1c39[70]](ContactEmail[_0x1c39[69]]({where:{email:_0xebfax24},defaults:{email:_0xebfax24},transaction:_0xebfax2f}))});return _0xebfax22;})[_0x1c39[79]]()[_0x1c39[44]](function(_0xebfax2d){_0xebfax1a=_[_0x1c39[72]](_0xebfax2d,function(_0xebfax28){return _0xebfax28[0]});return ;})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[78]](_0xebfax17,{transaction:_0xebfax2f})})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[77]](_0xebfax18,{transaction:_0xebfax2f})})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[76]](_0xebfax19,{transaction:_0xebfax2f})})[_0x1c39[44]](function(){return _0xebfax16[_0x1c39[75]](_0xebfax1a,{transaction:_0xebfax2f})})}})[_0x1c39[44]](function(_0xebfax2e){console[_0x1c39[22]](_0xebfax2e)})[_0x1c39[41]](function(_0xebfax10){console[_0x1c39[40]](_0xebfax10)});});_0xebfaxc[_0x1c39[47]](_0x1c39[85],function(_0xebfax31){console[_0x1c39[22]](_0xebfax31[_0x1c39[2]])});}_0xebfaxf(_0xebfaxb);MailServerIn[_0x1c39[86]](function(_0xebfaxb){_0xebfaxf(_0xebfaxb)});MailServerIn[_0x1c39[87]](function(_0xebfaxb){_0xebfaxd(_0xebfaxb)});MailServerIn[_0x1c39[88]](function(_0xebfaxb){_0xebfaxe(_0xebfaxb)});}}; \ No newline at end of file diff --git a/server/config/imap/index.js b/server/config/imap/index.js index 93d8098..6168ce3 100644 --- a/server/config/imap/index.js +++ b/server/config/imap/index.js @@ -1,30 +1 @@ -'use strict'; - -var MailAccount = require('../../models').MailAccount; -var MailServerIn = require('../../models').MailServerIn; - -module.exports = { - init: function () { - MailServerIn.afterCreate(function (doc) { - require('./imap').create(doc); - }); - - // Get all Mail Accounts - MailAccount - .findAll({ - include: [{ - all: true - }] - }) - .then(function (mailAccounts) { - for (var i = 0; i < mailAccounts.length; i++) { - if (mailAccounts[i].MailServerIn) { - require('./imap').create(mailAccounts[i].MailServerIn); - } - } - }) - .catch(function (err) { - console.error(err); - }); - } -}; +var _0xab32=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x65\x78\x70\x6F\x72\x74\x73","\x63\x72\x65\x61\x74\x65","\x2E\x2F\x69\x6D\x61\x70","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x6C\x65\x6E\x67\x74\x68","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C"];_0xab32[0];var MailAccount=require(_0xab32[2])[_0xab32[1]];var MailServerIn=require(_0xab32[2])[_0xab32[3]];module[_0xab32[4]]={init:function(){MailServerIn[_0xab32[7]](function(_0x990cx3){require(_0xab32[6])[_0xab32[5]](_0x990cx3)});MailAccount[_0xab32[12]]({include:[{all:true}]})[_0xab32[11]](function(_0x990cx5){for(var _0x990cx6=0;_0x990cx6<_0x990cx5[_0xab32[10]];_0x990cx6++){if(_0x990cx5[_0x990cx6][_0xab32[3]]){require(_0xab32[6])[_0xab32[5]](_0x990cx5[_0x990cx6].MailServerIn)}}})[_0xab32[9]](function(_0x990cx4){console[_0xab32[8]](_0x990cx4)});}}; \ No newline at end of file diff --git a/server/config/integration.js b/server/config/integration.js index 8b87bc5..dfc7a52 100644 --- a/server/config/integration.js +++ b/server/config/integration.js @@ -1,24 +1 @@ -'use strict'; - -var path = require('path'); -var fs = require('fs'); - -var Integration = require('../models').Integration; - -module.exports = function(io, ami) { - - Integration - .findAll() - .then(function(integrations) { - integrations.forEach(function(integration) { - var info = path.parse(integration.path); - var file = path.join(info.dir, info.name, integration.main); - if (fs.existsSync(file)) { - require(file)(io, ami); - } - }); - }) - .catch(function(err) { - console.error(err); - }); -}; +var _0x8ae1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x70\x61\x74\x68","\x66\x73","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x65\x78\x70\x6F\x72\x74\x73","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x70\x61\x72\x73\x65","\x64\x69\x72","\x6E\x61\x6D\x65","\x6D\x61\x69\x6E","\x6A\x6F\x69\x6E","\x65\x78\x69\x73\x74\x73\x53\x79\x6E\x63","\x66\x6F\x72\x45\x61\x63\x68","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C"];_0x8ae1[0];var path=require(_0x8ae1[1]);var fs=require(_0x8ae1[2]);var Integration=require(_0x8ae1[4])[_0x8ae1[3]];module[_0x8ae1[5]]=function(_0x459ax4,_0x459ax5){Integration[_0x8ae1[16]]()[_0x8ae1[15]](function(_0x459ax7){_0x459ax7[_0x8ae1[14]](function(_0x459ax8){var _0x459ax9=path[_0x8ae1[8]](_0x459ax8[_0x8ae1[1]]);var _0x459axa=path[_0x8ae1[12]](_0x459ax9[_0x8ae1[9]],_0x459ax9[_0x8ae1[10]],_0x459ax8[_0x8ae1[11]]);if(fs[_0x8ae1[13]](_0x459axa)){require(_0x459axa)(_0x459ax4,_0x459ax5)};})})[_0x8ae1[7]](function(_0x459ax6){console[_0x8ae1[6]](_0x459ax6)})}; \ No newline at end of file diff --git a/server/config/kue.chat.js b/server/config/kue.chat.js index 7c62351..efa4b31 100644 --- a/server/config/kue.chat.js +++ b/server/config/kue.chat.js @@ -1,560 +1 @@ - 'use strict'; - - var _ = require('lodash'); - var moment = require('moment'); - var md5 = require('md5'); - - var ChatApplication = require('../models').ChatApplication; - var ChatWebsite = require('../models').ChatWebsite; - var ChatVisitor = require('../models').ChatVisitor; - var ChatMessage = require('../models').ChatMessage; - var ChatQueue = require('../models').ChatQueue; - var ChatRoom = require('../models').ChatRoom; - var Interval = require('../models').Interval; - - var ReportChatSession = require('../models').ReportChatSession; - var ReportChat = require('../models').ReportChat; - - var User = require('../models').User; - - var timeouts = {}; - - module.exports = function (kue) { - var kueChat = kue.createQueue(); - // KUE PROCESS - kueChat.process('chat', 20, function (job, done) { - onProcess(job, done); - }); - // REPORT MAIL HOOKS - ReportChat.afterUpdate(function (doc) { - var _chatRoom; - - if (doc.changed('agentconnectedAt')) { - if (timeouts[doc.uniqueid]) { - clearTimeout(timeouts[doc.uniqueid].timeout); - timeouts[doc.uniqueid].done(); - delete timeouts[doc.uniqueid]; - } - - ChatRoom - .findById(doc.chatroomid) - .then(function (chatRoom) { - _chatRoom = chatRoom; - - chatRoom - .addUser(doc.agentid, { - individualHooks: true - }); - }) - .then(function () { - _chatRoom - .update({ - status: 'open' - }); - }) - .catch(function (err) { - console.error(err); - }); - - ReportChat - .update({ - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss"), - reason: "answered_elsewhere", - lastevent: "answered_elsewhere" - }, { - where: { - uniqueid: doc.uniqueid, - reason: null - }, - individualHooks: true - }) - .catch(function (err) { - console.error(err); - }); - - ReportChatSession - .update({ - chatleaveAt: moment().format("YYYY-MM-DD HH:mm:ss"), - agentid: doc.agentid, - fullname: doc.fullname, - membername: doc.membername, - chatqueuename: doc.chatqueuename - }, { - where: { - uniqueid: doc.uniqueid, - }, - individualHooks: true - }) - .catch(function (err) { - console.error(err); - }); - } - }); - // CHAT VISITOR HOOKS - ChatVisitor.afterCreate(function (doc) { - onSave(kueChat, doc); - }); - }; - - function onSave(kue, doc, cb) { - // CREATE KUE PROCESS - kue - .create('chat', doc.dataValues) - .save(); - } - - function onProcess(job, done) { - ChatWebsite - .findById(job.data.ChatWebsiteId, { - include: [{ - model: ChatApplication, - include: [{ - model: ChatQueue, - include: [{ - model: User - }] - }, { - model: User - }, { - model: Interval, - include: [{ - all: true - }] - }] - }] - }) - .then(function (ChatWebsite) { - if (!ChatWebsite) { - done(new Error('No Available ChatApplications..')); - return; - } - - if (!ChatWebsite.ChatApplications.length) { - done(new Error('DialPlan ended..')); - return; - } - - job.data.ChatVisitorId = job.data.id; - var session = _.merge(job.data, ChatWebsite.dataValues); - - // START CREATE/ASSIGN CHAT ROOM - ChatRoom - .create({ - type: 'external', - ChatVisitorId: session.ChatVisitorId, - ChatWebsiteId: session.id - }, { - include: [{ - all: true - }] - }) - .then(function (chatRoom) { - - onReportSession({ - uniqueid: session.ChatVisitorId, - chatroomid: chatRoom.id, - visitorname: session.fullname, - visitoremail: session.email, - websitename: session.name, - websiteid: session.id, - websiteaddress: session.address, - chatjoinAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - session.ChatApplications = _.sortBy(session.ChatApplications, 'priority'); - onInvite(session, 0, 0, 0, 0, chatRoom, done); - }) - .catch(function (err) { - console.error(err); - }); - // END CREATE/ASSIGN CHAT ROOM - }) - .catch(function (err) { - console.error(err); - }); - } - - function onInvite(data, i, j, holdtime, count, chatRoom, done) { - console.log('invite', 'i', i, 'j', j, 'holdtime', holdtime); - var timeout = 0; - var aTimeout; - - if (i === data.ChatApplications.length) { - console.error('DialPlan ended..'); - - onReportSession({ - uniqueid: data.ChatVisitorId, - mailunmanagedAt: moment().format("YYYY-MM-DD HH:mm:ss"), - mailleaveAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - done(new Error('DialPlan ended..')); - return; - } - - if (data.ChatApplications[i].ChatQueue) { - // QUEUE APPLICATION - - // ONLINE AGENTS COUNTER - var online = _.countBy(data.ChatApplications[i].ChatQueue.Users, { - online: true - }).true; - - if (online && onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) { - // AT LEAST ONE AVAILABLE AGENT - if (j === data.ChatApplications[i].ChatQueue.Users.length) { - if (data.ChatApplications[i].timeout > holdtime) { - onInvite(data, i, 0, holdtime, count, chatRoom, done); - return; - } else { - onInvite(data, ++i, 0, 0, count, chatRoom, done); - return; - } - } - - switch (data.ChatApplications[i].ChatQueue.strategy) { - case 'rrmemory': - if (data.ChatApplications[i].ChatQueue.Users[j].online && - onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) { - // AVAILABLE - timeout = (((data.ChatApplications[i].timeout - holdtime) > data.ChatApplications[i].ChatQueue.timeout) ? - data.ChatApplications[i].ChatQueue.timeout : (data.ChatApplications[i].timeout - holdtime)); - - onReport({ - uniqueid: data.ChatVisitorId, - chatroomid: chatRoom.id, - visitorname: data.fullname, - visitoremail: data.email, - websitename: data.name, - websiteid: data.id, - websiteaddress: data.address, - sorting: count, - timeslot: timeout, - application: data.ChatApplications[i].app, - fullname: data.ChatApplications[i].ChatQueue.Users[j].fullname, - membername: data.ChatApplications[i].ChatQueue.Users[j].name, - agentid: data.ChatApplications[i].ChatQueue.Users[j].id, - chatqueuename: data.ChatApplications[i].ChatQueue.name, - lastevent: 'called', - holdtime: holdtime, - agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - console.log('queue', data.ChatApplications[i].ChatQueue.name, 'agent', data.ChatApplications[i].ChatQueue.Users[j].name, 'timeout', timeout, 'holdtime', holdtime); - aTimeout = setTimeout(function () { - onReportUpdate({ - uniqueid: data.ChatVisitorId, - count: count, - reason: 'timeout', - lastevent: 'timeout', - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - holdtime += timeout; - onInvite(data, i, ++j, holdtime, ++count, chatRoom, done); - return; - }, timeout * 1000); - - if (!timeouts[data.ChatVisitorId]) { - timeouts[data.ChatVisitorId] = {}; - } - - timeouts[data.ChatVisitorId].timeout = aTimeout; - timeouts[data.ChatVisitorId].done = done; - - } else { - onInvite(data, i, ++j, holdtime, count, chatRoom, done); - return; - } - - break; - case 'beepall': - - timeout = (((data.ChatApplications[i].timeout - holdtime) > data.ChatApplications[i].ChatQueue.timeout) ? - data.ChatApplications[i].ChatQueue.timeout : (data.ChatApplications[i].timeout - holdtime)); - - var users = []; - data.ChatApplications[i].ChatQueue.Users.forEach(function (user) { - if (user.online) { - users.push({ - uniqueid: data.ChatVisitorId, - chatroomid: chatRoom.id, - sorting: count, - subject: data.subject, - timeslot: timeout, - from: data.from, - attachment: data.attachment, - accountname: data.name, - accountaddress: data.address, - application: data.ChatApplications[i].app, - fullname: user.fullname, - membername: user.name, - agentid: user.id, - chatqueuename: data.ChatApplications[i].ChatQueue.name, - lastevent: 'called', - holdtime: holdtime, - agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss"), - - visitorname: data.fullname, - visitoremail: data.email, - websitename: data.name, - websiteid: data.id, - websiteaddress: data.address, - }); - } - }); - - if (users.length && onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) { - onReport(users, true); - aTimeout = setTimeout(function () { - console.log('count', count); - onReportUpdate({ - uniqueid: data.ChatVisitorId, - count: count, - reason: 'timeout', - lastevent: 'timeout', - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - holdtime += timeout; - j += data.ChatApplications[i].ChatQueue.Users.length; - onInvite(data, i, j, holdtime, ++count, chatRoom, done); - return; - }, timeout * 1000); - - if (!timeouts[data.ChatVisitorId]) { - timeouts[data.ChatVisitorId] = {}; - } - - timeouts[data.ChatVisitorId].timeout = aTimeout; - timeouts[data.ChatVisitorId].done = done; - - } else { - console.log('queue', data.ChatApplications[i].ChatQueue.name, 'timeout', timeout, 'holdtime', holdtime); - - onInvite(data, ++i, 0, 0, count, chatRoom, done); - return; - } - - break; - default: - console.error('Unknown strategy'); - } - } else { - onInvite(data, ++i, 0, 0, count, chatRoom, done); - return; - } - } else { - // AGENT APPLICATION - timeout = data.ChatApplications[i].timeout; - if (data.ChatApplications[i].User.online && - onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) { - onReport({ - uniqueid: data.ChatVisitorId, - chatroomid: chatRoom.id, - sorting: count, - subject: data.subject, - timeslot: timeout, - from: data.from, - attachment: data.attachment, - accountname: data.name, - accountaddress: data.address, - application: data.ChatApplications[i].app, - fullname: data.ChatApplications[i].User.fullname, - membername: data.ChatApplications[i].User.name, - agentid: data.ChatApplications[i].User.id, - lastevent: 'called', - holdtime: holdtime, - agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss"), - - visitorname: data.fullname, - visitoremail: data.email, - websitename: data.name, - websiteid: data.id, - websiteaddress: data.address - }); - - console.log('agent', data.ChatApplications[i].User.name, 'timeout', timeout, 'holdtime', holdtime); - - aTimeout = setTimeout(function () { - onReportUpdate({ - uniqueid: data.ChatVisitorId, - count: count, - reason: 'timeout', - lastevent: 'timeout', - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - onInvite(data, ++i, 0, 0, count, chatRoom, done); - return; - }, timeout * 1000); - - if (!timeouts[data.ChatVisitorId]) { - timeouts[data.ChatVisitorId] = {}; - } - - timeouts[data.ChatVisitorId].timeout = aTimeout; - timeouts[data.ChatVisitorId].done = done; - } else { - onInvite(data, ++i, 0, 0, ++count, chatRoom, done); - return - } - } - } - - function onReport(report, bulk) { - if (bulk) { - ReportChat - .bulkCreate(report, { - individualHooks: true - }) - .catch(function (err) { - console.error(err); - }); - } else { - ReportChat - .create(report) - .catch(function (err) { - console.error(err); - }); - } - } - - function onReportSession(report) { - - ReportChatSession - .findOrCreate({ - where: { - uniqueid: report.uniqueid - }, - defaults: report - }) - .spread(function (ReportChatSession, created) { - if (!created) { - ReportChatSession - .update(report, { - individualHooks: true - }) - .catch(function (err) { - console.error(err); - }); - } - }); - } - - function onReportUpdate(report) { - ReportChat - .update(report, { - where: { - uniqueid: report.uniqueid, - sorting: report.count - }, - individualHooks: true - }) - .catch(function (err) { - console.error(err); - }); - } - - function onInterval(interval) { - if (_.isObject(interval)) { - for (var i = 0; i < interval.SubIntervals.length; i++) { - if (!onCheckInterval(interval.SubIntervals[i].interval)) { - return false; - } - } - return true; - } else { - return onCheckInterval(interval); - } - } - - function onCheckInterval(interval) { - - var daysOfWeek = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; - var daysOfMonth = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]; - var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; - var i, shift; - - var tRange = interval.split(',')[0]; - var dwRange = interval.split(',')[1]; - var dmRange = interval.split(',')[2]; - var mRange = interval.split(',')[3]; - // TIME RANGE CHECKING - if (tRange !== '*') { - var time = moment().format("HH:mm"); - var tFrom = tRange.split('-')[0]; - var tTo = tRange.split('-')[1]; - - if ((time < tFrom) || (time > tTo)) { - console.log('TRANGE KO'); - return false; - } - } - // DAYS OF WEEK RANGE CHECKING - if (dwRange !== '*') { - var cWeekDay = daysOfWeek[moment().day()]; - var dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]); - var dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]); - - for (i = 0; i < dwFrom; i++) { - shift = daysOfWeek.shift(); - daysOfWeek.push(shift); - } - - dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]); - dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]) + 1; - - daysOfWeek = daysOfWeek.slice(dwFrom, dwTo); - - if (!_.includes(daysOfWeek, cWeekDay)) { - console.log('DWRANGE KO'); - return false; - } - } - // DAYS OF MONTH RANGE CHECKING - if (dmRange !== '*') { - var cMonthDay = moment().date(); - var dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10)); - var dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1])); - - for (i = 0; i < dmFrom; i++) { - shift = daysOfMonth.shift(); - daysOfMonth.push(shift); - } - - dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10)); - dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1]), 10) + 1; - - daysOfMonth = daysOfMonth.slice(dmFrom, dmTo); - - if (!_.includes(daysOfMonth, cMonthDay)) { - console.log('DMRANGE KO'); - return false; - } - } - // MONTHS RANGE CHECKING - if (mRange !== '*') { - var cMonth = months[moment().month()]; - var mFrom = _.indexOf(months, mRange.split('-')[0]); - var mTo = _.indexOf(months, mRange.split('-')[1]); - - for (i = 0; i < mFrom; i++) { - shift = months.shift(); - months.push(shift); - } - - mFrom = _.indexOf(months, mRange.split('-')[0]); - mTo = _.indexOf(months, mRange.split('-')[1]) + 1; - - months = months.slice(mFrom, mTo); - - if (!_.includes(months, cMonth)) { - console.log('MRANGE KO'); - return false; - } - } - - console.log('INTERVAL OK'); - - return true; - } +var _0x9d12=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x6F\x6D\x65\x6E\x74","\x6D\x64\x35","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x53\x65\x73\x73\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x55\x73\x65\x72","\x65\x78\x70\x6F\x72\x74\x73","\x63\x72\x65\x61\x74\x65\x51\x75\x65\x75\x65","\x63\x68\x61\x74","\x70\x72\x6F\x63\x65\x73\x73","\x61\x67\x65\x6E\x74\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x41\x74","\x63\x68\x61\x6E\x67\x65\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x74\x69\x6D\x65\x6F\x75\x74","\x64\x6F\x6E\x65","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x6F\x70\x65\x6E","\x75\x70\x64\x61\x74\x65","\x74\x68\x65\x6E","\x61\x67\x65\x6E\x74\x69\x64","\x61\x64\x64\x55\x73\x65\x72","\x63\x68\x61\x74\x72\x6F\x6F\x6D\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x61\x6E\x73\x77\x65\x72\x65\x64\x5F\x65\x6C\x73\x65\x77\x68\x65\x72\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x63\x68\x61\x74\x71\x75\x65\x75\x65\x6E\x61\x6D\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x73\x61\x76\x65","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x63\x72\x65\x61\x74\x65","\x4E\x6F\x20\x41\x76\x61\x69\x6C\x61\x62\x6C\x65\x20\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x44\x69\x61\x6C\x50\x6C\x61\x6E\x20\x65\x6E\x64\x65\x64\x2E\x2E","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72\x49\x64","\x64\x61\x74\x61","\x69\x64","\x6D\x65\x72\x67\x65","\x65\x6D\x61\x69\x6C","\x6E\x61\x6D\x65","\x61\x64\x64\x72\x65\x73\x73","\x70\x72\x69\x6F\x72\x69\x74\x79","\x73\x6F\x72\x74\x42\x79","\x65\x78\x74\x65\x72\x6E\x61\x6C","\x69\x6E\x76\x69\x74\x65","\x69","\x6A","\x68\x6F\x6C\x64\x74\x69\x6D\x65","\x6C\x6F\x67","\x74\x72\x75\x65","\x63\x6F\x75\x6E\x74\x42\x79","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x55\x73\x65\x72\x73","\x6F\x6E\x6C\x69\x6E\x65","\x61\x70\x70","\x63\x61\x6C\x6C\x65\x64","\x71\x75\x65\x75\x65","\x61\x67\x65\x6E\x74","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x73\x75\x62\x6A\x65\x63\x74","\x66\x72\x6F\x6D","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x63\x6F\x75\x6E\x74","\x62\x65\x65\x70\x61\x6C\x6C","\x55\x6E\x6B\x6E\x6F\x77\x6E\x20\x73\x74\x72\x61\x74\x65\x67\x79","\x73\x74\x72\x61\x74\x65\x67\x79","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x73\x70\x72\x65\x61\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x69\x73\x4F\x62\x6A\x65\x63\x74","\x53\x75\x62\x49\x6E\x74\x65\x72\x76\x61\x6C\x73","\x73\x75\x6E","\x6D\x6F\x6E","\x74\x75\x65","\x77\x65\x64","\x74\x68\x75","\x66\x72\x69","\x73\x61\x74","\x6A\x61\x6E","\x66\x65\x62","\x6D\x61\x72","\x61\x70\x72","\x6D\x61\x79","\x6A\x75\x6E","\x6A\x75\x6C","\x61\x75\x67","\x73\x65\x70","\x6F\x63\x74","\x6E\x6F\x76","\x64\x65\x63","\x2C","\x73\x70\x6C\x69\x74","\x2A","\x48\x48\x3A\x6D\x6D","\x2D","\x54\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x64\x61\x79","\x69\x6E\x64\x65\x78\x4F\x66","\x73\x68\x69\x66\x74","\x73\x6C\x69\x63\x65","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x44\x57\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x64\x61\x74\x65","\x44\x4D\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x6D\x6F\x6E\x74\x68","\x4D\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x49\x4E\x54\x45\x52\x56\x41\x4C\x20\x4F\x4B"];_0x9d12[0];var _=require(_0x9d12[1]);var moment=require(_0x9d12[2]);var md5=require(_0x9d12[3]);var ChatApplication=require(_0x9d12[5])[_0x9d12[4]];var ChatWebsite=require(_0x9d12[5])[_0x9d12[6]];var ChatVisitor=require(_0x9d12[5])[_0x9d12[7]];var ChatMessage=require(_0x9d12[5])[_0x9d12[8]];var ChatQueue=require(_0x9d12[5])[_0x9d12[9]];var ChatRoom=require(_0x9d12[5])[_0x9d12[10]];var Interval=require(_0x9d12[5])[_0x9d12[11]];var ReportChatSession=require(_0x9d12[5])[_0x9d12[12]];var ReportChat=require(_0x9d12[5])[_0x9d12[13]];var User=require(_0x9d12[5])[_0x9d12[14]];var timeouts={};module[_0x9d12[15]]=function(_0xd796xf){var _0xd796x10=_0xd796xf[_0x9d12[16]]();_0xd796x10[_0x9d12[18]](_0x9d12[17],20,function(_0xd796x11,_0xd796x12){onProcess(_0xd796x11,_0xd796x12)});ReportChat[_0x9d12[39]](function(_0xd796x13){var _0xd796x14;if(_0xd796x13[_0x9d12[20]](_0x9d12[19])){if(timeouts[_0xd796x13[_0x9d12[21]]]){clearTimeout(timeouts[_0xd796x13[_0x9d12[21]]][_0x9d12[22]]);timeouts[_0xd796x13[_0x9d12[21]]][_0x9d12[23]]();delete timeouts[_0xd796x13[_0x9d12[21]]];};ChatRoom[_0x9d12[32]](_0xd796x13[_0x9d12[31]])[_0x9d12[28]](function(_0xd796x16){_0xd796x14=_0xd796x16;_0xd796x16[_0x9d12[30]](_0xd796x13[_0x9d12[29]],{individualHooks:true});})[_0x9d12[28]](function(){_0xd796x14[_0x9d12[27]]({status:_0x9d12[26]})})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)});ReportChat[_0x9d12[27]]({agentringnoanswerAt:moment()[_0x9d12[34]](_0x9d12[33]),reason:_0x9d12[35],lastevent:_0x9d12[35]},{where:{uniqueid:_0xd796x13[_0x9d12[21]],reason:null},individualHooks:true})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)});ReportChatSession[_0x9d12[27]]({chatleaveAt:moment()[_0x9d12[34]](_0x9d12[33]),agentid:_0xd796x13[_0x9d12[29]],fullname:_0xd796x13[_0x9d12[36]],membername:_0xd796x13[_0x9d12[37]],chatqueuename:_0xd796x13[_0x9d12[38]]},{where:{uniqueid:_0xd796x13[_0x9d12[21]]},individualHooks:true})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)});};});ChatVisitor[_0x9d12[40]](function(_0xd796x13){onSave(_0xd796x10,_0xd796x13)});};function onSave(_0xd796xf,_0xd796x13,_0xd796x18){_0xd796xf[_0x9d12[43]](_0x9d12[17],_0xd796x13[_0x9d12[42]])[_0x9d12[41]]()}function onProcess(_0xd796x11,_0xd796x12){ChatWebsite[_0x9d12[32]](_0xd796x11[_0x9d12[49]].ChatWebsiteId,{include:[{model:ChatApplication,include:[{model:ChatQueue,include:[{model:User}]},{model:User},{model:Interval,include:[{all:true}]}]}]})[_0x9d12[28]](function(ChatWebsite){if(!ChatWebsite){_0xd796x12( new Error(_0x9d12[44]));return ;};if(!ChatWebsite[_0x9d12[46]][_0x9d12[45]]){_0xd796x12( new Error(_0x9d12[47]));return ;};_0xd796x11[_0x9d12[49]][_0x9d12[48]]=_0xd796x11[_0x9d12[49]][_0x9d12[50]];var _0xd796x1a=_[_0x9d12[51]](_0xd796x11[_0x9d12[49]],ChatWebsite[_0x9d12[42]]);ChatRoom[_0x9d12[43]]({type:_0x9d12[57],ChatVisitorId:_0xd796x1a[_0x9d12[48]],ChatWebsiteId:_0xd796x1a[_0x9d12[50]]},{include:[{all:true}]})[_0x9d12[28]](function(_0xd796x16){onReportSession({uniqueid:_0xd796x1a[_0x9d12[48]],chatroomid:_0xd796x16[_0x9d12[50]],visitorname:_0xd796x1a[_0x9d12[36]],visitoremail:_0xd796x1a[_0x9d12[52]],websitename:_0xd796x1a[_0x9d12[53]],websiteid:_0xd796x1a[_0x9d12[50]],websiteaddress:_0xd796x1a[_0x9d12[54]],chatjoinAt:moment()[_0x9d12[34]](_0x9d12[33])});_0xd796x1a[_0x9d12[46]]=_[_0x9d12[56]](_0xd796x1a.ChatApplications,_0x9d12[55]);onInvite(_0xd796x1a,0,0,0,0,_0xd796x16,_0xd796x12);})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)});})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)})}function onInvite(_0xd796x1c,_0xd796x1d,_0xd796x1e,_0xd796x1f,_0xd796x20,_0xd796x16,_0xd796x12){console[_0x9d12[62]](_0x9d12[58],_0x9d12[59],_0xd796x1d,_0x9d12[60],_0xd796x1e,_0x9d12[61],_0xd796x1f);var _0xd796x21=0;var _0xd796x22;if(_0xd796x1d===_0xd796x1c[_0x9d12[46]][_0x9d12[45]]){console[_0x9d12[24]](_0x9d12[47]);onReportSession({uniqueid:_0xd796x1c[_0x9d12[48]],mailunmanagedAt:moment()[_0x9d12[34]](_0x9d12[33]),mailleaveAt:moment()[_0x9d12[34]](_0x9d12[33])});_0xd796x12( new Error(_0x9d12[47]));return ;};if(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]]){var _0xd796x23=_[_0x9d12[64]](_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]].Users,{online:true})[_0x9d12[63]];if(_0xd796x23&&onInterval(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]?_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[65]])){if(_0xd796x1e===_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0x9d12[45]]){if(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[22]]>_0xd796x1f){onInvite(_0xd796x1c,_0xd796x1d,0,_0xd796x1f,_0xd796x20,_0xd796x16,_0xd796x12);return ;}else {onInvite(_0xd796x1c,++_0xd796x1d,0,0,_0xd796x20,_0xd796x16,_0xd796x12);return ;}};switch(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[81]]){case _0x9d12[72]:if(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0xd796x1e][_0x9d12[67]]&&onInterval(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]?_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[65]])){_0xd796x21=(((_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[22]]-_0xd796x1f)>_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[22]])?_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[22]]:(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[22]]-_0xd796x1f));onReport({uniqueid:_0xd796x1c[_0x9d12[48]],chatroomid:_0xd796x16[_0x9d12[50]],visitorname:_0xd796x1c[_0x9d12[36]],visitoremail:_0xd796x1c[_0x9d12[52]],websitename:_0xd796x1c[_0x9d12[53]],websiteid:_0xd796x1c[_0x9d12[50]],websiteaddress:_0xd796x1c[_0x9d12[54]],sorting:_0xd796x20,timeslot:_0xd796x21,application:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[68]],fullname:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0xd796x1e][_0x9d12[36]],membername:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0xd796x1e][_0x9d12[53]],agentid:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0xd796x1e][_0x9d12[50]],chatqueuename:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[53]],lastevent:_0x9d12[69],holdtime:_0xd796x1f,agentcalledAt:moment()[_0x9d12[34]](_0x9d12[33])});console[_0x9d12[62]](_0x9d12[70],_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[53]],_0x9d12[71],_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0xd796x1e][_0x9d12[53]],_0x9d12[22],_0xd796x21,_0x9d12[61],_0xd796x1f);_0xd796x22=setTimeout(function(){onReportUpdate({uniqueid:_0xd796x1c[_0x9d12[48]],count:_0xd796x20,reason:_0x9d12[22],lastevent:_0x9d12[22],agentringnoanswerAt:moment()[_0x9d12[34]](_0x9d12[33])});_0xd796x1f+=_0xd796x21;onInvite(_0xd796x1c,_0xd796x1d,++_0xd796x1e,_0xd796x1f,++_0xd796x20,_0xd796x16,_0xd796x12);return ;},_0xd796x21*1000);if(!timeouts[_0xd796x1c[_0x9d12[48]]]){timeouts[_0xd796x1c[_0x9d12[48]]]={}};timeouts[_0xd796x1c[_0x9d12[48]]][_0x9d12[22]]=_0xd796x22;timeouts[_0xd796x1c[_0x9d12[48]]][_0x9d12[23]]=_0xd796x12;}else {onInvite(_0xd796x1c,_0xd796x1d,++_0xd796x1e,_0xd796x1f,_0xd796x20,_0xd796x16,_0xd796x12);return ;};break ;;case _0x9d12[79]:_0xd796x21=(((_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[22]]-_0xd796x1f)>_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[22]])?_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[22]]:(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[22]]-_0xd796x1f));var _0xd796x24=[];_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0x9d12[77]](function(_0xd796x25){if(_0xd796x25[_0x9d12[67]]){_0xd796x24[_0x9d12[76]]({uniqueid:_0xd796x1c[_0x9d12[48]],chatroomid:_0xd796x16[_0x9d12[50]],sorting:_0xd796x20,subject:_0xd796x1c[_0x9d12[73]],timeslot:_0xd796x21,from:_0xd796x1c[_0x9d12[74]],attachment:_0xd796x1c[_0x9d12[75]],accountname:_0xd796x1c[_0x9d12[53]],accountaddress:_0xd796x1c[_0x9d12[54]],application:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[68]],fullname:_0xd796x25[_0x9d12[36]],membername:_0xd796x25[_0x9d12[53]],agentid:_0xd796x25[_0x9d12[50]],chatqueuename:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[53]],lastevent:_0x9d12[69],holdtime:_0xd796x1f,agentcalledAt:moment()[_0x9d12[34]](_0x9d12[33]),visitorname:_0xd796x1c[_0x9d12[36]],visitoremail:_0xd796x1c[_0x9d12[52]],websitename:_0xd796x1c[_0x9d12[53]],websiteid:_0xd796x1c[_0x9d12[50]],websiteaddress:_0xd796x1c[_0x9d12[54]]})}});if(_0xd796x24[_0x9d12[45]]&&onInterval(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]?_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[65]])){onReport(_0xd796x24,true);_0xd796x22=setTimeout(function(){console[_0x9d12[62]](_0x9d12[78],_0xd796x20);onReportUpdate({uniqueid:_0xd796x1c[_0x9d12[48]],count:_0xd796x20,reason:_0x9d12[22],lastevent:_0x9d12[22],agentringnoanswerAt:moment()[_0x9d12[34]](_0x9d12[33])});_0xd796x1f+=_0xd796x21;_0xd796x1e+=_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[66]][_0x9d12[45]];onInvite(_0xd796x1c,_0xd796x1d,_0xd796x1e,_0xd796x1f,++_0xd796x20,_0xd796x16,_0xd796x12);return ;},_0xd796x21*1000);if(!timeouts[_0xd796x1c[_0x9d12[48]]]){timeouts[_0xd796x1c[_0x9d12[48]]]={}};timeouts[_0xd796x1c[_0x9d12[48]]][_0x9d12[22]]=_0xd796x22;timeouts[_0xd796x1c[_0x9d12[48]]][_0x9d12[23]]=_0xd796x12;}else {console[_0x9d12[62]](_0x9d12[70],_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[9]][_0x9d12[53]],_0x9d12[22],_0xd796x21,_0x9d12[61],_0xd796x1f);onInvite(_0xd796x1c,++_0xd796x1d,0,0,_0xd796x20,_0xd796x16,_0xd796x12);return ;};break ;;default:console[_0x9d12[24]](_0x9d12[80]);;};}else {onInvite(_0xd796x1c,++_0xd796x1d,0,0,_0xd796x20,_0xd796x16,_0xd796x12);return ;};}else {_0xd796x21=_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[22]];if(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[14]][_0x9d12[67]]&&onInterval(_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]?_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[11]]:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[65]])){onReport({uniqueid:_0xd796x1c[_0x9d12[48]],chatroomid:_0xd796x16[_0x9d12[50]],sorting:_0xd796x20,subject:_0xd796x1c[_0x9d12[73]],timeslot:_0xd796x21,from:_0xd796x1c[_0x9d12[74]],attachment:_0xd796x1c[_0x9d12[75]],accountname:_0xd796x1c[_0x9d12[53]],accountaddress:_0xd796x1c[_0x9d12[54]],application:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[68]],fullname:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[14]][_0x9d12[36]],membername:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[14]][_0x9d12[53]],agentid:_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[14]][_0x9d12[50]],lastevent:_0x9d12[69],holdtime:_0xd796x1f,agentcalledAt:moment()[_0x9d12[34]](_0x9d12[33]),visitorname:_0xd796x1c[_0x9d12[36]],visitoremail:_0xd796x1c[_0x9d12[52]],websitename:_0xd796x1c[_0x9d12[53]],websiteid:_0xd796x1c[_0x9d12[50]],websiteaddress:_0xd796x1c[_0x9d12[54]]});console[_0x9d12[62]](_0x9d12[71],_0xd796x1c[_0x9d12[46]][_0xd796x1d][_0x9d12[14]][_0x9d12[53]],_0x9d12[22],_0xd796x21,_0x9d12[61],_0xd796x1f);_0xd796x22=setTimeout(function(){onReportUpdate({uniqueid:_0xd796x1c[_0x9d12[48]],count:_0xd796x20,reason:_0x9d12[22],lastevent:_0x9d12[22],agentringnoanswerAt:moment()[_0x9d12[34]](_0x9d12[33])});onInvite(_0xd796x1c,++_0xd796x1d,0,0,_0xd796x20,_0xd796x16,_0xd796x12);return ;},_0xd796x21*1000);if(!timeouts[_0xd796x1c[_0x9d12[48]]]){timeouts[_0xd796x1c[_0x9d12[48]]]={}};timeouts[_0xd796x1c[_0x9d12[48]]][_0x9d12[22]]=_0xd796x22;timeouts[_0xd796x1c[_0x9d12[48]]][_0x9d12[23]]=_0xd796x12;}else {onInvite(_0xd796x1c,++_0xd796x1d,0,0,++_0xd796x20,_0xd796x16,_0xd796x12);return ;};};}function onReport(_0xd796x27,_0xd796x28){if(_0xd796x28){ReportChat[_0x9d12[82]](_0xd796x27,{individualHooks:true})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)})}else {ReportChat[_0x9d12[43]](_0xd796x27)[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)})}}function onReportSession(_0xd796x27){ReportChatSession[_0x9d12[84]]({where:{uniqueid:_0xd796x27[_0x9d12[21]]},defaults:_0xd796x27})[_0x9d12[83]](function(ReportChatSession,_0xd796x2a){if(!_0xd796x2a){ReportChatSession[_0x9d12[27]](_0xd796x27,{individualHooks:true})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)})}})}function onReportUpdate(_0xd796x27){ReportChat[_0x9d12[27]](_0xd796x27,{where:{uniqueid:_0xd796x27[_0x9d12[21]],sorting:_0xd796x27[_0x9d12[78]]},individualHooks:true})[_0x9d12[25]](function(_0xd796x15){console[_0x9d12[24]](_0xd796x15)})}function onInterval(_0xd796x2d){if(_[_0x9d12[85]](_0xd796x2d)){for(var _0xd796x1d=0;_0xd796x1d<_0xd796x2d[_0x9d12[86]][_0x9d12[45]];_0xd796x1d++){if(!onCheckInterval(_0xd796x2d[_0x9d12[86]][_0xd796x1d][_0x9d12[65]])){return false}};return true;}else {return onCheckInterval(_0xd796x2d)}}function onCheckInterval(_0xd796x2d){var _0xd796x2f=[_0x9d12[87],_0x9d12[88],_0x9d12[89],_0x9d12[90],_0x9d12[91],_0x9d12[92],_0x9d12[93]];var _0xd796x30=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];var _0xd796x31=[_0x9d12[94],_0x9d12[95],_0x9d12[96],_0x9d12[97],_0x9d12[98],_0x9d12[99],_0x9d12[100],_0x9d12[101],_0x9d12[102],_0x9d12[103],_0x9d12[104],_0x9d12[105]];var _0xd796x1d,_0xd796x32;var _0xd796x33=_0xd796x2d[_0x9d12[107]](_0x9d12[106])[0];var _0xd796x34=_0xd796x2d[_0x9d12[107]](_0x9d12[106])[1];var _0xd796x35=_0xd796x2d[_0x9d12[107]](_0x9d12[106])[2];var _0xd796x36=_0xd796x2d[_0x9d12[107]](_0x9d12[106])[3];if(_0xd796x33!==_0x9d12[108]){var _0xd796x37=moment()[_0x9d12[34]](_0x9d12[109]);var _0xd796x38=_0xd796x33[_0x9d12[107]](_0x9d12[110])[0];var _0xd796x39=_0xd796x33[_0x9d12[107]](_0x9d12[110])[1];if((_0xd796x37<_0xd796x38)||(_0xd796x37>_0xd796x39)){console[_0x9d12[62]](_0x9d12[111]);return false;};};if(_0xd796x34!==_0x9d12[108]){var _0xd796x3a=_0xd796x2f[moment()[_0x9d12[112]]()];var _0xd796x3b=_[_0x9d12[113]](_0xd796x2f,_0xd796x34[_0x9d12[107]](_0x9d12[110])[0]);var _0xd796x3c=_[_0x9d12[113]](_0xd796x2f,_0xd796x34[_0x9d12[107]](_0x9d12[110])[1]);for(_0xd796x1d=0;_0xd796x1d<_0xd796x3b;_0xd796x1d++){_0xd796x32=_0xd796x2f[_0x9d12[114]]();_0xd796x2f[_0x9d12[76]](_0xd796x32);};_0xd796x3b=_[_0x9d12[113]](_0xd796x2f,_0xd796x34[_0x9d12[107]](_0x9d12[110])[0]);_0xd796x3c=_[_0x9d12[113]](_0xd796x2f,_0xd796x34[_0x9d12[107]](_0x9d12[110])[1])+1;_0xd796x2f=_0xd796x2f[_0x9d12[115]](_0xd796x3b,_0xd796x3c);if(!_[_0x9d12[116]](_0xd796x2f,_0xd796x3a)){console[_0x9d12[62]](_0x9d12[117]);return false;};};if(_0xd796x35!==_0x9d12[108]){var _0xd796x3d=moment()[_0x9d12[118]]();var _0xd796x3e=_[_0x9d12[113]](_0xd796x30,parseInt(_0xd796x35[_0x9d12[107]](_0x9d12[110])[0],10));var _0xd796x3f=_[_0x9d12[113]](_0xd796x30,parseInt(_0xd796x35[_0x9d12[107]](_0x9d12[110])[1]));for(_0xd796x1d=0;_0xd796x1d<_0xd796x3e;_0xd796x1d++){_0xd796x32=_0xd796x30[_0x9d12[114]]();_0xd796x30[_0x9d12[76]](_0xd796x32);};_0xd796x3e=_[_0x9d12[113]](_0xd796x30,parseInt(_0xd796x35[_0x9d12[107]](_0x9d12[110])[0],10));_0xd796x3f=_[_0x9d12[113]](_0xd796x30,parseInt(_0xd796x35[_0x9d12[107]](_0x9d12[110])[1]),10)+1;_0xd796x30=_0xd796x30[_0x9d12[115]](_0xd796x3e,_0xd796x3f);if(!_[_0x9d12[116]](_0xd796x30,_0xd796x3d)){console[_0x9d12[62]](_0x9d12[119]);return false;};};if(_0xd796x36!==_0x9d12[108]){var _0xd796x40=_0xd796x31[moment()[_0x9d12[120]]()];var _0xd796x41=_[_0x9d12[113]](_0xd796x31,_0xd796x36[_0x9d12[107]](_0x9d12[110])[0]);var _0xd796x42=_[_0x9d12[113]](_0xd796x31,_0xd796x36[_0x9d12[107]](_0x9d12[110])[1]);for(_0xd796x1d=0;_0xd796x1d<_0xd796x41;_0xd796x1d++){_0xd796x32=_0xd796x31[_0x9d12[114]]();_0xd796x31[_0x9d12[76]](_0xd796x32);};_0xd796x41=_[_0x9d12[113]](_0xd796x31,_0xd796x36[_0x9d12[107]](_0x9d12[110])[0]);_0xd796x42=_[_0x9d12[113]](_0xd796x31,_0xd796x36[_0x9d12[107]](_0x9d12[110])[1])+1;_0xd796x31=_0xd796x31[_0x9d12[115]](_0xd796x41,_0xd796x42);if(!_[_0x9d12[116]](_0xd796x31,_0xd796x40)){console[_0x9d12[62]](_0x9d12[121]);return false;};};console[_0x9d12[62]](_0x9d12[122]);return true;} \ No newline at end of file diff --git a/server/config/kue.fax.js b/server/config/kue.fax.js index bfc3743..591f3bd 100644 --- a/server/config/kue.fax.js +++ b/server/config/kue.fax.js @@ -1,316 +1 @@ -'use strict'; - -var _ = require('lodash'); -var config = require('./environment'); -var async = require('async'); -var sockets = {}; -var User = require('../models').User; -var Event = require('../models').Event; -var FaxQueue = require('../models').FaxQueue; - -function invite(data, i, j, io, done) { - - var elapsed = 0; - var timeout = 0; - var body = []; - var users = []; - - if (i === data.applications.length) { - body.push({ - name: 'UNASSIGNED', - channel: 'FAX', - FaxRoomId: data.roomId, - FaxAccountId: data.accountId - }); - - traceEvent(body, function() {}); - - done(new Error('DialPlan ended..')); - return; - } - - if (data.applications[i].FaxQueue) { - - timeout = (((data.applications[i].timeout - elapsed) > data.applications[i].FaxQueue.timeout) ? - data.applications[i].FaxQueue.timeout : (data.applications[i].timeout - elapsed)); - - switch (data.applications[i].FaxQueue.strategy) { - case 'rrmemory': - body.push({ - name: 'ATTEMPT', - channel: 'FAX', - timeout: timeout, - UserId: data.applications[i].users[j].id, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - }); - users.push(data.applications[i].users[j].id); - break; - case 'beepall': - data.applications[i].users.forEach(function(user) { - var item = { - name: 'ATTEMPT', - channel: 'FAX', - timeout: timeout, - UserId: user.id, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - } - body.push(item); - users.push(user.id); - }); - break; - default: - console.log('Strategy unknown..'); - } - - traceEvent(body, function() { - emitEvent(users, 'FAX:QUEUE:' + data.applications[i].FaxQueue.id, { - timeout: timeout, - roomId: data.roomId - }, function(userId) { - clearInterval(qInterval); - clearTimeout(aTimeout); - var body = [{ - name: 'ASSIGNED', - channel: 'FAX', - timeout: timeout, - UserId: userId, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - }]; - traceEvent(body, function() { - done(); - }); - }); - }); - - } else { - // SET AGENT APPLICATION TIMEOUT - timeout = data.applications[i].timeout; - - users.push(data.applications[i].users[j].id); - body = [{ - name: 'ATTEMPT', - channel: 'FAX', - timeout: timeout, - UserId: data.applications[i].users[j].id, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - }]; - traceEvent(body, function() { - emitEvent(users, 'FAX:AGENT:' + data.applications[i].users[j].id, { - timeout: data.applications[i].timeout, - roomId: data.roomId - }, function(userId) { - clearInterval(qInterval); - clearTimeout(aTimeout); - var body = [{ - name: 'ASSIGNED', - channel: 'FAX', - timeout: timeout, - UserId: userId, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - }]; - traceEvent(body, function() { - done(); - }); - }); - }); - - } - - var qInterval = setInterval(function() { - var timeout = 0; - // NEXT AGENT - j++; - - if (j === data.applications[i].users.length) { - j = 0; - } - - if (data.applications[i].FaxQueue) { - - elapsed += data.applications[i].FaxQueue.timeout; - - timeout = (((data.applications[i].timeout - elapsed) > data.applications[i].FaxQueue.timeout) ? - data.applications[i].FaxQueue.timeout : (data.applications[i].timeout - elapsed)); - - var body = []; - var users = []; - - switch (data.applications[i].FaxQueue.strategy) { - case 'rrmemory': - var item = { - name: 'ATTEMPT', - channel: 'FAX', - timeout: timeout, - UserId: data.applications[i].users[j].id, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - }; - body.push(item); - users.push(data.applications[i].users[j].id); - break; - case 'beepall': - data.applications[i].users.forEach(function(user) { - var item = { - name: 'ATTEMPT', - channel: 'FAX', - timeout: timeout, - UserId: user.id, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - } - body.push(item); - users.push(user.id); - }); - break; - default: - console.log('Strategy unknown..'); - } - - traceEvent(body, function() { - emitEvent(users, 'FAX:QUEUE:' + data.applications[i].FaxQueue.id, { - timeout: timeout, - roomId: data.roomId - }, function(userId) { - console.log('userId', userId); - clearInterval(qInterval); - clearTimeout(aTimeout); - var body = [{ - name: 'ASSIGNED', - channel: 'FAX', - timeout: timeout, - UserId: userId, - FaxRoomId: data.roomId, - FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null, - FaxAccountId: data.accountId, - FaxApplicationId: data.applications[i].id - }]; - traceEvent(body, function() { - done(); - }); - }); - }); - - } - }, data.applications[i].FaxQueue ? data.applications[i].FaxQueue.timeout * 1000 : data.applications[i].timeout * 1000); - - var aTimeout = setTimeout(function() { - clearInterval(qInterval); - invite(data, ++i, 0, io, done); - }, data.applications[i].timeout * 1000); -} - -function processing(job, done, io) { - var elapsed = 0; - var applications = [ - // INIT - function(callback) { - callback(null, job.data, done, io); - }, - // BUILDING APPLICATION STRUCTURE - function(data, done, io, callback) { - for (var i = 0; i < data.applications.length; i++) { - switch (data.applications[i].app) { - case 'agent': - if (!data.applications[i].users) { - data.applications[i].users = []; - } - - data.applications[i].users.push(data.applications[i].User); - break; - case 'queue': - - for (var j = 0; j < data.applications[i].FaxQueue.Users.length; j++) { - - if (!data.applications[i].users) { - data.applications[i].users = []; - } - - data.applications[i].users.push( - data.applications[i].FaxQueue.Users[j] - ); - } - - break; - default: - - } - } - - callback(null, data, done, io); - } - ]; - - async.waterfall(applications, - // optional callback - function(err, data, done, io) { - invite(data, 0, 0, io, done); - }); -} - -function traceEvent(body, cb) { - Event - .bulkCreate(body) - .then(function() { - if (cb) { - cb(); - } - }) - .catch(function(err) { - console.error(err); - }); -} - -function emitEvent(users, event, params, cb) { - users.forEach(function(user) { - console.log(event, user); - if (sockets[user]) { - sockets[user].emit(event, params, cb); - } - }); -} - -module.exports = function(io, kue) { - - var kueFax = kue.createQueue(); - - /** - * Queue processing statement - */ - kueFax.process('fax', 20, function(job, done) { - processing(job, done, io); - }); - - require('../api/fax_room/fax_room.kue').register(kueFax); - - io.on('connection', function(socket) { - - if (socket.handshake.query.userId) { - sockets[socket.handshake.query.userId] = socket; - } - - socket.on('disconnect', function() { - if (sockets[socket.handshake.query.userId]) { - delete sockets[socket.handshake.query.userId]; - } - }); - }); -} +var _0x39d9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x61\x73\x79\x6E\x63","\x55\x73\x65\x72","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x45\x76\x65\x6E\x74","\x46\x61\x78\x51\x75\x65\x75\x65","\x6C\x65\x6E\x67\x74\x68","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x55\x4E\x41\x53\x53\x49\x47\x4E\x45\x44","\x46\x41\x58","\x72\x6F\x6F\x6D\x49\x64","\x61\x63\x63\x6F\x75\x6E\x74\x49\x64","\x70\x75\x73\x68","\x44\x69\x61\x6C\x50\x6C\x61\x6E\x20\x65\x6E\x64\x65\x64\x2E\x2E","\x74\x69\x6D\x65\x6F\x75\x74","\x41\x54\x54\x45\x4D\x50\x54","\x69\x64","\x75\x73\x65\x72\x73","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x66\x6F\x72\x45\x61\x63\x68","\x62\x65\x65\x70\x61\x6C\x6C","\x53\x74\x72\x61\x74\x65\x67\x79\x20\x75\x6E\x6B\x6E\x6F\x77\x6E\x2E\x2E","\x6C\x6F\x67","\x73\x74\x72\x61\x74\x65\x67\x79","\x46\x41\x58\x3A\x51\x55\x45\x55\x45\x3A","\x41\x53\x53\x49\x47\x4E\x45\x44","\x46\x41\x58\x3A\x41\x47\x45\x4E\x54\x3A","\x75\x73\x65\x72\x49\x64","\x64\x61\x74\x61","\x61\x67\x65\x6E\x74","\x55\x73\x65\x72\x73","\x71\x75\x65\x75\x65","\x61\x70\x70","\x77\x61\x74\x65\x72\x66\x61\x6C\x6C","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x65\x6D\x69\x74","\x65\x78\x70\x6F\x72\x74\x73","\x63\x72\x65\x61\x74\x65\x51\x75\x65\x75\x65","\x66\x61\x78","\x70\x72\x6F\x63\x65\x73\x73","\x72\x65\x67\x69\x73\x74\x65\x72","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x2F\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x2E\x6B\x75\x65","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E","\x71\x75\x65\x72\x79","\x68\x61\x6E\x64\x73\x68\x61\x6B\x65","\x64\x69\x73\x63\x6F\x6E\x6E\x65\x63\x74","\x6F\x6E"];_0x39d9[0];var _=require(_0x39d9[1]);var config=require(_0x39d9[2]);var async=require(_0x39d9[3]);var sockets={};var User=require(_0x39d9[5])[_0x39d9[4]];var Event=require(_0x39d9[5])[_0x39d9[6]];var FaxQueue=require(_0x39d9[5])[_0x39d9[7]];function invite(_0xe174x9,_0xe174xa,_0xe174xb,_0xe174xc,_0xe174xd){var _0xe174xe=0;var _0xe174xf=0;var _0xe174x10=[];var _0xe174x11=[];if(_0xe174xa===_0xe174x9[_0x39d9[9]][_0x39d9[8]]){_0xe174x10[_0x39d9[14]]({name:_0x39d9[10],channel:_0x39d9[11],FaxRoomId:_0xe174x9[_0x39d9[12]],FaxAccountId:_0xe174x9[_0x39d9[13]]});traceEvent(_0xe174x10,function(){});_0xe174xd( new Error(_0x39d9[15]));return ;};if(_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]){_0xe174xf=(((_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]]-_0xe174xe)>_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[16]])?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[16]]:(_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]]-_0xe174xe));switch(_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[25]]){case _0x39d9[20]:_0xe174x10[_0x39d9[14]]({name:_0x39d9[17],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0xe174xb][_0x39d9[18]],FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]});_0xe174x11[_0x39d9[14]](_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0xe174xb][_0x39d9[18]]);break ;;case _0x39d9[22]:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0x39d9[21]](function(_0xe174x12){var _0xe174x13={name:_0x39d9[17],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x12[_0x39d9[18]],FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]};_0xe174x10[_0x39d9[14]](_0xe174x13);_0xe174x11[_0x39d9[14]](_0xe174x12[_0x39d9[18]]);});break ;;default:console[_0x39d9[24]](_0x39d9[23]);;};traceEvent(_0xe174x10,function(){emitEvent(_0xe174x11,_0x39d9[26]+_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]],{timeout:_0xe174xf,roomId:_0xe174x9[_0x39d9[12]]},function(_0xe174x14){clearInterval(_0xe174x15);clearTimeout(_0xe174x16);var _0xe174x10=[{name:_0x39d9[27],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x14,FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]}];traceEvent(_0xe174x10,function(){_0xe174xd()});})});}else {_0xe174xf=_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]];_0xe174x11[_0x39d9[14]](_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0xe174xb][_0x39d9[18]]);_0xe174x10=[{name:_0x39d9[17],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0xe174xb][_0x39d9[18]],FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]}];traceEvent(_0xe174x10,function(){emitEvent(_0xe174x11,_0x39d9[28]+_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0xe174xb][_0x39d9[18]],{timeout:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]],roomId:_0xe174x9[_0x39d9[12]]},function(_0xe174x14){clearInterval(_0xe174x15);clearTimeout(_0xe174x16);var _0xe174x10=[{name:_0x39d9[27],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x14,FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]}];traceEvent(_0xe174x10,function(){_0xe174xd()});})});};var _0xe174x15=setInterval(function(){var _0xe174xf=0;_0xe174xb++;if(_0xe174xb===_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0x39d9[8]]){_0xe174xb=0};if(_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]){_0xe174xe+=_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[16]];_0xe174xf=(((_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]]-_0xe174xe)>_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[16]])?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[16]]:(_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]]-_0xe174xe));var _0xe174x10=[];var _0xe174x11=[];switch(_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[25]]){case _0x39d9[20]:var _0xe174x13={name:_0x39d9[17],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0xe174xb][_0x39d9[18]],FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]};_0xe174x10[_0x39d9[14]](_0xe174x13);_0xe174x11[_0x39d9[14]](_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0xe174xb][_0x39d9[18]]);break ;;case _0x39d9[22]:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0x39d9[21]](function(_0xe174x12){var _0xe174x13={name:_0x39d9[17],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x12[_0x39d9[18]],FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]};_0xe174x10[_0x39d9[14]](_0xe174x13);_0xe174x11[_0x39d9[14]](_0xe174x12[_0x39d9[18]]);});break ;;default:console[_0x39d9[24]](_0x39d9[23]);;};traceEvent(_0xe174x10,function(){emitEvent(_0xe174x11,_0x39d9[26]+_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]],{timeout:_0xe174xf,roomId:_0xe174x9[_0x39d9[12]]},function(_0xe174x14){console[_0x39d9[24]](_0x39d9[29],_0xe174x14);clearInterval(_0xe174x15);clearTimeout(_0xe174x16);var _0xe174x10=[{name:_0x39d9[27],channel:_0x39d9[11],timeout:_0xe174xf,UserId:_0xe174x14,FaxRoomId:_0xe174x9[_0x39d9[12]],FaxQueueId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[18]]:null,FaxAccountId:_0xe174x9[_0x39d9[13]],FaxApplicationId:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[18]]}];traceEvent(_0xe174x10,function(){_0xe174xd()});})});};},_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]]?_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[16]]*1000:_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]]*1000);var _0xe174x16=setTimeout(function(){clearInterval(_0xe174x15);invite(_0xe174x9,++_0xe174xa,0,_0xe174xc,_0xe174xd);},_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[16]]*1000);}function processing(_0xe174x18,_0xe174xd,_0xe174xc){var _0xe174xe=0;var _0xe174x19=[function(_0xe174x1a){_0xe174x1a(null,_0xe174x18[_0x39d9[30]],_0xe174xd,_0xe174xc)},function(_0xe174x9,_0xe174xd,_0xe174xc,_0xe174x1a){for(var _0xe174xa=0;_0xe174xa<_0xe174x9[_0x39d9[9]][_0x39d9[8]];_0xe174xa++){switch(_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[34]]){case _0x39d9[31]:if(!_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]]){_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]]=[]};_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0x39d9[14]](_0xe174x9[_0x39d9[9]][_0xe174xa].User);break ;;case _0x39d9[33]:for(var _0xe174xb=0;_0xe174xb<_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[32]][_0x39d9[8]];_0xe174xb++){if(!_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]]){_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]]=[]};_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[19]][_0x39d9[14]](_0xe174x9[_0x39d9[9]][_0xe174xa][_0x39d9[7]][_0x39d9[32]][_0xe174xb]);};break ;;default:;}};_0xe174x1a(null,_0xe174x9,_0xe174xd,_0xe174xc);}];async[_0x39d9[35]](_0xe174x19,function(_0xe174x1b,_0xe174x9,_0xe174xd,_0xe174xc){invite(_0xe174x9,0,0,_0xe174xc,_0xe174xd)});}function traceEvent(_0xe174x10,_0xe174x1d){Event[_0x39d9[39]](_0xe174x10)[_0x39d9[38]](function(){if(_0xe174x1d){_0xe174x1d()}})[_0x39d9[37]](function(_0xe174x1b){console[_0x39d9[36]](_0xe174x1b)})}function emitEvent(_0xe174x11,_0xe174x1f,_0xe174x20,_0xe174x1d){_0xe174x11[_0x39d9[21]](function(_0xe174x12){console[_0x39d9[24]](_0xe174x1f,_0xe174x12);if(sockets[_0xe174x12]){sockets[_0xe174x12][_0x39d9[40]](_0xe174x1f,_0xe174x20,_0xe174x1d)};})}module[_0x39d9[41]]=function(_0xe174xc,_0xe174x21){var _0xe174x22=_0xe174x21[_0x39d9[42]]();_0xe174x22[_0x39d9[44]](_0x39d9[43],20,function(_0xe174x18,_0xe174xd){processing(_0xe174x18,_0xe174xd,_0xe174xc)});require(_0x39d9[46])[_0x39d9[45]](_0xe174x22);_0xe174xc[_0x39d9[51]](_0x39d9[47],function(_0xe174x23){if(_0xe174x23[_0x39d9[49]][_0x39d9[48]][_0x39d9[29]]){sockets[_0xe174x23[_0x39d9[49]][_0x39d9[48]][_0x39d9[29]]]=_0xe174x23};_0xe174x23[_0x39d9[51]](_0x39d9[50],function(){if(sockets[_0xe174x23[_0x39d9[49]][_0x39d9[48]][_0x39d9[29]]]){delete sockets[_0xe174x23[_0x39d9[49]][_0x39d9[48]][_0x39d9[29]]]}});});}; \ No newline at end of file diff --git a/server/config/kue.mail.js b/server/config/kue.mail.js index d5f87d3..8d8f551 100644 --- a/server/config/kue.mail.js +++ b/server/config/kue.mail.js @@ -1,516 +1 @@ - 'use strict'; - - var _ = require('lodash'); - var moment = require('moment'); - - var MailApplication = require('../models').MailApplication; - var MailAccount = require('../models').MailAccount; - var MailQueue = require('../models').MailQueue; - var MailRoom = require('../models').MailRoom; - var Interval = require('../models').Interval; - - var ReportMailSession = require('../models').ReportMailSession; - var ReportMail = require('../models').ReportMail; - - var User = require('../models').User; - - var timeouts = {}; - - module.exports = function(kue) { - var kueMail = kue.createQueue(); - // KUE PROCESS - kueMail.process('mail', 20, function(job, done) { - onProcess(job, done); - }); - // REPORT MAIL HOOKS - ReportMail.afterUpdate(function(doc) { - if (doc.changed('agentconnectedAt')) { - if (timeouts[doc.uniqueid]) { - clearTimeout(timeouts[doc.uniqueid].timeout); - timeouts[doc.uniqueid].done(); - delete timeouts[doc.uniqueid]; - } - - MailRoom - .findById(doc.uniqueid) - .then(function(mailRoom) { - mailRoom - .update({ - UserId: doc.agentid - }) - }) - .catch(function(err) { - console.error(err); - }); - - ReportMail - .update({ - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss"), - reason: "answered_elsewhere", - lastevent: "answered_elsewhere" - }, { - where: { - uniqueid: doc.uniqueid, - reason: null - }, - individualHooks: true - }) - .catch(function(err) { - console.error(err); - }); - - ReportMailSession - .update({ - mailleaveAt: moment().format("YYYY-MM-DD HH:mm:ss"), - fullname: doc.fullname, - membername: doc.membername, - mailqueuename: doc.mailqueuename - }, { - where: { - uniqueid: doc.uniqueid, - }, - individualHooks: true - }) - .catch(function(err) { - console.error(err); - }); - } - }); - // MAIL ROOM HOOKS - MailRoom.afterCreate(function(doc) { - onSave(kueMail, doc); - }); - MailRoom.afterDestroy(function(doc) { - onSave(kueMail, doc); - }); - }; - - function onSave(kue, doc, cb) { - if (doc.status === 'NEW') { - // CREATE KUE PROCESS - kue.create('mail', doc.dataValues).save(); - } - } - - function onProcess(job, done) { - MailAccount - .findById(job.data.MailAccountId, { - include: [{ - model: MailApplication, - include: [{ - model: MailQueue, - include: [{ - model: User - }] - }, { - model: User - }, { - model: Interval, - include: [{ - all: true - }] - }] - }] - }) - .then(function(mailAccount) { - if (!mailAccount) { - done(new Error('No Available MailApplications..')); - return; - } - - if (!mailAccount.MailApplications.length) { - done(new Error('DialPlan ended..')); - return; - } - - job.data.MailRoomId = job.data.id; - var session = _.merge(job.data, mailAccount.dataValues); - - onReportSession({ - uniqueid: session.MailRoomId, - subject: session.subject, - from: session.from, - cc: session.cc, - attachment: session.attachment, - accountname: session.name, - accountaddress: session.address, - mailjoinAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - session.MailApplications = _.sortBy(session.MailApplications, 'priority'); - onInvite(session, 0, 0, 0, 0, done); - }) - .catch(function(err) { - console.error(err); - }); - } - - function onInvite(data, i, j, holdtime, count, done) { - console.log('invite', 'i', i, 'j', j, 'holdtime', holdtime); - var timeout = 0; - var aTimeout; - - if (i === data.MailApplications.length) { - console.error('DialPlan ended..'); - - onReportSession({ - uniqueid: data.MailRoomId, - mailunmanagedAt: moment().format("YYYY-MM-DD HH:mm:ss"), - mailleaveAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - done(new Error('DialPlan ended..')); - return; - } - - if (data.MailApplications[i].MailQueue) { - // QUEUE APPLICATION - - // ONLINE AGENTS COUNTER - var online = _.countBy(data.MailApplications[i].MailQueue.Users, { - online: true - }).true; - - if (online && onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) { - // AT LEAST ONE AVAILABLE AGENT - if (j === data.MailApplications[i].MailQueue.Users.length) { - if (data.MailApplications[i].timeout > holdtime) { - onInvite(data, i, 0, holdtime, count, done); - return; - } else { - onInvite(data, ++i, 0, 0, count, done); - return; - } - } - - switch (data.MailApplications[i].MailQueue.strategy) { - case 'rrmemory': - if (data.MailApplications[i].MailQueue.Users[j].online && - onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) { - // AVAILABLE - timeout = (((data.MailApplications[i].timeout - holdtime) > data.MailApplications[i].MailQueue.timeout) ? - data.MailApplications[i].MailQueue.timeout : (data.MailApplications[i].timeout - holdtime)); - - onReport({ - uniqueid: data.MailRoomId, - sorting: count, - subject: data.subject, - timeslot: timeout, - from: data.from, - attachment: data.attachment, - accountname: data.name, - accountaddress: data.address, - application: data.MailApplications[i].app, - fullname: data.MailApplications[i].MailQueue.Users[j].fullname, - membername: data.MailApplications[i].MailQueue.Users[j].name, - agentid: data.MailApplications[i].MailQueue.Users[j].id, - mailqueuename: data.MailApplications[i].MailQueue.name, - lastevent: 'called', - holdtime: holdtime, - agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - console.log('queue', data.MailApplications[i].MailQueue.name, 'agent', data.MailApplications[i].MailQueue.Users[j].name, 'timeout', timeout, 'holdtime', holdtime); - aTimeout = setTimeout(function() { - onReportUpdate({ - uniqueid: data.MailRoomId, - count: count, - reason: 'timeout', - lastevent: 'timeout', - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - holdtime += timeout; - onInvite(data, i, ++j, holdtime, ++count, done); - return; - }, timeout * 1000); - - if (!timeouts[data.MailRoomId]) { - timeouts[data.MailRoomId] = {}; - } - - timeouts[data.MailRoomId].timeout = aTimeout; - timeouts[data.MailRoomId].done = done; - - } else { - onInvite(data, i, ++j, holdtime, count, done); - return; - } - - break; - case 'beepall': - - timeout = (((data.MailApplications[i].timeout - holdtime) > data.MailApplications[i].MailQueue.timeout) ? - data.MailApplications[i].MailQueue.timeout : (data.MailApplications[i].timeout - holdtime)); - - var users = []; - data.MailApplications[i].MailQueue.Users.forEach(function(user) { - if (user.online) { - users.push({ - uniqueid: data.MailRoomId, - sorting: count, - subject: data.subject, - timeslot: timeout, - from: data.from, - attachment: data.attachment, - accountname: data.name, - accountaddress: data.address, - application: data.MailApplications[i].app, - fullname: user.fullname, - membername: user.name, - agentid: user.id, - mailqueuename: data.MailApplications[i].MailQueue.name, - lastevent: 'called', - holdtime: holdtime, - agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - } - }); - - if (users.length && onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) { - onReport(users, true); - aTimeout = setTimeout(function() { - console.log('count', count); - onReportUpdate({ - uniqueid: data.MailRoomId, - count: count, - reason: 'timeout', - lastevent: 'timeout', - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - holdtime += timeout; - j += data.MailApplications[i].MailQueue.Users.length; - onInvite(data, i, j, holdtime, ++count, done); - return; - }, timeout * 1000); - - if (!timeouts[data.MailRoomId]) { - timeouts[data.MailRoomId] = {}; - } - - timeouts[data.MailRoomId].timeout = aTimeout; - timeouts[data.MailRoomId].done = done; - - } else { - console.log('queue', data.MailApplications[i].MailQueue.name, 'timeout', timeout, 'holdtime', holdtime); - - onInvite(data, ++i, 0, 0, count, done); - return; - } - - break; - default: - console.error('Unknown strategy'); - } - } else { - onInvite(data, ++i, 0, 0, count, done); - return; - } - } else { - // AGENT APPLICATION - timeout = data.MailApplications[i].timeout; - if (data.MailApplications[i].User.online && - onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) { - onReport({ - uniqueid: data.MailRoomId, - sorting: count, - subject: data.subject, - timeslot: timeout, - from: data.from, - attachment: data.attachment, - accountname: data.name, - accountaddress: data.address, - application: data.MailApplications[i].app, - fullname: data.MailApplications[i].User.fullname, - membername: data.MailApplications[i].User.name, - agentid: data.MailApplications[i].User.id, - lastevent: 'called', - holdtime: holdtime, - agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - console.log('agent', data.MailApplications[i].User.name, 'timeout', timeout, 'holdtime', holdtime); - - aTimeout = setTimeout(function() { - onReportUpdate({ - uniqueid: data.MailRoomId, - count: count, - reason: 'timeout', - lastevent: 'timeout', - agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss") - }); - - onInvite(data, ++i, 0, 0, count, done); - return; - }, timeout * 1000); - - if (!timeouts[data.MailRoomId]) { - timeouts[data.MailRoomId] = {}; - } - - timeouts[data.MailRoomId].timeout = aTimeout; - timeouts[data.MailRoomId].done = done; - } else { - onInvite(data, ++i, 0, 0, ++count, done); - return - } - } - } - - function onReport(report, bulk) { - if (bulk) { - ReportMail - .bulkCreate(report, { - individualHooks: true - }) - .catch(function(err) { - console.error(err); - }); - } else { - ReportMail - .create(report) - .catch(function(err) { - console.error(err); - }); - } - } - - function onReportSession(report) { - - ReportMailSession - .findOrCreate({ - where: { - uniqueid: report.uniqueid - }, - defaults: report - }) - .spread(function(reportMailSession, created) { - if (!created) { - reportMailSession - .update(report, { - individualHooks: true - }) - .catch(function(err) { - console.error(err); - }); - } - }); - } - - function onReportUpdate(report) { - ReportMail - .update(report, { - where: { - uniqueid: report.uniqueid, - sorting: report.count - }, - individualHooks: true - }) - .catch(function(err) { - console.error(err); - }); - } - - function onInterval(interval) { - if (_.isObject(interval)) { - for (var i = 0; i < interval.SubIntervals.length; i++) { - if (!onCheckInterval(interval.SubIntervals[i].interval)) { - return false; - } - } - return true; - } else { - return onCheckInterval(interval); - } - } - - function onCheckInterval(interval) { - - var daysOfWeek = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; - var daysOfMonth = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]; - var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; - var i, shift; - - var tRange = interval.split(',')[0]; - var dwRange = interval.split(',')[1]; - var dmRange = interval.split(',')[2]; - var mRange = interval.split(',')[3]; - // TIME RANGE CHECKING - if (tRange !== '*') { - var time = moment().format("HH:mm"); - var tFrom = tRange.split('-')[0]; - var tTo = tRange.split('-')[1]; - - if ((time < tFrom) || (time > tTo)) { - console.log('TRANGE KO'); - return false; - } - } - // DAYS OF WEEK RANGE CHECKING - if (dwRange !== '*') { - var cWeekDay = daysOfWeek[moment().day()]; - var dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]); - var dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]); - - for (i = 0; i < dwFrom; i++) { - shift = daysOfWeek.shift(); - daysOfWeek.push(shift); - } - - dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]); - dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]) + 1; - - daysOfWeek = daysOfWeek.slice(dwFrom, dwTo); - - if (!_.includes(daysOfWeek, cWeekDay)) { - console.log('DWRANGE KO'); - return false; - } - } - // DAYS OF MONTH RANGE CHECKING - if (dmRange !== '*') { - var cMonthDay = moment().date(); - var dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10)); - var dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1])); - - for (i = 0; i < dmFrom; i++) { - shift = daysOfMonth.shift(); - daysOfMonth.push(shift); - } - - dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10)); - dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1]), 10) + 1; - - daysOfMonth = daysOfMonth.slice(dmFrom, dmTo); - - if (!_.includes(daysOfMonth, cMonthDay)) { - console.log('DMRANGE KO'); - return false; - } - } - // MONTHS RANGE CHECKING - if (mRange !== '*') { - var cMonth = months[moment().month()]; - var mFrom = _.indexOf(months, mRange.split('-')[0]); - var mTo = _.indexOf(months, mRange.split('-')[1]); - - for (i = 0; i < mFrom; i++) { - shift = months.shift(); - months.push(shift); - } - - mFrom = _.indexOf(months, mRange.split('-')[0]); - mTo = _.indexOf(months, mRange.split('-')[1]) + 1; - - months = months.slice(mFrom, mTo); - - if (!_.includes(months, cMonth)) { - console.log('MRANGE KO'); - return false; - } - } - - console.log('INTERVAL OK'); - - return true; - } +var _0x96ad=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x6F\x6D\x65\x6E\x74","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C","\x55\x73\x65\x72","\x65\x78\x70\x6F\x72\x74\x73","\x63\x72\x65\x61\x74\x65\x51\x75\x65\x75\x65","\x6D\x61\x69\x6C","\x70\x72\x6F\x63\x65\x73\x73","\x61\x67\x65\x6E\x74\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x41\x74","\x63\x68\x61\x6E\x67\x65\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x74\x69\x6D\x65\x6F\x75\x74","\x64\x6F\x6E\x65","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x61\x67\x65\x6E\x74\x69\x64","\x75\x70\x64\x61\x74\x65","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x42\x79\x49\x64","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x61\x6E\x73\x77\x65\x72\x65\x64\x5F\x65\x6C\x73\x65\x77\x68\x65\x72\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x6D\x61\x69\x6C\x71\x75\x65\x75\x65\x6E\x61\x6D\x65","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x73\x74\x61\x74\x75\x73","\x4E\x45\x57","\x73\x61\x76\x65","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x63\x72\x65\x61\x74\x65","\x4E\x6F\x20\x41\x76\x61\x69\x6C\x61\x62\x6C\x65\x20\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x44\x69\x61\x6C\x50\x6C\x61\x6E\x20\x65\x6E\x64\x65\x64\x2E\x2E","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x49\x64","\x64\x61\x74\x61","\x69\x64","\x6D\x65\x72\x67\x65","\x73\x75\x62\x6A\x65\x63\x74","\x66\x72\x6F\x6D","\x63\x63","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x6E\x61\x6D\x65","\x61\x64\x64\x72\x65\x73\x73","\x70\x72\x69\x6F\x72\x69\x74\x79","\x73\x6F\x72\x74\x42\x79","\x69\x6E\x76\x69\x74\x65","\x69","\x6A","\x68\x6F\x6C\x64\x74\x69\x6D\x65","\x6C\x6F\x67","\x74\x72\x75\x65","\x63\x6F\x75\x6E\x74\x42\x79","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x55\x73\x65\x72\x73","\x6F\x6E\x6C\x69\x6E\x65","\x61\x70\x70","\x63\x61\x6C\x6C\x65\x64","\x71\x75\x65\x75\x65","\x61\x67\x65\x6E\x74","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x63\x6F\x75\x6E\x74","\x62\x65\x65\x70\x61\x6C\x6C","\x55\x6E\x6B\x6E\x6F\x77\x6E\x20\x73\x74\x72\x61\x74\x65\x67\x79","\x73\x74\x72\x61\x74\x65\x67\x79","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x73\x70\x72\x65\x61\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x69\x73\x4F\x62\x6A\x65\x63\x74","\x53\x75\x62\x49\x6E\x74\x65\x72\x76\x61\x6C\x73","\x73\x75\x6E","\x6D\x6F\x6E","\x74\x75\x65","\x77\x65\x64","\x74\x68\x75","\x66\x72\x69","\x73\x61\x74","\x6A\x61\x6E","\x66\x65\x62","\x6D\x61\x72","\x61\x70\x72","\x6D\x61\x79","\x6A\x75\x6E","\x6A\x75\x6C","\x61\x75\x67","\x73\x65\x70","\x6F\x63\x74","\x6E\x6F\x76","\x64\x65\x63","\x2C","\x73\x70\x6C\x69\x74","\x2A","\x48\x48\x3A\x6D\x6D","\x2D","\x54\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x64\x61\x79","\x69\x6E\x64\x65\x78\x4F\x66","\x73\x68\x69\x66\x74","\x73\x6C\x69\x63\x65","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x44\x57\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x64\x61\x74\x65","\x44\x4D\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x6D\x6F\x6E\x74\x68","\x4D\x52\x41\x4E\x47\x45\x20\x4B\x4F","\x49\x4E\x54\x45\x52\x56\x41\x4C\x20\x4F\x4B"];_0x96ad[0];var _=require(_0x96ad[1]);var moment=require(_0x96ad[2]);var MailApplication=require(_0x96ad[4])[_0x96ad[3]];var MailAccount=require(_0x96ad[4])[_0x96ad[5]];var MailQueue=require(_0x96ad[4])[_0x96ad[6]];var MailRoom=require(_0x96ad[4])[_0x96ad[7]];var Interval=require(_0x96ad[4])[_0x96ad[8]];var ReportMailSession=require(_0x96ad[4])[_0x96ad[9]];var ReportMail=require(_0x96ad[4])[_0x96ad[10]];var User=require(_0x96ad[4])[_0x96ad[11]];var timeouts={};module[_0x96ad[12]]=function(_0x6f2cxc){var _0x6f2cxd=_0x6f2cxc[_0x96ad[13]]();_0x6f2cxd[_0x96ad[15]](_0x96ad[14],20,function(_0x6f2cxe,_0x6f2cxf){onProcess(_0x6f2cxe,_0x6f2cxf)});ReportMail[_0x96ad[33]](function(_0x6f2cx10){if(_0x6f2cx10[_0x96ad[17]](_0x96ad[16])){if(timeouts[_0x6f2cx10[_0x96ad[18]]]){clearTimeout(timeouts[_0x6f2cx10[_0x96ad[18]]][_0x96ad[19]]);timeouts[_0x6f2cx10[_0x96ad[18]]][_0x96ad[20]]();delete timeouts[_0x6f2cx10[_0x96ad[18]]];};MailRoom[_0x96ad[26]](_0x6f2cx10[_0x96ad[18]])[_0x96ad[25]](function(_0x6f2cx12){_0x6f2cx12[_0x96ad[24]]({UserId:_0x6f2cx10[_0x96ad[23]]})})[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)});ReportMail[_0x96ad[24]]({agentringnoanswerAt:moment()[_0x96ad[28]](_0x96ad[27]),reason:_0x96ad[29],lastevent:_0x96ad[29]},{where:{uniqueid:_0x6f2cx10[_0x96ad[18]],reason:null},individualHooks:true})[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)});ReportMailSession[_0x96ad[24]]({mailleaveAt:moment()[_0x96ad[28]](_0x96ad[27]),fullname:_0x6f2cx10[_0x96ad[30]],membername:_0x6f2cx10[_0x96ad[31]],mailqueuename:_0x6f2cx10[_0x96ad[32]]},{where:{uniqueid:_0x6f2cx10[_0x96ad[18]]},individualHooks:true})[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)});}});MailRoom[_0x96ad[34]](function(_0x6f2cx10){onSave(_0x6f2cxd,_0x6f2cx10)});MailRoom[_0x96ad[35]](function(_0x6f2cx10){onSave(_0x6f2cxd,_0x6f2cx10)});};function onSave(_0x6f2cxc,_0x6f2cx10,_0x6f2cx14){if(_0x6f2cx10[_0x96ad[36]]===_0x96ad[37]){_0x6f2cxc[_0x96ad[40]](_0x96ad[14],_0x6f2cx10[_0x96ad[39]])[_0x96ad[38]]()}}function onProcess(_0x6f2cxe,_0x6f2cxf){MailAccount[_0x96ad[26]](_0x6f2cxe[_0x96ad[46]].MailAccountId,{include:[{model:MailApplication,include:[{model:MailQueue,include:[{model:User}]},{model:User},{model:Interval,include:[{all:true}]}]}]})[_0x96ad[25]](function(_0x6f2cx16){if(!_0x6f2cx16){_0x6f2cxf( new Error(_0x96ad[41]));return ;};if(!_0x6f2cx16[_0x96ad[43]][_0x96ad[42]]){_0x6f2cxf( new Error(_0x96ad[44]));return ;};_0x6f2cxe[_0x96ad[46]][_0x96ad[45]]=_0x6f2cxe[_0x96ad[46]][_0x96ad[47]];var _0x6f2cx17=_[_0x96ad[48]](_0x6f2cxe[_0x96ad[46]],_0x6f2cx16[_0x96ad[39]]);onReportSession({uniqueid:_0x6f2cx17[_0x96ad[45]],subject:_0x6f2cx17[_0x96ad[49]],from:_0x6f2cx17[_0x96ad[50]],cc:_0x6f2cx17[_0x96ad[51]],attachment:_0x6f2cx17[_0x96ad[52]],accountname:_0x6f2cx17[_0x96ad[53]],accountaddress:_0x6f2cx17[_0x96ad[54]],mailjoinAt:moment()[_0x96ad[28]](_0x96ad[27])});_0x6f2cx17[_0x96ad[43]]=_[_0x96ad[56]](_0x6f2cx17.MailApplications,_0x96ad[55]);onInvite(_0x6f2cx17,0,0,0,0,_0x6f2cxf);})[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)})}function onInvite(_0x6f2cx19,_0x6f2cx1a,_0x6f2cx1b,_0x6f2cx1c,_0x6f2cx1d,_0x6f2cxf){console[_0x96ad[61]](_0x96ad[57],_0x96ad[58],_0x6f2cx1a,_0x96ad[59],_0x6f2cx1b,_0x96ad[60],_0x6f2cx1c);var _0x6f2cx1e=0;var _0x6f2cx1f;if(_0x6f2cx1a===_0x6f2cx19[_0x96ad[43]][_0x96ad[42]]){console[_0x96ad[21]](_0x96ad[44]);onReportSession({uniqueid:_0x6f2cx19[_0x96ad[45]],mailunmanagedAt:moment()[_0x96ad[28]](_0x96ad[27]),mailleaveAt:moment()[_0x96ad[28]](_0x96ad[27])});_0x6f2cxf( new Error(_0x96ad[44]));return ;};if(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]]){var _0x6f2cx20=_[_0x96ad[63]](_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]].Users,{online:true})[_0x96ad[62]];if(_0x6f2cx20&&onInterval(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]?_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[64]])){if(_0x6f2cx1b===_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x96ad[42]]){if(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[19]]>_0x6f2cx1c){onInvite(_0x6f2cx19,_0x6f2cx1a,0,_0x6f2cx1c,_0x6f2cx1d,_0x6f2cxf);return ;}else {onInvite(_0x6f2cx19,++_0x6f2cx1a,0,0,_0x6f2cx1d,_0x6f2cxf);return ;}};switch(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[77]]){case _0x96ad[71]:if(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x6f2cx1b][_0x96ad[66]]&&onInterval(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]?_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[64]])){_0x6f2cx1e=(((_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[19]]-_0x6f2cx1c)>_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[19]])?_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[19]]:(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[19]]-_0x6f2cx1c));onReport({uniqueid:_0x6f2cx19[_0x96ad[45]],sorting:_0x6f2cx1d,subject:_0x6f2cx19[_0x96ad[49]],timeslot:_0x6f2cx1e,from:_0x6f2cx19[_0x96ad[50]],attachment:_0x6f2cx19[_0x96ad[52]],accountname:_0x6f2cx19[_0x96ad[53]],accountaddress:_0x6f2cx19[_0x96ad[54]],application:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[67]],fullname:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x6f2cx1b][_0x96ad[30]],membername:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x6f2cx1b][_0x96ad[53]],agentid:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x6f2cx1b][_0x96ad[47]],mailqueuename:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[53]],lastevent:_0x96ad[68],holdtime:_0x6f2cx1c,agentcalledAt:moment()[_0x96ad[28]](_0x96ad[27])});console[_0x96ad[61]](_0x96ad[69],_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[53]],_0x96ad[70],_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x6f2cx1b][_0x96ad[53]],_0x96ad[19],_0x6f2cx1e,_0x96ad[60],_0x6f2cx1c);_0x6f2cx1f=setTimeout(function(){onReportUpdate({uniqueid:_0x6f2cx19[_0x96ad[45]],count:_0x6f2cx1d,reason:_0x96ad[19],lastevent:_0x96ad[19],agentringnoanswerAt:moment()[_0x96ad[28]](_0x96ad[27])});_0x6f2cx1c+=_0x6f2cx1e;onInvite(_0x6f2cx19,_0x6f2cx1a,++_0x6f2cx1b,_0x6f2cx1c,++_0x6f2cx1d,_0x6f2cxf);return ;},_0x6f2cx1e*1000);if(!timeouts[_0x6f2cx19[_0x96ad[45]]]){timeouts[_0x6f2cx19[_0x96ad[45]]]={}};timeouts[_0x6f2cx19[_0x96ad[45]]][_0x96ad[19]]=_0x6f2cx1f;timeouts[_0x6f2cx19[_0x96ad[45]]][_0x96ad[20]]=_0x6f2cxf;}else {onInvite(_0x6f2cx19,_0x6f2cx1a,++_0x6f2cx1b,_0x6f2cx1c,_0x6f2cx1d,_0x6f2cxf);return ;};break ;;case _0x96ad[75]:_0x6f2cx1e=(((_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[19]]-_0x6f2cx1c)>_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[19]])?_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[19]]:(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[19]]-_0x6f2cx1c));var _0x6f2cx21=[];_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x96ad[73]](function(_0x6f2cx22){if(_0x6f2cx22[_0x96ad[66]]){_0x6f2cx21[_0x96ad[72]]({uniqueid:_0x6f2cx19[_0x96ad[45]],sorting:_0x6f2cx1d,subject:_0x6f2cx19[_0x96ad[49]],timeslot:_0x6f2cx1e,from:_0x6f2cx19[_0x96ad[50]],attachment:_0x6f2cx19[_0x96ad[52]],accountname:_0x6f2cx19[_0x96ad[53]],accountaddress:_0x6f2cx19[_0x96ad[54]],application:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[67]],fullname:_0x6f2cx22[_0x96ad[30]],membername:_0x6f2cx22[_0x96ad[53]],agentid:_0x6f2cx22[_0x96ad[47]],mailqueuename:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[53]],lastevent:_0x96ad[68],holdtime:_0x6f2cx1c,agentcalledAt:moment()[_0x96ad[28]](_0x96ad[27])})}});if(_0x6f2cx21[_0x96ad[42]]&&onInterval(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]?_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[64]])){onReport(_0x6f2cx21,true);_0x6f2cx1f=setTimeout(function(){console[_0x96ad[61]](_0x96ad[74],_0x6f2cx1d);onReportUpdate({uniqueid:_0x6f2cx19[_0x96ad[45]],count:_0x6f2cx1d,reason:_0x96ad[19],lastevent:_0x96ad[19],agentringnoanswerAt:moment()[_0x96ad[28]](_0x96ad[27])});_0x6f2cx1c+=_0x6f2cx1e;_0x6f2cx1b+=_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[65]][_0x96ad[42]];onInvite(_0x6f2cx19,_0x6f2cx1a,_0x6f2cx1b,_0x6f2cx1c,++_0x6f2cx1d,_0x6f2cxf);return ;},_0x6f2cx1e*1000);if(!timeouts[_0x6f2cx19[_0x96ad[45]]]){timeouts[_0x6f2cx19[_0x96ad[45]]]={}};timeouts[_0x6f2cx19[_0x96ad[45]]][_0x96ad[19]]=_0x6f2cx1f;timeouts[_0x6f2cx19[_0x96ad[45]]][_0x96ad[20]]=_0x6f2cxf;}else {console[_0x96ad[61]](_0x96ad[69],_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[6]][_0x96ad[53]],_0x96ad[19],_0x6f2cx1e,_0x96ad[60],_0x6f2cx1c);onInvite(_0x6f2cx19,++_0x6f2cx1a,0,0,_0x6f2cx1d,_0x6f2cxf);return ;};break ;;default:console[_0x96ad[21]](_0x96ad[76]);;};}else {onInvite(_0x6f2cx19,++_0x6f2cx1a,0,0,_0x6f2cx1d,_0x6f2cxf);return ;};}else {_0x6f2cx1e=_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[19]];if(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[11]][_0x96ad[66]]&&onInterval(_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]?_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[8]]:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[64]])){onReport({uniqueid:_0x6f2cx19[_0x96ad[45]],sorting:_0x6f2cx1d,subject:_0x6f2cx19[_0x96ad[49]],timeslot:_0x6f2cx1e,from:_0x6f2cx19[_0x96ad[50]],attachment:_0x6f2cx19[_0x96ad[52]],accountname:_0x6f2cx19[_0x96ad[53]],accountaddress:_0x6f2cx19[_0x96ad[54]],application:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[67]],fullname:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[11]][_0x96ad[30]],membername:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[11]][_0x96ad[53]],agentid:_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[11]][_0x96ad[47]],lastevent:_0x96ad[68],holdtime:_0x6f2cx1c,agentcalledAt:moment()[_0x96ad[28]](_0x96ad[27])});console[_0x96ad[61]](_0x96ad[70],_0x6f2cx19[_0x96ad[43]][_0x6f2cx1a][_0x96ad[11]][_0x96ad[53]],_0x96ad[19],_0x6f2cx1e,_0x96ad[60],_0x6f2cx1c);_0x6f2cx1f=setTimeout(function(){onReportUpdate({uniqueid:_0x6f2cx19[_0x96ad[45]],count:_0x6f2cx1d,reason:_0x96ad[19],lastevent:_0x96ad[19],agentringnoanswerAt:moment()[_0x96ad[28]](_0x96ad[27])});onInvite(_0x6f2cx19,++_0x6f2cx1a,0,0,_0x6f2cx1d,_0x6f2cxf);return ;},_0x6f2cx1e*1000);if(!timeouts[_0x6f2cx19[_0x96ad[45]]]){timeouts[_0x6f2cx19[_0x96ad[45]]]={}};timeouts[_0x6f2cx19[_0x96ad[45]]][_0x96ad[19]]=_0x6f2cx1f;timeouts[_0x6f2cx19[_0x96ad[45]]][_0x96ad[20]]=_0x6f2cxf;}else {onInvite(_0x6f2cx19,++_0x6f2cx1a,0,0,++_0x6f2cx1d,_0x6f2cxf);return ;};};}function onReport(_0x6f2cx24,_0x6f2cx25){if(_0x6f2cx25){ReportMail[_0x96ad[78]](_0x6f2cx24,{individualHooks:true})[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)})}else {ReportMail[_0x96ad[40]](_0x6f2cx24)[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)})}}function onReportSession(_0x6f2cx24){ReportMailSession[_0x96ad[80]]({where:{uniqueid:_0x6f2cx24[_0x96ad[18]]},defaults:_0x6f2cx24})[_0x96ad[79]](function(_0x6f2cx27,_0x6f2cx28){if(!_0x6f2cx28){_0x6f2cx27[_0x96ad[24]](_0x6f2cx24,{individualHooks:true})[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)})}})}function onReportUpdate(_0x6f2cx24){ReportMail[_0x96ad[24]](_0x6f2cx24,{where:{uniqueid:_0x6f2cx24[_0x96ad[18]],sorting:_0x6f2cx24[_0x96ad[74]]},individualHooks:true})[_0x96ad[22]](function(_0x6f2cx11){console[_0x96ad[21]](_0x6f2cx11)})}function onInterval(_0x6f2cx2b){if(_[_0x96ad[81]](_0x6f2cx2b)){for(var _0x6f2cx1a=0;_0x6f2cx1a<_0x6f2cx2b[_0x96ad[82]][_0x96ad[42]];_0x6f2cx1a++){if(!onCheckInterval(_0x6f2cx2b[_0x96ad[82]][_0x6f2cx1a][_0x96ad[64]])){return false}};return true;}else {return onCheckInterval(_0x6f2cx2b)}}function onCheckInterval(_0x6f2cx2b){var _0x6f2cx2d=[_0x96ad[83],_0x96ad[84],_0x96ad[85],_0x96ad[86],_0x96ad[87],_0x96ad[88],_0x96ad[89]];var _0x6f2cx2e=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];var _0x6f2cx2f=[_0x96ad[90],_0x96ad[91],_0x96ad[92],_0x96ad[93],_0x96ad[94],_0x96ad[95],_0x96ad[96],_0x96ad[97],_0x96ad[98],_0x96ad[99],_0x96ad[100],_0x96ad[101]];var _0x6f2cx1a,_0x6f2cx30;var _0x6f2cx31=_0x6f2cx2b[_0x96ad[103]](_0x96ad[102])[0];var _0x6f2cx32=_0x6f2cx2b[_0x96ad[103]](_0x96ad[102])[1];var _0x6f2cx33=_0x6f2cx2b[_0x96ad[103]](_0x96ad[102])[2];var _0x6f2cx34=_0x6f2cx2b[_0x96ad[103]](_0x96ad[102])[3];if(_0x6f2cx31!==_0x96ad[104]){var _0x6f2cx35=moment()[_0x96ad[28]](_0x96ad[105]);var _0x6f2cx36=_0x6f2cx31[_0x96ad[103]](_0x96ad[106])[0];var _0x6f2cx37=_0x6f2cx31[_0x96ad[103]](_0x96ad[106])[1];if((_0x6f2cx35<_0x6f2cx36)||(_0x6f2cx35>_0x6f2cx37)){console[_0x96ad[61]](_0x96ad[107]);return false;};};if(_0x6f2cx32!==_0x96ad[104]){var _0x6f2cx38=_0x6f2cx2d[moment()[_0x96ad[108]]()];var _0x6f2cx39=_[_0x96ad[109]](_0x6f2cx2d,_0x6f2cx32[_0x96ad[103]](_0x96ad[106])[0]);var _0x6f2cx3a=_[_0x96ad[109]](_0x6f2cx2d,_0x6f2cx32[_0x96ad[103]](_0x96ad[106])[1]);for(_0x6f2cx1a=0;_0x6f2cx1a<_0x6f2cx39;_0x6f2cx1a++){_0x6f2cx30=_0x6f2cx2d[_0x96ad[110]]();_0x6f2cx2d[_0x96ad[72]](_0x6f2cx30);};_0x6f2cx39=_[_0x96ad[109]](_0x6f2cx2d,_0x6f2cx32[_0x96ad[103]](_0x96ad[106])[0]);_0x6f2cx3a=_[_0x96ad[109]](_0x6f2cx2d,_0x6f2cx32[_0x96ad[103]](_0x96ad[106])[1])+1;_0x6f2cx2d=_0x6f2cx2d[_0x96ad[111]](_0x6f2cx39,_0x6f2cx3a);if(!_[_0x96ad[112]](_0x6f2cx2d,_0x6f2cx38)){console[_0x96ad[61]](_0x96ad[113]);return false;};};if(_0x6f2cx33!==_0x96ad[104]){var _0x6f2cx3b=moment()[_0x96ad[114]]();var _0x6f2cx3c=_[_0x96ad[109]](_0x6f2cx2e,parseInt(_0x6f2cx33[_0x96ad[103]](_0x96ad[106])[0],10));var _0x6f2cx3d=_[_0x96ad[109]](_0x6f2cx2e,parseInt(_0x6f2cx33[_0x96ad[103]](_0x96ad[106])[1]));for(_0x6f2cx1a=0;_0x6f2cx1a<_0x6f2cx3c;_0x6f2cx1a++){_0x6f2cx30=_0x6f2cx2e[_0x96ad[110]]();_0x6f2cx2e[_0x96ad[72]](_0x6f2cx30);};_0x6f2cx3c=_[_0x96ad[109]](_0x6f2cx2e,parseInt(_0x6f2cx33[_0x96ad[103]](_0x96ad[106])[0],10));_0x6f2cx3d=_[_0x96ad[109]](_0x6f2cx2e,parseInt(_0x6f2cx33[_0x96ad[103]](_0x96ad[106])[1]),10)+1;_0x6f2cx2e=_0x6f2cx2e[_0x96ad[111]](_0x6f2cx3c,_0x6f2cx3d);if(!_[_0x96ad[112]](_0x6f2cx2e,_0x6f2cx3b)){console[_0x96ad[61]](_0x96ad[115]);return false;};};if(_0x6f2cx34!==_0x96ad[104]){var _0x6f2cx3e=_0x6f2cx2f[moment()[_0x96ad[116]]()];var _0x6f2cx3f=_[_0x96ad[109]](_0x6f2cx2f,_0x6f2cx34[_0x96ad[103]](_0x96ad[106])[0]);var _0x6f2cx40=_[_0x96ad[109]](_0x6f2cx2f,_0x6f2cx34[_0x96ad[103]](_0x96ad[106])[1]);for(_0x6f2cx1a=0;_0x6f2cx1a<_0x6f2cx3f;_0x6f2cx1a++){_0x6f2cx30=_0x6f2cx2f[_0x96ad[110]]();_0x6f2cx2f[_0x96ad[72]](_0x6f2cx30);};_0x6f2cx3f=_[_0x96ad[109]](_0x6f2cx2f,_0x6f2cx34[_0x96ad[103]](_0x96ad[106])[0]);_0x6f2cx40=_[_0x96ad[109]](_0x6f2cx2f,_0x6f2cx34[_0x96ad[103]](_0x96ad[106])[1])+1;_0x6f2cx2f=_0x6f2cx2f[_0x96ad[111]](_0x6f2cx3f,_0x6f2cx40);if(!_[_0x96ad[112]](_0x6f2cx2f,_0x6f2cx3e)){console[_0x96ad[61]](_0x96ad[117]);return false;};};console[_0x96ad[61]](_0x96ad[118]);return true;} \ No newline at end of file diff --git a/server/config/local.env.sample.js b/server/config/local.env.sample.js index 58ae668..7c2b260 100644 --- a/server/config/local.env.sample.js +++ b/server/config/local.env.sample.js @@ -1,23 +1 @@ -'use strict'; - -// Use local.env.js for environment variables that grunt will set when the server starts locally. -// Use for your api keys, secrets, etc. This file should not be tracked by git. -// -// You will need to set these on the server you deploy to. - -module.exports = { - DOMAIN: 'http://localhost:9000', - SESSION_SECRET: 'xcallyshuttle-secret', - - FACEBOOK_ID: 'app-id', - FACEBOOK_SECRET: 'secret', - - TWITTER_ID: 'app-id', - TWITTER_SECRET: 'secret', - - GOOGLE_ID: 'app-id', - GOOGLE_SECRET: 'secret', - - // Control debug level for modules using visionmedia/debug - DEBUG: '' -}; +var _0xca9e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x68\x74\x74\x70\x3A\x2F\x2F\x6C\x6F\x63\x61\x6C\x68\x6F\x73\x74\x3A\x39\x30\x30\x30","\x78\x63\x61\x6C\x6C\x79\x73\x68\x75\x74\x74\x6C\x65\x2D\x73\x65\x63\x72\x65\x74","\x61\x70\x70\x2D\x69\x64","\x73\x65\x63\x72\x65\x74",""];_0xca9e[0];module[_0xca9e[1]]={DOMAIN:_0xca9e[2],SESSION_SECRET:_0xca9e[3],FACEBOOK_ID:_0xca9e[4],FACEBOOK_SECRET:_0xca9e[5],TWITTER_ID:_0xca9e[4],TWITTER_SECRET:_0xca9e[5],GOOGLE_ID:_0xca9e[4],GOOGLE_SECRET:_0xca9e[5],DEBUG:_0xca9e[6]}; \ No newline at end of file diff --git a/server/config/logger.js b/server/config/logger.js index 1542f7e..2235a58 100644 --- a/server/config/logger.js +++ b/server/config/logger.js @@ -1,120 +1 @@ -var winston = require('winston'); -var path = require('path'); -var config = require('./environment'); - -winston.emitErrs = true; - -var debug = new winston.Logger({ - transports: [ - new winston.transports.Console({ - level: 'debug', - handleExceptions: true, - json: false, - colorize: true - }) - ] -}); - -if (config.logging.debugToFile) { - debug.add( - winston.transports.File, { - name: 'debug-file', - level: 'debug', - filename: config.logging.debug, - handleExceptions: true, - json: true, - maxsize: 5242880, //5MB - maxFiles: 5, - colorize: false - } - ); -} - -var info = new winston.Logger({ - transports: [ - new winston.transports.File({ - name: 'info-file', - level: 'info', - filename: config.logging.info, - handleExceptions: true, - json: true, - maxsize: 5242880, //5MB - maxFiles: 5, - colorize: false - }), - new winston.transports.Console({ - level: 'info', - handleExceptions: true, - json: false, - colorize: true - }) - ] -}); - -var warn = new winston.Logger({ - transports: [ - new winston.transports.File({ - name: 'warn-file', - level: 'warn', - filename: config.logging.warn, - handleExceptions: true, - json: true, - maxsize: 5242880, //5MB - maxFiles: 5, - colorize: false - }), - new winston.transports.Console({ - level: 'warn', - handleExceptions: true, - json: false, - colorize: true - }) - ] -}); - -var error = new winston.Logger({ - transports: [ - new winston.transports.File({ - name: 'error-file', - level: 'error', - filename: config.logging.error, - handleExceptions: true, - json: true, - maxsize: 5242880, //5MB - maxFiles: 5, - colorize: false - }), - new winston.transports.Console({ - level: 'error', - handleExceptions: true, - json: false, - colorize: true - }) - ] -}); - -var loggers = { - debug: function(msg, callback) { - debug.debug(msg, callback); - }, - info: function(msg, callback) { - info.info(msg, callback); - }, - warn: function(msg, callback) { - warn.warn(msg, callback); - }, - error: function(msg, callback) { - error.error(msg, callback); - }, - log: function(level, msg, callback) { - var lvl = exports[level]; - lvl(msg, callback); - } -}; - -module.exports = loggers; -module.exports.stream = { - write: function(message, encoding) { - loggers.info(message); - } -}; +var _0xe967=["\x77\x69\x6E\x73\x74\x6F\x6E","\x70\x61\x74\x68","\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x65\x6D\x69\x74\x45\x72\x72\x73","\x64\x65\x62\x75\x67","\x74\x72\x61\x6E\x73\x70\x6F\x72\x74\x73","\x64\x65\x62\x75\x67\x54\x6F\x46\x69\x6C\x65","\x6C\x6F\x67\x67\x69\x6E\x67","\x64\x65\x62\x75\x67\x2D\x66\x69\x6C\x65","\x61\x64\x64","\x69\x6E\x66\x6F\x2D\x66\x69\x6C\x65","\x69\x6E\x66\x6F","\x77\x61\x72\x6E\x2D\x66\x69\x6C\x65","\x77\x61\x72\x6E","\x65\x72\x72\x6F\x72\x2D\x66\x69\x6C\x65","\x65\x72\x72\x6F\x72","\x65\x78\x70\x6F\x72\x74\x73","\x73\x74\x72\x65\x61\x6D"];var winston=require(_0xe967[0]);var path=require(_0xe967[1]);var config=require(_0xe967[2]);winston[_0xe967[3]]=true;var debug= new winston.Logger({transports:[ new winston[_0xe967[5]].Console({level:_0xe967[4],handleExceptions:true,json:false,colorize:true})]});if(config[_0xe967[7]][_0xe967[6]]){debug[_0xe967[9]](winston[_0xe967[5]].File,{name:_0xe967[8],level:_0xe967[4],filename:config[_0xe967[7]][_0xe967[4]],handleExceptions:true,json:true,maxsize:5242880,maxFiles:5,colorize:false})};var info= new winston.Logger({transports:[ new winston[_0xe967[5]].File({name:_0xe967[10],level:_0xe967[11],filename:config[_0xe967[7]][_0xe967[11]],handleExceptions:true,json:true,maxsize:5242880,maxFiles:5,colorize:false}), new winston[_0xe967[5]].Console({level:_0xe967[11],handleExceptions:true,json:false,colorize:true})]});var warn= new winston.Logger({transports:[ new winston[_0xe967[5]].File({name:_0xe967[12],level:_0xe967[13],filename:config[_0xe967[7]][_0xe967[13]],handleExceptions:true,json:true,maxsize:5242880,maxFiles:5,colorize:false}), new winston[_0xe967[5]].Console({level:_0xe967[13],handleExceptions:true,json:false,colorize:true})]});var error= new winston.Logger({transports:[ new winston[_0xe967[5]].File({name:_0xe967[14],level:_0xe967[15],filename:config[_0xe967[7]][_0xe967[15]],handleExceptions:true,json:true,maxsize:5242880,maxFiles:5,colorize:false}), new winston[_0xe967[5]].Console({level:_0xe967[15],handleExceptions:true,json:false,colorize:true})]});var loggers={debug:function(_0x3c4cx9,_0x3c4cxa){debug[_0xe967[4]](_0x3c4cx9,_0x3c4cxa)},info:function(_0x3c4cx9,_0x3c4cxa){info[_0xe967[11]](_0x3c4cx9,_0x3c4cxa)},warn:function(_0x3c4cx9,_0x3c4cxa){warn[_0xe967[13]](_0x3c4cx9,_0x3c4cxa)},error:function(_0x3c4cx9,_0x3c4cxa){error[_0xe967[15]](_0x3c4cx9,_0x3c4cxa)},log:function(_0x3c4cxb,_0x3c4cx9,_0x3c4cxa){var _0x3c4cxc=exports[_0x3c4cxb];_0x3c4cxc(_0x3c4cx9,_0x3c4cxa);}};module[_0xe967[16]]=loggers;module[_0xe967[16]][_0xe967[17]]={write:function(_0x3c4cxd,_0x3c4cxe){loggers[_0xe967[11]](_0x3c4cxd)}}; \ No newline at end of file diff --git a/server/config/seed.js b/server/config/seed.js index becaf69..6f58d59 100644 --- a/server/config/seed.js +++ b/server/config/seed.js @@ -1,1072 +1 @@ -/** - * Populate DB with sample data on server start - * to disable, edit config/environment/index.js, and set `seedDB: false` - */ - -'use strict'; - -var _ = require('lodash'); -var models = require('../models'); - -models.User - .bulkCreate([{ - provider: 'local', - role: 'agent', - fullname: 'Giuseppe Careri', - email: 'giuseppe.careri@xcally.com', - name: 'giuseppe.careri', - password: '75xcally75', - defaultuser: 'giuseppe.careri', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1000 - }, { - provider: 'local', - role: 'agent', - fullname: 'Daniele Cinti', - email: 'daniele.cinti@xcally.com', - name: 'daniele.cinti', - password: '75xcally75', - defaultuser: 'daniele.cinti', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1001 - }, { - provider: 'local', - role: 'agent', - fullname: 'Andrea Bianco', - email: 'andrea.bianco@xcally.com', - name: 'andrea.bianco', - password: '75xcally75', - defaultuser: 'andrea.bianco', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1002 - }, { - provider: 'local', - role: 'agent', - fullname: 'Massimiliano Bungaro', - email: 'massimiliano.bungaro@xcally.com', - name: 'massimiliano.bungaro', - password: '75xcally75', - defaultuser: 'massimiliano.bungaro', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1003 - }, { - provider: 'local', - role: 'agent', - fullname: 'Valerio Ciotta', - email: 'valerio.ciotta@xcally.com', - name: 'valerio.ciotta', - password: '75xcally75', - defaultuser: 'valerio.ciotta', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1004 - }, { - provider: 'local', - role: 'admin', - fullname: 'Clarotech', - email: 'clarotech@xcally.com', - name: 'clarotech', - password: 'clarotech', - defaultuser: 'clarotech', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1005 - }, { - provider: 'local', - role: 'agent', - fullname: 'Abigael', - email: 'abigael@xcally.com', - name: 'abigael', - password: '75xcally75', - defaultuser: 'abigael', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1006 - }, { - provider: 'local', - role: 'agent', - fullname: 'Tony Russell', - email: 'tonyr@xclarotech.co.za', - name: 'tony.russell', - password: 'clarotech', - defaultuser: 'tony.russell', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1007 - }, { - provider: 'local', - role: 'agent', - fullname: 'Colin Fair', - email: 'colinf@xclarotech.co.za', - name: 'colin.fair', - password: 'clarotech', - defaultuser: 'colin.fair', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1008 - }, { - provider: 'local', - role: 'agent', - fullname: 'Diego Gosmar', - email: 'diego.gosmar@xcally.com', - name: 'diego.gosmar', - password: '75xcally75', - defaultuser: 'diego.gosmar', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1009 - }, { - provider: 'local', - role: 'agent', - fullname: 'Giuseppe Innamorato', - email: 'giuseppe.innamorato@xcally.com', - name: 'giuseppe.innamorato', - password: '75xcally75', - defaultuser: 'giuseppe.innamorato', - host: 'dynamic', - type: 'FRIEND', - transport: 'upd', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1010 - }, { - provider: 'local', - role: 'agent', - fullname: 'Alessandra Bessone', - email: 'alessandra.bessone@xcally.com', - name: 'alessandra.bessone', - password: '75xcally75', - defaultuser: 'alessandra.bessone', - host: 'dynamic', - type: 'FRIEND', - transport: 'upd', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1011 - }, { - provider: 'local', - role: 'agent', - fullname: 'Felice Briscese', - email: 'felice.briscese@xcally.com', - name: 'felice.briscese', - password: '75xcally75', - defaultuser: 'felice.briscese', - host: 'dynamic', - type: 'FRIEND', - transport: 'upd', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1012 - }, { - provider: 'local', - role: 'admin', - fullname: 'xCally', - email: 'info.xcally@xcally.com', - name: 'xcally', - password: '388xshuttle388', - defaultuser: 'xcally', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1013 - }, { - provider: 'local', - role: 'agent', - fullname: 'John Doe', - email: 'john.doe@gmail.com', - name: 'john.doe', - password: '75xcally75', - defaultuser: 'john.doe', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1014 - }, { - provider: 'local', - role: 'agent', - fullname: 'Jane Miller', - email: 'jane.miller@gmail.com', - name: 'jane.miller', - password: '75xcally75', - defaultuser: 'jane.miller', - host: 'dynamic', - type: 'FRIEND', - transport: 'udp', - allow: 'alaw;ulaw;gsm', - qualify: 'yes', - nat: 'force_rport,comedia', - disallow: 'all', - context: 'from-sip', - internal: 1015 - }], { - ignoreDuplicates: true, - individualHooks: true - }).then(function() { - console.log('Finished populating users'); - }); - -models.Trunk - .bulkCreate([{ - name: 'citalia', - type: 'friend', - insecure: 'port,invite', - defaultuser: '01119827770', - secret: 'T!NPnv-qjCMe9v', - password: 'T!NPnv-qjCMe9v', - context: 'from-voip-provider', - language: 'it', - host: 'voip.eutelia.it', - fromdomain: 'voip.eutelia.it', - dtmfmode: 'rfc2833', - qualify: 'yes', - nat: 'force_rport,comedia', - callerid: ' "" <>', - limitonpeers: 'yes', - callcounter: 'yes', - disallow: 'all', - allow: 'ulaw;alaw;gsm', - canreinvite: 'no', - directmedia: 'no' - }], { - ignoreDuplicates: true, - individualHooks: true - }).then(function() { - console.log('Finished populating trunks'); - }); - - -// Init modules table -models.Module - .bulkCreate([{ - name: "dashboard", - title: "APPLICATION_DASHBOARD" - }, { - name: "users", - title: "APPLICATION_USERS" - }, { - name: "agents", - title: "APPLICATION_AGENTS" - }, { - name: "teams", - title: "APPLICATION_TEAMS" - }, { - name: "chat", - title: "APPLICATION_CHAT" - }, { - name: "voice", - title: "APPLICATION_VOICE" - }, { - name: "mail", - title: "APPLICATION_MAIL" - }, { - name: "fax", - title: "APPLICATION_FAX" - }, { - name: "audio", - title: "APPLICATION_AUDIO" - }, { - name: "callysquare", - title: "APPLICATION_CALLYSQUARE" - }, { - name: "analytics", - title: "APPLICATION_ANALYTICS" - }, { - name: "realtime", - title: "APPLICATION_REALTIME" - }, { - name: "voicemails", - title: "APPLICATION_VOICEMAILS" - }, { - name: "settings", - title: "APPLICATION_SETTINGS" - }], { - ignoreDuplicates: true - }).then(function() { - console.log('Finished populating modules'); - }); - -models.Team - .create({ - name: "T1", - description: "Default Team", - defaultEntry: true - }) - .then(function(team) { - - models.User - .findAll({ - where: { - role: 'agent' - } - }) - .then(function(users) { - team - .addUsers(_.pluck(users, 'id')) - .then(function() { - models.ChatQueue - .create({ - name: "CQ1", - description: "CQ1 Desc", - timeout: 5, - strategy: "rrmemory" - }) - .then(function(chatQueue) { - console.log('Finished populating chat queue 1'); - - models.Team - .findOne({ - where: { - name: 'T1' - }, - include: [{ - all: true - }] - }) - .then(function(team) { - chatQueue - .addUsers(_.pluck(team.Users, 'id')) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }); - - models.MailQueue - .create({ - name: "MQ1", - description: "MQ1 Desc", - timeout: 5, - strategy: "rrmemory" - }) - .then(function(mailQueue) { - console.log('Finished populating mail queue 1'); - - models.Team - .findOne({ - where: { - name: 'T1' - }, - include: [{ - all: true - }] - }) - .then(function(team) { - if (team) { - console.log('team found'); - } else { - console.log('test'); - } - mailQueue - .addUsers(_.pluck(team.Users, 'id')) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }); - - models.FaxQueue - .create({ - name: "FQ1", - description: "FQ1 Desc", - timeout: 5, - strategy: "rrmemory" - }) - .then(function(faxQueue) { - console.log('Finished populating fax queue 1'); - - models.Team - .findOne({ - where: { - name: 'T1' - }, - include: [{ - all: true - }] - }) - .then(function(team) { - faxQueue - .addUsers(_.pluck(team.Users, 'id')) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - -models.MailAccount - .create({ - name: "xCally Development", - description: "xCally Development", - address: "development@xcally.com" - }) - .then(function(mailAccount) { - console.log('Finished populating mail account'); - models.MailServerIn - .create({ - description: 'xcally', - host: 'imap.xcally.com', - username: 'development@xcally.com', - password: 'phokucloka', - port: 143, - mailbox: 'INBOX', - ssl: false, - delete: false, - filter: 'UNSEEN', - protocol: 'IMAP', - MailAccountId: mailAccount.id - }) - .then(function() { - console.log('Finished populating mail server in'); - models.MailServerOut - .create({ - description: 'xcally', - host: 'smtp.xcally.com', - username: 'development@xcally.com', - password: 'phokucloka', - port: 587, - ssl: false, - MailAccountId: mailAccount.id - }) - .then(function() { - console.log('Finished populating mail server out'); - }) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }); - -models.FaxAccount - .create({ - description: 'FA1 Desc', - name: 'FA1', - phone: '01119827770', - ecm: true, - faxheader: 'xCALLY', - localid: '01119827770', - maxrate: '9600', - minrate: '14400', - }) - .then(function(faxAccount) { - console.log('Finished populating fax account'); - - models.Trunk - .findOne({ - where: { - name: 'citalia' - } - }) - .then(function(trunk) { - faxAccount - .setTrunk(trunk) - .catch(function(err) { - // console.error(err); - }); - - - models.VoiceExtension - .create({ - context: 'from-voip-provider', - exten: '01119827770', - priority: 1, - app: 'Goto', - appdata: 'inbound-fax,s,1', - type: 'inbound-fax', - TrunkId: trunk.id - }) - - }) - .catch(function(err) { - // console.error(err); - }); - - models.FaxQueue - .findAll() - .then(function(faxQueues) { - models.FaxApplication - .create({ - app: 'queue', - appdata: faxQueues[0].id, - priority: 1, - timeout: 30, - FaxAccountId: faxAccount.id, - FaxQueueId: faxQueues[0].id - }) - .then(function() { - console.log('Finished populating chat website application 1'); - }) - .catch(function(err) { - // console.error(err); - }); - - models.FaxApplication - .create({ - app: 'queue', - appdata: faxQueues[1].id, - priority: 2, - timeout: 30, - FaxAccountId: faxAccount.id, - FaxQueueId: faxQueues[1].id - }) - .then(function() { - console.log('Finished populating chat website application 2'); - }) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - -models.VoiceExtension - .bulkCreate([{ - context: 'outbound-fax', - exten: 's', - priority: 1, - app: 'NoOp', - appdata: 'Fax UUID: ${FAXUUID}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 2, - app: 'UserEvent', - appdata: 'Fax,uuid: ${FAXUUID}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 3, - app: 'Set', - appdata: 'FAXOPT(filename):${FAXFILE}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 4, - app: 'Set', - appdata: 'FAXOPT(ecm):${ECM}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 5, - app: 'Set', - appdata: 'FAXOPT(headerinfo):${FAXHEADER}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 6, - app: 'Set', - appdata: 'FAXOPT(localstationid):${LOCALID}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 7, - app: 'Set', - appdata: 'FAXOPT(maxrate):${MAXRATE}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 8, - app: 'Set', - appdata: 'FAXOPT(minrate):${MINRATE}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 9, - app: 'SendFAX', - appdata: '${FAXFILE},d', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 's', - priority: 10, - app: 'NoOp', - appdata: 'ERROR "${TIMESTAMP}" "NO_STATUS" "NO_PAGES"', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 1, - app: 'NoOp', - appdata: 'FAXOPT(ecm) : ${FAXOPT(ecm)}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 2, - app: 'NoOp', - appdata: 'FaxStatus : ${FAXSTATUS}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 3, - app: 'NoOp', - appdata: 'FaxStatusString : ${FAXSTATUSSTRING}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 4, - app: 'NoOp', - appdata: 'FaxError : ${FAXERROR}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 5, - app: 'NoOp', - appdata: 'RemoteStationID : ${REMOTESTATIONID}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 6, - app: 'NoOp', - appdata: 'FaxPages : ${FAXPAGES}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 7, - app: 'NoOp', - appdata: 'FaxBitRate : ${FAXBITRATE}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 8, - app: 'NoOp', - appdata: 'FaxResolution : ${FAXRESOLUTION}', - type: 'outbound-fax' - }, { - context: 'outbound-fax', - exten: 'h', - priority: 9, - app: 'NoOp', - appdata: 'OK "${TIMESTAMP}" "${FAXSTATUSSTRING}" "${FAXPAGES}"', - type: 'outbound-fax' - }], { - ignoreDuplicates: true - }) - .then(function() { - console.log('Finished populating fax outbound voice extension'); - }); - -models.VoiceExtension - .bulkCreate([{ - context: 'inbound-fax', - exten: 's', - priority: 1, - app: 'NoOp', - appdata: '**** FAX RECEIVED from ${CALLERID(num)} ${STRFTIME(${EPOCH},,%c)} ****', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 2, - app: 'Set', - appdata: 'FAXOPT(ecm):yes', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 3, - app: 'Set', - appdata: 'FILENAME:${UNIQUEID}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 4, - app: 'Set', - appdata: 'FAXFILE:${FILENAME}.tif', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 5, - app: 'Set', - appdata: 'FAXOPT(headerinfo):Received by XeniaLAB ${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M)}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 6, - app: 'Set', - appdata: 'FAXOPT(localstationid):${LOCALID}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 7, - app: 'Set', - appdata: 'FAXOPT(maxrate):${MAXRATE}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 8, - app: 'Set', - appdata: 'FAXOPT(minrate):${MINRATE}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 9, - app: 'NoOp', - appdata: 'FAXOPT(ecm) : ${FAXOPT(ecm)}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 10, - app: 'NoOp', - appdata: 'FAXOPT(headerinfo) : ${FAXOPT(headerinfo)}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 11, - app: 'NoOp', - appdata: 'FAXOPT(localstationid) : ${FAXOPT(localstationid)}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 12, - app: 'NoOp', - appdata: 'FAXOPT(maxrate) : ${FAXOPT(maxrate)}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 13, - app: 'NoOp', - appdata: 'FAXOPT(minrate) : ${FAXOPT(minrate)}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 14, - app: 'NoOp', - appdata: '**** RECEIVING FAX : ${FAXFILE} ****', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 15, - app: 'ReceiveFax', - appdata: '/tmp/${FAXFILE}', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 's', - priority: 16, - app: 'Hangup', - type: 'inbound-fax' - }, { - context: 'inbound-fax', - exten: 'h', - priority: 1, - app: 'NoOp', - appdata: 'FAXOPT(ecm) : ${FAXOPT(ecm)}', - type: 'inbound-fax' - }], { - ignoreDuplicates: true - }) - .then(function() { - console.log('Finished populating fax outbound voice extension'); - }); - -models.SquareProject - .bulkCreate([{ - name: "project1", - description: "description project" - }], { - ignoreDuplicates: true - }).then(function() { - console.log('Finished populating square projects'); - }); - -models.ChatWebsite - .create({ - name: 'xCally Shop', - description: 'xCally Shop', - address: 'http://www.xcally.com/shop/', - color: '#f51111', - color_focus: '#f51111', - color_button: '#f51111', - remote: 'http://185.43.210.57:9000', - animation: true, - header_shape: 'squared', - header_online: 'We are here!', - online_message: 'Questions? Insert your name and email address to start a live-chat with our support team.', - username_placeholder: 'Your name', - email_placeholder: 'Your email address', - start_chat_button: 'Chat', - header_offline: 'Contact us', - offline_message: "'We're not online.
It doesn't mean we're not there to help - leave your message below and we'll be in touch as soon as possible.'", - enquiry_message_placeholder: 'Your message...', - enquiry_button: 'Leave message', - download_transcript: true - }) - .then(function(chatWebsite) { - console.log('Finished populating chat website'); - models.ChatQueue - .findAll() - .then(function(chatQueues) { - models.ChatApplication - .create({ - app: 'queue', - appdata: chatQueues[0].id, - priority: 1, - timeout: 30, - ChatWebsiteId: chatWebsite.id, - ChatQueueId: chatQueues[0].id - }) - .then(function() { - console.log('Finished populating chat website application 1'); - }) - .catch(function(err) { - // console.error(err); - }); - - models.ChatApplication - .create({ - app: 'queue', - appdata: chatQueues[1].id, - priority: 2, - timeout: 30, - ChatWebsiteId: chatWebsite.id, - ChatQueueId: chatQueues[1].id - }) - .then(function() { - console.log('Finished populating chat website application 2'); - }) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - }) - .catch(function(err) { - // console.error(err); - }); - -models.Variable - .bulkCreate([{ - name: "variable1", - description: "description project" - }], { - ignoreDuplicates: true - }).then(function() { - console.log('Finished populating variables'); - }); - -models.VoiceContext - .bulkCreate([{ - name: "from-sip", - description: "Default context (DO NOT DELETE)", - defaultEntry: true - }, { - name: "from-voip-provider", - description: "Default context (DO NOT DELETE)", - defaultEntry: true - }, { - name: "inbound-fax", - description: "Default context (DO NOT DELETE)", - defaultEntry: true - }, { - name: "outbound-fax", - description: "Default context (DO NOT DELETE)", - defaultEntry: true - }], { - ignoreDuplicates: true, - individualHooks: true - }).then(function() { - console.log('Finished populating context variables'); - }); - -models.VoiceMusicOnHold - .bulkCreate([{ - name: "default", - mode: "files", - directory: 'var/lib/asterisk/moh', - sort: 'alpha', - format: 'wav', - defaultEntry: true - }], { - ignoreDuplicates: true, - individualHooks: true - }).then(function() { - console.log('Finished populating moh variables'); - }); - -models.Settings - .bulkCreate([{ - mac: '00-50-FC-A0-67-2C', - netmask: '255.255.255.0', - address: '127.0.0.1', - min_internal: 1000 - }], { - ignoreDuplicates: true, - individualHooks: true - }).then(function() { - console.log('Finished populating moh variables'); - }); - -models.Dashboard - .bulkCreate([{ - name: 'Motion Dashboard', - model: JSON.stringify({ - title: 'Motion Dashboard', - rows: [{ - columns: [{ - styleClass: 'col-md-4', - widgets: [{ - type: 'clock', - title: 'Clock', - config: { - timePattern: 'hh:mm:ss a', - datePattern: 'dddd, MMMM Do YYYY' - } - }] - }, { - styleClass: 'col-md-8', - widgets: [{ - type: 'iframe', - title: 'Iframe', - config: { - url: 'https://demo.xcally.com/shop/' - } - }] - }] - }] - }), - defaultEntry: true - }], { - ignoreDuplicates: true, - individualHooks: true - }).then(function() { - console.log('Finished populating moh variables'); - }); +var _0xe743=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x75\x73\x65\x72\x73","\x6C\x6F\x67","\x74\x68\x65\x6E","\x6C\x6F\x63\x61\x6C","\x61\x67\x65\x6E\x74","\x47\x69\x75\x73\x65\x70\x70\x65\x20\x43\x61\x72\x65\x72\x69","\x67\x69\x75\x73\x65\x70\x70\x65\x2E\x63\x61\x72\x65\x72\x69\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x67\x69\x75\x73\x65\x70\x70\x65\x2E\x63\x61\x72\x65\x72\x69","\x37\x35\x78\x63\x61\x6C\x6C\x79\x37\x35","\x64\x79\x6E\x61\x6D\x69\x63","\x46\x52\x49\x45\x4E\x44","\x75\x64\x70","\x61\x6C\x61\x77\x3B\x75\x6C\x61\x77\x3B\x67\x73\x6D","\x79\x65\x73","\x66\x6F\x72\x63\x65\x5F\x72\x70\x6F\x72\x74\x2C\x63\x6F\x6D\x65\x64\x69\x61","\x61\x6C\x6C","\x66\x72\x6F\x6D\x2D\x73\x69\x70","\x44\x61\x6E\x69\x65\x6C\x65\x20\x43\x69\x6E\x74\x69","\x64\x61\x6E\x69\x65\x6C\x65\x2E\x63\x69\x6E\x74\x69\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x64\x61\x6E\x69\x65\x6C\x65\x2E\x63\x69\x6E\x74\x69","\x41\x6E\x64\x72\x65\x61\x20\x42\x69\x61\x6E\x63\x6F","\x61\x6E\x64\x72\x65\x61\x2E\x62\x69\x61\x6E\x63\x6F\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x61\x6E\x64\x72\x65\x61\x2E\x62\x69\x61\x6E\x63\x6F","\x4D\x61\x73\x73\x69\x6D\x69\x6C\x69\x61\x6E\x6F\x20\x42\x75\x6E\x67\x61\x72\x6F","\x6D\x61\x73\x73\x69\x6D\x69\x6C\x69\x61\x6E\x6F\x2E\x62\x75\x6E\x67\x61\x72\x6F\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x6D\x61\x73\x73\x69\x6D\x69\x6C\x69\x61\x6E\x6F\x2E\x62\x75\x6E\x67\x61\x72\x6F","\x56\x61\x6C\x65\x72\x69\x6F\x20\x43\x69\x6F\x74\x74\x61","\x76\x61\x6C\x65\x72\x69\x6F\x2E\x63\x69\x6F\x74\x74\x61\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x76\x61\x6C\x65\x72\x69\x6F\x2E\x63\x69\x6F\x74\x74\x61","\x61\x64\x6D\x69\x6E","\x43\x6C\x61\x72\x6F\x74\x65\x63\x68","\x63\x6C\x61\x72\x6F\x74\x65\x63\x68\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x63\x6C\x61\x72\x6F\x74\x65\x63\x68","\x41\x62\x69\x67\x61\x65\x6C","\x61\x62\x69\x67\x61\x65\x6C\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x61\x62\x69\x67\x61\x65\x6C","\x54\x6F\x6E\x79\x20\x52\x75\x73\x73\x65\x6C\x6C","\x74\x6F\x6E\x79\x72\x40\x78\x63\x6C\x61\x72\x6F\x74\x65\x63\x68\x2E\x63\x6F\x2E\x7A\x61","\x74\x6F\x6E\x79\x2E\x72\x75\x73\x73\x65\x6C\x6C","\x43\x6F\x6C\x69\x6E\x20\x46\x61\x69\x72","\x63\x6F\x6C\x69\x6E\x66\x40\x78\x63\x6C\x61\x72\x6F\x74\x65\x63\x68\x2E\x63\x6F\x2E\x7A\x61","\x63\x6F\x6C\x69\x6E\x2E\x66\x61\x69\x72","\x44\x69\x65\x67\x6F\x20\x47\x6F\x73\x6D\x61\x72","\x64\x69\x65\x67\x6F\x2E\x67\x6F\x73\x6D\x61\x72\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x64\x69\x65\x67\x6F\x2E\x67\x6F\x73\x6D\x61\x72","\x47\x69\x75\x73\x65\x70\x70\x65\x20\x49\x6E\x6E\x61\x6D\x6F\x72\x61\x74\x6F","\x67\x69\x75\x73\x65\x70\x70\x65\x2E\x69\x6E\x6E\x61\x6D\x6F\x72\x61\x74\x6F\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x67\x69\x75\x73\x65\x70\x70\x65\x2E\x69\x6E\x6E\x61\x6D\x6F\x72\x61\x74\x6F","\x75\x70\x64","\x41\x6C\x65\x73\x73\x61\x6E\x64\x72\x61\x20\x42\x65\x73\x73\x6F\x6E\x65","\x61\x6C\x65\x73\x73\x61\x6E\x64\x72\x61\x2E\x62\x65\x73\x73\x6F\x6E\x65\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x61\x6C\x65\x73\x73\x61\x6E\x64\x72\x61\x2E\x62\x65\x73\x73\x6F\x6E\x65","\x46\x65\x6C\x69\x63\x65\x20\x42\x72\x69\x73\x63\x65\x73\x65","\x66\x65\x6C\x69\x63\x65\x2E\x62\x72\x69\x73\x63\x65\x73\x65\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x66\x65\x6C\x69\x63\x65\x2E\x62\x72\x69\x73\x63\x65\x73\x65","\x78\x43\x61\x6C\x6C\x79","\x69\x6E\x66\x6F\x2E\x78\x63\x61\x6C\x6C\x79\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x78\x63\x61\x6C\x6C\x79","\x33\x38\x38\x78\x73\x68\x75\x74\x74\x6C\x65\x33\x38\x38","\x4A\x6F\x68\x6E\x20\x44\x6F\x65","\x6A\x6F\x68\x6E\x2E\x64\x6F\x65\x40\x67\x6D\x61\x69\x6C\x2E\x63\x6F\x6D","\x6A\x6F\x68\x6E\x2E\x64\x6F\x65","\x4A\x61\x6E\x65\x20\x4D\x69\x6C\x6C\x65\x72","\x6A\x61\x6E\x65\x2E\x6D\x69\x6C\x6C\x65\x72\x40\x67\x6D\x61\x69\x6C\x2E\x63\x6F\x6D","\x6A\x61\x6E\x65\x2E\x6D\x69\x6C\x6C\x65\x72","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x55\x73\x65\x72","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x74\x72\x75\x6E\x6B\x73","\x63\x69\x74\x61\x6C\x69\x61","\x66\x72\x69\x65\x6E\x64","\x70\x6F\x72\x74\x2C\x69\x6E\x76\x69\x74\x65","\x30\x31\x31\x31\x39\x38\x32\x37\x37\x37\x30","\x54\x21\x4E\x50\x6E\x76\x2D\x71\x6A\x43\x4D\x65\x39\x76","\x66\x72\x6F\x6D\x2D\x76\x6F\x69\x70\x2D\x70\x72\x6F\x76\x69\x64\x65\x72","\x69\x74","\x76\x6F\x69\x70\x2E\x65\x75\x74\x65\x6C\x69\x61\x2E\x69\x74","\x72\x66\x63\x32\x38\x33\x33","\x20\x22\x22\x20\x3C\x3E","\x75\x6C\x61\x77\x3B\x61\x6C\x61\x77\x3B\x67\x73\x6D","\x6E\x6F","\x54\x72\x75\x6E\x6B","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x6D\x6F\x64\x75\x6C\x65\x73","\x64\x61\x73\x68\x62\x6F\x61\x72\x64","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x44\x41\x53\x48\x42\x4F\x41\x52\x44","\x75\x73\x65\x72\x73","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x55\x53\x45\x52\x53","\x61\x67\x65\x6E\x74\x73","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x41\x47\x45\x4E\x54\x53","\x74\x65\x61\x6D\x73","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x54\x45\x41\x4D\x53","\x63\x68\x61\x74","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x43\x48\x41\x54","\x76\x6F\x69\x63\x65","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x56\x4F\x49\x43\x45","\x6D\x61\x69\x6C","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x4D\x41\x49\x4C","\x66\x61\x78","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x46\x41\x58","\x61\x75\x64\x69\x6F","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x41\x55\x44\x49\x4F","\x63\x61\x6C\x6C\x79\x73\x71\x75\x61\x72\x65","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x43\x41\x4C\x4C\x59\x53\x51\x55\x41\x52\x45","\x61\x6E\x61\x6C\x79\x74\x69\x63\x73","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x41\x4E\x41\x4C\x59\x54\x49\x43\x53","\x72\x65\x61\x6C\x74\x69\x6D\x65","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x52\x45\x41\x4C\x54\x49\x4D\x45","\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x73","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x56\x4F\x49\x43\x45\x4D\x41\x49\x4C\x53","\x73\x65\x74\x74\x69\x6E\x67\x73","\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E\x5F\x53\x45\x54\x54\x49\x4E\x47\x53","\x4D\x6F\x64\x75\x6C\x65","\x63\x61\x74\x63\x68","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x63\x68\x61\x74\x20\x71\x75\x65\x75\x65\x20\x31","\x69\x64","\x70\x6C\x75\x63\x6B","\x61\x64\x64\x55\x73\x65\x72\x73","\x54\x31","\x66\x69\x6E\x64\x4F\x6E\x65","\x54\x65\x61\x6D","\x43\x51\x31","\x43\x51\x31\x20\x44\x65\x73\x63","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x63\x72\x65\x61\x74\x65","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x6D\x61\x69\x6C\x20\x71\x75\x65\x75\x65\x20\x31","\x74\x65\x61\x6D\x20\x66\x6F\x75\x6E\x64","\x74\x65\x73\x74","\x4D\x51\x31","\x4D\x51\x31\x20\x44\x65\x73\x63","\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x66\x61\x78\x20\x71\x75\x65\x75\x65\x20\x31","\x46\x51\x31","\x46\x51\x31\x20\x44\x65\x73\x63","\x46\x61\x78\x51\x75\x65\x75\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x44\x65\x66\x61\x75\x6C\x74\x20\x54\x65\x61\x6D","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x6D\x61\x69\x6C\x20\x61\x63\x63\x6F\x75\x6E\x74","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x6D\x61\x69\x6C\x20\x73\x65\x72\x76\x65\x72\x20\x69\x6E","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x6D\x61\x69\x6C\x20\x73\x65\x72\x76\x65\x72\x20\x6F\x75\x74","\x73\x6D\x74\x70\x2E\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x64\x65\x76\x65\x6C\x6F\x70\x6D\x65\x6E\x74\x40\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x70\x68\x6F\x6B\x75\x63\x6C\x6F\x6B\x61","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x69\x6D\x61\x70\x2E\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D","\x49\x4E\x42\x4F\x58","\x55\x4E\x53\x45\x45\x4E","\x49\x4D\x41\x50","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x78\x43\x61\x6C\x6C\x79\x20\x44\x65\x76\x65\x6C\x6F\x70\x6D\x65\x6E\x74","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x66\x61\x78\x20\x61\x63\x63\x6F\x75\x6E\x74","\x73\x65\x74\x54\x72\x75\x6E\x6B","\x47\x6F\x74\x6F","\x69\x6E\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78\x2C\x73\x2C\x31","\x69\x6E\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x63\x68\x61\x74\x20\x77\x65\x62\x73\x69\x74\x65\x20\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x31","\x71\x75\x65\x75\x65","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x63\x68\x61\x74\x20\x77\x65\x62\x73\x69\x74\x65\x20\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x32","\x46\x41\x31\x20\x44\x65\x73\x63","\x46\x41\x31","\x78\x43\x41\x4C\x4C\x59","\x39\x36\x30\x30","\x31\x34\x34\x30\x30","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x66\x61\x78\x20\x6F\x75\x74\x62\x6F\x75\x6E\x64\x20\x76\x6F\x69\x63\x65\x20\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x6F\x75\x74\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x73","\x4E\x6F\x4F\x70","\x46\x61\x78\x20\x55\x55\x49\x44\x3A\x20\x24\x7B\x46\x41\x58\x55\x55\x49\x44\x7D","\x55\x73\x65\x72\x45\x76\x65\x6E\x74","\x46\x61\x78\x2C\x75\x75\x69\x64\x3A\x20\x24\x7B\x46\x41\x58\x55\x55\x49\x44\x7D","\x53\x65\x74","\x46\x41\x58\x4F\x50\x54\x28\x66\x69\x6C\x65\x6E\x61\x6D\x65\x29\x3A\x24\x7B\x46\x41\x58\x46\x49\x4C\x45\x7D","\x46\x41\x58\x4F\x50\x54\x28\x65\x63\x6D\x29\x3A\x24\x7B\x45\x43\x4D\x7D","\x46\x41\x58\x4F\x50\x54\x28\x68\x65\x61\x64\x65\x72\x69\x6E\x66\x6F\x29\x3A\x24\x7B\x46\x41\x58\x48\x45\x41\x44\x45\x52\x7D","\x46\x41\x58\x4F\x50\x54\x28\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64\x29\x3A\x24\x7B\x4C\x4F\x43\x41\x4C\x49\x44\x7D","\x46\x41\x58\x4F\x50\x54\x28\x6D\x61\x78\x72\x61\x74\x65\x29\x3A\x24\x7B\x4D\x41\x58\x52\x41\x54\x45\x7D","\x46\x41\x58\x4F\x50\x54\x28\x6D\x69\x6E\x72\x61\x74\x65\x29\x3A\x24\x7B\x4D\x49\x4E\x52\x41\x54\x45\x7D","\x53\x65\x6E\x64\x46\x41\x58","\x24\x7B\x46\x41\x58\x46\x49\x4C\x45\x7D\x2C\x64","\x45\x52\x52\x4F\x52\x20\x22\x24\x7B\x54\x49\x4D\x45\x53\x54\x41\x4D\x50\x7D\x22\x20\x22\x4E\x4F\x5F\x53\x54\x41\x54\x55\x53\x22\x20\x22\x4E\x4F\x5F\x50\x41\x47\x45\x53\x22","\x68","\x46\x41\x58\x4F\x50\x54\x28\x65\x63\x6D\x29\x20\x3A\x20\x24\x7B\x46\x41\x58\x4F\x50\x54\x28\x65\x63\x6D\x29\x7D","\x46\x61\x78\x53\x74\x61\x74\x75\x73\x20\x3A\x20\x24\x7B\x46\x41\x58\x53\x54\x41\x54\x55\x53\x7D","\x46\x61\x78\x53\x74\x61\x74\x75\x73\x53\x74\x72\x69\x6E\x67\x20\x3A\x20\x24\x7B\x46\x41\x58\x53\x54\x41\x54\x55\x53\x53\x54\x52\x49\x4E\x47\x7D","\x46\x61\x78\x45\x72\x72\x6F\x72\x20\x3A\x20\x24\x7B\x46\x41\x58\x45\x52\x52\x4F\x52\x7D","\x52\x65\x6D\x6F\x74\x65\x53\x74\x61\x74\x69\x6F\x6E\x49\x44\x20\x3A\x20\x24\x7B\x52\x45\x4D\x4F\x54\x45\x53\x54\x41\x54\x49\x4F\x4E\x49\x44\x7D","\x46\x61\x78\x50\x61\x67\x65\x73\x20\x3A\x20\x24\x7B\x46\x41\x58\x50\x41\x47\x45\x53\x7D","\x46\x61\x78\x42\x69\x74\x52\x61\x74\x65\x20\x3A\x20\x24\x7B\x46\x41\x58\x42\x49\x54\x52\x41\x54\x45\x7D","\x46\x61\x78\x52\x65\x73\x6F\x6C\x75\x74\x69\x6F\x6E\x20\x3A\x20\x24\x7B\x46\x41\x58\x52\x45\x53\x4F\x4C\x55\x54\x49\x4F\x4E\x7D","\x4F\x4B\x20\x22\x24\x7B\x54\x49\x4D\x45\x53\x54\x41\x4D\x50\x7D\x22\x20\x22\x24\x7B\x46\x41\x58\x53\x54\x41\x54\x55\x53\x53\x54\x52\x49\x4E\x47\x7D\x22\x20\x22\x24\x7B\x46\x41\x58\x50\x41\x47\x45\x53\x7D\x22","\x2A\x2A\x2A\x2A\x20\x46\x41\x58\x20\x52\x45\x43\x45\x49\x56\x45\x44\x20\x66\x72\x6F\x6D\x20\x24\x7B\x43\x41\x4C\x4C\x45\x52\x49\x44\x28\x6E\x75\x6D\x29\x7D\x20\x24\x7B\x53\x54\x52\x46\x54\x49\x4D\x45\x28\x24\x7B\x45\x50\x4F\x43\x48\x7D\x2C\x2C\x25\x63\x29\x7D\x20\x2A\x2A\x2A\x2A","\x46\x41\x58\x4F\x50\x54\x28\x65\x63\x6D\x29\x3A\x79\x65\x73","\x46\x49\x4C\x45\x4E\x41\x4D\x45\x3A\x24\x7B\x55\x4E\x49\x51\x55\x45\x49\x44\x7D","\x46\x41\x58\x46\x49\x4C\x45\x3A\x24\x7B\x46\x49\x4C\x45\x4E\x41\x4D\x45\x7D\x2E\x74\x69\x66","\x46\x41\x58\x4F\x50\x54\x28\x68\x65\x61\x64\x65\x72\x69\x6E\x66\x6F\x29\x3A\x52\x65\x63\x65\x69\x76\x65\x64\x20\x62\x79\x20\x58\x65\x6E\x69\x61\x4C\x41\x42\x20\x24\x7B\x53\x54\x52\x46\x54\x49\x4D\x45\x28\x24\x7B\x45\x50\x4F\x43\x48\x7D\x2C\x2C\x25\x59\x2D\x25\x6D\x2D\x25\x64\x20\x25\x48\x3A\x25\x4D\x29\x7D","\x46\x41\x58\x4F\x50\x54\x28\x68\x65\x61\x64\x65\x72\x69\x6E\x66\x6F\x29\x20\x3A\x20\x24\x7B\x46\x41\x58\x4F\x50\x54\x28\x68\x65\x61\x64\x65\x72\x69\x6E\x66\x6F\x29\x7D","\x46\x41\x58\x4F\x50\x54\x28\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64\x29\x20\x3A\x20\x24\x7B\x46\x41\x58\x4F\x50\x54\x28\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64\x29\x7D","\x46\x41\x58\x4F\x50\x54\x28\x6D\x61\x78\x72\x61\x74\x65\x29\x20\x3A\x20\x24\x7B\x46\x41\x58\x4F\x50\x54\x28\x6D\x61\x78\x72\x61\x74\x65\x29\x7D","\x46\x41\x58\x4F\x50\x54\x28\x6D\x69\x6E\x72\x61\x74\x65\x29\x20\x3A\x20\x24\x7B\x46\x41\x58\x4F\x50\x54\x28\x6D\x69\x6E\x72\x61\x74\x65\x29\x7D","\x2A\x2A\x2A\x2A\x20\x52\x45\x43\x45\x49\x56\x49\x4E\x47\x20\x46\x41\x58\x20\x3A\x20\x24\x7B\x46\x41\x58\x46\x49\x4C\x45\x7D\x20\x2A\x2A\x2A\x2A","\x52\x65\x63\x65\x69\x76\x65\x46\x61\x78","\x2F\x74\x6D\x70\x2F\x24\x7B\x46\x41\x58\x46\x49\x4C\x45\x7D","\x48\x61\x6E\x67\x75\x70","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x73\x71\x75\x61\x72\x65\x20\x70\x72\x6F\x6A\x65\x63\x74\x73","\x70\x72\x6F\x6A\x65\x63\x74\x31","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x20\x70\x72\x6F\x6A\x65\x63\x74","\x53\x71\x75\x61\x72\x65\x50\x72\x6F\x6A\x65\x63\x74","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x63\x68\x61\x74\x20\x77\x65\x62\x73\x69\x74\x65","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x78\x43\x61\x6C\x6C\x79\x20\x53\x68\x6F\x70","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D\x2F\x73\x68\x6F\x70\x2F","\x23\x66\x35\x31\x31\x31\x31","\x68\x74\x74\x70\x3A\x2F\x2F\x31\x38\x35\x2E\x34\x33\x2E\x32\x31\x30\x2E\x35\x37\x3A\x39\x30\x30\x30","\x73\x71\x75\x61\x72\x65\x64","\x57\x65\x20\x61\x72\x65\x20\x68\x65\x72\x65\x21","\x51\x75\x65\x73\x74\x69\x6F\x6E\x73\x3F\x20\x49\x6E\x73\x65\x72\x74\x20\x79\x6F\x75\x72\x20\x6E\x61\x6D\x65\x20\x61\x6E\x64\x20\x65\x6D\x61\x69\x6C\x20\x61\x64\x64\x72\x65\x73\x73\x20\x74\x6F\x20\x73\x74\x61\x72\x74\x20\x61\x20\x6C\x69\x76\x65\x2D\x63\x68\x61\x74\x20\x77\x69\x74\x68\x20\x6F\x75\x72\x20\x73\x75\x70\x70\x6F\x72\x74\x20\x74\x65\x61\x6D\x2E","\x59\x6F\x75\x72\x20\x6E\x61\x6D\x65","\x59\x6F\x75\x72\x20\x65\x6D\x61\x69\x6C\x20\x61\x64\x64\x72\x65\x73\x73","\x43\x68\x61\x74","\x43\x6F\x6E\x74\x61\x63\x74\x20\x75\x73","\x27\x3C\x73\x74\x72\x6F\x6E\x67\x3E\x57\x65\x27\x72\x65\x20\x6E\x6F\x74\x20\x6F\x6E\x6C\x69\x6E\x65\x2E\x3C\x2F\x73\x74\x72\x6F\x6E\x67\x3E\x3C\x62\x72\x20\x2F\x3E\x49\x74\x20\x64\x6F\x65\x73\x6E\x27\x74\x20\x6D\x65\x61\x6E\x20\x77\x65\x27\x72\x65\x20\x6E\x6F\x74\x20\x74\x68\x65\x72\x65\x20\x74\x6F\x20\x68\x65\x6C\x70\x20\x2D\x20\x6C\x65\x61\x76\x65\x20\x79\x6F\x75\x72\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x62\x65\x6C\x6F\x77\x20\x61\x6E\x64\x20\x77\x65\x27\x6C\x6C\x20\x62\x65\x20\x69\x6E\x20\x74\x6F\x75\x63\x68\x20\x61\x73\x20\x73\x6F\x6F\x6E\x20\x61\x73\x20\x70\x6F\x73\x73\x69\x62\x6C\x65\x2E\x27","\x59\x6F\x75\x72\x20\x6D\x65\x73\x73\x61\x67\x65\x2E\x2E\x2E","\x4C\x65\x61\x76\x65\x20\x6D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x76\x61\x72\x69\x61\x62\x6C\x65\x31","\x56\x61\x72\x69\x61\x62\x6C\x65","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x63\x6F\x6E\x74\x65\x78\x74\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x44\x65\x66\x61\x75\x6C\x74\x20\x63\x6F\x6E\x74\x65\x78\x74\x20\x28\x44\x4F\x20\x4E\x4F\x54\x20\x44\x45\x4C\x45\x54\x45\x29","\x56\x6F\x69\x63\x65\x43\x6F\x6E\x74\x65\x78\x74","\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x70\x6F\x70\x75\x6C\x61\x74\x69\x6E\x67\x20\x6D\x6F\x68\x20\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x64\x65\x66\x61\x75\x6C\x74","\x66\x69\x6C\x65\x73","\x76\x61\x72\x2F\x6C\x69\x62\x2F\x61\x73\x74\x65\x72\x69\x73\x6B\x2F\x6D\x6F\x68","\x61\x6C\x70\x68\x61","\x77\x61\x76","\x56\x6F\x69\x63\x65\x4D\x75\x73\x69\x63\x4F\x6E\x48\x6F\x6C\x64","\x30\x30\x2D\x35\x30\x2D\x46\x43\x2D\x41\x30\x2D\x36\x37\x2D\x32\x43","\x32\x35\x35\x2E\x32\x35\x35\x2E\x32\x35\x35\x2E\x30","\x31\x32\x37\x2E\x30\x2E\x30\x2E\x31","\x53\x65\x74\x74\x69\x6E\x67\x73","\x4D\x6F\x74\x69\x6F\x6E\x20\x44\x61\x73\x68\x62\x6F\x61\x72\x64","\x63\x6F\x6C\x2D\x6D\x64\x2D\x34","\x63\x6C\x6F\x63\x6B","\x43\x6C\x6F\x63\x6B","\x68\x68\x3A\x6D\x6D\x3A\x73\x73\x20\x61","\x64\x64\x64\x64\x2C\x20\x4D\x4D\x4D\x4D\x20\x44\x6F\x20\x59\x59\x59\x59","\x63\x6F\x6C\x2D\x6D\x64\x2D\x38","\x69\x66\x72\x61\x6D\x65","\x49\x66\x72\x61\x6D\x65","\x68\x74\x74\x70\x73\x3A\x2F\x2F\x64\x65\x6D\x6F\x2E\x78\x63\x61\x6C\x6C\x79\x2E\x63\x6F\x6D\x2F\x73\x68\x6F\x70\x2F","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x44\x61\x73\x68\x62\x6F\x61\x72\x64"];_0xe743[0];var _=require(_0xe743[1]);var models=require(_0xe743[2]);models[_0xe743[69]][_0xe743[68]]([{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[8],email:_0xe743[9],name:_0xe743[10],password:_0xe743[11],defaultuser:_0xe743[10],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1000},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[20],email:_0xe743[21],name:_0xe743[22],password:_0xe743[11],defaultuser:_0xe743[22],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1001},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[23],email:_0xe743[24],name:_0xe743[25],password:_0xe743[11],defaultuser:_0xe743[25],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1002},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[26],email:_0xe743[27],name:_0xe743[28],password:_0xe743[11],defaultuser:_0xe743[28],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1003},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[29],email:_0xe743[30],name:_0xe743[31],password:_0xe743[11],defaultuser:_0xe743[31],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1004},{provider:_0xe743[6],role:_0xe743[32],fullname:_0xe743[33],email:_0xe743[34],name:_0xe743[35],password:_0xe743[35],defaultuser:_0xe743[35],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1005},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[36],email:_0xe743[37],name:_0xe743[38],password:_0xe743[11],defaultuser:_0xe743[38],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1006},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[39],email:_0xe743[40],name:_0xe743[41],password:_0xe743[35],defaultuser:_0xe743[41],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1007},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[42],email:_0xe743[43],name:_0xe743[44],password:_0xe743[35],defaultuser:_0xe743[44],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1008},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[45],email:_0xe743[46],name:_0xe743[47],password:_0xe743[11],defaultuser:_0xe743[47],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1009},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[48],email:_0xe743[49],name:_0xe743[50],password:_0xe743[11],defaultuser:_0xe743[50],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[51],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1010},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[52],email:_0xe743[53],name:_0xe743[54],password:_0xe743[11],defaultuser:_0xe743[54],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[51],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1011},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[55],email:_0xe743[56],name:_0xe743[57],password:_0xe743[11],defaultuser:_0xe743[57],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[51],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1012},{provider:_0xe743[6],role:_0xe743[32],fullname:_0xe743[58],email:_0xe743[59],name:_0xe743[60],password:_0xe743[61],defaultuser:_0xe743[60],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1013},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[62],email:_0xe743[63],name:_0xe743[64],password:_0xe743[11],defaultuser:_0xe743[64],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1014},{provider:_0xe743[6],role:_0xe743[7],fullname:_0xe743[65],email:_0xe743[66],name:_0xe743[67],password:_0xe743[11],defaultuser:_0xe743[67],host:_0xe743[12],type:_0xe743[13],transport:_0xe743[14],allow:_0xe743[15],qualify:_0xe743[16],nat:_0xe743[17],disallow:_0xe743[18],context:_0xe743[19],internal:1015}],{ignoreDuplicates:true,individualHooks:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[3])});models[_0xe743[83]][_0xe743[68]]([{name:_0xe743[71],type:_0xe743[72],insecure:_0xe743[73],defaultuser:_0xe743[74],secret:_0xe743[75],password:_0xe743[75],context:_0xe743[76],language:_0xe743[77],host:_0xe743[78],fromdomain:_0xe743[78],dtmfmode:_0xe743[79],qualify:_0xe743[16],nat:_0xe743[17],callerid:_0xe743[80],limitonpeers:_0xe743[16],callcounter:_0xe743[16],disallow:_0xe743[18],allow:_0xe743[81],canreinvite:_0xe743[82],directmedia:_0xe743[82]}],{ignoreDuplicates:true,individualHooks:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[70])});models[_0xe743[113]][_0xe743[68]]([{name:_0xe743[85],title:_0xe743[86]},{name:_0xe743[87],title:_0xe743[88]},{name:_0xe743[89],title:_0xe743[90]},{name:_0xe743[91],title:_0xe743[92]},{name:_0xe743[93],title:_0xe743[94]},{name:_0xe743[95],title:_0xe743[96]},{name:_0xe743[97],title:_0xe743[98]},{name:_0xe743[99],title:_0xe743[100]},{name:_0xe743[101],title:_0xe743[102]},{name:_0xe743[103],title:_0xe743[104]},{name:_0xe743[105],title:_0xe743[106]},{name:_0xe743[107],title:_0xe743[108]},{name:_0xe743[109],title:_0xe743[110]},{name:_0xe743[111],title:_0xe743[112]}],{ignoreDuplicates:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[84])});models[_0xe743[121]][_0xe743[125]]({name:_0xe743[119],description:_0xe743[138],defaultEntry:true})[_0xe743[5]](function(_0xc7ddx4){models[_0xe743[69]][_0xe743[137]]({where:{role:_0xe743[7]}})[_0xe743[5]](function(_0xc7ddx5){_0xc7ddx4[_0xe743[118]](_[_0xe743[117]](_0xc7ddx5,_0xe743[116]))[_0xe743[5]](function(){models[_0xe743[126]][_0xe743[125]]({name:_0xe743[122],description:_0xe743[123],timeout:5,strategy:_0xe743[124]})[_0xe743[5]](function(_0xc7ddx6){console[_0xe743[4]](_0xe743[115]);models[_0xe743[121]][_0xe743[120]]({where:{name:_0xe743[119]},include:[{all:true}]})[_0xe743[5]](function(_0xc7ddx4){_0xc7ddx6[_0xe743[118]](_[_0xe743[117]](_0xc7ddx4.Users,_0xe743[116]))[_0xe743[114]](function(_0xc7ddx3){})})[_0xe743[114]](function(_0xc7ddx3){});});models[_0xe743[132]][_0xe743[125]]({name:_0xe743[130],description:_0xe743[131],timeout:5,strategy:_0xe743[124]})[_0xe743[5]](function(_0xc7ddx7){console[_0xe743[4]](_0xe743[127]);models[_0xe743[121]][_0xe743[120]]({where:{name:_0xe743[119]},include:[{all:true}]})[_0xe743[5]](function(_0xc7ddx4){if(_0xc7ddx4){console[_0xe743[4]](_0xe743[128])}else {console[_0xe743[4]](_0xe743[129])};_0xc7ddx7[_0xe743[118]](_[_0xe743[117]](_0xc7ddx4.Users,_0xe743[116]))[_0xe743[114]](function(_0xc7ddx3){});})[_0xe743[114]](function(_0xc7ddx3){});});models[_0xe743[136]][_0xe743[125]]({name:_0xe743[134],description:_0xe743[135],timeout:5,strategy:_0xe743[124]})[_0xe743[5]](function(_0xc7ddx8){console[_0xe743[4]](_0xe743[133]);models[_0xe743[121]][_0xe743[120]]({where:{name:_0xe743[119]},include:[{all:true}]})[_0xe743[5]](function(_0xc7ddx4){_0xc7ddx8[_0xe743[118]](_[_0xe743[117]](_0xc7ddx4.Users,_0xe743[116]))[_0xe743[114]](function(_0xc7ddx3){})})[_0xe743[114]](function(_0xc7ddx3){});});})[_0xe743[114]](function(_0xc7ddx3){})})[_0xe743[114]](function(_0xc7ddx3){})})[_0xe743[114]](function(_0xc7ddx3){});models[_0xe743[152]][_0xe743[125]]({name:_0xe743[151],description:_0xe743[151],address:_0xe743[143]})[_0xe743[5]](function(_0xc7ddx9){console[_0xe743[4]](_0xe743[139]);models[_0xe743[150]][_0xe743[125]]({description:_0xe743[60],host:_0xe743[146],username:_0xe743[143],password:_0xe743[144],port:143,mailbox:_0xe743[147],ssl:false,delete:false,filter:_0xe743[148],protocol:_0xe743[149],MailAccountId:_0xc7ddx9[_0xe743[116]]})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[140]);models[_0xe743[145]][_0xe743[125]]({description:_0xe743[60],host:_0xe743[142],username:_0xe743[143],password:_0xe743[144],port:587,ssl:false,MailAccountId:_0xc7ddx9[_0xe743[116]]})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[141])})[_0xe743[114]](function(_0xc7ddx3){});})[_0xe743[114]](function(_0xc7ddx3){});});models[_0xe743[168]][_0xe743[125]]({description:_0xe743[163],name:_0xe743[164],phone:_0xe743[74],ecm:true,faxheader:_0xe743[165],localid:_0xe743[74],maxrate:_0xe743[166],minrate:_0xe743[167]})[_0xe743[5]](function(_0xc7ddxa){console[_0xe743[4]](_0xe743[153]);models[_0xe743[83]][_0xe743[120]]({where:{name:_0xe743[71]}})[_0xe743[5]](function(_0xc7ddxb){_0xc7ddxa[_0xe743[154]](_0xc7ddxb)[_0xe743[114]](function(_0xc7ddx3){});models[_0xe743[158]][_0xe743[125]]({context:_0xe743[76],exten:_0xe743[74],priority:1,app:_0xe743[155],appdata:_0xe743[156],type:_0xe743[157],TrunkId:_0xc7ddxb[_0xe743[116]]});})[_0xe743[114]](function(_0xc7ddx3){});models[_0xe743[136]][_0xe743[137]]()[_0xe743[5]](function(_0xc7ddxc){models[_0xe743[161]][_0xe743[125]]({app:_0xe743[160],appdata:_0xc7ddxc[0][_0xe743[116]],priority:1,timeout:30,FaxAccountId:_0xc7ddxa[_0xe743[116]],FaxQueueId:_0xc7ddxc[0][_0xe743[116]]})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[159])})[_0xe743[114]](function(_0xc7ddx3){});models[_0xe743[161]][_0xe743[125]]({app:_0xe743[160],appdata:_0xc7ddxc[1][_0xe743[116]],priority:2,timeout:30,FaxAccountId:_0xc7ddxa[_0xe743[116]],FaxQueueId:_0xc7ddxc[1][_0xe743[116]]})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[162])})[_0xe743[114]](function(_0xc7ddx3){});})[_0xe743[114]](function(_0xc7ddx3){});})[_0xe743[114]](function(_0xc7ddx3){});models[_0xe743[158]][_0xe743[68]]([{context:_0xe743[170],exten:_0xe743[171],priority:1,app:_0xe743[172],appdata:_0xe743[173],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:2,app:_0xe743[174],appdata:_0xe743[175],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:3,app:_0xe743[176],appdata:_0xe743[177],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:4,app:_0xe743[176],appdata:_0xe743[178],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:5,app:_0xe743[176],appdata:_0xe743[179],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:6,app:_0xe743[176],appdata:_0xe743[180],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:7,app:_0xe743[176],appdata:_0xe743[181],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:8,app:_0xe743[176],appdata:_0xe743[182],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:9,app:_0xe743[183],appdata:_0xe743[184],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[171],priority:10,app:_0xe743[172],appdata:_0xe743[185],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:1,app:_0xe743[172],appdata:_0xe743[187],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:2,app:_0xe743[172],appdata:_0xe743[188],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:3,app:_0xe743[172],appdata:_0xe743[189],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:4,app:_0xe743[172],appdata:_0xe743[190],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:5,app:_0xe743[172],appdata:_0xe743[191],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:6,app:_0xe743[172],appdata:_0xe743[192],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:7,app:_0xe743[172],appdata:_0xe743[193],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:8,app:_0xe743[172],appdata:_0xe743[194],type:_0xe743[170]},{context:_0xe743[170],exten:_0xe743[186],priority:9,app:_0xe743[172],appdata:_0xe743[195],type:_0xe743[170]}],{ignoreDuplicates:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[169])});models[_0xe743[158]][_0xe743[68]]([{context:_0xe743[157],exten:_0xe743[171],priority:1,app:_0xe743[172],appdata:_0xe743[196],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:2,app:_0xe743[176],appdata:_0xe743[197],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:3,app:_0xe743[176],appdata:_0xe743[198],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:4,app:_0xe743[176],appdata:_0xe743[199],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:5,app:_0xe743[176],appdata:_0xe743[200],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:6,app:_0xe743[176],appdata:_0xe743[180],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:7,app:_0xe743[176],appdata:_0xe743[181],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:8,app:_0xe743[176],appdata:_0xe743[182],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:9,app:_0xe743[172],appdata:_0xe743[187],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:10,app:_0xe743[172],appdata:_0xe743[201],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:11,app:_0xe743[172],appdata:_0xe743[202],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:12,app:_0xe743[172],appdata:_0xe743[203],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:13,app:_0xe743[172],appdata:_0xe743[204],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:14,app:_0xe743[172],appdata:_0xe743[205],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:15,app:_0xe743[206],appdata:_0xe743[207],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[171],priority:16,app:_0xe743[208],type:_0xe743[157]},{context:_0xe743[157],exten:_0xe743[186],priority:1,app:_0xe743[172],appdata:_0xe743[187],type:_0xe743[157]}],{ignoreDuplicates:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[169])});models[_0xe743[212]][_0xe743[68]]([{name:_0xe743[210],description:_0xe743[211]}],{ignoreDuplicates:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[209])});models[_0xe743[229]][_0xe743[125]]({name:_0xe743[215],description:_0xe743[215],address:_0xe743[216],color:_0xe743[217],color_focus:_0xe743[217],color_button:_0xe743[217],remote:_0xe743[218],animation:true,header_shape:_0xe743[219],header_online:_0xe743[220],online_message:_0xe743[221],username_placeholder:_0xe743[222],email_placeholder:_0xe743[223],start_chat_button:_0xe743[224],header_offline:_0xe743[225],offline_message:_0xe743[226],enquiry_message_placeholder:_0xe743[227],enquiry_button:_0xe743[228],download_transcript:true})[_0xe743[5]](function(_0xc7ddxd){console[_0xe743[4]](_0xe743[213]);models[_0xe743[126]][_0xe743[137]]()[_0xe743[5]](function(_0xc7ddxe){models[_0xe743[214]][_0xe743[125]]({app:_0xe743[160],appdata:_0xc7ddxe[0][_0xe743[116]],priority:1,timeout:30,ChatWebsiteId:_0xc7ddxd[_0xe743[116]],ChatQueueId:_0xc7ddxe[0][_0xe743[116]]})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[159])})[_0xe743[114]](function(_0xc7ddx3){});models[_0xe743[214]][_0xe743[125]]({app:_0xe743[160],appdata:_0xc7ddxe[1][_0xe743[116]],priority:2,timeout:30,ChatWebsiteId:_0xc7ddxd[_0xe743[116]],ChatQueueId:_0xc7ddxe[1][_0xe743[116]]})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[162])})[_0xe743[114]](function(_0xc7ddx3){});})[_0xe743[114]](function(_0xc7ddx3){});})[_0xe743[114]](function(_0xc7ddx3){});models[_0xe743[232]][_0xe743[68]]([{name:_0xe743[231],description:_0xe743[211]}],{ignoreDuplicates:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[230])});models[_0xe743[235]][_0xe743[68]]([{name:_0xe743[19],description:_0xe743[234],defaultEntry:true},{name:_0xe743[76],description:_0xe743[234],defaultEntry:true},{name:_0xe743[157],description:_0xe743[234],defaultEntry:true},{name:_0xe743[170],description:_0xe743[234],defaultEntry:true}],{ignoreDuplicates:true,individualHooks:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[233])});models[_0xe743[242]][_0xe743[68]]([{name:_0xe743[237],mode:_0xe743[238],directory:_0xe743[239],sort:_0xe743[240],format:_0xe743[241],defaultEntry:true}],{ignoreDuplicates:true,individualHooks:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[236])});models[_0xe743[246]][_0xe743[68]]([{mac:_0xe743[243],netmask:_0xe743[244],address:_0xe743[245],min_internal:1000}],{ignoreDuplicates:true,individualHooks:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[236])});models[_0xe743[258]][_0xe743[68]]([{name:_0xe743[247],model:JSON[_0xe743[257]]({title:_0xe743[247],rows:[{columns:[{styleClass:_0xe743[248],widgets:[{type:_0xe743[249],title:_0xe743[250],config:{timePattern:_0xe743[251],datePattern:_0xe743[252]}}]},{styleClass:_0xe743[253],widgets:[{type:_0xe743[254],title:_0xe743[255],config:{url:_0xe743[256]}}]}]}]}),defaultEntry:true}],{ignoreDuplicates:true,individualHooks:true})[_0xe743[5]](function(){console[_0xe743[4]](_0xe743[236])}); \ No newline at end of file diff --git a/server/config/smtp/index.js b/server/config/smtp/index.js index e5bf8e2..c38ad53 100644 --- a/server/config/smtp/index.js +++ b/server/config/smtp/index.js @@ -1,24 +1 @@ -'use strict'; - -var _ = require('lodash'); -var MailServerOut = require('../../models').MailServerOut; - -module.exports = { - init: function () { - - MailServerOut.afterCreate(function (doc) { - require('./smtp').create(doc); - }); - - return MailServerOut - .findAll() - .then(function (data) { - data.forEach(function (elm) { - require('./smtp').create(elm); - }); - }) - .catch(function (err) { - console.error(err); - }); - } -}; +var _0x30d9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x65\x78\x70\x6F\x72\x74\x73","\x63\x72\x65\x61\x74\x65","\x2E\x2F\x73\x6D\x74\x70","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x66\x6F\x72\x45\x61\x63\x68","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C"];_0x30d9[0];var _=require(_0x30d9[1]);var MailServerOut=require(_0x30d9[3])[_0x30d9[2]];module[_0x30d9[4]]={init:function(){MailServerOut[_0x30d9[7]](function(_0x98dcx3){require(_0x30d9[6])[_0x30d9[5]](_0x98dcx3)});return MailServerOut[_0x30d9[12]]()[_0x30d9[11]](function(_0x98dcx5){_0x98dcx5[_0x30d9[10]](function(_0x98dcx6){require(_0x30d9[6])[_0x30d9[5]](_0x98dcx6)})})[_0x30d9[9]](function(_0x98dcx4){console[_0x30d9[8]](_0x98dcx4)});}}; \ No newline at end of file diff --git a/server/config/smtp/smtp.js b/server/config/smtp/smtp.js index 422a01b..1568712 100644 --- a/server/config/smtp/smtp.js +++ b/server/config/smtp/smtp.js @@ -1,428 +1 @@ -'use strict'; - -var _ = require('lodash'); -var nodemailer = require('nodemailer'); -var smtpTransport = require('nodemailer-smtp-transport'); - -var Contact = require('../../models').Contact; -var MailRoom = require('../../models').MailRoom; -var MailMessage = require('../../models').MailMessage; -var ContactEmail = require('../../models').ContactEmail; -var MailServerOut = require('../../models').MailServerOut; - -module.exports = { - create: function (doc) { - - var _smtp; - var _doc; - - function onSave(doc) { - console.log("MAIL - Account " + doc.username + " SMTP CREATE"); - _doc = doc; - _smtp = nodemailer.createTransport(smtpTransport({ - host: doc.host, - port: doc.port, - secure: doc.ssl, - debug: true, - auth: { - user: doc.username, - pass: doc.password - } - })); - } - - function onUpdate(doc) { - if (_smtp.transporter.options.auth.user === doc.username) { - console.log("MAIL - Account " + doc.username + " SMTP UPDATE"); - _smtp = null; - _smtp = nodemailer.createTransport(smtpTransport({ - host: doc.host, - port: doc.port, - secure: doc.ssl, - debug: true, - auth: { - user: doc.username, - pass: doc.password - } - })); - } - } - - function onRemove(doc) { - if (_smtp.transporter.options.auth.user === doc.username) { - console.log("[MAIL - Account " + doc.username + " SMTP DESTROY"); - _smtp = null; - } - } - - function onSend(mailMessage, options) { - if (mailMessage.changed('status') && mailMessage.status === 'SENDING' && _smtp.transporter.options.auth.user === mailMessage.from) { - console.log('onSend', mailMessage.from); - var _mRoom; - var _mMessage = mailMessage; - var _mFrom, _mTo, _mCc, _mBcc; - - if (_mMessage.inReplyTo) { - return MailMessage - .findOne({ - where: { - messageId: _mMessage.inReplyTo - } - }) - .then(function (mailMessageParent) { - return mailMessageParent - .getMailRoom(); - }) - .then(function (mailRoom) { - _mRoom = mailRoom; - return mailRoom - .addMailMessage(_mMessage, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return ContactEmail - .findOrCreate({ - where: { - email: _mMessage.from - }, - defaults: { - email: _mMessage.from - }, - transaction: options ? options.transaction : null - }); - }) - .spread(function (mFrom, created) { - var promises = []; - var tos = _mMessage.to ? _mMessage.to.split(';') : []; - _mFrom = mFrom; - - tos.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: options ? options.transaction : null - })); - }); - - return promises; - }) - .all() - .then(function (mTo) { - var promises = []; - var ccs = _mMessage.cc ? _mMessage.cc.split(';') : []; - _mTo = _.map(mTo, function (elm) { - return elm[0]; - }); - - ccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: options ? options.transaction : null - })); - }); - - return promises; - }) - .all() - .then(function (mCc) { - var promises = []; - var bccs = _mMessage.bcc ? _mMessage.bcc.split(';') : []; - _mCc = _.map(mCc, function (elm) { - return elm[0]; - }); - - bccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: options ? options.transaction : null - })); - }); - - return promises; - }) - .all() - .then(function (mBcc) { - _mBcc = _.map(mBcc, function (elm) { - return elm[0]; - }); - - return; - }) - .then(function () { - return _mMessage - .setFrom(_mFrom, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return _mMessage - .setTo(_mTo, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return _mMessage - .setCc(_mCc, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return _mMessage - .setBcc(_mBcc, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - var mail = { - status: _mMessage.status, - from: _mMessage.from, - to: _mMessage.to, - cc: _mMessage.cc, - subject: _mMessage.subject, - html: _mMessage.html, - text: _mMessage.text, - headers: { - 'X-Laziness-level': 1000 - } - }; - - if (_mMessage.MailAttachments) { - mail.attachments = _.map(_mMessage.MailAttachments, function (elm) { - return { - path: elm.path - } - }); - } - - return new Promise(function (resolve, reject) { - _smtp.sendMail(mail, function (err, info) { - if (err) { - return reject(err); - } else { - resolve(info); - } - }); - }); - }) - .then(function (info) { - return _mMessage - .update({ - messageId: info.messageId, - status: 'SENT' - }, { - transaction: options ? options.transaction : null - }); - }); - } else { - return MailRoom - .findOrCreate({ - where: { - id: _mMessage.MailRoomId - }, - defaults: { - subject: _mMessage.subject, - from: _mMessage.from, - status: 'OPEN', - MailAccountId: _doc.MailAccountId - }, - transaction: options ? options.transaction : null - }) - .spread(function (mailRoom) { - _mRoom = mailRoom; - return mailRoom - .addMailMessage(_mMessage, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return ContactEmail - .findOrCreate({ - where: { - email: _mMessage.from - }, - defaults: { - email: _mMessage.from, - }, - transaction: options ? options.transaction : null - }); - }) - .spread(function (mFrom) { - var promises = []; - var tos = _mMessage.to ? _mMessage.to.split(';') : []; - _mFrom = mFrom; - - tos.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: options ? options.transaction : null - })); - }); - - return promises; - }) - .all() - .then(function (mTo) { - var promises = []; - var ccs = _mMessage.cc ? _mMessage.cc.split(';') : []; - _mTo = _.map(mTo, function (elm) { - return elm[0]; - }); - - ccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: options ? options.transaction : null - })); - }); - - return promises; - }) - .all() - .then(function (mCc) { - var promises = []; - var bccs = _mMessage.bcc ? _mMessage.bcc.split(';') : []; - _mCc = _.map(mCc, function (elm) { - return elm[0]; - }); - - bccs.forEach(function (email) { - promises.push(ContactEmail - .findOrCreate({ - where: { - email: email - }, - defaults: { - email: email - }, - transaction: options ? options.transaction : null - })); - }); - - return promises; - }) - .all() - .then(function (mBcc) { - _mBcc = _.map(mBcc, function (elm) { - return elm[0]; - }); - - return; - }) - .then(function () { - return _mMessage - .setFrom(_mFrom, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return _mMessage - .setTo(_mTo, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return _mMessage - .setCc(_mCc, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - return _mMessage - .setBcc(_mBcc, { - transaction: options ? options.transaction : null - }); - }) - .then(function () { - var mail = { - status: _mMessage.status, - from: _mMessage.from, - to: _mMessage.to, - cc: _mMessage.cc, - subject: _mMessage.subject, - html: _mMessage.html, - text: _mMessage.text, - headers: { - 'X-Laziness-level': 1000 - } - }; - - if (_mMessage.MailAttachments) { - mail.attachments = _.map(_mMessage.MailAttachments, function (elm) { - return { - path: elm.path - } - }); - } - - return new Promise(function (resolve, reject) { - _smtp.sendMail(mail, function (err, info) { - if (err) { - return reject(err); - } else { - resolve(info); - } - }); - }); - }) - .then(function (info) { - return _mMessage - .update({ - messageId: info.messageId, - status: 'SENT' - }, { - transaction: options ? options.transaction : null - }); - }); - } - } - } - - onSave(doc); - - // HANDLE ACCOUNT UPDATE/DELETE - MailServerOut.afterUpdate(function (doc) { - onUpdate(doc); - }); - MailServerOut.afterDestroy(function (doc) { - onRemove(doc); - }); - // HANDLE SEND MAIL - MailMessage.afterCreate(function (doc, options) { - return onSend(doc, options); - }); - // HANDLE SEND MAIL - // MailMessage.afterUpdate(function (doc) { - // // onSend(doc); - // }); - } -}; +var _0x9216=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6E\x6F\x64\x65\x6D\x61\x69\x6C\x65\x72","\x6E\x6F\x64\x65\x6D\x61\x69\x6C\x65\x72\x2D\x73\x6D\x74\x70\x2D\x74\x72\x61\x6E\x73\x70\x6F\x72\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x41\x49\x4C\x20\x2D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x20\x53\x4D\x54\x50\x20\x43\x52\x45\x41\x54\x45","\x6C\x6F\x67","\x68\x6F\x73\x74","\x70\x6F\x72\x74","\x73\x73\x6C","\x70\x61\x73\x73\x77\x6F\x72\x64","\x63\x72\x65\x61\x74\x65\x54\x72\x61\x6E\x73\x70\x6F\x72\x74","\x75\x73\x65\x72","\x61\x75\x74\x68","\x6F\x70\x74\x69\x6F\x6E\x73","\x74\x72\x61\x6E\x73\x70\x6F\x72\x74\x65\x72","\x20\x53\x4D\x54\x50\x20\x55\x50\x44\x41\x54\x45","\x5B\x4D\x41\x49\x4C\x20\x2D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20","\x20\x53\x4D\x54\x50\x20\x44\x45\x53\x54\x52\x4F\x59","\x73\x74\x61\x74\x75\x73","\x63\x68\x61\x6E\x67\x65\x64","\x53\x45\x4E\x44\x49\x4E\x47","\x66\x72\x6F\x6D","\x6F\x6E\x53\x65\x6E\x64","\x69\x6E\x52\x65\x70\x6C\x79\x54\x6F","\x6D\x65\x73\x73\x61\x67\x65\x49\x64","\x53\x45\x4E\x54","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x74\x68\x65\x6E","\x74\x6F","\x63\x63","\x73\x75\x62\x6A\x65\x63\x74","\x68\x74\x6D\x6C","\x74\x65\x78\x74","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x70\x61\x74\x68","\x6D\x61\x70","\x73\x65\x6E\x64\x4D\x61\x69\x6C","\x73\x65\x74\x42\x63\x63","\x73\x65\x74\x43\x63","\x73\x65\x74\x54\x6F","\x73\x65\x74\x46\x72\x6F\x6D","\x61\x6C\x6C","\x62\x63\x63","\x3B","\x73\x70\x6C\x69\x74","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x73\x70\x72\x65\x61\x64","\x61\x64\x64\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x67\x65\x74\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x66\x69\x6E\x64\x4F\x6E\x65","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x49\x64","\x4F\x50\x45\x4E","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65"];_0x9216[0];var _=require(_0x9216[1]);var nodemailer=require(_0x9216[2]);var smtpTransport=require(_0x9216[3]);var Contact=require(_0x9216[5])[_0x9216[4]];var MailRoom=require(_0x9216[5])[_0x9216[6]];var MailMessage=require(_0x9216[5])[_0x9216[7]];var ContactEmail=require(_0x9216[5])[_0x9216[8]];var MailServerOut=require(_0x9216[5])[_0x9216[9]];module[_0x9216[10]]={create:function(_0xe497x9){var _0xe497xa;var _0xe497xb;function _0xe497xc(_0xe497x9){console[_0x9216[14]](_0x9216[11]+_0xe497x9[_0x9216[12]]+_0x9216[13]);_0xe497xb=_0xe497x9;_0xe497xa=nodemailer[_0x9216[19]](smtpTransport({host:_0xe497x9[_0x9216[15]],port:_0xe497x9[_0x9216[16]],secure:_0xe497x9[_0x9216[17]],debug:true,auth:{user:_0xe497x9[_0x9216[12]],pass:_0xe497x9[_0x9216[18]]}}));}function _0xe497xd(_0xe497x9){if(_0xe497xa[_0x9216[23]][_0x9216[22]][_0x9216[21]][_0x9216[20]]===_0xe497x9[_0x9216[12]]){console[_0x9216[14]](_0x9216[11]+_0xe497x9[_0x9216[12]]+_0x9216[24]);_0xe497xa=null;_0xe497xa=nodemailer[_0x9216[19]](smtpTransport({host:_0xe497x9[_0x9216[15]],port:_0xe497x9[_0x9216[16]],secure:_0xe497x9[_0x9216[17]],debug:true,auth:{user:_0xe497x9[_0x9216[12]],pass:_0xe497x9[_0x9216[18]]}}));}}function _0xe497xe(_0xe497x9){if(_0xe497xa[_0x9216[23]][_0x9216[22]][_0x9216[21]][_0x9216[20]]===_0xe497x9[_0x9216[12]]){console[_0x9216[14]](_0x9216[25]+_0xe497x9[_0x9216[12]]+_0x9216[26]);_0xe497xa=null;}}function _0xe497xf(_0xe497x10,_0xe497x11){if(_0xe497x10[_0x9216[28]](_0x9216[27])&&_0xe497x10[_0x9216[27]]===_0x9216[29]&&_0xe497xa[_0x9216[23]][_0x9216[22]][_0x9216[21]][_0x9216[20]]===_0xe497x10[_0x9216[30]]){console[_0x9216[14]](_0x9216[31],_0xe497x10[_0x9216[30]]);var _0xe497x12;var _0xe497x13=_0xe497x10;var _0xe497x14,_0xe497x15,_0xe497x16,_0xe497x17;if(_0xe497x13[_0x9216[32]]){return MailMessage[_0x9216[62]]({where:{messageId:_0xe497x13[_0x9216[32]]}})[_0x9216[37]](function(_0xe497x29){return _0xe497x29[_0x9216[61]]()})[_0x9216[37]](function(_0xe497x28){_0xe497x12=_0xe497x28;return _0xe497x28[_0x9216[60]](_0xe497x13,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null});})[_0x9216[37]](function(){return ContactEmail[_0x9216[56]]({where:{email:_0xe497x13[_0x9216[30]]},defaults:{email:_0xe497x13[_0x9216[30]]},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[59]](function(_0xe497x25,_0xe497x26){var _0xe497x20=[];var _0xe497x27=_0xe497x13[_0x9216[38]]?_0xe497x13[_0x9216[38]][_0x9216[55]](_0x9216[54]):[];_0xe497x14=_0xe497x25;_0xe497x27[_0x9216[58]](function(_0xe497x22){_0xe497x20[_0x9216[57]](ContactEmail[_0x9216[56]]({where:{email:_0xe497x22},defaults:{email:_0xe497x22},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null}))});return _0xe497x20;})[_0x9216[52]]()[_0x9216[37]](function(_0xe497x23){var _0xe497x20=[];var _0xe497x24=_0xe497x13[_0x9216[39]]?_0xe497x13[_0x9216[39]][_0x9216[55]](_0x9216[54]):[];_0xe497x15=_[_0x9216[46]](_0xe497x23,function(_0xe497x1a){return _0xe497x1a[0]});_0xe497x24[_0x9216[58]](function(_0xe497x22){_0xe497x20[_0x9216[57]](ContactEmail[_0x9216[56]]({where:{email:_0xe497x22},defaults:{email:_0xe497x22},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null}))});return _0xe497x20;})[_0x9216[52]]()[_0x9216[37]](function(_0xe497x1f){var _0xe497x20=[];var _0xe497x21=_0xe497x13[_0x9216[53]]?_0xe497x13[_0x9216[53]][_0x9216[55]](_0x9216[54]):[];_0xe497x16=_[_0x9216[46]](_0xe497x1f,function(_0xe497x1a){return _0xe497x1a[0]});_0xe497x21[_0x9216[58]](function(_0xe497x22){_0xe497x20[_0x9216[57]](ContactEmail[_0x9216[56]]({where:{email:_0xe497x22},defaults:{email:_0xe497x22},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null}))});return _0xe497x20;})[_0x9216[52]]()[_0x9216[37]](function(_0xe497x1e){_0xe497x17=_[_0x9216[46]](_0xe497x1e,function(_0xe497x1a){return _0xe497x1a[0]});return ;})[_0x9216[37]](function(){return _0xe497x13[_0x9216[51]](_0xe497x14,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){return _0xe497x13[_0x9216[50]](_0xe497x15,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){return _0xe497x13[_0x9216[49]](_0xe497x16,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){return _0xe497x13[_0x9216[48]](_0xe497x17,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){var _0xe497x19={status:_0xe497x13[_0x9216[27]],from:_0xe497x13[_0x9216[30]],to:_0xe497x13[_0x9216[38]],cc:_0xe497x13[_0x9216[39]],subject:_0xe497x13[_0x9216[40]],html:_0xe497x13[_0x9216[41]],text:_0xe497x13[_0x9216[42]],headers:{"\x58\x2D\x4C\x61\x7A\x69\x6E\x65\x73\x73\x2D\x6C\x65\x76\x65\x6C":1000}};if(_0xe497x13[_0x9216[43]]){_0xe497x19[_0x9216[44]]=_[_0x9216[46]](_0xe497x13.MailAttachments,function(_0xe497x1a){return {path:_0xe497x1a[_0x9216[45]]}})};return new Promise(function(_0xe497x1b,_0xe497x1c){_0xe497xa[_0x9216[47]](_0xe497x19,function(_0xe497x1d,_0xe497x18){if(_0xe497x1d){return _0xe497x1c(_0xe497x1d)}else {_0xe497x1b(_0xe497x18)}})});})[_0x9216[37]](function(_0xe497x18){return _0xe497x13[_0x9216[36]]({messageId:_0xe497x18[_0x9216[33]],status:_0x9216[34]},{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})}else {return MailRoom[_0x9216[56]]({where:{id:_0xe497x13[_0x9216[63]]},defaults:{subject:_0xe497x13[_0x9216[40]],from:_0xe497x13[_0x9216[30]],status:_0x9216[64],MailAccountId:_0xe497xb[_0x9216[65]]},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})[_0x9216[59]](function(_0xe497x28){_0xe497x12=_0xe497x28;return _0xe497x28[_0x9216[60]](_0xe497x13,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null});})[_0x9216[37]](function(){return ContactEmail[_0x9216[56]]({where:{email:_0xe497x13[_0x9216[30]]},defaults:{email:_0xe497x13[_0x9216[30]]},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[59]](function(_0xe497x25){var _0xe497x20=[];var _0xe497x27=_0xe497x13[_0x9216[38]]?_0xe497x13[_0x9216[38]][_0x9216[55]](_0x9216[54]):[];_0xe497x14=_0xe497x25;_0xe497x27[_0x9216[58]](function(_0xe497x22){_0xe497x20[_0x9216[57]](ContactEmail[_0x9216[56]]({where:{email:_0xe497x22},defaults:{email:_0xe497x22},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null}))});return _0xe497x20;})[_0x9216[52]]()[_0x9216[37]](function(_0xe497x23){var _0xe497x20=[];var _0xe497x24=_0xe497x13[_0x9216[39]]?_0xe497x13[_0x9216[39]][_0x9216[55]](_0x9216[54]):[];_0xe497x15=_[_0x9216[46]](_0xe497x23,function(_0xe497x1a){return _0xe497x1a[0]});_0xe497x24[_0x9216[58]](function(_0xe497x22){_0xe497x20[_0x9216[57]](ContactEmail[_0x9216[56]]({where:{email:_0xe497x22},defaults:{email:_0xe497x22},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null}))});return _0xe497x20;})[_0x9216[52]]()[_0x9216[37]](function(_0xe497x1f){var _0xe497x20=[];var _0xe497x21=_0xe497x13[_0x9216[53]]?_0xe497x13[_0x9216[53]][_0x9216[55]](_0x9216[54]):[];_0xe497x16=_[_0x9216[46]](_0xe497x1f,function(_0xe497x1a){return _0xe497x1a[0]});_0xe497x21[_0x9216[58]](function(_0xe497x22){_0xe497x20[_0x9216[57]](ContactEmail[_0x9216[56]]({where:{email:_0xe497x22},defaults:{email:_0xe497x22},transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null}))});return _0xe497x20;})[_0x9216[52]]()[_0x9216[37]](function(_0xe497x1e){_0xe497x17=_[_0x9216[46]](_0xe497x1e,function(_0xe497x1a){return _0xe497x1a[0]});return ;})[_0x9216[37]](function(){return _0xe497x13[_0x9216[51]](_0xe497x14,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){return _0xe497x13[_0x9216[50]](_0xe497x15,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){return _0xe497x13[_0x9216[49]](_0xe497x16,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){return _0xe497x13[_0x9216[48]](_0xe497x17,{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})[_0x9216[37]](function(){var _0xe497x19={status:_0xe497x13[_0x9216[27]],from:_0xe497x13[_0x9216[30]],to:_0xe497x13[_0x9216[38]],cc:_0xe497x13[_0x9216[39]],subject:_0xe497x13[_0x9216[40]],html:_0xe497x13[_0x9216[41]],text:_0xe497x13[_0x9216[42]],headers:{"\x58\x2D\x4C\x61\x7A\x69\x6E\x65\x73\x73\x2D\x6C\x65\x76\x65\x6C":1000}};if(_0xe497x13[_0x9216[43]]){_0xe497x19[_0x9216[44]]=_[_0x9216[46]](_0xe497x13.MailAttachments,function(_0xe497x1a){return {path:_0xe497x1a[_0x9216[45]]}})};return new Promise(function(_0xe497x1b,_0xe497x1c){_0xe497xa[_0x9216[47]](_0xe497x19,function(_0xe497x1d,_0xe497x18){if(_0xe497x1d){return _0xe497x1c(_0xe497x1d)}else {_0xe497x1b(_0xe497x18)}})});})[_0x9216[37]](function(_0xe497x18){return _0xe497x13[_0x9216[36]]({messageId:_0xe497x18[_0x9216[33]],status:_0x9216[34]},{transaction:_0xe497x11?_0xe497x11[_0x9216[35]]:null})})};}}_0xe497xc(_0xe497x9);MailServerOut[_0x9216[66]](function(_0xe497x9){_0xe497xd(_0xe497x9)});MailServerOut[_0x9216[67]](function(_0xe497x9){_0xe497xe(_0xe497x9)});MailMessage[_0x9216[68]](function(_0xe497x9,_0xe497x11){return _0xe497xf(_0xe497x9,_0xe497x11)});}}; \ No newline at end of file diff --git a/server/config/socketio.js b/server/config/socketio.js index 0d12443..66ace9d 100644 --- a/server/config/socketio.js +++ b/server/config/socketio.js @@ -1,195 +1 @@ -/** - * Socket.io configuration - */ - -'use strict'; - -var moment = require('moment'); -var config = require('./environment'); -var User = require('../models').User; - -function onDisconnect(socket) { - if (socket.userId) { - return User - .findById(socket.userId) - .then(function(user) { - if (user) { - return user - .updateAttributes({ - online: false - }); - } else { - throw new Error('socket: anyone users found'); - } - }) - .then(function(user) { - console.log('socket: user offline', user.name); - }) - .catch(function(err) { - console.error(err); - }); - } else { - console.log('socket: anyone users found'); - } -} - -function onConnect(socket) { - if (socket.userId) { - return User - .findById(socket.userId) - .then(function(user) { - if (user) { - return user - .updateAttributes({ - online: true, - lastLoginAt: moment().format("YYYY-MM-DD HH:mm:ss") - }) - } else { - throw new Error('socket: anyone users found'); - } - }) - .then(function(user) { - console.log('socket: user online', user.name); - - // Insert sockets below - - //Ordered alphabetically - require('../api/agent/agent.socket').register(socket); - require('../api/ami/ami.socket').register(socket); - require('../api/automation/automation.socket').register(socket); - require('../api/business_action/business_action.socket').register(socket); - require('../api/business_condition/business_condition.socket').register(socket); - require('../api/chat_application/chat_application.socket').register(socket); - require('../api/chat_enquiry/enquiry.socket').register(socket); - require('../api/chat_message/chat_message.socket').register(socket); - require('../api/chat_queue/chat_queue.socket').register(socket); - require('../api/chat_room/chat_room.socket').register(socket); - require('../api/chat_visitor/chat_visitor.socket').register(socket); - require('../api/chat_website/chat_website.socket').register(socket); - require('../api/company/company.socket').register(socket); - require('../api/contact/contact.socket').register(socket); - require('../api/contact_manager/contact_manager.socket').register(socket); - require('../api/custom_field/custom_field.socket').register(socket); - require('../api/dashboard/dashboard.socket').register(socket); - require('../api/desk_account/desk_account.socket').register(socket); - require('../api/desk_configuration/desk_configuration.socket').register(socket); - require('../api/desk_field/desk_field.socket').register(socket); - require('../api/event/event.socket').register(socket); - require('../api/fax_account/fax_account.socket').register(socket); - require('../api/fax_application/fax_application.socket').register(socket); - require('../api/fax_business_automation/fax_business_automation.socket').register(socket); - require('../api/fax_message/fax_message.socket').register(socket); - require('../api/fax_queue/fax_queue.socket').register(socket); - require('../api/fax_room/fax_room.socket').register(socket); - require('../api/freshdesk_account/freshdesk_account.socket').register(socket); - require('../api/freshdesk_configuration/freshdesk_configuration.socket').register(socket); - require('../api/freshdesk_field/freshdesk_field.socket').register(socket); - require('../api/integration/integration.socket').register(socket); - require('../api/interval/interval.socket').register(socket); - require('../api/mail_account/mail_account.socket').register(socket); - require('../api/mail_application/mail_application.socket').register(socket); - require('../api/mail_attachment/mail_attachment.socket').register(socket); - require('../api/mail_business_automation/mail_business_automation.socket').register(socket); - require('../api/mail_message/mail_message.socket').register(socket); - require('../api/mail_queue/mail_queue.socket').register(socket); - require('../api/mail_room/mail_room.socket').register(socket); - require('../api/mail_server_in/mail_server_in.socket').register(socket); - require('../api/mail_template/mail_template.socket').register(socket); - require('../api/module/module.socket').register(socket); - require('../api/motionbar/motionbar.socket').register(socket); - require('../api/default_report/default_report.socket').register(socket); - require('../api/custom_report/custom_report.socket').register(socket); - require('../api/report_tree/report_tree.socket').register(socket); - require('../api/report_agent/report_agent.socket').register(socket); - require('../api/report_chat/report_chat.socket').register(socket); - require('../api/report_chat_session/report_chat_session.socket').register(socket); - require('../api/report_integration/report_integration.socket').register(socket); - require('../api/report_mail/report_mail.socket').register(socket); - require('../api/report_mail_session/report_mail_session.socket').register(socket); - require('../api/report_queue/report_queue.socket').register(socket); - require('../api/salesforce_account/salesforce_account.socket').register(socket); - require('../api/salesforce_configuration/salesforce_configuration.socket').register(socket); - require('../api/salesforce_field/salesforce_field.socket').register(socket); - require('../api/setting/setting.socket').register(socket); - require('../api/square_odbc/square_odbc.socket').register(socket); - require('../api/square_project/square_project.socket').register(socket); - require('../api/sugarcrm_account/sugarcrm_account.socket').register(socket); - require('../api/sugarcrm_configuration/sugarcrm_configuration.socket').register(socket); - require('../api/sugarcrm_field/sugarcrm_field.socket').register(socket); - require('../api/tag/tag.socket').register(socket); - require('../api/team/team.socket.js').register(socket); - require('../api/trigger/trigger.socket').register(socket); - require('../api/trunk/trunk.socket').register(socket); - require('../api/user/user.socket').register(socket); - require('../api/update/update.socket').register(socket); - require('../api/upload/upload.socket').register(socket); - require('../api/user_has_chat_queue/user_has_chat_queue.socket').register(socket); - require('../api/user_has_chat_room/user_has_chat_room.socket').register(socket); - require('../api/user_has_fax_queue/user_has_fax_queue.socket').register(socket); - require('../api/user_has_mail_queue/user_has_mail_queue.socket').register(socket); - require('../api/user_has_team/user_has_team.socket').register(socket); - require('../api/user_has_voice_queue/user_has_voice_queue.socket').register(socket); - require('../api/variable/variable.socket').register(socket); - require('../api/metric/metric.socket').register(socket); - require('../api/voice_context/voice_context.socket').register(socket); - require('../api/voice_extension/voice_extension.socket').register(socket); - require('../api/voice_musiconhold/voice_musiconhold.socket').register(socket); - require('../api/voice_queue/voice_queue.socket').register(socket); - require('../api/voice_voicemail/voice_voicemail.socket').register(socket); - require('../api/xchatty/xchatty.socket').register(socket); - require('../api/zendesk_account/zendesk_account.socket').register(socket); - require('../api/zendesk_configuration/zendesk_configuration.socket').register(socket); - require('../api/zendesk_field/zendesk_field.socket').register(socket); - - }) - .catch(function(err) { - console.error(err); - }); - } else { - console.log('socket: anyone users found'); - } - - socket.on('info', function(data) { - console.info('[%s] %s', socket.address, JSON.stringify(data, null, 2)); - }); - -} - -module.exports = function(socketio) { - // socket.io (v1.x.x) is powered by debug. - // In order to see all the debug output, set DEBUG (in server/config/local.env.js) to including the desired scope. - // - // ex: DEBUG: "http*,socket.io:socket" - - // We can authenticate socket.io users and access their token through socket.handshake.decoded_token - // - // 1. You will need to send the token in `client/components/socket/socket.service.js` - // - // 2. Require authentication here: - socketio.use(require('socketio-jwt').authorize({ - secret: config.session.secret, - handshake: true - })); - - socketio.on('connection', function(socket) { - socket.address = socket.handshake.address !== null ? socket.handshake - .address.address + ':' + socket.handshake.address.port : process.env - .DOMAIN; - - socket.connectedAt = new Date(); - socket.userId = socket.handshake.query.userId; - socket.role = socket.handshake.query.role; - socket.name = socket.handshake.query.name; - socket.source = socket.handshake.query.source; - - // Call onDisconnect. - socket.on('disconnect', function() { - onDisconnect(socket); - console.info('[%s] SOCKET DISCONNECTED', socket.handshake.address); - }); - - // Call onConnect. - onConnect(socket); - console.info('[%s] SOCKET CONNECTED', socket.handshake.address); - }); -}; +var _0x20dc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6D\x6F\x6D\x65\x6E\x74","\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x73\x65\x72\x49\x64","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x73\x6F\x63\x6B\x65\x74\x3A\x20\x75\x73\x65\x72\x20\x6F\x66\x66\x6C\x69\x6E\x65","\x6E\x61\x6D\x65","\x6C\x6F\x67","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x73\x6F\x63\x6B\x65\x74\x3A\x20\x61\x6E\x79\x6F\x6E\x65\x20\x75\x73\x65\x72\x73\x20\x66\x6F\x75\x6E\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x73\x6F\x63\x6B\x65\x74\x3A\x20\x75\x73\x65\x72\x20\x6F\x6E\x6C\x69\x6E\x65","\x72\x65\x67\x69\x73\x74\x65\x72","\x2E\x2E\x2F\x61\x70\x69\x2F\x61\x67\x65\x6E\x74\x2F\x61\x67\x65\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x61\x6D\x69\x2F\x61\x6D\x69\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x63\x74\x69\x6F\x6E\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x63\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x63\x68\x61\x74\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x65\x6E\x71\x75\x69\x72\x79\x2F\x65\x6E\x71\x75\x69\x72\x79\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x6D\x65\x73\x73\x61\x67\x65\x2F\x63\x68\x61\x74\x5F\x6D\x65\x73\x73\x61\x67\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x2F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x2F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x76\x69\x73\x69\x74\x6F\x72\x2F\x63\x68\x61\x74\x5F\x76\x69\x73\x69\x74\x6F\x72\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x77\x65\x62\x73\x69\x74\x65\x2F\x63\x68\x61\x74\x5F\x77\x65\x62\x73\x69\x74\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x6F\x6D\x70\x61\x6E\x79\x2F\x63\x6F\x6D\x70\x61\x6E\x79\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x2F\x63\x6F\x6E\x74\x61\x63\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x5F\x6D\x61\x6E\x61\x67\x65\x72\x2F\x63\x6F\x6E\x74\x61\x63\x74\x5F\x6D\x61\x6E\x61\x67\x65\x72\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x2F\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2F\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2F\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2F\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x65\x76\x65\x6E\x74\x2F\x65\x76\x65\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2F\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x66\x61\x78\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2F\x66\x61\x78\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x2F\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x2F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x2F\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x72\x76\x61\x6C\x2F\x69\x6E\x74\x65\x72\x76\x61\x6C\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2F\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x6D\x61\x69\x6C\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x2F\x6D\x61\x69\x6C\x5F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2F\x6D\x61\x69\x6C\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x2F\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x2F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D\x2F\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x69\x6E\x2F\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x69\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x74\x65\x6D\x70\x6C\x61\x74\x65\x2F\x6D\x61\x69\x6C\x5F\x74\x65\x6D\x70\x6C\x61\x74\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x6F\x64\x75\x6C\x65\x2F\x6D\x6F\x64\x75\x6C\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x64\x65\x66\x61\x75\x6C\x74\x5F\x72\x65\x70\x6F\x72\x74\x2F\x64\x65\x66\x61\x75\x6C\x74\x5F\x72\x65\x70\x6F\x72\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65\x2F\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x2F\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x5F\x73\x65\x73\x73\x69\x6F\x6E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x5F\x73\x65\x73\x73\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x2F\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x65\x74\x74\x69\x6E\x67\x2F\x73\x65\x74\x74\x69\x6E\x67\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x5F\x6F\x64\x62\x63\x2F\x73\x71\x75\x61\x72\x65\x5F\x6F\x64\x62\x63\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x5F\x70\x72\x6F\x6A\x65\x63\x74\x2F\x73\x71\x75\x61\x72\x65\x5F\x70\x72\x6F\x6A\x65\x63\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x74\x61\x67\x2F\x74\x61\x67\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x74\x65\x61\x6D\x2F\x74\x65\x61\x6D\x2E\x73\x6F\x63\x6B\x65\x74\x2E\x6A\x73","\x2E\x2E\x2F\x61\x70\x69\x2F\x74\x72\x69\x67\x67\x65\x72\x2F\x74\x72\x69\x67\x67\x65\x72\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x74\x72\x75\x6E\x6B\x2F\x74\x72\x75\x6E\x6B\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x2F\x75\x73\x65\x72\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x70\x64\x61\x74\x65\x2F\x75\x70\x64\x61\x74\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x70\x6C\x6F\x61\x64\x2F\x75\x70\x6C\x6F\x61\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x76\x61\x72\x69\x61\x62\x6C\x65\x2F\x76\x61\x72\x69\x61\x62\x6C\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x6D\x65\x74\x72\x69\x63\x2F\x6D\x65\x74\x72\x69\x63\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x2F\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x2F\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64\x2F\x76\x6F\x69\x63\x65\x5F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x2F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x2F\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x78\x63\x68\x61\x74\x74\x79\x2F\x78\x63\x68\x61\x74\x74\x79\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x2E\x73\x6F\x63\x6B\x65\x74","\x2E\x2E\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x2E\x73\x6F\x63\x6B\x65\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x69\x6E\x66\x6F","\x5B\x25\x73\x5D\x20\x25\x73","\x61\x64\x64\x72\x65\x73\x73","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x6F\x6E","\x65\x78\x70\x6F\x72\x74\x73","\x73\x65\x63\x72\x65\x74","\x73\x65\x73\x73\x69\x6F\x6E","\x61\x75\x74\x68\x6F\x72\x69\x7A\x65","\x73\x6F\x63\x6B\x65\x74\x69\x6F\x2D\x6A\x77\x74","\x75\x73\x65","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E","\x68\x61\x6E\x64\x73\x68\x61\x6B\x65","\x3A","\x70\x6F\x72\x74","\x44\x4F\x4D\x41\x49\x4E","\x65\x6E\x76","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x41\x74","\x71\x75\x65\x72\x79","\x72\x6F\x6C\x65","\x73\x6F\x75\x72\x63\x65","\x64\x69\x73\x63\x6F\x6E\x6E\x65\x63\x74","\x5B\x25\x73\x5D\x20\x53\x4F\x43\x4B\x45\x54\x20\x44\x49\x53\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x5B\x25\x73\x5D\x20\x53\x4F\x43\x4B\x45\x54\x20\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44"];_0x20dc[0];var moment=require(_0x20dc[1]);var config=require(_0x20dc[2]);var User=require(_0x20dc[4])[_0x20dc[3]];function onDisconnect(_0x6e2ax5){if(_0x6e2ax5[_0x20dc[5]]){return User[_0x20dc[14]](_0x6e2ax5[_0x20dc[5]])[_0x20dc[11]](function(_0x6e2ax7){if(_0x6e2ax7){return _0x6e2ax7[_0x20dc[12]]({online:false})}else {throw new Error(_0x20dc[13])}})[_0x20dc[11]](function(_0x6e2ax7){console[_0x20dc[10]](_0x20dc[8],_0x6e2ax7[_0x20dc[9]])})[_0x20dc[7]](function(_0x6e2ax6){console[_0x20dc[6]](_0x6e2ax6)})}else {console[_0x20dc[10]](_0x20dc[13])}}function onConnect(_0x6e2ax5){if(_0x6e2ax5[_0x20dc[5]]){return User[_0x20dc[14]](_0x6e2ax5[_0x20dc[5]])[_0x20dc[11]](function(_0x6e2ax7){if(_0x6e2ax7){return _0x6e2ax7[_0x20dc[12]]({online:true,lastLoginAt:moment()[_0x20dc[104]](_0x20dc[103])})}else {throw new Error(_0x20dc[13])}})[_0x20dc[11]](function(_0x6e2ax7){console[_0x20dc[10]](_0x20dc[15],_0x6e2ax7[_0x20dc[9]]);require(_0x20dc[17])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[18])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[19])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[20])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[21])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[22])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[23])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[24])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[25])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[26])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[27])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[28])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[29])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[30])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[31])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[32])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[33])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[34])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[35])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[36])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[37])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[38])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[39])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[40])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[41])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[42])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[43])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[44])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[45])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[46])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[47])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[48])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[49])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[50])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[51])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[52])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[53])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[54])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[55])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[56])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[57])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[58])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[59])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[60])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[61])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[62])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[63])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[64])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[65])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[66])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[67])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[68])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[69])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[70])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[71])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[72])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[73])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[74])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[75])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[76])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[77])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[78])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[79])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[80])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[81])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[82])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[83])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[84])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[85])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[86])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[87])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[88])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[89])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[90])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[91])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[92])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[93])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[94])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[95])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[96])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[97])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[98])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[99])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[100])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[101])[_0x20dc[16]](_0x6e2ax5);require(_0x20dc[102])[_0x20dc[16]](_0x6e2ax5);})[_0x20dc[7]](function(_0x6e2ax6){console[_0x20dc[6]](_0x6e2ax6)})}else {console[_0x20dc[10]](_0x20dc[13])};_0x6e2ax5[_0x20dc[109]](_0x20dc[105],function(_0x6e2ax9){console[_0x20dc[105]](_0x20dc[106],_0x6e2ax5[_0x20dc[107]],JSON[_0x20dc[108]](_0x6e2ax9,null,2))});}module[_0x20dc[110]]=function(_0x6e2axa){_0x6e2axa[_0x20dc[115]](require(_0x20dc[114])[_0x20dc[113]]({secret:config[_0x20dc[112]][_0x20dc[111]],handshake:true}));_0x6e2axa[_0x20dc[109]](_0x20dc[116],function(_0x6e2ax5){_0x6e2ax5[_0x20dc[107]]=_0x6e2ax5[_0x20dc[117]][_0x20dc[107]]!==null?_0x6e2ax5[_0x20dc[117]][_0x20dc[107]][_0x20dc[107]]+_0x20dc[118]+_0x6e2ax5[_0x20dc[117]][_0x20dc[107]][_0x20dc[119]]:process[_0x20dc[121]][_0x20dc[120]];_0x6e2ax5[_0x20dc[122]]= new Date();_0x6e2ax5[_0x20dc[5]]=_0x6e2ax5[_0x20dc[117]][_0x20dc[123]][_0x20dc[5]];_0x6e2ax5[_0x20dc[124]]=_0x6e2ax5[_0x20dc[117]][_0x20dc[123]][_0x20dc[124]];_0x6e2ax5[_0x20dc[9]]=_0x6e2ax5[_0x20dc[117]][_0x20dc[123]][_0x20dc[9]];_0x6e2ax5[_0x20dc[125]]=_0x6e2ax5[_0x20dc[117]][_0x20dc[123]][_0x20dc[125]];_0x6e2ax5[_0x20dc[109]](_0x20dc[126],function(){onDisconnect(_0x6e2ax5);console[_0x20dc[105]](_0x20dc[127],_0x6e2ax5[_0x20dc[117]][_0x20dc[107]]);});onConnect(_0x6e2ax5);console[_0x20dc[105]](_0x20dc[128],_0x6e2ax5[_0x20dc[117]][_0x20dc[107]]);});}; \ No newline at end of file diff --git a/server/config/triggers/chat.js b/server/config/triggers/chat.js index a96e72f..ef46229 100644 --- a/server/config/triggers/chat.js +++ b/server/config/triggers/chat.js @@ -1,71 +1 @@ -var _ = require('lodash'); -var Mustache = require('mustache'); - -var sequelize = require('../../models').sequelize; -var ChatEnquiry = require('../../models').ChatEnquiry; -var MailMessage = require('../../models').MailMessage; -var MailServerOut = require('../../models').MailServerOut; - -function Chat() { - console.log('Trigger Chat Initialization...'); - - ChatEnquiry.afterCreate(function (chatEnquiry, options) { - var _chatEnquiry = chatEnquiry; - var _chatWebsite; - var _mailServerOut; - var _offlineTemplate; - - return chatEnquiry - .getChatWebsite() - .then(function (chatWebsite) { - _chatWebsite = chatWebsite; - _chatEnquiry.chatWebsite = _chatWebsite.name; - if (_chatWebsite && _chatWebsite.enquiry_forwarding && _chatWebsite.enquiry_forwarding_address) { - return _chatWebsite - .getOfflineTemplate(); - } else { - throw new Error({ - message: 'chatWebsite can\'t send offline messages via mail' - }); - } - }) - .then(function (offlineTemplate) { - _offlineTemplate = offlineTemplate; - if (_offlineTemplate) { - _offlineTemplate.html = Mustache.render(_offlineTemplate.html, _chatEnquiry); - _offlineTemplate.subject = Mustache.render(_offlineTemplate.subject, _chatEnquiry); - } else { - throw new Error({ - message: 'offlineTemplate not found. ChatWebsite: ' + _chatWebsite.name - }); - } - - return MailServerOut - .findOne({ - where: { - service: true - } - }); - }) - .then(function (mailServerOut) { - _mailServerOut = mailServerOut; - - if (!_mailServerOut) { - throw new Error('Motion Service SMTP not configured!'); - } - - return MailMessage - .create({ - from: _mailServerOut.username, - to: _chatWebsite.enquiry_forwarding_address, - subject: _offlineTemplate.subject, - html: _offlineTemplate.html, - status: 'SENDING' - }, { - transaction: options ? options.transaction : null - }); - }); - }); -} - -module.exports = Chat; +var _0xd3f9=["\x6C\x6F\x64\x61\x73\x68","\x6D\x75\x73\x74\x61\x63\x68\x65","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x45\x6E\x71\x75\x69\x72\x79","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x54\x72\x69\x67\x67\x65\x72\x20\x43\x68\x61\x74\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x4D\x6F\x74\x69\x6F\x6E\x20\x53\x65\x72\x76\x69\x63\x65\x20\x53\x4D\x54\x50\x20\x6E\x6F\x74\x20\x63\x6F\x6E\x66\x69\x67\x75\x72\x65\x64\x21","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x65\x6E\x71\x75\x69\x72\x79\x5F\x66\x6F\x72\x77\x61\x72\x64\x69\x6E\x67\x5F\x61\x64\x64\x72\x65\x73\x73","\x73\x75\x62\x6A\x65\x63\x74","\x68\x74\x6D\x6C","\x53\x45\x4E\x44\x49\x4E\x47","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x63\x72\x65\x61\x74\x65","\x74\x68\x65\x6E","\x72\x65\x6E\x64\x65\x72","\x6F\x66\x66\x6C\x69\x6E\x65\x54\x65\x6D\x70\x6C\x61\x74\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2E\x20\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x3A\x20","\x6E\x61\x6D\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x63\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x65\x6E\x71\x75\x69\x72\x79\x5F\x66\x6F\x72\x77\x61\x72\x64\x69\x6E\x67","\x67\x65\x74\x4F\x66\x66\x6C\x69\x6E\x65\x54\x65\x6D\x70\x6C\x61\x74\x65","\x63\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x20\x63\x61\x6E\x27\x74\x20\x73\x65\x6E\x64\x20\x6F\x66\x66\x6C\x69\x6E\x65\x20\x6D\x65\x73\x73\x61\x67\x65\x73\x20\x76\x69\x61\x20\x6D\x61\x69\x6C","\x67\x65\x74\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];var _=require(_0xd3f9[0]);var Mustache=require(_0xd3f9[1]);var sequelize=require(_0xd3f9[3])[_0xd3f9[2]];var ChatEnquiry=require(_0xd3f9[3])[_0xd3f9[4]];var MailMessage=require(_0xd3f9[3])[_0xd3f9[5]];var MailServerOut=require(_0xd3f9[3])[_0xd3f9[6]];function Chat(){console[_0xd3f9[8]](_0xd3f9[7]);ChatEnquiry[_0xd3f9[27]](function(_0x29c3x8,_0x29c3x9){var _0x29c3xa=_0x29c3x8;var _0x29c3xb;var _0x29c3xc;var _0x29c3xd;return _0x29c3x8[_0xd3f9[26]]()[_0xd3f9[17]](function(_0x29c3x10){_0x29c3xb=_0x29c3x10;_0x29c3xa[_0xd3f9[22]]=_0x29c3xb[_0xd3f9[20]];if(_0x29c3xb&&_0x29c3xb[_0xd3f9[23]]&&_0x29c3xb[_0xd3f9[11]]){return _0x29c3xb[_0xd3f9[24]]()}else {throw new Error({message:_0xd3f9[25]})};})[_0xd3f9[17]](function(_0x29c3xf){_0x29c3xd=_0x29c3xf;if(_0x29c3xd){_0x29c3xd[_0xd3f9[13]]=Mustache[_0xd3f9[18]](_0x29c3xd[_0xd3f9[13]],_0x29c3xa);_0x29c3xd[_0xd3f9[12]]=Mustache[_0xd3f9[18]](_0x29c3xd[_0xd3f9[12]],_0x29c3xa);}else {throw new Error({message:_0xd3f9[19]+_0x29c3xb[_0xd3f9[20]]})};return MailServerOut[_0xd3f9[21]]({where:{service:true}});})[_0xd3f9[17]](function(_0x29c3xe){_0x29c3xc=_0x29c3xe;if(!_0x29c3xc){throw new Error(_0xd3f9[9])};return MailMessage[_0xd3f9[16]]({from:_0x29c3xc[_0xd3f9[10]],to:_0x29c3xb[_0xd3f9[11]],subject:_0x29c3xd[_0xd3f9[12]],html:_0x29c3xd[_0xd3f9[13]],status:_0xd3f9[14]},{transaction:_0x29c3x9?_0x29c3x9[_0xd3f9[15]]:null});});});}module[_0xd3f9[28]]=Chat; \ No newline at end of file diff --git a/server/config/triggers/cm.js b/server/config/triggers/cm.js index ecd621e..0156383 100644 --- a/server/config/triggers/cm.js +++ b/server/config/triggers/cm.js @@ -1,68 +1 @@ -var _ = require('lodash'); - -function Cm() { - console.log('Trigger Cm Initialization...'); -} - -Cm.prototype.manageContact = function(doc, channel) { - manageContact(doc, channel); -} - -function manageContact(doc, channel) { - var Contact = require('../../models').Contact; - var ContactPhone = require('../../models').ContactPhone; - var ContactEmail = require('../../models').ContactEmail; - var ReportIntegration = require('../../models').ReportIntegration; - delete doc.id - doc.integration = 'contactmanager'; - var modelInclude = {}; - switch (channel) { - case 'voice': - modelInclude = { - model: ContactPhone, - as: 'Phones', - where: { - phone: doc.calleridnum - } - }; - break; - case 'mail': - modelInclude = { - model: ContactEmail, - as: 'Emails', - where: { - email: doc.from - } - }; - break; - default: - } - console.log('CM triggered by ' + channel + ' channel, finding contact...'); - Contact.findAll({ - include: [modelInclude] - }) - .then(function(contacts) { - if (contacts.length) { - console.log('Found contact, open_contact row in report_integrations table...'); - doc.event = 'openContactTab'; - doc.contacts = JSON.stringify(_.map(_.pluck(contacts, 'dataValues'), function(elem) { - return { - id: elem.id, - name: elem.fullname - } - })); - } else { - console.log('Contact not found, new_contact tab row in report_integrations table...'); - doc.event = 'newContactTab'; - } - ReportIntegration.create(doc) - .catch(function(err) { - console.log(err); - }); - }) - .catch(function(err) { - console.log(err); - }); -} - -module.exports = Cm; +var _0xaf46=["\x6C\x6F\x64\x61\x73\x68","\x54\x72\x69\x67\x67\x65\x72\x20\x43\x6D\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x6D\x61\x6E\x61\x67\x65\x43\x6F\x6E\x74\x61\x63\x74","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x6F\x6E\x74\x61\x63\x74\x50\x68\x6F\x6E\x65","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x69\x64","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72","\x50\x68\x6F\x6E\x65\x73","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x76\x6F\x69\x63\x65","\x45\x6D\x61\x69\x6C\x73","\x66\x72\x6F\x6D","\x6D\x61\x69\x6C","\x43\x4D\x20\x74\x72\x69\x67\x67\x65\x72\x65\x64\x20\x62\x79\x20","\x20\x63\x68\x61\x6E\x6E\x65\x6C\x2C\x20\x66\x69\x6E\x64\x69\x6E\x67\x20\x63\x6F\x6E\x74\x61\x63\x74\x2E\x2E\x2E","\x63\x61\x74\x63\x68","\x6C\x65\x6E\x67\x74\x68","\x46\x6F\x75\x6E\x64\x20\x63\x6F\x6E\x74\x61\x63\x74\x2C\x20\x6F\x70\x65\x6E\x5F\x63\x6F\x6E\x74\x61\x63\x74\x20\x72\x6F\x77\x20\x69\x6E\x20\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73\x20\x74\x61\x62\x6C\x65\x2E\x2E\x2E","\x65\x76\x65\x6E\x74","\x6F\x70\x65\x6E\x43\x6F\x6E\x74\x61\x63\x74\x54\x61\x62","\x63\x6F\x6E\x74\x61\x63\x74\x73","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x6C\x75\x63\x6B","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6D\x61\x70","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x43\x6F\x6E\x74\x61\x63\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2C\x20\x6E\x65\x77\x5F\x63\x6F\x6E\x74\x61\x63\x74\x20\x74\x61\x62\x20\x72\x6F\x77\x20\x69\x6E\x20\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73\x20\x74\x61\x62\x6C\x65\x2E\x2E\x2E","\x6E\x65\x77\x43\x6F\x6E\x74\x61\x63\x74\x54\x61\x62","\x63\x72\x65\x61\x74\x65","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x65\x78\x70\x6F\x72\x74\x73"];var _=require(_0xaf46[0]);function Cm(){console[_0xaf46[2]](_0xaf46[1])}Cm[_0xaf46[4]][_0xaf46[3]]=function(_0xe074x3,_0xe074x4){manageContact(_0xe074x3,_0xe074x4)};function manageContact(_0xe074x3,_0xe074x4){var _0xe074x6=require(_0xaf46[6])[_0xaf46[5]];var _0xe074x7=require(_0xaf46[6])[_0xaf46[7]];var _0xe074x8=require(_0xaf46[6])[_0xaf46[8]];var _0xe074x9=require(_0xaf46[6])[_0xaf46[9]];delete _0xe074x3[_0xaf46[10]];_0xe074x3[_0xaf46[11]]=_0xaf46[12];var _0xe074xa={};switch(_0xe074x4){case _0xaf46[15]:_0xe074xa={model:_0xe074x7,as:_0xaf46[13],where:{phone:_0xe074x3[_0xaf46[14]]}};break ;;case _0xaf46[18]:_0xe074xa={model:_0xe074x8,as:_0xaf46[16],where:{email:_0xe074x3[_0xaf46[17]]}};break ;;default:;};console[_0xaf46[2]](_0xaf46[19]+_0xe074x4+_0xaf46[20]);_0xe074x6[_0xaf46[36]]({include:[_0xe074xa]})[_0xaf46[35]](function(_0xe074xc){if(_0xe074xc[_0xaf46[22]]){console[_0xaf46[2]](_0xaf46[23]);_0xe074x3[_0xaf46[24]]=_0xaf46[25];_0xe074x3[_0xaf46[26]]=JSON[_0xaf46[31]](_[_0xaf46[30]](_[_0xaf46[28]](_0xe074xc,_0xaf46[27]),function(_0xe074xd){return {id:_0xe074xd[_0xaf46[10]],name:_0xe074xd[_0xaf46[29]]}}));}else {console[_0xaf46[2]](_0xaf46[32]);_0xe074x3[_0xaf46[24]]=_0xaf46[33];};_0xe074x9[_0xaf46[34]](_0xe074x3)[_0xaf46[21]](function(_0xe074xb){console[_0xaf46[2]](_0xe074xb)});})[_0xaf46[21]](function(_0xe074xb){console[_0xaf46[2]](_0xe074xb)});}module[_0xaf46[37]]=Cm; \ No newline at end of file diff --git a/server/config/triggers/index.js b/server/config/triggers/index.js index 80cbe70..9657cc0 100644 --- a/server/config/triggers/index.js +++ b/server/config/triggers/index.js @@ -1,97 +1 @@ -'use strict'; - -var _ = require('lodash'); -var Util = require('./util'); -var Voice = require('./voice'); -var Mail = require('./mail'); -var Chat = require('./chat'); -var Cm = require('./cm'); -var Trigger = require('../../models').Trigger; -var ReportAgent = require('../../models').ReportAgent; -var MailMessage = require('../../models').MailMessage; - -module.exports = function () { - - var util = new Util(); - var voice = new Voice(); - var chat = new Chat(); - var mail = new Mail(); - var cm = new Cm(); - - Trigger - .findAll() - .then(function (triggers) { - synchTriggers(triggers); - console.log('Triggers are ', triggers.length); - ReportAgent.afterCreate(function (doc) { - var actions = util.getActionsByTriggers(doc, _.filter(triggers, { - channel: 'voice' - })); - console.log('After agent create, Actions are ', actions.length); - execActions(actions, doc, 'voice', util, voice, mail, cm); - }) - ReportAgent.afterUpdate(function (doc) { - var actions = util.getActionsByTriggers(doc, _.filter(triggers, { - channel: 'voice' - })); - console.log('After agent update, Actions are ', actions.length); - execActions(actions, doc, 'voice', util, voice, mail, cm); - }) - MailMessage.afterCreate(function (doc) { - if (doc.status === 'RECEIVED') { - var actions = util.getActionsByTriggers(doc, _.filter(triggers, { - channel: 'mail' - })); - execActions(actions, doc, 'mail', util, voice, mail, cm); - } - }) - }) - .catch(function (err) { - console.error(err); - }); -} - - -function execActions(actions, doc, channel, util, voice, mail, cm) { - actions.forEach(function (rule) { - console.log('Executing action "' + rule.field.value + '"'); - switch (rule.field.value) { - case 'contactManager': - cm.manageContact(doc.dataValues, channel); - break; - case 'template': - mail.sendTemplate(rule.data, rule.data2); - break; - default: - } - }); -} - -function synchTriggers(triggers) { - Trigger.afterCreate(function (doc) { - updateCollection(triggers, doc); - console.log('After create, Triggers are ', triggers.length); - }); - Trigger.afterUpdate(function (doc) { - updateCollection(triggers, doc); - console.log('After update, Triggers are ', triggers.length); - }); - Trigger.afterDestroy(function (doc) { - _.remove(triggers, { - id: doc.id - }); - console.log('After destroy, Triggers are ', triggers.length); - }); -} - -function updateCollection(collection, doc) { - var oldItem = _.find(collection, { - id: doc.id - }); - var index = collection.indexOf(oldItem); - if (oldItem) { - _.merge(collection[index], doc); - } else { - collection.unshift(doc); - } -} +var _0x5cf9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2F\x75\x74\x69\x6C","\x2E\x2F\x76\x6F\x69\x63\x65","\x2E\x2F\x6D\x61\x69\x6C","\x2E\x2F\x63\x68\x61\x74","\x2E\x2F\x63\x6D","\x54\x72\x69\x67\x67\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x65\x78\x70\x6F\x72\x74\x73","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x54\x72\x69\x67\x67\x65\x72\x73\x20\x61\x72\x65\x20","\x6C\x65\x6E\x67\x74\x68","\x6C\x6F\x67","\x76\x6F\x69\x63\x65","\x66\x69\x6C\x74\x65\x72","\x67\x65\x74\x41\x63\x74\x69\x6F\x6E\x73\x42\x79\x54\x72\x69\x67\x67\x65\x72\x73","\x41\x66\x74\x65\x72\x20\x61\x67\x65\x6E\x74\x20\x63\x72\x65\x61\x74\x65\x2C\x20\x41\x63\x74\x69\x6F\x6E\x73\x20\x61\x72\x65\x20","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x41\x66\x74\x65\x72\x20\x61\x67\x65\x6E\x74\x20\x75\x70\x64\x61\x74\x65\x2C\x20\x41\x63\x74\x69\x6F\x6E\x73\x20\x61\x72\x65\x20","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x73\x74\x61\x74\x75\x73","\x52\x45\x43\x45\x49\x56\x45\x44","\x6D\x61\x69\x6C","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x45\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x61\x63\x74\x69\x6F\x6E\x20\x22","\x76\x61\x6C\x75\x65","\x66\x69\x65\x6C\x64","\x22","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x6D\x61\x6E\x61\x67\x65\x43\x6F\x6E\x74\x61\x63\x74","\x63\x6F\x6E\x74\x61\x63\x74\x4D\x61\x6E\x61\x67\x65\x72","\x64\x61\x74\x61","\x64\x61\x74\x61\x32","\x73\x65\x6E\x64\x54\x65\x6D\x70\x6C\x61\x74\x65","\x74\x65\x6D\x70\x6C\x61\x74\x65","\x66\x6F\x72\x45\x61\x63\x68","\x41\x66\x74\x65\x72\x20\x63\x72\x65\x61\x74\x65\x2C\x20\x54\x72\x69\x67\x67\x65\x72\x73\x20\x61\x72\x65\x20","\x41\x66\x74\x65\x72\x20\x75\x70\x64\x61\x74\x65\x2C\x20\x54\x72\x69\x67\x67\x65\x72\x73\x20\x61\x72\x65\x20","\x69\x64","\x72\x65\x6D\x6F\x76\x65","\x41\x66\x74\x65\x72\x20\x64\x65\x73\x74\x72\x6F\x79\x2C\x20\x54\x72\x69\x67\x67\x65\x72\x73\x20\x61\x72\x65\x20","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x69\x6E\x64\x65\x78\x4F\x66","\x6D\x65\x72\x67\x65","\x75\x6E\x73\x68\x69\x66\x74"];_0x5cf9[0];var _=require(_0x5cf9[1]);var Util=require(_0x5cf9[2]);var Voice=require(_0x5cf9[3]);var Mail=require(_0x5cf9[4]);var Chat=require(_0x5cf9[5]);var Cm=require(_0x5cf9[6]);var Trigger=require(_0x5cf9[8])[_0x5cf9[7]];var ReportAgent=require(_0x5cf9[8])[_0x5cf9[9]];var MailMessage=require(_0x5cf9[8])[_0x5cf9[10]];module[_0x5cf9[11]]=function(){var _0x9631xa= new Util();var _0x9631xb= new Voice();var _0x9631xc= new Chat();var _0x9631xd= new Mail();var _0x9631xe= new Cm();Trigger[_0x5cf9[28]]()[_0x5cf9[27]](function(_0x9631x10){synchTriggers(_0x9631x10);console[_0x5cf9[16]](_0x5cf9[14],_0x9631x10[_0x5cf9[15]]);ReportAgent[_0x5cf9[21]](function(_0x9631x11){var _0x9631x12=_0x9631xa[_0x5cf9[19]](_0x9631x11,_[_0x5cf9[18]](_0x9631x10,{channel:_0x5cf9[17]}));console[_0x5cf9[16]](_0x5cf9[20],_0x9631x12[_0x5cf9[15]]);execActions(_0x9631x12,_0x9631x11,_0x5cf9[17],_0x9631xa,_0x9631xb,_0x9631xd,_0x9631xe);});ReportAgent[_0x5cf9[23]](function(_0x9631x11){var _0x9631x12=_0x9631xa[_0x5cf9[19]](_0x9631x11,_[_0x5cf9[18]](_0x9631x10,{channel:_0x5cf9[17]}));console[_0x5cf9[16]](_0x5cf9[22],_0x9631x12[_0x5cf9[15]]);execActions(_0x9631x12,_0x9631x11,_0x5cf9[17],_0x9631xa,_0x9631xb,_0x9631xd,_0x9631xe);});MailMessage[_0x5cf9[21]](function(_0x9631x11){if(_0x9631x11[_0x5cf9[24]]===_0x5cf9[25]){var _0x9631x12=_0x9631xa[_0x5cf9[19]](_0x9631x11,_[_0x5cf9[18]](_0x9631x10,{channel:_0x5cf9[26]}));execActions(_0x9631x12,_0x9631x11,_0x5cf9[26],_0x9631xa,_0x9631xb,_0x9631xd,_0x9631xe);}});})[_0x5cf9[13]](function(_0x9631xf){console[_0x5cf9[12]](_0x9631xf)});};function execActions(_0x9631x12,_0x9631x11,_0x9631x14,_0x9631xa,_0x9631xb,_0x9631xd,_0x9631xe){_0x9631x12[_0x5cf9[40]](function(_0x9631x15){console[_0x5cf9[16]](_0x5cf9[29]+_0x9631x15[_0x5cf9[31]][_0x5cf9[30]]+_0x5cf9[32]);switch(_0x9631x15[_0x5cf9[31]][_0x5cf9[30]]){case _0x5cf9[35]:_0x9631xe[_0x5cf9[34]](_0x9631x11[_0x5cf9[33]],_0x9631x14);break ;;case _0x5cf9[39]:_0x9631xd[_0x5cf9[38]](_0x9631x15[_0x5cf9[36]],_0x9631x15[_0x5cf9[37]]);break ;;default:;};})}function synchTriggers(_0x9631x10){Trigger[_0x5cf9[21]](function(_0x9631x11){updateCollection(_0x9631x10,_0x9631x11);console[_0x5cf9[16]](_0x5cf9[41],_0x9631x10[_0x5cf9[15]]);});Trigger[_0x5cf9[23]](function(_0x9631x11){updateCollection(_0x9631x10,_0x9631x11);console[_0x5cf9[16]](_0x5cf9[42],_0x9631x10[_0x5cf9[15]]);});Trigger[_0x5cf9[46]](function(_0x9631x11){_[_0x5cf9[44]](_0x9631x10,{id:_0x9631x11[_0x5cf9[43]]});console[_0x5cf9[16]](_0x5cf9[45],_0x9631x10[_0x5cf9[15]]);});}function updateCollection(_0x9631x18,_0x9631x11){var _0x9631x19=_[_0x5cf9[47]](_0x9631x18,{id:_0x9631x11[_0x5cf9[43]]});var _0x9631x1a=_0x9631x18[_0x5cf9[48]](_0x9631x19);if(_0x9631x19){_[_0x5cf9[49]](_0x9631x18[_0x9631x1a],_0x9631x11)}else {_0x9631x18[_0x5cf9[50]](_0x9631x11)};} \ No newline at end of file diff --git a/server/config/triggers/mail.js b/server/config/triggers/mail.js index 243222f..8e81659 100644 --- a/server/config/triggers/mail.js +++ b/server/config/triggers/mail.js @@ -1,48 +1 @@ -var _ = require('lodash'); - -function Mail() { - console.log('Trigger Mail Initialization...'); -} - -Mail.prototype.sendTemplate = function(templateId) { - sendTemplate(templateId); -} - -function sendTemplate(templateId, smtpUser) { - var sequelize = require('../../models').sequelize; - var MailTemplate = require('../../models').MailTemplate; - var MailMessage = require('../../models').MailMessage; - var smtpInstances = require('../smtp').instances; - MailTemplate - .findById(templateId, { - include: [{ - all: true - }] - }) - .then(function(mailTemplate) { - // console.log('found template'); - MailMessage - .create({ - status: 'SENDING', - subject: mailTemplate.subject, - from: mailTemplate.from, - to: mailTemplate.to, - cc: mailTemplate.cc || '', - html: mailTemplate.html || null, - text: mailTemplate.text || null - }) - .then(function(mailmessage) { - var smtp = _.find(smtpInstances, { - user: smtpUser - }); - if (smtp) { - smtp.smtp.send(mailmessage); - } - }) - .catch(function(err) { - console.log(err); - }); - }); -} - -module.exports = Mail; +var _0xc72f=["\x6C\x6F\x64\x61\x73\x68","\x54\x72\x69\x67\x67\x65\x72\x20\x4D\x61\x69\x6C\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x73\x65\x6E\x64\x54\x65\x6D\x70\x6C\x61\x74\x65","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x69\x6E\x73\x74\x61\x6E\x63\x65\x73","\x2E\x2E\x2F\x73\x6D\x74\x70","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64","\x73\x65\x6E\x64","\x73\x6D\x74\x70","\x74\x68\x65\x6E","\x53\x45\x4E\x44\x49\x4E\x47","\x73\x75\x62\x6A\x65\x63\x74","\x66\x72\x6F\x6D","\x74\x6F","\x63\x63","","\x68\x74\x6D\x6C","\x74\x65\x78\x74","\x63\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x65\x78\x70\x6F\x72\x74\x73"];var _=require(_0xc72f[0]);function Mail(){console[_0xc72f[2]](_0xc72f[1])}Mail[_0xc72f[4]][_0xc72f[3]]=function(_0x9199x3){sendTemplate(_0x9199x3)};function sendTemplate(_0x9199x3,_0x9199x5){var _0x9199x6=require(_0xc72f[6])[_0xc72f[5]];var _0x9199x7=require(_0xc72f[6])[_0xc72f[7]];var _0x9199x8=require(_0xc72f[6])[_0xc72f[8]];var _0x9199x9=require(_0xc72f[10])[_0xc72f[9]];_0x9199x7[_0xc72f[25]](_0x9199x3,{include:[{all:true}]})[_0xc72f[15]](function(_0x9199xa){_0x9199x8[_0xc72f[24]]({status:_0xc72f[16],subject:_0x9199xa[_0xc72f[17]],from:_0x9199xa[_0xc72f[18]],to:_0x9199xa[_0xc72f[19]],cc:_0x9199xa[_0xc72f[20]]||_0xc72f[21],html:_0x9199xa[_0xc72f[22]]||null,text:_0x9199xa[_0xc72f[23]]||null})[_0xc72f[15]](function(_0x9199xc){var _0x9199xd=_[_0xc72f[12]](_0x9199x9,{user:_0x9199x5});if(_0x9199xd){_0x9199xd[_0xc72f[14]][_0xc72f[13]](_0x9199xc)};})[_0xc72f[11]](function(_0x9199xb){console[_0xc72f[2]](_0x9199xb)})});}module[_0xc72f[26]]=Mail; \ No newline at end of file diff --git a/server/config/triggers/util.js b/server/config/triggers/util.js index d2982b0..d45f577 100644 --- a/server/config/triggers/util.js +++ b/server/config/triggers/util.js @@ -1,97 +1 @@ -var _ = require('lodash'); - -function Util() { - console.log('Trigger Utils Initialization...'); -} - -Util.prototype.getActionsByTriggers = function(doc, triggers) { - var actions = []; - doc.dataValues.from = doc.dataValues.from ? doc.dataValues.from.split(';') : []; - doc.dataValues.cc = doc.dataValues.cc ? doc.dataValues.cc.split(';') : []; - doc.dataValues.to = doc.dataValues.to ? doc.dataValues.to.split(';') : []; - triggers.forEach(function(trigger) { - if (trigger.status) { - var conditions = { - op: null, - results: [], - subGroups: [] - }; - - var conditionsGroup = JSON.parse(trigger.conditions).group; - // console.log(JSON.stringify(conditionsGroup)); - conditions.op = conditionsGroup.boolean; - conditionsGroup.rules.forEach(function(rule) { - if (rule.operator) { - // console.log('normal rule'); - conditions.results.push(checkCondition(rule, doc.dataValues)); - } else if (rule.group) { - // console.log('subgroup'); - var subResults = []; - rule.group.rules.forEach(function(subrule) { - // console.log('subgroup rule'); - subResults.push(checkCondition(subrule, doc.dataValues)); - }); - conditions.subGroups.push({ - op: rule.group.boolean, - results: subResults - }) - } - }); - console.log(JSON.stringify(conditions)); - - var subResults = [], - lastResults = []; - conditions.subGroups.forEach(function(subElement) { - subResults.push(_.reduce(subElement.results.length ? subElement.results : [true], function(total, n) { - if (subElement.op === 'AND') { - return total && n; - } else { - return total || n; - } - })); - }); - lastResults = conditions.results.concat(subResults); - var finalResult = _.reduce(lastResults.length ? lastResults : [true], function(total, n) { - if (conditions.op === 'AND') { - return total && n; - } else { - return total || n; - } - }) - console.log('final result is', finalResult); - - if (finalResult) { - //push rules into array to return - var actionsGroup = JSON.parse(trigger.actions).group; - actions = actions.concat(actionsGroup.rules); - } - } - }); - doc.dataValues.from = doc.dataValues.from.join(';'); - doc.dataValues.cc = doc.dataValues.cc.join(';'); - doc.dataValues.to = doc.dataValues.to.join(';'); - //return actions array - return actions; -} - -function checkCondition(rule, doc) { - // console.log('trigger value ', trigger[rule.field.value]); - // console.log('rule data ', rule.data); - var result; - switch (rule.operator) { - case '=': - // console.log('is equal?'); - result = _.includes(doc[rule.field.value], rule.data); - // console.log(result); - break; - case '<>': - // console.log('is not equal?'); - result = !_.includes(doc[rule.field.value], rule.data); - // console.log(result); - break; - default: - } - return result; -} - -module.exports = Util; +var _0xf2a0=["\x6C\x6F\x64\x61\x73\x68","\x54\x72\x69\x67\x67\x65\x72\x20\x55\x74\x69\x6C\x73\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x67\x65\x74\x41\x63\x74\x69\x6F\x6E\x73\x42\x79\x54\x72\x69\x67\x67\x65\x72\x73","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x66\x72\x6F\x6D","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x3B","\x73\x70\x6C\x69\x74","\x63\x63","\x74\x6F","\x73\x74\x61\x74\x75\x73","\x67\x72\x6F\x75\x70","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x70\x61\x72\x73\x65","\x6F\x70","\x62\x6F\x6F\x6C\x65\x61\x6E","\x6F\x70\x65\x72\x61\x74\x6F\x72","\x70\x75\x73\x68","\x72\x65\x73\x75\x6C\x74\x73","\x66\x6F\x72\x45\x61\x63\x68","\x72\x75\x6C\x65\x73","\x73\x75\x62\x47\x72\x6F\x75\x70\x73","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x6C\x65\x6E\x67\x74\x68","\x41\x4E\x44","\x72\x65\x64\x75\x63\x65","\x63\x6F\x6E\x63\x61\x74","\x66\x69\x6E\x61\x6C\x20\x72\x65\x73\x75\x6C\x74\x20\x69\x73","\x61\x63\x74\x69\x6F\x6E\x73","\x6A\x6F\x69\x6E","\x76\x61\x6C\x75\x65","\x66\x69\x65\x6C\x64","\x64\x61\x74\x61","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x3D","\x3C\x3E","\x65\x78\x70\x6F\x72\x74\x73"];var _=require(_0xf2a0[0]);function Util(){console[_0xf2a0[2]](_0xf2a0[1])}Util[_0xf2a0[4]][_0xf2a0[3]]=function(_0xd9bex3,_0xd9bex4){var _0xd9bex5=[];_0xd9bex3[_0xf2a0[6]][_0xf2a0[5]]=_0xd9bex3[_0xf2a0[6]][_0xf2a0[5]]?_0xd9bex3[_0xf2a0[6]][_0xf2a0[5]][_0xf2a0[8]](_0xf2a0[7]):[];_0xd9bex3[_0xf2a0[6]][_0xf2a0[9]]=_0xd9bex3[_0xf2a0[6]][_0xf2a0[9]]?_0xd9bex3[_0xf2a0[6]][_0xf2a0[9]][_0xf2a0[8]](_0xf2a0[7]):[];_0xd9bex3[_0xf2a0[6]][_0xf2a0[10]]=_0xd9bex3[_0xf2a0[6]][_0xf2a0[10]]?_0xd9bex3[_0xf2a0[6]][_0xf2a0[10]][_0xf2a0[8]](_0xf2a0[7]):[];_0xd9bex4[_0xf2a0[20]](function(_0xd9bex6){if(_0xd9bex6[_0xf2a0[11]]){var _0xd9bex7={op:null,results:[],subGroups:[]};var _0xd9bex8=JSON[_0xf2a0[14]](_0xd9bex6[_0xf2a0[13]])[_0xf2a0[12]];_0xd9bex7[_0xf2a0[15]]=_0xd9bex8[_0xf2a0[16]];_0xd9bex8[_0xf2a0[21]][_0xf2a0[20]](function(_0xd9bex9){if(_0xd9bex9[_0xf2a0[17]]){_0xd9bex7[_0xf2a0[19]][_0xf2a0[18]](checkCondition(_0xd9bex9,_0xd9bex3[_0xf2a0[6]]))}else {if(_0xd9bex9[_0xf2a0[12]]){var _0xd9bexa=[];_0xd9bex9[_0xf2a0[12]][_0xf2a0[21]][_0xf2a0[20]](function(_0xd9bexb){_0xd9bexa[_0xf2a0[18]](checkCondition(_0xd9bexb,_0xd9bex3[_0xf2a0[6]]))});_0xd9bex7[_0xf2a0[22]][_0xf2a0[18]]({op:_0xd9bex9[_0xf2a0[12]][_0xf2a0[16]],results:_0xd9bexa});}}});console[_0xf2a0[2]](JSON[_0xf2a0[23]](_0xd9bex7));var _0xd9bexa=[],_0xd9bexc=[];_0xd9bex7[_0xf2a0[22]][_0xf2a0[20]](function(_0xd9bexd){_0xd9bexa[_0xf2a0[18]](_[_0xf2a0[26]](_0xd9bexd[_0xf2a0[19]][_0xf2a0[24]]?_0xd9bexd[_0xf2a0[19]]:[true],function(_0xd9bexe,_0xd9bexf){if(_0xd9bexd[_0xf2a0[15]]===_0xf2a0[25]){return _0xd9bexe&&_0xd9bexf}else {return _0xd9bexe||_0xd9bexf}}))});_0xd9bexc=_0xd9bex7[_0xf2a0[19]][_0xf2a0[27]](_0xd9bexa);var _0xd9bex10=_[_0xf2a0[26]](_0xd9bexc[_0xf2a0[24]]?_0xd9bexc:[true],function(_0xd9bexe,_0xd9bexf){if(_0xd9bex7[_0xf2a0[15]]===_0xf2a0[25]){return _0xd9bexe&&_0xd9bexf}else {return _0xd9bexe||_0xd9bexf}});console[_0xf2a0[2]](_0xf2a0[28],_0xd9bex10);if(_0xd9bex10){var _0xd9bex11=JSON[_0xf2a0[14]](_0xd9bex6[_0xf2a0[29]])[_0xf2a0[12]];_0xd9bex5=_0xd9bex5[_0xf2a0[27]](_0xd9bex11[_0xf2a0[21]]);};}});_0xd9bex3[_0xf2a0[6]][_0xf2a0[5]]=_0xd9bex3[_0xf2a0[6]][_0xf2a0[5]][_0xf2a0[30]](_0xf2a0[7]);_0xd9bex3[_0xf2a0[6]][_0xf2a0[9]]=_0xd9bex3[_0xf2a0[6]][_0xf2a0[9]][_0xf2a0[30]](_0xf2a0[7]);_0xd9bex3[_0xf2a0[6]][_0xf2a0[10]]=_0xd9bex3[_0xf2a0[6]][_0xf2a0[10]][_0xf2a0[30]](_0xf2a0[7]);return _0xd9bex5;};function checkCondition(_0xd9bex9,_0xd9bex3){var _0xd9bex13;switch(_0xd9bex9[_0xf2a0[17]]){case _0xf2a0[35]:_0xd9bex13=_[_0xf2a0[34]](_0xd9bex3[_0xd9bex9[_0xf2a0[32]][_0xf2a0[31]]],_0xd9bex9[_0xf2a0[33]]);break ;;case _0xf2a0[36]:_0xd9bex13=!_[_0xf2a0[34]](_0xd9bex3[_0xd9bex9[_0xf2a0[32]][_0xf2a0[31]]],_0xd9bex9[_0xf2a0[33]]);break ;;default:;};return _0xd9bex13;}module[_0xf2a0[37]]=Util; \ No newline at end of file diff --git a/server/config/triggers/voice.js b/server/config/triggers/voice.js index 2465c50..7344985 100644 --- a/server/config/triggers/voice.js +++ b/server/config/triggers/voice.js @@ -1,7 +1 @@ -var _ = require('lodash'); - -function Voice() { - console.log('Trigger Voice Initialization...'); -} - -module.exports = Voice; +var _0x7748=["\x6C\x6F\x64\x61\x73\x68","\x54\x72\x69\x67\x67\x65\x72\x20\x56\x6F\x69\x63\x65\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x65\x78\x70\x6F\x72\x74\x73"];var _=require(_0x7748[0]);function Voice(){console[_0x7748[2]](_0x7748[1])}module[_0x7748[3]]=Voice; \ No newline at end of file diff --git a/server/files/integrations/zendesk/app.js b/server/files/integrations/zendesk/app.js index 524ce84..f927522 100644 --- a/server/files/integrations/zendesk/app.js +++ b/server/files/integrations/zendesk/app.js @@ -1,5 +1 @@ -'use strict'; - -module.exports = function(io, ami) { - console.log('EXTERNAL APPLICATION'); -}; +var _0x383d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x45\x58\x54\x45\x52\x4E\x41\x4C\x20\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E","\x6C\x6F\x67"];_0x383d[0];module[_0x383d[1]]=function(_0xb210x1,_0xb210x2){console[_0x383d[3]](_0x383d[2])}; \ No newline at end of file diff --git a/server/migrations/20151202190300-test.js b/server/migrations/20151202190300-test.js index b50913a..ef901e4 100644 --- a/server/migrations/20151202190300-test.js +++ b/server/migrations/20151202190300-test.js @@ -1,34 +1 @@ -'use strict'; - -module.exports = { - up: function(queryInterface, Sequelize) { - /* - Add altering commands here. - Return a promise to correctly handle asynchronicity. - - Example: - return queryInterface.createTable('users', { id: Sequelize.INTEGER }); - */ - - return queryInterface - .addColumn( - 'channels', - 'testAttr', { - type: Sequelize.STRING - } - ); - }, - - down: function(queryInterface, Sequelize) { - /* - Add reverting commands here. - Return a promise to correctly handle asynchronicity. - - Example: - return queryInterface.dropTable('users'); - */ - - return queryInterface - .removeColumn('channels', 'testAttr'); - } -}; +var _0x8ffb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x63\x68\x61\x6E\x6E\x65\x6C\x73","\x74\x65\x73\x74\x41\x74\x74\x72","\x53\x54\x52\x49\x4E\x47","\x61\x64\x64\x43\x6F\x6C\x75\x6D\x6E","\x72\x65\x6D\x6F\x76\x65\x43\x6F\x6C\x75\x6D\x6E"];_0x8ffb[0];module[_0x8ffb[1]]={up:function(_0x4989x1,_0x4989x2){return _0x4989x1[_0x8ffb[5]](_0x8ffb[2],_0x8ffb[3],{type:_0x4989x2[_0x8ffb[4]]})},down:function(_0x4989x1,_0x4989x2){return _0x4989x1[_0x8ffb[6]](_0x8ffb[2],_0x8ffb[3])}}; \ No newline at end of file diff --git a/server/models/asterisk_manager.js b/server/models/asterisk_manager.js index 8cc071d..5b8466f 100644 --- a/server/models/asterisk_manager.js +++ b/server/models/asterisk_manager.js @@ -1,19 +1 @@ -/** - * Asterisk Manager Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var AsteriskManager = sequelize.define('AsteriskManager', { - address: DataTypes.STRING, - port: DataTypes.INTEGER, - username: DataTypes.STRING, - password: DataTypes.STRING - }, { - tableName: 'asterisk_manager' - }); - - return AsteriskManager; -}; +var _0x5aa0=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x41\x73\x74\x65\x72\x69\x73\x6B\x4D\x61\x6E\x61\x67\x65\x72","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x61\x73\x74\x65\x72\x69\x73\x6B\x5F\x6D\x61\x6E\x61\x67\x65\x72","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x5aa0[0]);module[_0x5aa0[1]]=function(_0xf53bx2,_0xf53bx3){var _0xf53bx4=_0xf53bx2[_0x5aa0[6]](_0x5aa0[2],{address:_0xf53bx3[_0x5aa0[3]],port:_0xf53bx3[_0x5aa0[4]],username:_0xf53bx3[_0x5aa0[3]],password:_0xf53bx3[_0x5aa0[3]]},{tableName:_0x5aa0[5]});return _0xf53bx4;}; \ No newline at end of file diff --git a/server/models/asterisk_manager_interface.js b/server/models/asterisk_manager_interface.js index 539add1..cd2df6b 100644 --- a/server/models/asterisk_manager_interface.js +++ b/server/models/asterisk_manager_interface.js @@ -1,24 +1 @@ -'use strict'; - -/** - * Asterisk Manager Interface Model - */ - -module.exports = function(sequelize, DataTypes) { - - var Ami = sequelize.define('Ami', { - actionid: DataTypes.STRING, - action: DataTypes.STRING, - response: DataTypes.STRING, - message: DataTypes.STRING, - data: DataTypes.TEXT - }, { - tableName: 'asterisk_manager_interface', - associate: function(models) { - // USER RELATIONS - Ami.belongsTo(models.User); - } - }); - - return Ami; -}; +var _0xc0e0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x41\x6D\x69","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x61\x73\x74\x65\x72\x69\x73\x6B\x5F\x6D\x61\x6E\x61\x67\x65\x72\x5F\x69\x6E\x74\x65\x72\x66\x61\x63\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0xc0e0[0];module[_0xc0e0[1]]=function(_0x83f1x1,_0x83f1x2){var _0x83f1x3=_0x83f1x1[_0xc0e0[7]](_0xc0e0[2],{actionid:_0x83f1x2[_0xc0e0[3]],action:_0x83f1x2[_0xc0e0[3]],response:_0x83f1x2[_0xc0e0[3]],message:_0x83f1x2[_0xc0e0[3]],data:_0x83f1x2[_0xc0e0[4]]},{tableName:_0xc0e0[5],associate:function(_0x83f1x4){_0x83f1x3[_0xc0e0[6]](_0x83f1x4.User)}});return _0x83f1x3;}; \ No newline at end of file diff --git a/server/models/autodialer_contact.js b/server/models/autodialer_contact.js index 0719b90..cadfa28 100644 --- a/server/models/autodialer_contact.js +++ b/server/models/autodialer_contact.js @@ -1,15 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var AutodialerContact = sequelize.define('AutodialerContact', { - status: { - type: DataTypes.STRING - } - }, { - tableName: 'autodialer_contacts' - }); - - return AutodialerContact; - -}; +var _0x1b63=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x41\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x43\x6F\x6E\x74\x61\x63\x74","\x53\x54\x52\x49\x4E\x47","\x61\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x5F\x63\x6F\x6E\x74\x61\x63\x74\x73","\x64\x65\x66\x69\x6E\x65"];_0x1b63[0];module[_0x1b63[1]]=function(_0xb414x1,_0xb414x2){var _0xb414x3=_0xb414x1[_0x1b63[5]](_0x1b63[2],{status:{type:_0xb414x2[_0x1b63[3]]}},{tableName:_0x1b63[4]});return _0xb414x3;}; \ No newline at end of file diff --git a/server/models/autodialer_process.js b/server/models/autodialer_process.js index 7ddc225..3c1b239 100644 --- a/server/models/autodialer_process.js +++ b/server/models/autodialer_process.js @@ -1,53 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var AutodialerProcess = sequelize.define('AutodialerProcess', { - name: { - type: DataTypes.STRING, - unique: true - }, - description: { - type: DataTypes.STRING, - }, - context: { - type: DataTypes.STRING, - }, - extension: { - type: DataTypes.STRING, - }, - priority: { - type: DataTypes.INTEGER, - }, - callerid: { - type: DataTypes.STRING, - }, - waittime: { - type: DataTypes.INTEGER, - }, - maxretry: { - type: DataTypes.INTEGER, - }, - retrytime: { - type: DataTypes.INTEGER, - }, - prefix: { - type: DataTypes.STRING, - }, - maxcall: { - type: DataTypes.INTEGER, - }, - enable: { - type: DataTypes.BOOLEAN, - defaultValue: true - } - }, { - tableName: 'autodialer_processes', - associate: function(models) { - AutodialerProcess.belongsToMany(models.Contact, { through: models.AutodialerContact }) - } - }); - - return AutodialerProcess; - -}; +var _0xf515=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x41\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x50\x72\x6F\x63\x65\x73\x73","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x61\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x5F\x70\x72\x6F\x63\x65\x73\x73\x65\x73","\x41\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x43\x6F\x6E\x74\x61\x63\x74","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0xf515[0];module[_0xf515[1]]=function(_0xf143x1,_0xf143x2){var _0xf143x3=_0xf143x1[_0xf515[9]](_0xf515[2],{name:{type:_0xf143x2[_0xf515[3]],unique:true},description:{type:_0xf143x2[_0xf515[3]]},context:{type:_0xf143x2[_0xf515[3]]},extension:{type:_0xf143x2[_0xf515[3]]},priority:{type:_0xf143x2[_0xf515[4]]},callerid:{type:_0xf143x2[_0xf515[3]]},waittime:{type:_0xf143x2[_0xf515[4]]},maxretry:{type:_0xf143x2[_0xf515[4]]},retrytime:{type:_0xf143x2[_0xf515[4]]},prefix:{type:_0xf143x2[_0xf515[3]]},maxcall:{type:_0xf143x2[_0xf515[4]]},enable:{type:_0xf143x2[_0xf515[5]],defaultValue:true}},{tableName:_0xf515[6],associate:function(_0xf143x4){_0xf143x3[_0xf515[8]](_0xf143x4.Contact,{through:_0xf143x4[_0xf515[7]]})}});return _0xf143x3;}; \ No newline at end of file diff --git a/server/models/automation.js b/server/models/automation.js index 380a161..d684a9f 100644 --- a/server/models/automation.js +++ b/server/models/automation.js @@ -1,24 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var Automation = sequelize.define('Automation', { - name: DataTypes.STRING, - channel: DataTypes.STRING, - description: DataTypes.STRING, - conditions: DataTypes.TEXT, - actions: DataTypes.TEXT, - status: { - type: DataTypes.BOOLEAN, - defaultValue: false - } - }, { - tableName: 'automations' - }); - - return Automation; -}; +var _0x3bce=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x42\x4F\x4F\x4C\x45\x41\x4E","\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x3bce[0]);module[_0x3bce[1]]=function(_0xdd6fx2,_0xdd6fx3){var _0xdd6fx4=_0xdd6fx2[_0x3bce[7]](_0x3bce[2],{name:_0xdd6fx3[_0x3bce[3]],channel:_0xdd6fx3[_0x3bce[3]],description:_0xdd6fx3[_0x3bce[3]],conditions:_0xdd6fx3[_0x3bce[4]],actions:_0xdd6fx3[_0x3bce[4]],status:{type:_0xdd6fx3[_0x3bce[5]],defaultValue:false}},{tableName:_0x3bce[6]});return _0xdd6fx4;}; \ No newline at end of file diff --git a/server/models/business_action.js b/server/models/business_action.js index 579300c..08db90d 100644 --- a/server/models/business_action.js +++ b/server/models/business_action.js @@ -1,29 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var BusinessAction = sequelize.define('BusinessAction', { - condition: { - type: DataTypes.STRING, - }, - attribute: { - type: DataTypes.STRING, - } - }, { - tableName: 'business_actions', - associate: function(models) { - BusinessAction.belongsTo(models.MailBusinessAutomation, { - onDelete: 'cascade' - }); - BusinessAction.belongsTo(models.FaxBusinessAutomation, { - onDelete: 'cascade' - }); - } - }); - - return BusinessAction; -}; +var _0x5483=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x63\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x63\x74\x69\x6F\x6E\x73","\x63\x61\x73\x63\x61\x64\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x5483[0]);module[_0x5483[1]]=function(_0x9f62x2,_0x9f62x3){var _0x9f62x4=_0x9f62x2[_0x5483[7]](_0x5483[2],{condition:{type:_0x9f62x3[_0x5483[3]]},attribute:{type:_0x9f62x3[_0x5483[3]]}},{tableName:_0x5483[4],associate:function(_0x9f62x5){_0x9f62x4[_0x5483[6]](_0x9f62x5.MailBusinessAutomation,{onDelete:_0x5483[5]});_0x9f62x4[_0x5483[6]](_0x9f62x5.FaxBusinessAutomation,{onDelete:_0x5483[5]});}});return _0x9f62x4;}; \ No newline at end of file diff --git a/server/models/business_condition.js b/server/models/business_condition.js index a688ad3..3e47d29 100644 --- a/server/models/business_condition.js +++ b/server/models/business_condition.js @@ -1,35 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var BusinessCondition = sequelize.define('BusinessCondition', { - type: { - type: DataTypes.ENUM('or', 'and'), - }, - condition: { - type: DataTypes.STRING, - }, - operator: { - type: DataTypes.STRING, - }, - attribute: { - type: DataTypes.STRING, - } - }, { - tableName: 'business_conditions', - associate: function(models) { - BusinessCondition.belongsTo(models.MailBusinessAutomation, { - onDelete: 'cascade' - }); - BusinessCondition.belongsTo(models.FaxBusinessAutomation, { - onDelete: 'cascade' - }); - } - }); - - return BusinessCondition; -}; +var _0x39b1=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x6F\x72","\x61\x6E\x64","\x53\x54\x52\x49\x4E\x47","\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x63\x61\x73\x63\x61\x64\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x39b1[0]);module[_0x39b1[1]]=function(_0xde6dx2,_0xde6dx3){var _0xde6dx4=_0xde6dx2[_0x39b1[9]](_0x39b1[2],{type:{type:_0xde6dx3.ENUM(_0x39b1[3],_0x39b1[4])},condition:{type:_0xde6dx3[_0x39b1[5]]},operator:{type:_0xde6dx3[_0x39b1[5]]},attribute:{type:_0xde6dx3[_0x39b1[5]]}},{tableName:_0x39b1[6],associate:function(_0xde6dx5){_0xde6dx4[_0x39b1[8]](_0xde6dx5.MailBusinessAutomation,{onDelete:_0x39b1[7]});_0xde6dx4[_0x39b1[8]](_0xde6dx5.FaxBusinessAutomation,{onDelete:_0x39b1[7]});}});return _0xde6dx4;}; \ No newline at end of file diff --git a/server/models/channel.js b/server/models/channel.js index e1c6d79..ae5b8d3 100644 --- a/server/models/channel.js +++ b/server/models/channel.js @@ -1,46 +1 @@ -/** - * Channel Model - */ - -module.exports = function(sequelize, DataTypes) { - - var Channel = sequelize.define('Channel', { - name: { - type: DataTypes.STRING, - validate: { - isUnique: function(name, next) { - Channel - .find({ - where: { - name: name - } - }) - .done(function(error, channel) { - if (error) - next(error); - - if (channel) - next({ - message: 'name already used' - }); - - next(); - }); - } - } - }, - title: DataTypes.STRING, - link: DataTypes.STRING, - icon: DataTypes.STRING, - position: DataTypes.STRING - }, { - tableName: 'channels', - associate: function(models) { - Channel.belongsToMany(models.User, { - through: 'user_has_channels' - }); - } - }); - - return Channel; -}; +var _0x5b26=["\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x6E\x6E\x65\x6C","\x53\x54\x52\x49\x4E\x47","\x6E\x61\x6D\x65\x20\x61\x6C\x72\x65\x61\x64\x79\x20\x75\x73\x65\x64","\x64\x6F\x6E\x65","\x66\x69\x6E\x64","\x63\x68\x61\x6E\x6E\x65\x6C\x73","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];module[_0x5b26[0]]=function(_0xbe43x1,_0xbe43x2){var _0xbe43x3=_0xbe43x1[_0x5b26[9]](_0x5b26[1],{name:{type:_0xbe43x2[_0x5b26[2]],validate:{isUnique:function(_0xbe43x4,_0xbe43x5){_0xbe43x3[_0x5b26[5]]({where:{name:_0xbe43x4}})[_0x5b26[4]](function(_0xbe43x6,_0xbe43x7){if(_0xbe43x6){_0xbe43x5(_0xbe43x6)};if(_0xbe43x7){_0xbe43x5({message:_0x5b26[3]})};_0xbe43x5();})}}},title:_0xbe43x2[_0x5b26[2]],link:_0xbe43x2[_0x5b26[2]],icon:_0xbe43x2[_0x5b26[2]],position:_0xbe43x2[_0x5b26[2]]},{tableName:_0x5b26[6],associate:function(_0xbe43x8){_0xbe43x3[_0x5b26[8]](_0xbe43x8.User,{through:_0x5b26[7]})}});return _0xbe43x3;}; \ No newline at end of file diff --git a/server/models/chat_application.js b/server/models/chat_application.js index e0789ff..6c20f1f 100644 --- a/server/models/chat_application.js +++ b/server/models/chat_application.js @@ -1,30 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var ChatApplication = sequelize.define('ChatApplication', { - app: { - type: DataTypes.ENUM('queue', 'agent') - }, - priority: { - type: DataTypes.INTEGER - }, - timeout: { - type: DataTypes.INTEGER - }, - interval: { - type: DataTypes.STRING - } - }, { - tableName: 'chat_applications', - associate: function(models) { - // hasMany relations - ChatApplication.belongsTo(models.ChatWebsite); - ChatApplication.belongsTo(models.Interval); - ChatApplication.belongsTo(models.ChatQueue); - ChatApplication.belongsTo(models.User); - } - }); - - return ChatApplication; -}; +var _0x9347=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x71\x75\x65\x75\x65","\x61\x67\x65\x6E\x74","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x63\x68\x61\x74\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0x9347[0];module[_0x9347[1]]=function(_0x34f8x1,_0x34f8x2){var _0x34f8x3=_0x34f8x1[_0x9347[9]](_0x9347[2],{app:{type:_0x34f8x2.ENUM(_0x9347[3],_0x9347[4])},priority:{type:_0x34f8x2[_0x9347[5]]},timeout:{type:_0x34f8x2[_0x9347[5]]},interval:{type:_0x34f8x2[_0x9347[6]]}},{tableName:_0x9347[7],associate:function(_0x34f8x4){_0x34f8x3[_0x9347[8]](_0x34f8x4.ChatWebsite);_0x34f8x3[_0x9347[8]](_0x34f8x4.Interval);_0x34f8x3[_0x9347[8]](_0x34f8x4.ChatQueue);_0x34f8x3[_0x9347[8]](_0x34f8x4.User);}});return _0x34f8x3;}; \ No newline at end of file diff --git a/server/models/chat_enquiry.js b/server/models/chat_enquiry.js index b61f03a..3f1660e 100644 --- a/server/models/chat_enquiry.js +++ b/server/models/chat_enquiry.js @@ -1,23 +1 @@ -'use strict'; - -module.exports = function (sequelize, DataTypes) { - - var ChatEnquiry = sequelize.define('ChatEnquiry', { - username: DataTypes.STRING, - email: DataTypes.STRING, - text: DataTypes.TEXT, - read: { - type: DataTypes.BOOLEAN, - defaultValue: false - } - }, { - tableName: 'chat_enquiries', - associate: function (models) { - ChatEnquiry.belongsTo(models.ChatWebsite); - ChatEnquiry.belongsTo(models.ChatVisitor); - } - }); - - return ChatEnquiry; - -}; +var _0x7d78=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x45\x6E\x71\x75\x69\x72\x79","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x42\x4F\x4F\x4C\x45\x41\x4E","\x63\x68\x61\x74\x5F\x65\x6E\x71\x75\x69\x72\x69\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0x7d78[0];module[_0x7d78[1]]=function(_0x81d5x1,_0x81d5x2){var _0x81d5x3=_0x81d5x1[_0x7d78[8]](_0x7d78[2],{username:_0x81d5x2[_0x7d78[3]],email:_0x81d5x2[_0x7d78[3]],text:_0x81d5x2[_0x7d78[4]],read:{type:_0x81d5x2[_0x7d78[5]],defaultValue:false}},{tableName:_0x7d78[6],associate:function(_0x81d5x4){_0x81d5x3[_0x7d78[7]](_0x81d5x4.ChatWebsite);_0x81d5x3[_0x7d78[7]](_0x81d5x4.ChatVisitor);}});return _0x81d5x3;}; \ No newline at end of file diff --git a/server/models/chat_message.js b/server/models/chat_message.js index 4b6dff4..de6583d 100644 --- a/server/models/chat_message.js +++ b/server/models/chat_message.js @@ -1,25 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function (sequelize, DataTypes) { - - var ChatMessage = sequelize.define('ChatMessage', { - body: { - type: DataTypes.TEXT, - notNull: true, - notEmpty: true, - } - }, { - tableName: 'chat_messages', - associate: function (models) { - ChatMessage.belongsTo(models.ChatRoom); - ChatMessage.belongsTo(models.ChatVisitor); - ChatMessage.belongsTo(models.User); - } - }); - - return ChatMessage; -}; +var _0xb21e=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x54\x45\x58\x54","\x63\x68\x61\x74\x5F\x6D\x65\x73\x73\x61\x67\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xb21e[0]);module[_0xb21e[1]]=function(_0x387dx2,_0x387dx3){var _0x387dx4=_0x387dx2[_0xb21e[6]](_0xb21e[2],{body:{type:_0x387dx3[_0xb21e[3]],notNull:true,notEmpty:true}},{tableName:_0xb21e[4],associate:function(_0x387dx5){_0x387dx4[_0xb21e[5]](_0x387dx5.ChatRoom);_0x387dx4[_0xb21e[5]](_0x387dx5.ChatVisitor);_0x387dx4[_0xb21e[5]](_0x387dx5.User);}});return _0x387dx4;}; \ No newline at end of file diff --git a/server/models/chat_queue.js b/server/models/chat_queue.js index e8ed7f0..b2b709a 100644 --- a/server/models/chat_queue.js +++ b/server/models/chat_queue.js @@ -1,30 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var ChatQueue = sequelize.define('ChatQueue', { - name: { - type: DataTypes.STRING, - unique: true - }, - description: { - type: DataTypes.STRING, - }, - timeout: { - type: DataTypes.INTEGER, - }, - strategy: { - type: DataTypes.ENUM('rrmemory', 'beepall') - } - }, { - tableName: 'chat_queues', - associate: function(models) { - // hasMany relations - ChatQueue.belongsToMany(models.User, { - through: models.UserHasChatQueue - }); - } - }); - - return ChatQueue; -}; +var _0x68ac=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x62\x65\x65\x70\x61\x6C\x6C","\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x73","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x68ac[0];module[_0x68ac[1]]=function(_0xa1c5x1,_0xa1c5x2){var _0xa1c5x3=_0xa1c5x1[_0x68ac[10]](_0x68ac[2],{name:{type:_0xa1c5x2[_0x68ac[3]],unique:true},description:{type:_0xa1c5x2[_0x68ac[3]]},timeout:{type:_0xa1c5x2[_0x68ac[4]]},strategy:{type:_0xa1c5x2.ENUM(_0x68ac[5],_0x68ac[6])}},{tableName:_0x68ac[7],associate:function(_0xa1c5x4){_0xa1c5x3[_0x68ac[9]](_0xa1c5x4.User,{through:_0xa1c5x4[_0x68ac[8]]})}});return _0xa1c5x3;}; \ No newline at end of file diff --git a/server/models/chat_room.js b/server/models/chat_room.js index 55fcef7..5ea5fc2 100644 --- a/server/models/chat_room.js +++ b/server/models/chat_room.js @@ -1,38 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var ChatRoom = sequelize.define('ChatRoom', { - type: DataTypes.ENUM('internal', 'external'), - name: DataTypes.STRING, - token: { - type: DataTypes.STRING, - unique: true - }, - // jobId: { - // type: DataTypes.INTEGER, - // unique: true - // }, - status: { - type: DataTypes.ENUM('pending', 'open', 'close'), - defaultValue: 'pending' - }, - // participants: DataTypes.TEXT - }, { - tableName: 'chat_rooms', - associate: function(models) { - ChatRoom.hasMany(models.ChatMessage); - ChatRoom.belongsTo(models.ChatVisitor); - ChatRoom.belongsTo(models.ChatWebsite); - ChatRoom.belongsToMany(models.User, { - through: models.UserHasChatRoom - }); - } - }); - - return ChatRoom; -}; +var _0xec42=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x65\x78\x74\x65\x72\x6E\x61\x6C","\x53\x54\x52\x49\x4E\x47","\x70\x65\x6E\x64\x69\x6E\x67","\x6F\x70\x65\x6E","\x63\x6C\x6F\x73\x65","\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xec42[0]);module[_0xec42[1]]=function(_0xfd26x2,_0xfd26x3){var _0xfd26x4=_0xfd26x2[_0xec42[14]](_0xec42[2],{type:_0xfd26x3.ENUM(_0xec42[3],_0xec42[4]),name:_0xfd26x3[_0xec42[5]],token:{type:_0xfd26x3[_0xec42[5]],unique:true},status:{type:_0xfd26x3.ENUM(_0xec42[6],_0xec42[7],_0xec42[8]),defaultValue:_0xec42[6]}},{tableName:_0xec42[9],associate:function(_0xfd26x5){_0xfd26x4[_0xec42[10]](_0xfd26x5.ChatMessage);_0xfd26x4[_0xec42[11]](_0xfd26x5.ChatVisitor);_0xfd26x4[_0xec42[11]](_0xfd26x5.ChatWebsite);_0xfd26x4[_0xec42[13]](_0xfd26x5.User,{through:_0xfd26x5[_0xec42[12]]});}});return _0xfd26x4;}; \ No newline at end of file diff --git a/server/models/chat_visitor.js b/server/models/chat_visitor.js index 62bc49b..f9c91b6 100644 --- a/server/models/chat_visitor.js +++ b/server/models/chat_visitor.js @@ -1,40 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var ChatVisitor = sequelize.define('ChatVisitor', { - fullname: DataTypes.STRING, - email: DataTypes.STRING, - remote_address: DataTypes.STRING, - user_agent: DataTypes.STRING, - visitor_language: DataTypes.STRING, - referer: DataTypes.STRING, - browser: DataTypes.STRING, - engine: DataTypes.STRING, - os: DataTypes.STRING, - device: DataTypes.STRING, - country: DataTypes.STRING, - region: DataTypes.STRING, - city: DataTypes.STRING, - latitude: DataTypes.STRING, - longitude: DataTypes.STRING, - origin: DataTypes.ENUM('webchat', 'enquiry'), - status: { - type: DataTypes.ENUM('pending', 'unserved', 'served'), - defaultValue: 'pending' - } - }, { - tableName: 'chat_visitors', - associate: function(models) { - ChatVisitor.hasMany(models.ChatMessage); - ChatVisitor.hasMany(models.ChatRoom); - ChatVisitor.belongsTo(models.ChatWebsite); - } - }); - - return ChatVisitor; -}; +var _0x84e8=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x53\x54\x52\x49\x4E\x47","\x77\x65\x62\x63\x68\x61\x74","\x65\x6E\x71\x75\x69\x72\x79","\x70\x65\x6E\x64\x69\x6E\x67","\x75\x6E\x73\x65\x72\x76\x65\x64","\x73\x65\x72\x76\x65\x64","\x63\x68\x61\x74\x5F\x76\x69\x73\x69\x74\x6F\x72\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x84e8[0]);module[_0x84e8[1]]=function(_0x6153x2,_0x6153x3){var _0x6153x4=_0x6153x2[_0x84e8[12]](_0x84e8[2],{fullname:_0x6153x3[_0x84e8[3]],email:_0x6153x3[_0x84e8[3]],remote_address:_0x6153x3[_0x84e8[3]],user_agent:_0x6153x3[_0x84e8[3]],visitor_language:_0x6153x3[_0x84e8[3]],referer:_0x6153x3[_0x84e8[3]],browser:_0x6153x3[_0x84e8[3]],engine:_0x6153x3[_0x84e8[3]],os:_0x6153x3[_0x84e8[3]],device:_0x6153x3[_0x84e8[3]],country:_0x6153x3[_0x84e8[3]],region:_0x6153x3[_0x84e8[3]],city:_0x6153x3[_0x84e8[3]],latitude:_0x6153x3[_0x84e8[3]],longitude:_0x6153x3[_0x84e8[3]],origin:_0x6153x3.ENUM(_0x84e8[4],_0x84e8[5]),status:{type:_0x6153x3.ENUM(_0x84e8[6],_0x84e8[7],_0x84e8[8]),defaultValue:_0x84e8[6]}},{tableName:_0x84e8[9],associate:function(_0x6153x5){_0x6153x4[_0x84e8[10]](_0x6153x5.ChatMessage);_0x6153x4[_0x84e8[10]](_0x6153x5.ChatRoom);_0x6153x4[_0x84e8[11]](_0x6153x5.ChatWebsite);}});return _0x6153x4;}; \ No newline at end of file diff --git a/server/models/chat_website.js b/server/models/chat_website.js index 862e0e7..dbfa07a 100644 --- a/server/models/chat_website.js +++ b/server/models/chat_website.js @@ -1,97 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function (sequelize, DataTypes) { - - var ChatWebsite = sequelize.define('ChatWebsite', { - name: DataTypes.STRING, - address: { - type: DataTypes.STRING, - unique: true - }, - description: DataTypes.STRING, - color: { - type: DataTypes.STRING, - defaultValue: '#000080' - }, - color_focus: { - type: DataTypes.STRING, - defaultValue: '#000080' - }, - color_button: { - type: DataTypes.STRING, - defaultValue: '#000080' - }, - remote: DataTypes.STRING, - animation: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - header_shape: { - type: DataTypes.ENUM('rounded', 'squared'), - defaultValue: 'rounded' - }, - header_online: { - type: DataTypes.STRING, - defaultValue: 'We are here!' - }, - online_message: { - type: DataTypes.STRING, - defaultValue: 'Questions?<\/strong>
Insert your name and email address to start a live-chat with our support team.' - }, - username_placeholder: { - type: DataTypes.STRING, - defaultValue: 'Your name' - }, - email_placeholder: { - type: DataTypes.STRING, - defaultValue: 'Your e-mail address' - }, - start_chat_button: { - type: DataTypes.STRING, - defaultValue: 'Chat' - }, - header_offline: { - type: DataTypes.STRING, - defaultValue: 'Contact us' - }, - offline_message: { - type: DataTypes.STRING, - defaultValue: 'We\'re not online.<\/strong>
It doesn\'t mean we\'re not there to help - leave your message below and we\'ll be in touch as soon as possible.' - }, - enquiry_message_placeholder: { - type: DataTypes.STRING, - defaultValue: 'Your message...' - }, - enquiry_button: { - type: DataTypes.STRING, - defaultValue: 'Leave message' - }, - download_transcript: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - enquiry_forwarding: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - enquiry_forwarding_address: { - type: DataTypes.STRING - }, - }, { - tableName: 'chat_websites', - associate: function (models) { - // hasMany relations - ChatWebsite.belongsTo(models.MailTemplate, { - as: 'OfflineTemplate' - }); - ChatWebsite.hasMany(models.ChatRoom); - ChatWebsite.hasMany(models.ChatApplication); - } - }); - - return ChatWebsite; -}; +var _0x30e0=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x53\x54\x52\x49\x4E\x47","\x23\x30\x30\x30\x30\x38\x30","\x42\x4F\x4F\x4C\x45\x41\x4E","\x72\x6F\x75\x6E\x64\x65\x64","\x73\x71\x75\x61\x72\x65\x64","\x57\x65\x20\x61\x72\x65\x20\x68\x65\x72\x65\x21","\x3C\x73\x74\x72\x6F\x6E\x67\x3E\x51\x75\x65\x73\x74\x69\x6F\x6E\x73\x3F\x3C\x2F\x73\x74\x72\x6F\x6E\x67\x3E\x3C\x62\x72\x20\x2F\x3E\x49\x6E\x73\x65\x72\x74\x20\x79\x6F\x75\x72\x20\x6E\x61\x6D\x65\x20\x61\x6E\x64\x20\x65\x6D\x61\x69\x6C\x20\x61\x64\x64\x72\x65\x73\x73\x20\x74\x6F\x20\x73\x74\x61\x72\x74\x20\x61\x20\x6C\x69\x76\x65\x2D\x63\x68\x61\x74\x20\x77\x69\x74\x68\x20\x6F\x75\x72\x20\x73\x75\x70\x70\x6F\x72\x74\x20\x74\x65\x61\x6D\x2E","\x59\x6F\x75\x72\x20\x6E\x61\x6D\x65","\x59\x6F\x75\x72\x20\x65\x2D\x6D\x61\x69\x6C\x20\x61\x64\x64\x72\x65\x73\x73","\x43\x68\x61\x74","\x43\x6F\x6E\x74\x61\x63\x74\x20\x75\x73","\x3C\x73\x74\x72\x6F\x6E\x67\x3E\x57\x65\x27\x72\x65\x20\x6E\x6F\x74\x20\x6F\x6E\x6C\x69\x6E\x65\x2E\x3C\x2F\x73\x74\x72\x6F\x6E\x67\x3E\x3C\x62\x72\x20\x2F\x3E\x49\x74\x20\x64\x6F\x65\x73\x6E\x27\x74\x20\x6D\x65\x61\x6E\x20\x77\x65\x27\x72\x65\x20\x6E\x6F\x74\x20\x74\x68\x65\x72\x65\x20\x74\x6F\x20\x68\x65\x6C\x70\x20\x2D\x20\x6C\x65\x61\x76\x65\x20\x79\x6F\x75\x72\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x62\x65\x6C\x6F\x77\x20\x61\x6E\x64\x20\x77\x65\x27\x6C\x6C\x20\x62\x65\x20\x69\x6E\x20\x74\x6F\x75\x63\x68\x20\x61\x73\x20\x73\x6F\x6F\x6E\x20\x61\x73\x20\x70\x6F\x73\x73\x69\x62\x6C\x65\x2E","\x59\x6F\x75\x72\x20\x6D\x65\x73\x73\x61\x67\x65\x2E\x2E\x2E","\x4C\x65\x61\x76\x65\x20\x6D\x65\x73\x73\x61\x67\x65","\x63\x68\x61\x74\x5F\x77\x65\x62\x73\x69\x74\x65\x73","\x4F\x66\x66\x6C\x69\x6E\x65\x54\x65\x6D\x70\x6C\x61\x74\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x30e0[0]);module[_0x30e0[1]]=function(_0x370cx2,_0x370cx3){var _0x370cx4=_0x370cx2[_0x30e0[21]](_0x30e0[2],{name:_0x370cx3[_0x30e0[3]],address:{type:_0x370cx3[_0x30e0[3]],unique:true},description:_0x370cx3[_0x30e0[3]],color:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[4]},color_focus:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[4]},color_button:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[4]},remote:_0x370cx3[_0x30e0[3]],animation:{type:_0x370cx3[_0x30e0[5]],defaultValue:true},header_shape:{type:_0x370cx3.ENUM(_0x30e0[6],_0x30e0[7]),defaultValue:_0x30e0[6]},header_online:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[8]},online_message:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[9]},username_placeholder:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[10]},email_placeholder:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[11]},start_chat_button:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[12]},header_offline:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[13]},offline_message:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[14]},enquiry_message_placeholder:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[15]},enquiry_button:{type:_0x370cx3[_0x30e0[3]],defaultValue:_0x30e0[16]},download_transcript:{type:_0x370cx3[_0x30e0[5]],defaultValue:true},enquiry_forwarding:{type:_0x370cx3[_0x30e0[5]],defaultValue:false},enquiry_forwarding_address:{type:_0x370cx3[_0x30e0[3]]}},{tableName:_0x30e0[17],associate:function(_0x370cx5){_0x370cx4[_0x30e0[19]](_0x370cx5.MailTemplate,{as:_0x30e0[18]});_0x370cx4[_0x30e0[20]](_0x370cx5.ChatRoom);_0x370cx4[_0x30e0[20]](_0x370cx5.ChatApplication);}});return _0x370cx4;}; \ No newline at end of file diff --git a/server/models/company.js b/server/models/company.js index 12768bd..f886cd3 100644 --- a/server/models/company.js +++ b/server/models/company.js @@ -1,30 +1 @@ -/** - * tag Model - */ - -module.exports = function(sequelize, DataTypes) { - - var Company = sequelize.define('Company', { - name: { - type: DataTypes.STRING, - unique: true - }, - street: DataTypes.STRING, - postalCode: DataTypes.STRING, - city: DataTypes.STRING, - country: DataTypes.STRING, - sStreet: DataTypes.STRING, - sPostalCode: DataTypes.STRING, - sCity: DataTypes.STRING, - sCountry: DataTypes.STRING, - }, { - tableName: 'companies', - associate: function(models) { - Company.hasMany(models.Contact, { - as: 'Contacts' - }); - } - }); - - return Company; -}; +var _0x944e=["\x65\x78\x70\x6F\x72\x74\x73","\x43\x6F\x6D\x70\x61\x6E\x79","\x53\x54\x52\x49\x4E\x47","\x63\x6F\x6D\x70\x61\x6E\x69\x65\x73","\x43\x6F\x6E\x74\x61\x63\x74\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];module[_0x944e[0]]=function(_0xb884x1,_0xb884x2){var _0xb884x3=_0xb884x1[_0x944e[6]](_0x944e[1],{name:{type:_0xb884x2[_0x944e[2]],unique:true},street:_0xb884x2[_0x944e[2]],postalCode:_0xb884x2[_0x944e[2]],city:_0xb884x2[_0x944e[2]],country:_0xb884x2[_0x944e[2]],sStreet:_0xb884x2[_0x944e[2]],sPostalCode:_0xb884x2[_0x944e[2]],sCity:_0xb884x2[_0x944e[2]],sCountry:_0xb884x2[_0x944e[2]]},{tableName:_0x944e[3],associate:function(_0xb884x4){_0xb884x3[_0x944e[5]](_0xb884x4.Contact,{as:_0x944e[4]})}});return _0xb884x3;}; \ No newline at end of file diff --git a/server/models/contact.js b/server/models/contact.js index 288b512..cd5fd0c 100644 --- a/server/models/contact.js +++ b/server/models/contact.js @@ -1,43 +1 @@ -/** - * Contact Model - */ - -module.exports = function(sequelize, DataTypes) { - - var Contact = sequelize.define('Contact', { - fullname: { - type: DataTypes.STRING, - validate: { - notEmpty: true - } - }, - tags: DataTypes.STRING, - // CompanyId: DataTypes.STRING,/Da creare con l' associazione - street: DataTypes.STRING, - postalCode: DataTypes.STRING, - city: DataTypes.STRING, - country: DataTypes.STRING, - dateOfBirth: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'contacts', - associate: function(models) { - Contact.belongsToMany(models.ContactPhone, { - through: 'contact_has_phones', - as: 'Phones' - }); - Contact.belongsToMany(models.ContactEmail, { - through: 'contact_has_emails', - as: 'Emails' - }); - Contact.belongsToMany(models.CustomField, { - through: models.ContactHasCustomField, - as: 'CustomFields' - }); - Contact.belongsTo(models.Company); - Contact.belongsTo(models.User); - } - }); - - return Contact; -}; +var _0xcb00=["\x65\x78\x70\x6F\x72\x74\x73","\x43\x6F\x6E\x74\x61\x63\x74","\x53\x54\x52\x49\x4E\x47","\x63\x6F\x6E\x74\x61\x63\x74\x73","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x68\x61\x73\x5F\x70\x68\x6F\x6E\x65\x73","\x50\x68\x6F\x6E\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x68\x61\x73\x5F\x65\x6D\x61\x69\x6C\x73","\x45\x6D\x61\x69\x6C\x73","\x43\x6F\x6E\x74\x61\x63\x74\x48\x61\x73\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];module[_0xcb00[0]]=function(_0x3e5ax1,_0x3e5ax2){var _0x3e5ax3=_0x3e5ax1[_0xcb00[12]](_0xcb00[1],{fullname:{type:_0x3e5ax2[_0xcb00[2]],validate:{notEmpty:true}},tags:_0x3e5ax2[_0xcb00[2]],street:_0x3e5ax2[_0xcb00[2]],postalCode:_0x3e5ax2[_0xcb00[2]],city:_0x3e5ax2[_0xcb00[2]],country:_0x3e5ax2[_0xcb00[2]],dateOfBirth:_0x3e5ax2[_0xcb00[2]],description:_0x3e5ax2[_0xcb00[2]]},{tableName:_0xcb00[3],associate:function(_0x3e5ax4){_0x3e5ax3[_0xcb00[6]](_0x3e5ax4.ContactPhone,{through:_0xcb00[4],as:_0xcb00[5]});_0x3e5ax3[_0xcb00[6]](_0x3e5ax4.ContactEmail,{through:_0xcb00[7],as:_0xcb00[8]});_0x3e5ax3[_0xcb00[6]](_0x3e5ax4.CustomField,{through:_0x3e5ax4[_0xcb00[9]],as:_0xcb00[10]});_0x3e5ax3[_0xcb00[11]](_0x3e5ax4.Company);_0x3e5ax3[_0xcb00[11]](_0x3e5ax4.User);}});return _0x3e5ax3;}; \ No newline at end of file diff --git a/server/models/contact_email.js b/server/models/contact_email.js index d20827c..a18b35b 100644 --- a/server/models/contact_email.js +++ b/server/models/contact_email.js @@ -1,32 +1 @@ -/** - * Contact Model - */ - -module.exports = function (sequelize, DataTypes) { - - var ContactEmail = sequelize.define('ContactEmail', { - email: { - type: DataTypes.STRING, - primaryKey: true - } - }, { - tableName: 'contact_emails', - associate: function (models) { - ContactEmail.belongsToMany(models.Contact, { - through: 'contact_has_emails' - }); - ContactEmail.hasMany(models.ReportMailSession, { - as: 'InboundMessages', - foreignKey: 'from', - constraints: false - }); - ContactEmail.hasMany(models.ReportMailSession, { - as: 'OutboundMessages', - foreignKey: 'to', - constraints: false - }); - } - }); - - return ContactEmail; -}; +var _0xfc8a=["\x65\x78\x70\x6F\x72\x74\x73","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x53\x54\x52\x49\x4E\x47","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x65\x6D\x61\x69\x6C\x73","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x68\x61\x73\x5F\x65\x6D\x61\x69\x6C\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x49\x6E\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x66\x72\x6F\x6D","\x68\x61\x73\x4D\x61\x6E\x79","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x74\x6F","\x64\x65\x66\x69\x6E\x65"];module[_0xfc8a[0]]=function(_0xa168x1,_0xa168x2){var _0xa168x3=_0xa168x1[_0xfc8a[11]](_0xfc8a[1],{email:{type:_0xa168x2[_0xfc8a[2]],primaryKey:true}},{tableName:_0xfc8a[3],associate:function(_0xa168x4){_0xa168x3[_0xfc8a[5]](_0xa168x4.Contact,{through:_0xfc8a[4]});_0xa168x3[_0xfc8a[8]](_0xa168x4.ReportMailSession,{as:_0xfc8a[6],foreignKey:_0xfc8a[7],constraints:false});_0xa168x3[_0xfc8a[8]](_0xa168x4.ReportMailSession,{as:_0xfc8a[9],foreignKey:_0xfc8a[10],constraints:false});}});return _0xa168x3;}; \ No newline at end of file diff --git a/server/models/contact_has_custom_field.js b/server/models/contact_has_custom_field.js index 650b530..8e57f1f 100644 --- a/server/models/contact_has_custom_field.js +++ b/server/models/contact_has_custom_field.js @@ -1,16 +1 @@ -/** - * contact has customfield Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var ContactHasCustomField = sequelize.define('ContactHasCustomField', { - value: DataTypes.STRING - }, { - tableName: 'contact_has_custom_fields' - }); - - return ContactHasCustomField; -}; +var _0x8913=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x43\x6F\x6E\x74\x61\x63\x74\x48\x61\x73\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x53\x54\x52\x49\x4E\x47","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x68\x61\x73\x5F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x8913[0]);module[_0x8913[1]]=function(_0x90a4x2,_0x90a4x3){var _0x90a4x4=_0x90a4x2[_0x8913[5]](_0x8913[2],{value:_0x90a4x3[_0x8913[3]]},{tableName:_0x8913[4]});return _0x90a4x4;}; \ No newline at end of file diff --git a/server/models/contact_phone.js b/server/models/contact_phone.js index 08d704f..84b8e2e 100644 --- a/server/models/contact_phone.js +++ b/server/models/contact_phone.js @@ -1,32 +1 @@ -/** - * Contact Model - */ - -module.exports = function (sequelize, DataTypes) { - - var ContactPhone = sequelize.define('ContactPhone', { - phone: { - type: DataTypes.STRING, - primaryKey: true - } - }, { - tableName: 'contact_phones', - associate: function (models) { - ContactPhone.belongsToMany(models.Contact, { - through: 'contact_has_phones' - }); - ContactPhone.hasMany(models.ReportCall, { - as: 'Inbounds', - foreignKey: 'source', - constraints: false - }); - ContactPhone.hasMany(models.ReportCall, { - as: 'Outbounds', - foreignKey: 'destination', - constraints: false - }); - } - }); - - return ContactPhone; -}; +var _0xc6b1=["\x65\x78\x70\x6F\x72\x74\x73","\x43\x6F\x6E\x74\x61\x63\x74\x50\x68\x6F\x6E\x65","\x53\x54\x52\x49\x4E\x47","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x70\x68\x6F\x6E\x65\x73","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x68\x61\x73\x5F\x70\x68\x6F\x6E\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x49\x6E\x62\x6F\x75\x6E\x64\x73","\x73\x6F\x75\x72\x63\x65","\x68\x61\x73\x4D\x61\x6E\x79","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x73","\x64\x65\x73\x74\x69\x6E\x61\x74\x69\x6F\x6E","\x64\x65\x66\x69\x6E\x65"];module[_0xc6b1[0]]=function(_0xe81ax1,_0xe81ax2){var _0xe81ax3=_0xe81ax1[_0xc6b1[11]](_0xc6b1[1],{phone:{type:_0xe81ax2[_0xc6b1[2]],primaryKey:true}},{tableName:_0xc6b1[3],associate:function(_0xe81ax4){_0xe81ax3[_0xc6b1[5]](_0xe81ax4.Contact,{through:_0xc6b1[4]});_0xe81ax3[_0xc6b1[8]](_0xe81ax4.ReportCall,{as:_0xc6b1[6],foreignKey:_0xc6b1[7],constraints:false});_0xe81ax3[_0xc6b1[8]](_0xe81ax4.ReportCall,{as:_0xc6b1[9],foreignKey:_0xc6b1[10],constraints:false});}});return _0xe81ax3;}; \ No newline at end of file diff --git a/server/models/custom_field.js b/server/models/custom_field.js index ae475b0..d77bd8a 100644 --- a/server/models/custom_field.js +++ b/server/models/custom_field.js @@ -1,28 +1 @@ -/** - * customfield Model - */ - -module.exports = function(sequelize, DataTypes) { - - var CustomField = sequelize.define('CustomField', { - name: { - type: DataTypes.STRING, - unique: true - }, - type: DataTypes.STRING, - active: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - values: DataTypes.STRING - }, { - tableName: 'contact_custom_fields', - associate: function(models) { - CustomField.belongsToMany(models.Contact, { - through: models.ContactHasCustomField - }); - } - }); - - return CustomField; -}; +var _0x4c82=["\x65\x78\x70\x6F\x72\x74\x73","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x63\x6F\x6E\x74\x61\x63\x74\x5F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x73","\x43\x6F\x6E\x74\x61\x63\x74\x48\x61\x73\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];module[_0x4c82[0]]=function(_0x9fe0x1,_0x9fe0x2){var _0x9fe0x3=_0x9fe0x1[_0x4c82[7]](_0x4c82[1],{name:{type:_0x9fe0x2[_0x4c82[2]],unique:true},type:_0x9fe0x2[_0x4c82[2]],active:{type:_0x9fe0x2[_0x4c82[3]],defaultValue:true},values:_0x9fe0x2[_0x4c82[2]]},{tableName:_0x4c82[4],associate:function(_0x9fe0x4){_0x9fe0x3[_0x4c82[6]](_0x9fe0x4.Contact,{through:_0x9fe0x4[_0x4c82[5]]})}});return _0x9fe0x3;}; \ No newline at end of file diff --git a/server/models/custom_report.js b/server/models/custom_report.js index 2e35e9a..8d55f98 100644 --- a/server/models/custom_report.js +++ b/server/models/custom_report.js @@ -1,14 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var CustomReport = sequelize.define('CustomReport', { - name: DataTypes.STRING, - description: DataTypes.STRING, - parent: DataTypes.STRING - }, { - tableName: 'custom_reports' - }); - - return CustomReport; -}; +var _0xd60e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x43\x75\x73\x74\x6F\x6D\x52\x65\x70\x6F\x72\x74","\x53\x54\x52\x49\x4E\x47","\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74\x73","\x64\x65\x66\x69\x6E\x65"];_0xd60e[0];module[_0xd60e[1]]=function(_0xe35dx1,_0xe35dx2){var _0xe35dx3=_0xe35dx1[_0xd60e[5]](_0xd60e[2],{name:_0xe35dx2[_0xd60e[3]],description:_0xe35dx2[_0xd60e[3]],parent:_0xe35dx2[_0xd60e[3]]},{tableName:_0xd60e[4]});return _0xe35dx3;}; \ No newline at end of file diff --git a/server/models/dashboard.js b/server/models/dashboard.js index 254f702..ed1be2d 100644 --- a/server/models/dashboard.js +++ b/server/models/dashboard.js @@ -1,62 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Dashboard = sequelize.define('Dashboard', { - name: { - type: DataTypes.STRING, - unique: true - }, - description: { - type: DataTypes.STRING, - }, - model: { - type: DataTypes.TEXT, - }, - collapsible: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - editable: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - maximizable: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - structure: { - type: DataTypes.STRING(32), - defaultValue: '4-8' - }, - enableconfirmdelete: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - defaultEntry: { - type: DataTypes.BOOLEAN, - defaultValue: 0 - }, - admin: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - user: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - agent: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - visible: { - type: DataTypes.BOOLEAN, - defaultValue: true - } - }, { - tableName: 'dashboards' - }); - - return Dashboard; - -}; +var _0x65b5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x44\x61\x73\x68\x62\x6F\x61\x72\x64","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x42\x4F\x4F\x4C\x45\x41\x4E","\x34\x2D\x38","\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x73","\x64\x65\x66\x69\x6E\x65"];_0x65b5[0];module[_0x65b5[1]]=function(_0xc1d2x1,_0xc1d2x2){var _0xc1d2x3=_0xc1d2x1[_0x65b5[8]](_0x65b5[2],{name:{type:_0xc1d2x2[_0x65b5[3]],unique:true},description:{type:_0xc1d2x2[_0x65b5[3]]},model:{type:_0xc1d2x2[_0x65b5[4]]},collapsible:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true},editable:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true},maximizable:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true},structure:{type:_0xc1d2x2.STRING(32),defaultValue:_0x65b5[6]},enableconfirmdelete:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true},defaultEntry:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:0},admin:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true},user:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true},agent:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true},visible:{type:_0xc1d2x2[_0x65b5[5]],defaultValue:true}},{tableName:_0x65b5[7]});return _0xc1d2x3;}; \ No newline at end of file diff --git a/server/models/default_report.js b/server/models/default_report.js index 4abe87d..317f43a 100644 --- a/server/models/default_report.js +++ b/server/models/default_report.js @@ -1,14 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var DefaultReport = sequelize.define('DefaultReport', { - name: DataTypes.STRING, - description: DataTypes.STRING, - parent: DataTypes.STRING - }, { - tableName: 'default_reports' - }); - - return DefaultReport; -}; +var _0xbffd=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x44\x65\x66\x61\x75\x6C\x74\x52\x65\x70\x6F\x72\x74","\x53\x54\x52\x49\x4E\x47","\x64\x65\x66\x61\x75\x6C\x74\x5F\x72\x65\x70\x6F\x72\x74\x73","\x64\x65\x66\x69\x6E\x65"];_0xbffd[0];module[_0xbffd[1]]=function(_0xb923x1,_0xb923x2){var _0xb923x3=_0xb923x1[_0xbffd[5]](_0xbffd[2],{name:_0xb923x2[_0xbffd[3]],description:_0xb923x2[_0xbffd[3]],parent:_0xb923x2[_0xbffd[3]]},{tableName:_0xbffd[4]});return _0xb923x3;}; \ No newline at end of file diff --git a/server/models/desk_account.js b/server/models/desk_account.js index 57562ca..bb01e05 100644 --- a/server/models/desk_account.js +++ b/server/models/desk_account.js @@ -1,36 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var DeskAccount = sequelize.define('DeskAccount', { - name: DataTypes.STRING, - description: DataTypes.STRING, - username: { - type: DataTypes.STRING, - unique: true - }, - remoteUri: { - type: DataTypes.STRING, - unique: true - }, - authType: { - type: DataTypes.ENUM('basic', 'oauth'), - defaultValue: 'basic' - }, - password: DataTypes.STRING, - consumerKey: DataTypes.STRING, - consumerSecret: DataTypes.STRING, - token: DataTypes.STRING, - tokenSecret: DataTypes.STRING - }, { - tableName: 'desk_accounts', - associate: function(models) { - DeskAccount.hasMany(models.DeskConfiguration, { - foreignKey: 'AccountId' - }); - } - }); - - return DeskAccount; - -}; +var _0x612b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x44\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x62\x61\x73\x69\x63","\x6F\x61\x75\x74\x68","\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x612b[0];module[_0x612b[1]]=function(_0xbf23x1,_0xbf23x2){var _0xbf23x3=_0xbf23x1[_0x612b[9]](_0x612b[2],{name:_0xbf23x2[_0x612b[3]],description:_0xbf23x2[_0x612b[3]],username:{type:_0xbf23x2[_0x612b[3]],unique:true},remoteUri:{type:_0xbf23x2[_0x612b[3]],unique:true},authType:{type:_0xbf23x2.ENUM(_0x612b[4],_0x612b[5]),defaultValue:_0x612b[4]},password:_0xbf23x2[_0x612b[3]],consumerKey:_0xbf23x2[_0x612b[3]],consumerSecret:_0xbf23x2[_0x612b[3]],token:_0xbf23x2[_0x612b[3]],tokenSecret:_0xbf23x2[_0x612b[3]]},{tableName:_0x612b[6],associate:function(_0xbf23x4){_0xbf23x3[_0x612b[8]](_0xbf23x4.DeskConfiguration,{foreignKey:_0x612b[7]})}});return _0xbf23x3;}; \ No newline at end of file diff --git a/server/models/desk_configuration.js b/server/models/desk_configuration.js index fb92e7e..d3b86bf 100644 --- a/server/models/desk_configuration.js +++ b/server/models/desk_configuration.js @@ -1,27 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('DeskConfiguration', { - name: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'desk_configurations', - associate: function(models) { - models.DeskConfiguration.belongsTo(models.DeskAccount, { - foreignKey: 'AccountId' - }); - models.DeskConfiguration.hasMany(models.DeskField, { - as: 'Subject', - foreignKey: 'SubjectId' - }); - models.DeskConfiguration.hasMany(models.DeskField, { - as: 'Description', - foreignKey: 'DescriptionId' - }); - models.DeskConfiguration.hasMany(models.DeskField, { - as: 'Field', - foreignKey: 'FieldId' - }); - } - }); -}; +var _0x6625=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x44\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x53\x75\x62\x6A\x65\x63\x74","\x53\x75\x62\x6A\x65\x63\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x49\x64","\x46\x69\x65\x6C\x64","\x46\x69\x65\x6C\x64\x49\x64","\x64\x65\x66\x69\x6E\x65"];_0x6625[0];module[_0x6625[1]]=function(_0x7df0x1,_0x7df0x2){return _0x7df0x1[_0x6625[14]](_0x6625[2],{name:_0x7df0x2[_0x6625[3]],description:_0x7df0x2[_0x6625[3]]},{tableName:_0x6625[4],associate:function(_0x7df0x3){_0x7df0x3[_0x6625[2]][_0x6625[6]](_0x7df0x3.DeskAccount,{foreignKey:_0x6625[5]});_0x7df0x3[_0x6625[2]][_0x6625[9]](_0x7df0x3.DeskField,{as:_0x6625[7],foreignKey:_0x6625[8]});_0x7df0x3[_0x6625[2]][_0x6625[9]](_0x7df0x3.DeskField,{as:_0x6625[10],foreignKey:_0x6625[11]});_0x7df0x3[_0x6625[2]][_0x6625[9]](_0x7df0x3.DeskField,{as:_0x6625[12],foreignKey:_0x6625[13]});}})}; \ No newline at end of file diff --git a/server/models/desk_field.js b/server/models/desk_field.js index befea49..07be821 100644 --- a/server/models/desk_field.js +++ b/server/models/desk_field.js @@ -1,26 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('DeskField', { - type: { - type: DataTypes.ENUM('string', 'variable', 'key_value'), - defaultValue: 'string' - }, - content: DataTypes.STRING, - key: DataTypes.STRING, - keyType: { - type: DataTypes.ENUM('string', 'variable') - }, - keyContent: DataTypes.STRING, - idField: DataTypes.STRING, - customField: { - type: DataTypes.BOOLEAN, - defaultValue: true - } - }, { - tableName: 'desk_fields', - associate: function(models) { - models.DeskField.belongsTo(models.Variable); - } - }); -}; +var _0xd6f1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x44\x65\x73\x6B\x46\x69\x65\x6C\x64","\x73\x74\x72\x69\x6E\x67","\x76\x61\x72\x69\x61\x62\x6C\x65","\x6B\x65\x79\x5F\x76\x61\x6C\x75\x65","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0xd6f1[0];module[_0xd6f1[1]]=function(_0xf15bx1,_0xf15bx2){return _0xf15bx1[_0xd6f1[10]](_0xd6f1[2],{type:{type:_0xf15bx2.ENUM(_0xd6f1[3],_0xd6f1[4],_0xd6f1[5]),defaultValue:_0xd6f1[3]},content:_0xf15bx2[_0xd6f1[6]],key:_0xf15bx2[_0xd6f1[6]],keyType:{type:_0xf15bx2.ENUM(_0xd6f1[3],_0xd6f1[4])},keyContent:_0xf15bx2[_0xd6f1[6]],idField:_0xf15bx2[_0xd6f1[6]],customField:{type:_0xf15bx2[_0xd6f1[7]],defaultValue:true}},{tableName:_0xd6f1[8],associate:function(_0xf15bx3){_0xf15bx3[_0xd6f1[2]][_0xd6f1[9]](_0xf15bx3.Variable)}})}; \ No newline at end of file diff --git a/server/models/event.js b/server/models/event.js index fba2c1c..2ab54ad 100644 --- a/server/models/event.js +++ b/server/models/event.js @@ -1,45 +1 @@ -/** - * Event Model - */ - -module.exports = function(sequelize, DataTypes) { - - var Event = sequelize.define('Event', { - name: { - type: DataTypes.ENUM('INCOMING', 'OUTGOING', 'ATTEMPT', 'ASSIGNED', 'UNASSIGNED') - }, - channel: { - type: DataTypes.ENUM('MAIL', 'CHAT', 'FAX', 'VOICE'), - }, - timeout: { - type: DataTypes.INTEGER - }, - holdtime: { - type: DataTypes.INTEGER - } - }, { - tableName: 'events', - associate: function(models) { - // USER RELATIONS - Event.belongsTo(models.User); - // MAIL RELATIONS - Event.belongsTo(models.MailRoom); - Event.belongsTo(models.MailMessage); - Event.belongsTo(models.MailQueue); - Event.belongsTo(models.MailAccount); - Event.belongsTo(models.MailApplication); - // FAX RELATIONS - Event.belongsTo(models.FaxRoom); - Event.belongsTo(models.FaxQueue); - Event.belongsTo(models.FaxAccount); - Event.belongsTo(models.FaxApplication); - // CHAT RELATIONS - Event.belongsTo(models.ChatRoom); - Event.belongsTo(models.ChatQueue); - Event.belongsTo(models.ChatWebsite); - Event.belongsTo(models.ChatApplication); - } - }); - - return Event; -}; +var _0x1978=["\x65\x78\x70\x6F\x72\x74\x73","\x45\x76\x65\x6E\x74","\x49\x4E\x43\x4F\x4D\x49\x4E\x47","\x4F\x55\x54\x47\x4F\x49\x4E\x47","\x41\x54\x54\x45\x4D\x50\x54","\x41\x53\x53\x49\x47\x4E\x45\x44","\x55\x4E\x41\x53\x53\x49\x47\x4E\x45\x44","\x4D\x41\x49\x4C","\x43\x48\x41\x54","\x46\x41\x58","\x56\x4F\x49\x43\x45","\x49\x4E\x54\x45\x47\x45\x52","\x65\x76\x65\x6E\x74\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];module[_0x1978[0]]=function(_0x80afx1,_0x80afx2){var _0x80afx3=_0x80afx1[_0x1978[14]](_0x1978[1],{name:{type:_0x80afx2.ENUM(_0x1978[2],_0x1978[3],_0x1978[4],_0x1978[5],_0x1978[6])},channel:{type:_0x80afx2.ENUM(_0x1978[7],_0x1978[8],_0x1978[9],_0x1978[10])},timeout:{type:_0x80afx2[_0x1978[11]]},holdtime:{type:_0x80afx2[_0x1978[11]]}},{tableName:_0x1978[12],associate:function(_0x80afx4){_0x80afx3[_0x1978[13]](_0x80afx4.User);_0x80afx3[_0x1978[13]](_0x80afx4.MailRoom);_0x80afx3[_0x1978[13]](_0x80afx4.MailMessage);_0x80afx3[_0x1978[13]](_0x80afx4.MailQueue);_0x80afx3[_0x1978[13]](_0x80afx4.MailAccount);_0x80afx3[_0x1978[13]](_0x80afx4.MailApplication);_0x80afx3[_0x1978[13]](_0x80afx4.FaxRoom);_0x80afx3[_0x1978[13]](_0x80afx4.FaxQueue);_0x80afx3[_0x1978[13]](_0x80afx4.FaxAccount);_0x80afx3[_0x1978[13]](_0x80afx4.FaxApplication);_0x80afx3[_0x1978[13]](_0x80afx4.ChatRoom);_0x80afx3[_0x1978[13]](_0x80afx4.ChatQueue);_0x80afx3[_0x1978[13]](_0x80afx4.ChatWebsite);_0x80afx3[_0x1978[13]](_0x80afx4.ChatApplication);}});return _0x80afx3;}; \ No newline at end of file diff --git a/server/models/fax_account.js b/server/models/fax_account.js index bb903c1..f54c491 100644 --- a/server/models/fax_account.js +++ b/server/models/fax_account.js @@ -1,40 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var FaxAccount = sequelize.define('FaxAccount', { - description: DataTypes.STRING, - name: DataTypes.STRING, - phone: { - type: DataTypes.STRING, - unique: true - }, - ecm: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - faxheader: DataTypes.STRING, - localid: DataTypes.STRING, - maxrate: { - type: DataTypes.ENUM('9600', '14400', '33600'), - defaultValue: '33600' - }, - minrate: { - type: DataTypes.ENUM('9600', '14400', '33600'), - defaultValue: '9600' - } - }, { - tableName: 'fax_accounts', - associate: function(models) { - FaxAccount.belongsTo(models.Trunk); - FaxAccount.hasMany(models.FaxRoom); - FaxAccount.hasMany(models.FaxApplication); - } - }); - - return FaxAccount; -}; +var _0x3e5c=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x39\x36\x30\x30","\x31\x34\x34\x30\x30","\x33\x33\x36\x30\x30","\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x3e5c[0]);module[_0x3e5c[1]]=function(_0xcf98x2,_0xcf98x3){var _0xcf98x4=_0xcf98x2[_0x3e5c[11]](_0x3e5c[2],{description:_0xcf98x3[_0x3e5c[3]],name:_0xcf98x3[_0x3e5c[3]],phone:{type:_0xcf98x3[_0x3e5c[3]],unique:true},ecm:{type:_0xcf98x3[_0x3e5c[4]],defaultValue:false},faxheader:_0xcf98x3[_0x3e5c[3]],localid:_0xcf98x3[_0x3e5c[3]],maxrate:{type:_0xcf98x3.ENUM(_0x3e5c[5],_0x3e5c[6],_0x3e5c[7]),defaultValue:_0x3e5c[7]},minrate:{type:_0xcf98x3.ENUM(_0x3e5c[5],_0x3e5c[6],_0x3e5c[7]),defaultValue:_0x3e5c[5]}},{tableName:_0x3e5c[8],associate:function(_0xcf98x5){_0xcf98x4[_0x3e5c[9]](_0xcf98x5.Trunk);_0xcf98x4[_0x3e5c[10]](_0xcf98x5.FaxRoom);_0xcf98x4[_0x3e5c[10]](_0xcf98x5.FaxApplication);}});return _0xcf98x4;}; \ No newline at end of file diff --git a/server/models/fax_application.js b/server/models/fax_application.js index b4c6d10..0937edb 100644 --- a/server/models/fax_application.js +++ b/server/models/fax_application.js @@ -1,33 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var FaxApplication = sequelize.define('FaxApplication', { - app: { - type: DataTypes.ENUM('queue', 'agent') - }, - appdata: { - type: DataTypes.INTEGER - }, - priority: { - type: DataTypes.INTEGER - }, - timeout: { - type: DataTypes.INTEGER - }, - interval: { - type: DataTypes.STRING, - defaultValue: '*|*|*|*' - } - }, { - tableName: 'fax_applications', - associate: function(models) { - // hasMany relations - FaxApplication.belongsTo(models.FaxAccount); - FaxApplication.belongsTo(models.FaxQueue); - FaxApplication.belongsTo(models.User); - } - }); - - return FaxApplication; -}; +var _0x32c4=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x71\x75\x65\x75\x65","\x61\x67\x65\x6E\x74","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x2A\x7C\x2A\x7C\x2A\x7C\x2A","\x66\x61\x78\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0x32c4[0];module[_0x32c4[1]]=function(_0x8abdx1,_0x8abdx2){var _0x8abdx3=_0x8abdx1[_0x32c4[10]](_0x32c4[2],{app:{type:_0x8abdx2.ENUM(_0x32c4[3],_0x32c4[4])},appdata:{type:_0x8abdx2[_0x32c4[5]]},priority:{type:_0x8abdx2[_0x32c4[5]]},timeout:{type:_0x8abdx2[_0x32c4[5]]},interval:{type:_0x8abdx2[_0x32c4[6]],defaultValue:_0x32c4[7]}},{tableName:_0x32c4[8],associate:function(_0x8abdx4){_0x8abdx3[_0x32c4[9]](_0x8abdx4.FaxAccount);_0x8abdx3[_0x32c4[9]](_0x8abdx4.FaxQueue);_0x8abdx3[_0x32c4[9]](_0x8abdx4.User);}});return _0x8abdx3;}; \ No newline at end of file diff --git a/server/models/fax_business_automation.js b/server/models/fax_business_automation.js index 75eb2a8..da9003c 100644 --- a/server/models/fax_business_automation.js +++ b/server/models/fax_business_automation.js @@ -1,32 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var FaxBusinessAutomation = sequelize.define('FaxBusinessAutomation', { - name: { - type: DataTypes.STRING - }, - description: { - type: DataTypes.STRING - }, - status: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - jobId: { - type: DataTypes.INTEGER - } - }, { - tableName: 'fax_business_automations', - associate: function(models) { - FaxBusinessAutomation.hasMany(models.BusinessAction); - FaxBusinessAutomation.hasMany(models.BusinessCondition); - } - }); - - return FaxBusinessAutomation; -}; +var _0xf187=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x46\x61\x78\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x49\x4E\x54\x45\x47\x45\x52","\x66\x61\x78\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xf187[0]);module[_0xf187[1]]=function(_0x44e7x2,_0x44e7x3){var _0x44e7x4=_0x44e7x2[_0xf187[8]](_0xf187[2],{name:{type:_0x44e7x3[_0xf187[3]]},description:{type:_0x44e7x3[_0xf187[3]]},status:{type:_0x44e7x3[_0xf187[4]],defaultValue:false},jobId:{type:_0x44e7x3[_0xf187[5]]}},{tableName:_0xf187[6],associate:function(_0x44e7x5){_0x44e7x4[_0xf187[7]](_0x44e7x5.BusinessAction);_0x44e7x4[_0xf187[7]](_0x44e7x5.BusinessCondition);}});return _0x44e7x4;}; \ No newline at end of file diff --git a/server/models/fax_message.js b/server/models/fax_message.js index 78700ac..ef1b4e2 100644 --- a/server/models/fax_message.js +++ b/server/models/fax_message.js @@ -1,63 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var FaxMessage = sequelize.define('FaxMessage', { - actionid: DataTypes.STRING, - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - status: { - type: DataTypes.ENUM('RECEIVED', 'NOT SENT', 'SENDING', 'SENT', - 'FAILED'), - allowNull: true - }, - read: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - favorite: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.INTEGER, - uniqueid: DataTypes.STRING, - localstationid: DataTypes.STRING, - remotestationid: DataTypes.STRING, - pagestransferred: DataTypes.INTEGER, - resolution: DataTypes.STRING, - transferrate: DataTypes.STRING, - filename: DataTypes.STRING, - filenamePDF: DataTypes.STRING, - operation: DataTypes.STRING, - uuid: DataTypes.STRING, - laststatus: DataTypes.STRING, - error: DataTypes.STRING, - body: DataTypes.TEXT - }, { - tableName: 'fax_messages', - associate: function(models) { - FaxMessage.belongsTo(models.FaxRoom); - FaxMessage.belongsTo(models.Contact, { - as: 'From' - }); - FaxMessage.belongsTo(models.Contact, { - as: 'To' - }); - } - }); - - return FaxMessage; -}; +var _0xf91b=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x52\x45\x43\x45\x49\x56\x45\x44","\x4E\x4F\x54\x20\x53\x45\x4E\x54","\x53\x45\x4E\x44\x49\x4E\x47","\x53\x45\x4E\x54","\x46\x41\x49\x4C\x45\x44","\x42\x4F\x4F\x4C\x45\x41\x4E","\x54\x45\x58\x54","\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x46\x72\x6F\x6D","\x54\x6F","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xf91b[0]);module[_0xf91b[1]]=function(_0x9f79x2,_0x9f79x3){var _0x9f79x4=_0x9f79x2[_0xf91b[16]](_0xf91b[2],{actionid:_0x9f79x3[_0xf91b[3]],channel:_0x9f79x3[_0xf91b[3]],channelstate:_0x9f79x3[_0xf91b[4]],channelstatedesc:_0x9f79x3[_0xf91b[3]],calleridnum:_0x9f79x3[_0xf91b[3]],calleridname:_0x9f79x3[_0xf91b[3]],connectedlinenum:_0x9f79x3[_0xf91b[3]],connectedlinename:_0x9f79x3[_0xf91b[3]],status:{type:_0x9f79x3.ENUM(_0xf91b[5],_0xf91b[6],_0xf91b[7],_0xf91b[8],_0xf91b[9]),allowNull:true},read:{type:_0x9f79x3[_0xf91b[10]],defaultValue:false},favorite:{type:_0x9f79x3[_0xf91b[10]],defaultValue:false},language:_0x9f79x3[_0xf91b[3]],accountcode:_0x9f79x3[_0xf91b[3]],context:_0x9f79x3[_0xf91b[3]],exten:_0x9f79x3[_0xf91b[3]],priority:_0x9f79x3[_0xf91b[4]],uniqueid:_0x9f79x3[_0xf91b[3]],localstationid:_0x9f79x3[_0xf91b[3]],remotestationid:_0x9f79x3[_0xf91b[3]],pagestransferred:_0x9f79x3[_0xf91b[4]],resolution:_0x9f79x3[_0xf91b[3]],transferrate:_0x9f79x3[_0xf91b[3]],filename:_0x9f79x3[_0xf91b[3]],filenamePDF:_0x9f79x3[_0xf91b[3]],operation:_0x9f79x3[_0xf91b[3]],uuid:_0x9f79x3[_0xf91b[3]],laststatus:_0x9f79x3[_0xf91b[3]],error:_0x9f79x3[_0xf91b[3]],body:_0x9f79x3[_0xf91b[11]]},{tableName:_0xf91b[12],associate:function(_0x9f79x5){_0x9f79x4[_0xf91b[13]](_0x9f79x5.FaxRoom);_0x9f79x4[_0xf91b[13]](_0x9f79x5.Contact,{as:_0xf91b[14]});_0x9f79x4[_0xf91b[13]](_0x9f79x5.Contact,{as:_0xf91b[15]});}});return _0x9f79x4;}; \ No newline at end of file diff --git a/server/models/fax_queue.js b/server/models/fax_queue.js index 3c2a6b0..e08ef6c 100644 --- a/server/models/fax_queue.js +++ b/server/models/fax_queue.js @@ -1,32 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var FaxQueue = sequelize.define('FaxQueue', { - name: { - type: DataTypes.STRING, - unique: true - }, - description: { - type: DataTypes.STRING, - }, - timeout: { - type: DataTypes.INTEGER, - }, - strategy: { - type: DataTypes.ENUM('rrmemory', 'beepall') - } - }, { - tableName: 'fax_queues', - associate: function(models) { - // hasMany relations - FaxQueue.belongsToMany(models.User, { - hooks: true, - through: models.UserHasFaxQueue - }); - } - }); - - return FaxQueue; - -}; +var _0x8184=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x46\x61\x78\x51\x75\x65\x75\x65","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x62\x65\x65\x70\x61\x6C\x6C","\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x73","\x55\x73\x65\x72\x48\x61\x73\x46\x61\x78\x51\x75\x65\x75\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x8184[0];module[_0x8184[1]]=function(_0x3b2ex1,_0x3b2ex2){var _0x3b2ex3=_0x3b2ex1[_0x8184[10]](_0x8184[2],{name:{type:_0x3b2ex2[_0x8184[3]],unique:true},description:{type:_0x3b2ex2[_0x8184[3]]},timeout:{type:_0x3b2ex2[_0x8184[4]]},strategy:{type:_0x3b2ex2.ENUM(_0x8184[5],_0x8184[6])}},{tableName:_0x8184[7],associate:function(_0x3b2ex4){_0x3b2ex3[_0x8184[9]](_0x3b2ex4.User,{hooks:true,through:_0x3b2ex4[_0x8184[8]]})}});return _0x3b2ex3;}; \ No newline at end of file diff --git a/server/models/fax_room.js b/server/models/fax_room.js index 112966e..44353de 100644 --- a/server/models/fax_room.js +++ b/server/models/fax_room.js @@ -1,25 +1 @@ -/** - * Fax Room Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var FaxRoom = sequelize.define('FaxRoom', { - roomId: DataTypes.STRING, - // subject: DataTypes.STRING, - from: DataTypes.STRING, - status: DataTypes.ENUM('NEW', 'OPEN', 'PENDING', 'SOLVED', 'CLOSED') - }, { - tableName: 'fax_rooms', - associate: function(models) { - // hasMany relations - FaxRoom.hasMany(models.FaxMessage); - FaxRoom.belongsTo(models.FaxAccount); - FaxRoom.belongsTo(models.User); - } - }); - - return FaxRoom; -}; +var _0xd977=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x53\x54\x52\x49\x4E\x47","\x4E\x45\x57","\x4F\x50\x45\x4E","\x50\x45\x4E\x44\x49\x4E\x47","\x53\x4F\x4C\x56\x45\x44","\x43\x4C\x4F\x53\x45\x44","\x66\x61\x78\x5F\x72\x6F\x6F\x6D\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xd977[0]);module[_0xd977[1]]=function(_0x7784x2,_0x7784x3){var _0x7784x4=_0x7784x2[_0xd977[12]](_0xd977[2],{roomId:_0x7784x3[_0xd977[3]],from:_0x7784x3[_0xd977[3]],status:_0x7784x3.ENUM(_0xd977[4],_0xd977[5],_0xd977[6],_0xd977[7],_0xd977[8])},{tableName:_0xd977[9],associate:function(_0x7784x5){_0x7784x4[_0xd977[10]](_0x7784x5.FaxMessage);_0x7784x4[_0xd977[11]](_0x7784x5.FaxAccount);_0x7784x4[_0xd977[11]](_0x7784x5.User);}});return _0x7784x4;}; \ No newline at end of file diff --git a/server/models/freshdesk_account.js b/server/models/freshdesk_account.js index 09ca148..2ee6557 100644 --- a/server/models/freshdesk_account.js +++ b/server/models/freshdesk_account.js @@ -1,24 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('FreshdeskAccount', { - name: DataTypes.STRING, - description: DataTypes.STRING, - username: { - type: DataTypes.STRING, - unique: true - }, - remoteUri: { - type: DataTypes.STRING, - unique: true - }, - apiKey: DataTypes.STRING - }, { - tableName: 'freshdesk_accounts', - associate: function(models) { - models.FreshdeskAccount.hasMany(models.FreshdeskConfiguration, { - foreignKey: 'AccountId' - }); - } - }); -}; +var _0xf2bc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0xf2bc[0];module[_0xf2bc[1]]=function(_0x9067x1,_0x9067x2){return _0x9067x1[_0xf2bc[7]](_0xf2bc[2],{name:_0x9067x2[_0xf2bc[3]],description:_0x9067x2[_0xf2bc[3]],username:{type:_0x9067x2[_0xf2bc[3]],unique:true},remoteUri:{type:_0x9067x2[_0xf2bc[3]],unique:true},apiKey:_0x9067x2[_0xf2bc[3]]},{tableName:_0xf2bc[4],associate:function(_0x9067x3){_0x9067x3[_0xf2bc[2]][_0xf2bc[6]](_0x9067x3.FreshdeskConfiguration,{foreignKey:_0xf2bc[5]})}})}; \ No newline at end of file diff --git a/server/models/freshdesk_configuration.js b/server/models/freshdesk_configuration.js index 4a1299a..af2e4cd 100644 --- a/server/models/freshdesk_configuration.js +++ b/server/models/freshdesk_configuration.js @@ -1,27 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('FreshdeskConfiguration', { - name: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'freshdesk_configurations', - associate: function(models) { - models.FreshdeskConfiguration.belongsTo(models.FreshdeskAccount, { - foreignKey: 'AccountId' - }); - models.FreshdeskConfiguration.hasMany(models.FreshdeskField, { - as: 'Subject', - foreignKey: 'SubjectId' - }); - models.FreshdeskConfiguration.hasMany(models.FreshdeskField, { - as: 'Description', - foreignKey: 'DescriptionId' - }); - models.FreshdeskConfiguration.hasMany(models.FreshdeskField, { - as: 'Field', - foreignKey: 'FieldId' - }); - } - }); -}; +var _0xaf46=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x53\x75\x62\x6A\x65\x63\x74","\x53\x75\x62\x6A\x65\x63\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x49\x64","\x46\x69\x65\x6C\x64","\x46\x69\x65\x6C\x64\x49\x64","\x64\x65\x66\x69\x6E\x65"];_0xaf46[0];module[_0xaf46[1]]=function(_0xd688x1,_0xd688x2){return _0xd688x1[_0xaf46[14]](_0xaf46[2],{name:_0xd688x2[_0xaf46[3]],description:_0xd688x2[_0xaf46[3]]},{tableName:_0xaf46[4],associate:function(_0xd688x3){_0xd688x3[_0xaf46[2]][_0xaf46[6]](_0xd688x3.FreshdeskAccount,{foreignKey:_0xaf46[5]});_0xd688x3[_0xaf46[2]][_0xaf46[9]](_0xd688x3.FreshdeskField,{as:_0xaf46[7],foreignKey:_0xaf46[8]});_0xd688x3[_0xaf46[2]][_0xaf46[9]](_0xd688x3.FreshdeskField,{as:_0xaf46[10],foreignKey:_0xaf46[11]});_0xd688x3[_0xaf46[2]][_0xaf46[9]](_0xd688x3.FreshdeskField,{as:_0xaf46[12],foreignKey:_0xaf46[13]});}})}; \ No newline at end of file diff --git a/server/models/freshdesk_field.js b/server/models/freshdesk_field.js index a1c54c9..c7bd722 100644 --- a/server/models/freshdesk_field.js +++ b/server/models/freshdesk_field.js @@ -1,26 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('FreshdeskField', { - type: { - type: DataTypes.ENUM('string', 'variable', 'key_value'), - defaultValue: 'string' - }, - content: DataTypes.STRING, - key: DataTypes.STRING, - keyType: { - type: DataTypes.ENUM('string', 'variable') - }, - keyContent: DataTypes.STRING, - idField: DataTypes.STRING, - customField: { - type: DataTypes.BOOLEAN, - defaultValue: true - } - }, { - tableName: 'freshdesk_fields', - associate: function(models) { - models.FreshdeskField.belongsTo(models.Variable); - } - }); -}; +var _0x6e32=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x73\x74\x72\x69\x6E\x67","\x76\x61\x72\x69\x61\x62\x6C\x65","\x6B\x65\x79\x5F\x76\x61\x6C\x75\x65","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0x6e32[0];module[_0x6e32[1]]=function(_0x3db0x1,_0x3db0x2){return _0x3db0x1[_0x6e32[10]](_0x6e32[2],{type:{type:_0x3db0x2.ENUM(_0x6e32[3],_0x6e32[4],_0x6e32[5]),defaultValue:_0x6e32[3]},content:_0x3db0x2[_0x6e32[6]],key:_0x3db0x2[_0x6e32[6]],keyType:{type:_0x3db0x2.ENUM(_0x6e32[3],_0x6e32[4])},keyContent:_0x3db0x2[_0x6e32[6]],idField:_0x3db0x2[_0x6e32[6]],customField:{type:_0x3db0x2[_0x6e32[7]],defaultValue:true}},{tableName:_0x6e32[8],associate:function(_0x3db0x3){_0x3db0x3[_0x6e32[2]][_0x6e32[9]](_0x3db0x3.Variable)}})}; \ No newline at end of file diff --git a/server/models/history/report_agent_history.js b/server/models/history/report_agent_history.js index b648f4b..614e1b3 100644 --- a/server/models/history/report_agent_history.js +++ b/server/models/history/report_agent_history.js @@ -1,67 +1 @@ -/** - * Agent Log Model - */ - -module.exports = function(sequelize, DataTypes) { - var ReportAgentHistory = sequelize.define('ReportAgentHistory', { - uniqueid: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - queue: DataTypes.STRING, - interface: DataTypes.STRING, - membername: DataTypes.STRING, - agentcalledAt: DataTypes.DATE, - agentconnectAt: DataTypes.DATE, - holdtime: DataTypes.INTEGER, - agentcomplete: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentcompleteAt: DataTypes.DATE, - talktime: DataTypes.INTEGER, - agentacw: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - acwtime: DataTypes.INTEGER, - reason: DataTypes.STRING, - agentringnoanswer: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentringnoanswerAt: DataTypes.DATE, - agentdump: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentdumpAt: DataTypes.DATE, - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.STRING, - destchannel: DataTypes.STRING, - destchannelstate: DataTypes.INTEGER, - destchannelstatedesc: DataTypes.STRING, - destcalleridnum: DataTypes.STRING, - destcalleridname: DataTypes.STRING, - destconnectedlinenum: DataTypes.STRING, - destconnectedlinename: DataTypes.STRING, - destlanguage: DataTypes.STRING, - destaccountcode: DataTypes.STRING, - destcontext: DataTypes.STRING, - destexten: DataTypes.STRING, - destpriority: DataTypes.STRING, - destuniqueid: DataTypes.STRING - }, { - tableName: 'report_agent_history' - }); - - ReportAgentHistory.removeAttribute('id'); - return ReportAgentHistory; -}; +var _0x8700=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74\x48\x69\x73\x74\x6F\x72\x79","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74\x5F\x68\x69\x73\x74\x6F\x72\x79","\x64\x65\x66\x69\x6E\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65"];module[_0x8700[0]]=function(_0x64f4x1,_0x64f4x2){var _0x64f4x3=_0x64f4x1[_0x8700[7]](_0x8700[1],{uniqueid:_0x64f4x2[_0x8700[2]],calleridnum:_0x64f4x2[_0x8700[2]],calleridname:_0x64f4x2[_0x8700[2]],queue:_0x64f4x2[_0x8700[2]],interface:_0x64f4x2[_0x8700[2]],membername:_0x64f4x2[_0x8700[2]],agentcalledAt:_0x64f4x2[_0x8700[3]],agentconnectAt:_0x64f4x2[_0x8700[3]],holdtime:_0x64f4x2[_0x8700[4]],agentcomplete:{type:_0x64f4x2[_0x8700[5]],defaultValue:false},agentcompleteAt:_0x64f4x2[_0x8700[3]],talktime:_0x64f4x2[_0x8700[4]],agentacw:{type:_0x64f4x2[_0x8700[5]],defaultValue:false},acwtime:_0x64f4x2[_0x8700[4]],reason:_0x64f4x2[_0x8700[2]],agentringnoanswer:{type:_0x64f4x2[_0x8700[5]],defaultValue:false},agentringnoanswerAt:_0x64f4x2[_0x8700[3]],agentdump:{type:_0x64f4x2[_0x8700[5]],defaultValue:false},agentdumpAt:_0x64f4x2[_0x8700[3]],channel:_0x64f4x2[_0x8700[2]],channelstate:_0x64f4x2[_0x8700[4]],channelstatedesc:_0x64f4x2[_0x8700[2]],connectedlinenum:_0x64f4x2[_0x8700[2]],connectedlinename:_0x64f4x2[_0x8700[2]],language:_0x64f4x2[_0x8700[2]],accountcode:_0x64f4x2[_0x8700[2]],context:_0x64f4x2[_0x8700[2]],exten:_0x64f4x2[_0x8700[2]],priority:_0x64f4x2[_0x8700[2]],destchannel:_0x64f4x2[_0x8700[2]],destchannelstate:_0x64f4x2[_0x8700[4]],destchannelstatedesc:_0x64f4x2[_0x8700[2]],destcalleridnum:_0x64f4x2[_0x8700[2]],destcalleridname:_0x64f4x2[_0x8700[2]],destconnectedlinenum:_0x64f4x2[_0x8700[2]],destconnectedlinename:_0x64f4x2[_0x8700[2]],destlanguage:_0x64f4x2[_0x8700[2]],destaccountcode:_0x64f4x2[_0x8700[2]],destcontext:_0x64f4x2[_0x8700[2]],destexten:_0x64f4x2[_0x8700[2]],destpriority:_0x64f4x2[_0x8700[2]],destuniqueid:_0x64f4x2[_0x8700[2]]},{tableName:_0x8700[6]});_0x64f4x3[_0x8700[9]](_0x8700[8]);return _0x64f4x3;}; \ No newline at end of file diff --git a/server/models/history/report_call_history.js b/server/models/history/report_call_history.js index ec7ea22..25cbb5f 100644 --- a/server/models/history/report_call_history.js +++ b/server/models/history/report_call_history.js @@ -1,56 +1 @@ -/** - * CDR Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportCallHistory = sequelize.define('ReportCallHistory', { - accountcode: DataTypes.STRING, - source: DataTypes.STRING, - destination: DataTypes.STRING, - destinationcontext: DataTypes.STRING, - callerid: DataTypes.STRING, - channel: DataTypes.STRING, - destinationchannel: DataTypes.STRING, - lastapplication: DataTypes.STRING, - lastdata: DataTypes.STRING, - starttime: DataTypes.DATE, - answertime: { - type: DataTypes.DATE, - set: function(answertime) { - if (answertime !== '') { - this.setDataValue('answertime', answertime); - } else { - this.setDataValue('answertime', null); - } - } - }, - endtime: DataTypes.DATE, - duration: DataTypes.INTEGER, - billableseconds: DataTypes.INTEGER, - disposition: DataTypes.STRING, - amaflags: DataTypes.STRING, - uniqueid: { - type: DataTypes.STRING, - primaryKey: true - }, - userfield: DataTypes.STRING, - }, { - tableName: 'report_call_history', - associate: function(models) { - ReportCallHistory.hasMany(models.ReportQueueHistory, { - as: 'HistoryQueueCalls', - foreignKey: 'uniqueid', - constraints: false - }); - ReportCallHistory.hasMany(models.ReportAgentHistory, { - as: 'HistoryReportAgents', - foreignKey: 'uniqueid', - constraints: false - }); - } - }); - - ReportCallHistory.removeAttribute('id'); - return ReportCallHistory; -}; +var _0x2fa5=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C\x48\x69\x73\x74\x6F\x72\x79","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","","\x61\x6E\x73\x77\x65\x72\x74\x69\x6D\x65","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x49\x4E\x54\x45\x47\x45\x52","\x72\x65\x70\x6F\x72\x74\x5F\x63\x61\x6C\x6C\x5F\x68\x69\x73\x74\x6F\x72\x79","\x48\x69\x73\x74\x6F\x72\x79\x51\x75\x65\x75\x65\x43\x61\x6C\x6C\x73","\x75\x6E\x69\x71\x75\x65\x69\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x48\x69\x73\x74\x6F\x72\x79\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74\x73","\x64\x65\x66\x69\x6E\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65"];module[_0x2fa5[0]]=function(_0x5c91x1,_0x5c91x2){var _0x5c91x3=_0x5c91x1[_0x2fa5[13]](_0x2fa5[1],{accountcode:_0x5c91x2[_0x2fa5[2]],source:_0x5c91x2[_0x2fa5[2]],destination:_0x5c91x2[_0x2fa5[2]],destinationcontext:_0x5c91x2[_0x2fa5[2]],callerid:_0x5c91x2[_0x2fa5[2]],channel:_0x5c91x2[_0x2fa5[2]],destinationchannel:_0x5c91x2[_0x2fa5[2]],lastapplication:_0x5c91x2[_0x2fa5[2]],lastdata:_0x5c91x2[_0x2fa5[2]],starttime:_0x5c91x2[_0x2fa5[3]],answertime:{type:_0x5c91x2[_0x2fa5[3]],set:function(_0x5c91x4){if(_0x5c91x4!==_0x2fa5[4]){this[_0x2fa5[6]](_0x2fa5[5],_0x5c91x4)}else {this[_0x2fa5[6]](_0x2fa5[5],null)}}},endtime:_0x5c91x2[_0x2fa5[3]],duration:_0x5c91x2[_0x2fa5[7]],billableseconds:_0x5c91x2[_0x2fa5[7]],disposition:_0x5c91x2[_0x2fa5[2]],amaflags:_0x5c91x2[_0x2fa5[2]],uniqueid:{type:_0x5c91x2[_0x2fa5[2]],primaryKey:true},userfield:_0x5c91x2[_0x2fa5[2]]},{tableName:_0x2fa5[8],associate:function(_0x5c91x5){_0x5c91x3[_0x2fa5[11]](_0x5c91x5.ReportQueueHistory,{as:_0x2fa5[9],foreignKey:_0x2fa5[10],constraints:false});_0x5c91x3[_0x2fa5[11]](_0x5c91x5.ReportAgentHistory,{as:_0x2fa5[12],foreignKey:_0x2fa5[10],constraints:false});}});_0x5c91x3[_0x2fa5[15]](_0x2fa5[14]);return _0x5c91x3;}; \ No newline at end of file diff --git a/server/models/history/report_dial_history.js b/server/models/history/report_dial_history.js index 634bdfe..258bb90 100644 --- a/server/models/history/report_dial_history.js +++ b/server/models/history/report_dial_history.js @@ -1,42 +1 @@ -/** - * DIAL Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportDialHistory = sequelize.define('ReportDialHistory', { - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.INTEGER, - uniqueid: DataTypes.STRING, - destchannel: DataTypes.STRING, - destchannelstate: DataTypes.INTEGER, - destchannelstatedesc: DataTypes.STRING, - destcalleridnum: DataTypes.STRING, - destcalleridname: DataTypes.STRING, - destconnectedlinenum: DataTypes.STRING, - destconnectedlinename: DataTypes.STRING, - destlanguage: DataTypes.STRING, - destaccountcode: DataTypes.STRING, - destcontext: DataTypes.STRING, - destexten: DataTypes.STRING, - destpriority: DataTypes.INTEGER, - destuniqueid: DataTypes.STRING, - dialstring: DataTypes.STRING, - dialstatus: DataTypes.STRING - }, { - tableName: 'report_dial_history' - }); - - ReportDialHistory.removeAttribute('id'); - return ReportDialHistory; -}; +var _0x6c9a=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x44\x69\x61\x6C\x48\x69\x73\x74\x6F\x72\x79","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x72\x65\x70\x6F\x72\x74\x5F\x64\x69\x61\x6C\x5F\x68\x69\x73\x74\x6F\x72\x79","\x64\x65\x66\x69\x6E\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65"];module[_0x6c9a[0]]=function(_0x80ddx1,_0x80ddx2){var _0x80ddx3=_0x80ddx1[_0x6c9a[5]](_0x6c9a[1],{channel:_0x80ddx2[_0x6c9a[2]],channelstate:_0x80ddx2[_0x6c9a[3]],channelstatedesc:_0x80ddx2[_0x6c9a[2]],calleridnum:_0x80ddx2[_0x6c9a[2]],calleridname:_0x80ddx2[_0x6c9a[2]],connectedlinenum:_0x80ddx2[_0x6c9a[2]],connectedlinename:_0x80ddx2[_0x6c9a[2]],language:_0x80ddx2[_0x6c9a[2]],accountcode:_0x80ddx2[_0x6c9a[2]],context:_0x80ddx2[_0x6c9a[2]],exten:_0x80ddx2[_0x6c9a[2]],priority:_0x80ddx2[_0x6c9a[3]],uniqueid:_0x80ddx2[_0x6c9a[2]],destchannel:_0x80ddx2[_0x6c9a[2]],destchannelstate:_0x80ddx2[_0x6c9a[3]],destchannelstatedesc:_0x80ddx2[_0x6c9a[2]],destcalleridnum:_0x80ddx2[_0x6c9a[2]],destcalleridname:_0x80ddx2[_0x6c9a[2]],destconnectedlinenum:_0x80ddx2[_0x6c9a[2]],destconnectedlinename:_0x80ddx2[_0x6c9a[2]],destlanguage:_0x80ddx2[_0x6c9a[2]],destaccountcode:_0x80ddx2[_0x6c9a[2]],destcontext:_0x80ddx2[_0x6c9a[2]],destexten:_0x80ddx2[_0x6c9a[2]],destpriority:_0x80ddx2[_0x6c9a[3]],destuniqueid:_0x80ddx2[_0x6c9a[2]],dialstring:_0x80ddx2[_0x6c9a[2]],dialstatus:_0x80ddx2[_0x6c9a[2]]},{tableName:_0x6c9a[4]});_0x80ddx3[_0x6c9a[7]](_0x6c9a[6]);return _0x80ddx3;}; \ No newline at end of file diff --git a/server/models/history/report_integration_history.js b/server/models/history/report_integration_history.js index 9b80979..7cdd585 100644 --- a/server/models/history/report_integration_history.js +++ b/server/models/history/report_integration_history.js @@ -1,84 +1 @@ -/** - * report_integrations Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportIntegrationHistory = sequelize.define('ReportIntegrationHistory', { - integration: DataTypes.STRING, - event: DataTypes.STRING, - contacts: DataTypes.STRING, - uniqueid: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - queue: DataTypes.STRING, - interface: DataTypes.STRING, - membername: DataTypes.STRING, - agentcalledAt: DataTypes.DATE, - agentconnectAt: DataTypes.DATE, - holdtime: DataTypes.INTEGER, - agentcomplete: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentcompleteAt: DataTypes.DATE, - talktime: DataTypes.INTEGER, - agentacw: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - acwtime: DataTypes.INTEGER, - reason: DataTypes.STRING, - agentringnoanswer: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentringnoanswerAt: DataTypes.DATE, - agentdump: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentdumpAt: DataTypes.DATE, - lastevent: DataTypes.STRING, - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.STRING, - destchannel: DataTypes.STRING, - destchannelstate: DataTypes.INTEGER, - destchannelstatedesc: DataTypes.STRING, - destcalleridnum: DataTypes.STRING, - destcalleridname: DataTypes.STRING, - destconnectedlinenum: DataTypes.STRING, - destconnectedlinename: DataTypes.STRING, - destlanguage: DataTypes.STRING, - destaccountcode: DataTypes.STRING, - destcontext: DataTypes.STRING, - destexten: DataTypes.STRING, - destpriority: DataTypes.STRING, - destuniqueid: DataTypes.STRING, - messageId: DataTypes.STRING, - inReplyTo: DataTypes.STRING, - subject: DataTypes.STRING, - from: DataTypes.STRING, - to: DataTypes.STRING, - cc: DataTypes.STRING, - attachment: DataTypes.TEXT, - html: DataTypes.TEXT, - text: DataTypes.TEXT, - status: { - type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED') - } - }, { - tableName: 'report_integration_history' - }); - - ReportIntegrationHistory.removeAttribute('id'); - return ReportIntegrationHistory; -}; +var _0x19a5=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x48\x69\x73\x74\x6F\x72\x79","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x54\x45\x58\x54","\x53\x45\x4E\x54","\x53\x45\x4E\x44\x49\x4E\x47","\x52\x45\x43\x45\x49\x56\x45\x44","\x46\x41\x49\x4C\x45\x44","\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x5F\x68\x69\x73\x74\x6F\x72\x79","\x64\x65\x66\x69\x6E\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65"];module[_0x19a5[0]]=function(_0x78e0x1,_0x78e0x2){var _0x78e0x3=_0x78e0x1[_0x19a5[12]](_0x19a5[1],{integration:_0x78e0x2[_0x19a5[2]],event:_0x78e0x2[_0x19a5[2]],contacts:_0x78e0x2[_0x19a5[2]],uniqueid:_0x78e0x2[_0x19a5[2]],calleridnum:_0x78e0x2[_0x19a5[2]],calleridname:_0x78e0x2[_0x19a5[2]],queue:_0x78e0x2[_0x19a5[2]],interface:_0x78e0x2[_0x19a5[2]],membername:_0x78e0x2[_0x19a5[2]],agentcalledAt:_0x78e0x2[_0x19a5[3]],agentconnectAt:_0x78e0x2[_0x19a5[3]],holdtime:_0x78e0x2[_0x19a5[4]],agentcomplete:{type:_0x78e0x2[_0x19a5[5]],defaultValue:false},agentcompleteAt:_0x78e0x2[_0x19a5[3]],talktime:_0x78e0x2[_0x19a5[4]],agentacw:{type:_0x78e0x2[_0x19a5[5]],defaultValue:false},acwtime:_0x78e0x2[_0x19a5[4]],reason:_0x78e0x2[_0x19a5[2]],agentringnoanswer:{type:_0x78e0x2[_0x19a5[5]],defaultValue:false},agentringnoanswerAt:_0x78e0x2[_0x19a5[3]],agentdump:{type:_0x78e0x2[_0x19a5[5]],defaultValue:false},agentdumpAt:_0x78e0x2[_0x19a5[3]],lastevent:_0x78e0x2[_0x19a5[2]],channel:_0x78e0x2[_0x19a5[2]],channelstate:_0x78e0x2[_0x19a5[4]],channelstatedesc:_0x78e0x2[_0x19a5[2]],connectedlinenum:_0x78e0x2[_0x19a5[2]],connectedlinename:_0x78e0x2[_0x19a5[2]],language:_0x78e0x2[_0x19a5[2]],accountcode:_0x78e0x2[_0x19a5[2]],context:_0x78e0x2[_0x19a5[2]],exten:_0x78e0x2[_0x19a5[2]],priority:_0x78e0x2[_0x19a5[2]],destchannel:_0x78e0x2[_0x19a5[2]],destchannelstate:_0x78e0x2[_0x19a5[4]],destchannelstatedesc:_0x78e0x2[_0x19a5[2]],destcalleridnum:_0x78e0x2[_0x19a5[2]],destcalleridname:_0x78e0x2[_0x19a5[2]],destconnectedlinenum:_0x78e0x2[_0x19a5[2]],destconnectedlinename:_0x78e0x2[_0x19a5[2]],destlanguage:_0x78e0x2[_0x19a5[2]],destaccountcode:_0x78e0x2[_0x19a5[2]],destcontext:_0x78e0x2[_0x19a5[2]],destexten:_0x78e0x2[_0x19a5[2]],destpriority:_0x78e0x2[_0x19a5[2]],destuniqueid:_0x78e0x2[_0x19a5[2]],messageId:_0x78e0x2[_0x19a5[2]],inReplyTo:_0x78e0x2[_0x19a5[2]],subject:_0x78e0x2[_0x19a5[2]],from:_0x78e0x2[_0x19a5[2]],to:_0x78e0x2[_0x19a5[2]],cc:_0x78e0x2[_0x19a5[2]],attachment:_0x78e0x2[_0x19a5[6]],html:_0x78e0x2[_0x19a5[6]],text:_0x78e0x2[_0x19a5[6]],status:{type:_0x78e0x2.ENUM(_0x19a5[7],_0x19a5[8],_0x19a5[9],_0x19a5[10])}},{tableName:_0x19a5[11]});_0x78e0x3[_0x19a5[14]](_0x19a5[13]);return _0x78e0x3;}; \ No newline at end of file diff --git a/server/models/history/report_mail_session_history.js b/server/models/history/report_mail_session_history.js index f64724e..913609a 100644 --- a/server/models/history/report_mail_session_history.js +++ b/server/models/history/report_mail_session_history.js @@ -1,31 +1 @@ -/** - * Agent Log Model - */ - -var moment = require('moment'); - -module.exports = function(sequelize, DataTypes) { - - var ReportMailSessionHistory = sequelize.define('ReportMailSessionHistory', { - uniqueid: { - type: DataTypes.INTEGER - }, - subject: DataTypes.STRING, - from: DataTypes.STRING, - cc: DataTypes.STRING, - attachment: DataTypes.BOOLEAN, - accountname: DataTypes.STRING, - accountaddress: DataTypes.STRING, - fullname: DataTypes.STRING, - membername: DataTypes.STRING, - mailqueuename: DataTypes.STRING, - mailjoinAt: DataTypes.DATE, - mailleaveAt: DataTypes.DATE, - mailunmanagedAt: DataTypes.DATE, - }, { - tableName: 'report_mail_session_history' - }); - - ReportMailSessionHistory.removeAttribute('id'); - return ReportMailSessionHistory; -}; +var _0x89cf=["\x6D\x6F\x6D\x65\x6E\x74","\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E\x48\x69\x73\x74\x6F\x72\x79","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x44\x41\x54\x45","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E\x5F\x68\x69\x73\x74\x6F\x72\x79","\x64\x65\x66\x69\x6E\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65"];var moment=require(_0x89cf[0]);module[_0x89cf[1]]=function(_0xae57x2,_0xae57x3){var _0xae57x4=_0xae57x2[_0x89cf[8]](_0x89cf[2],{uniqueid:{type:_0xae57x3[_0x89cf[3]]},subject:_0xae57x3[_0x89cf[4]],from:_0xae57x3[_0x89cf[4]],cc:_0xae57x3[_0x89cf[4]],attachment:_0xae57x3[_0x89cf[5]],accountname:_0xae57x3[_0x89cf[4]],accountaddress:_0xae57x3[_0x89cf[4]],fullname:_0xae57x3[_0x89cf[4]],membername:_0xae57x3[_0x89cf[4]],mailqueuename:_0xae57x3[_0x89cf[4]],mailjoinAt:_0xae57x3[_0x89cf[6]],mailleaveAt:_0xae57x3[_0x89cf[6]],mailunmanagedAt:_0xae57x3[_0x89cf[6]]},{tableName:_0x89cf[7]});_0xae57x4[_0x89cf[10]](_0x89cf[9]);return _0xae57x4;}; \ No newline at end of file diff --git a/server/models/history/report_member_history.js b/server/models/history/report_member_history.js index dbb928a..7c6bea7 100644 --- a/server/models/history/report_member_history.js +++ b/server/models/history/report_member_history.js @@ -1,23 +1 @@ -/** - * DIAL Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportMemberHistory = sequelize.define('ReportMemberHistory', { - stateinterface: DataTypes.STRING, - queue: DataTypes.STRING, - membername: DataTypes.STRING, - interface: DataTypes.STRING, - state: DataTypes.INTEGER, - statedesc: DataTypes.STRING, - enterdate: DataTypes.DATE, - exitdate: DataTypes.DATE, - reason: DataTypes.STRING - }, { - tableName: 'report_member_history' - }); - - ReportMemberHistory.removeAttribute('id'); - return ReportMemberHistory; -}; +var _0x8ca4=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x4D\x65\x6D\x62\x65\x72\x48\x69\x73\x74\x6F\x72\x79","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x44\x41\x54\x45","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x65\x6D\x62\x65\x72\x5F\x68\x69\x73\x74\x6F\x72\x79","\x64\x65\x66\x69\x6E\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65"];module[_0x8ca4[0]]=function(_0x65acx1,_0x65acx2){var _0x65acx3=_0x65acx1[_0x8ca4[6]](_0x8ca4[1],{stateinterface:_0x65acx2[_0x8ca4[2]],queue:_0x65acx2[_0x8ca4[2]],membername:_0x65acx2[_0x8ca4[2]],interface:_0x65acx2[_0x8ca4[2]],state:_0x65acx2[_0x8ca4[3]],statedesc:_0x65acx2[_0x8ca4[2]],enterdate:_0x65acx2[_0x8ca4[4]],exitdate:_0x65acx2[_0x8ca4[4]],reason:_0x65acx2[_0x8ca4[2]]},{tableName:_0x8ca4[5]});_0x65acx3[_0x8ca4[8]](_0x8ca4[7]);return _0x65acx3;}; \ No newline at end of file diff --git a/server/models/history/report_queue_history.js b/server/models/history/report_queue_history.js index 2f4a450..107011c 100644 --- a/server/models/history/report_queue_history.js +++ b/server/models/history/report_queue_history.js @@ -1,39 +1 @@ -/** - * QueueLog Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportQueueHistory = sequelize.define('ReportQueueHistory', { - uniqueid: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - queue: DataTypes.STRING, - queuecallerjoinAt: DataTypes.DATE, - queuecallerleaveAt: DataTypes.DATE, - position: DataTypes.INTEGER, - count: DataTypes.INTEGER, - queuecallerabandon: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - queuecallerabandonAt: DataTypes.DATE, - queuecallercompleteAt: DataTypes.DATE, - originalposition: DataTypes.INTEGER, - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.STRING, - }, { - tableName: 'report_queue_history' - }); - - ReportQueueHistory.removeAttribute('id'); - return ReportQueueHistory; -}; +var _0xa6f1=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x75\x65\x48\x69\x73\x74\x6F\x72\x79","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65\x5F\x68\x69\x73\x74\x6F\x72\x79","\x64\x65\x66\x69\x6E\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65"];module[_0xa6f1[0]]=function(_0x8f86x1,_0x8f86x2){var _0x8f86x3=_0x8f86x1[_0xa6f1[7]](_0xa6f1[1],{uniqueid:_0x8f86x2[_0xa6f1[2]],calleridnum:_0x8f86x2[_0xa6f1[2]],calleridname:_0x8f86x2[_0xa6f1[2]],queue:_0x8f86x2[_0xa6f1[2]],queuecallerjoinAt:_0x8f86x2[_0xa6f1[3]],queuecallerleaveAt:_0x8f86x2[_0xa6f1[3]],position:_0x8f86x2[_0xa6f1[4]],count:_0x8f86x2[_0xa6f1[4]],queuecallerabandon:{type:_0x8f86x2[_0xa6f1[5]],defaultValue:false},queuecallerabandonAt:_0x8f86x2[_0xa6f1[3]],queuecallercompleteAt:_0x8f86x2[_0xa6f1[3]],originalposition:_0x8f86x2[_0xa6f1[4]],channel:_0x8f86x2[_0xa6f1[2]],channelstate:_0x8f86x2[_0xa6f1[4]],channelstatedesc:_0x8f86x2[_0xa6f1[2]],connectedlinenum:_0x8f86x2[_0xa6f1[2]],connectedlinename:_0x8f86x2[_0xa6f1[2]],language:_0x8f86x2[_0xa6f1[2]],accountcode:_0x8f86x2[_0xa6f1[2]],context:_0x8f86x2[_0xa6f1[2]],exten:_0x8f86x2[_0xa6f1[2]],priority:_0x8f86x2[_0xa6f1[2]]},{tableName:_0xa6f1[6]});_0x8f86x3[_0xa6f1[9]](_0xa6f1[8]);return _0x8f86x3;}; \ No newline at end of file diff --git a/server/models/index.js b/server/models/index.js index d299094..b379fe0 100644 --- a/server/models/index.js +++ b/server/models/index.js @@ -1,96 +1 @@ -"use strict"; - -var fs = require("fs"); -var path = require("path"); -var config = require('../config/environment'); -var Sequelize = require("sequelize"); -var moment = require('moment'); - -//Used to disable all warnings for Promise! -Sequelize.Promise.config({ - // Enables all warnings except forgotten return statements. - warnings: { - wForgottenReturn: false - } -}); - -var sequelize = new Sequelize(config.db.database, config.db.username, config.db.password, { - host: config.db.host, - dialect: 'mysql', - timezone: moment().format("Z"), - logging: false -}); - -var db = {}; - -fs - .readdirSync(__dirname) - .filter(function (file) { - return (fs.lstatSync(path.join(__dirname, file)).isFile()) && - (file.indexOf(".") !== 0) && (file.indexOf('.spec.') === -1) && (file !== "index.js"); - }) - .forEach(function (file) { - var model = sequelize["import"](path.join(__dirname, file)); - db[model.name] = model; - }); - -// Invoke associations on each of the models -Object.keys(db).forEach(function (modelName) { - if (db[modelName].options.hasOwnProperty('associate')) { - db[modelName].options.associate(db); - } -}); - -db.history = {}; - -var sequelize_history = new Sequelize(config.db_history.database, config.db_history.username, config.db_history.password, { - host: config.db_history.host, - dialect: 'mysql', - timezone: moment().format("Z"), - logging: false -}); - -fs - .readdirSync(path.join(__dirname, 'history')) - .filter(function (file) { - return (fs.lstatSync(path.join(__dirname, 'history', file)).isFile()) && - (file.indexOf(".") !== 0) && (file.indexOf('.spec.') === -1) && (file !== "index.js"); - }) - .forEach(function (file) { - var model = sequelize_history["import"](path.join(__dirname, 'history', file)); - db.history[model.name] = model; - }); - -// Invoke associations on each of the models -Object.keys(db.history).forEach(function (modelName) { - if (db.history[modelName].options.hasOwnProperty('associate')) { - db.history[modelName].options.associate(db.history); - } -}); - -db.ContactPhone.hasMany(db.history.ReportCallHistory, { - as: 'HistoryInbounds', - foreignKey: 'source', - constraints: false -}); -db.ContactPhone.hasMany(db.history.ReportCallHistory, { - as: 'HistoryOutbounds', - foreignKey: 'destination', - constraints: false -}); -db.ContactEmail.hasMany(db.history.ReportMailSessionHistory, { - as: 'HistoryInboundMessages', - foreignKey: 'from', - constraints: false -}); -db.ContactEmail.hasMany(db.history.ReportMailSessionHistory, { - as: 'HistoryOutboundMessages', - foreignKey: 'to', - constraints: false -}); - -db.sequelize = sequelize; -db.sequelize_history = sequelize_history; -db.Sequelize = Sequelize; - -module.exports = db; +var _0xc029=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x66\x73","\x70\x61\x74\x68","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x6D\x6F\x6D\x65\x6E\x74","\x63\x6F\x6E\x66\x69\x67","\x50\x72\x6F\x6D\x69\x73\x65","\x64\x61\x74\x61\x62\x61\x73\x65","\x64\x62","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x68\x6F\x73\x74","\x6D\x79\x73\x71\x6C","\x5A","\x66\x6F\x72\x6D\x61\x74","\x6A\x6F\x69\x6E","\x69\x6D\x70\x6F\x72\x74","\x6E\x61\x6D\x65","\x66\x6F\x72\x45\x61\x63\x68","\x69\x73\x46\x69\x6C\x65","\x6C\x73\x74\x61\x74\x53\x79\x6E\x63","\x2E","\x69\x6E\x64\x65\x78\x4F\x66","\x2E\x73\x70\x65\x63\x2E","\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x66\x69\x6C\x74\x65\x72","\x72\x65\x61\x64\x64\x69\x72\x53\x79\x6E\x63","\x61\x73\x73\x6F\x63\x69\x61\x74\x65","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x6F\x70\x74\x69\x6F\x6E\x73","\x6B\x65\x79\x73","\x68\x69\x73\x74\x6F\x72\x79","\x64\x62\x5F\x68\x69\x73\x74\x6F\x72\x79","\x48\x69\x73\x74\x6F\x72\x79\x49\x6E\x62\x6F\x75\x6E\x64\x73","\x73\x6F\x75\x72\x63\x65","\x68\x61\x73\x4D\x61\x6E\x79","\x43\x6F\x6E\x74\x61\x63\x74\x50\x68\x6F\x6E\x65","\x48\x69\x73\x74\x6F\x72\x79\x4F\x75\x74\x62\x6F\x75\x6E\x64\x73","\x64\x65\x73\x74\x69\x6E\x61\x74\x69\x6F\x6E","\x48\x69\x73\x74\x6F\x72\x79\x49\x6E\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x66\x72\x6F\x6D","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x48\x69\x73\x74\x6F\x72\x79\x4F\x75\x74\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x74\x6F","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65\x5F\x68\x69\x73\x74\x6F\x72\x79","\x53\x65\x71\x75\x65\x6C\x69\x7A\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xc029[0];var fs=require(_0xc029[1]);var path=require(_0xc029[2]);var config=require(_0xc029[3]);var Sequelize=require(_0xc029[4]);var moment=require(_0xc029[5]);Sequelize[_0xc029[7]][_0xc029[6]]({warnings:{wForgottenReturn:false}});var sequelize= new Sequelize(config[_0xc029[9]][_0xc029[8]],config[_0xc029[9]][_0xc029[10]],config[_0xc029[9]][_0xc029[11]],{host:config[_0xc029[9]][_0xc029[12]],dialect:_0xc029[13],timezone:moment()[_0xc029[15]](_0xc029[14]),logging:false});var db={};fs[_0xc029[27]](__dirname)[_0xc029[26]](function(_0x63bdx8){return (fs[_0xc029[21]](path[_0xc029[16]](__dirname,_0x63bdx8))[_0xc029[20]]())&&(_0x63bdx8[_0xc029[23]](_0xc029[22])!==0)&&(_0x63bdx8[_0xc029[23]](_0xc029[24])=== -1)&&(_0x63bdx8!==_0xc029[25])})[_0xc029[19]](function(_0x63bdx8){var _0x63bdx9=sequelize[_0xc029[17]](path[_0xc029[16]](__dirname,_0x63bdx8));db[_0x63bdx9[_0xc029[18]]]=_0x63bdx9;});Object[_0xc029[31]](db)[_0xc029[19]](function(_0x63bdxa){if(db[_0x63bdxa][_0xc029[30]][_0xc029[29]](_0xc029[28])){db[_0x63bdxa][_0xc029[30]][_0xc029[28]](db)}});db[_0xc029[32]]={};var sequelize_history= new Sequelize(config[_0xc029[33]][_0xc029[8]],config[_0xc029[33]][_0xc029[10]],config[_0xc029[33]][_0xc029[11]],{host:config[_0xc029[33]][_0xc029[12]],dialect:_0xc029[13],timezone:moment()[_0xc029[15]](_0xc029[14]),logging:false});fs[_0xc029[27]](path[_0xc029[16]](__dirname,_0xc029[32]))[_0xc029[26]](function(_0x63bdx8){return (fs[_0xc029[21]](path[_0xc029[16]](__dirname,_0xc029[32],_0x63bdx8))[_0xc029[20]]())&&(_0x63bdx8[_0xc029[23]](_0xc029[22])!==0)&&(_0x63bdx8[_0xc029[23]](_0xc029[24])=== -1)&&(_0x63bdx8!==_0xc029[25])})[_0xc029[19]](function(_0x63bdx8){var _0x63bdx9=sequelize_history[_0xc029[17]](path[_0xc029[16]](__dirname,_0xc029[32],_0x63bdx8));db[_0xc029[32]][_0x63bdx9[_0xc029[18]]]=_0x63bdx9;});Object[_0xc029[31]](db[_0xc029[32]])[_0xc029[19]](function(_0x63bdxa){if(db[_0xc029[32]][_0x63bdxa][_0xc029[30]][_0xc029[29]](_0xc029[28])){db[_0xc029[32]][_0x63bdxa][_0xc029[30]][_0xc029[28]](db[_0xc029[32]])}});db[_0xc029[37]][_0xc029[36]](db[_0xc029[32]].ReportCallHistory,{as:_0xc029[34],foreignKey:_0xc029[35],constraints:false});db[_0xc029[37]][_0xc029[36]](db[_0xc029[32]].ReportCallHistory,{as:_0xc029[38],foreignKey:_0xc029[39],constraints:false});db[_0xc029[42]][_0xc029[36]](db[_0xc029[32]].ReportMailSessionHistory,{as:_0xc029[40],foreignKey:_0xc029[41],constraints:false});db[_0xc029[42]][_0xc029[36]](db[_0xc029[32]].ReportMailSessionHistory,{as:_0xc029[43],foreignKey:_0xc029[44],constraints:false});db[_0xc029[4]]=sequelize;db[_0xc029[45]]=sequelize_history;db[_0xc029[46]]=Sequelize;module[_0xc029[47]]=db; \ No newline at end of file diff --git a/server/models/integration.js b/server/models/integration.js index 53aecce..6c523fa 100644 --- a/server/models/integration.js +++ b/server/models/integration.js @@ -1,62 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Integration = sequelize.define('Integration', { - name: { - type: DataTypes.STRING, - allowNull: false, - unique: 'unique_name_and_version', - validate: { - notEmpty: true - } - }, - version: { - type: DataTypes.STRING, - allowNull: false, - unique: 'unique_name_and_version', - validate: { - notEmpty: true - } - }, - main: { - type: DataTypes.STRING, - defaultValue: 'app.js' - }, - filename: { - type: DataTypes.STRING, - // allowNull: false, - // validate: { - // notEmpty: true - // } - }, - path: { - type: DataTypes.STRING, - // allowNull: false, - // validate: { - // notEmpty: true - // } - }, - type: { - type: DataTypes.STRING, - // allowNull: false - }, - size: { - type: DataTypes.INTEGER, - // allowNull: false - }, - active: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - author: DataTypes.STRING, - logo: DataTypes.STRING, - state: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'integrations' - }); - - return Integration; - -}; +var _0x8055=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x75\x6E\x69\x71\x75\x65\x5F\x6E\x61\x6D\x65\x5F\x61\x6E\x64\x5F\x76\x65\x72\x73\x69\x6F\x6E","\x61\x70\x70\x2E\x6A\x73","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73","\x64\x65\x66\x69\x6E\x65"];_0x8055[0];module[_0x8055[1]]=function(_0xdaeax1,_0xdaeax2){var _0xdaeax3=_0xdaeax1[_0x8055[9]](_0x8055[2],{name:{type:_0xdaeax2[_0x8055[3]],allowNull:false,unique:_0x8055[4],validate:{notEmpty:true}},version:{type:_0xdaeax2[_0x8055[3]],allowNull:false,unique:_0x8055[4],validate:{notEmpty:true}},main:{type:_0xdaeax2[_0x8055[3]],defaultValue:_0x8055[5]},filename:{type:_0xdaeax2[_0x8055[3]]},path:{type:_0xdaeax2[_0x8055[3]]},type:{type:_0xdaeax2[_0x8055[3]]},size:{type:_0xdaeax2[_0x8055[6]]},active:{type:_0xdaeax2[_0x8055[7]],defaultValue:false},author:_0xdaeax2[_0x8055[3]],logo:_0xdaeax2[_0x8055[3]],state:_0xdaeax2[_0x8055[3]],description:_0xdaeax2[_0x8055[3]]},{tableName:_0x8055[8]});return _0xdaeax3;}; \ No newline at end of file diff --git a/server/models/interval.js b/server/models/interval.js index ea0e3de..58cf422 100644 --- a/server/models/interval.js +++ b/server/models/interval.js @@ -1,661 +1 @@ -/* jshint indent: 2 */ -var util = require('util'); -var _ = require('lodash'); - -var Applications = { - Dial: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Set', - appdata: 'CALLERID(all)=%s' - }, { - app: 'Dial', - appdata: '%s,%s,%s,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Dial Application End' - }], - Queue: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Answer', - appdata: '' - }, { - app: 'Queue', - appdata: '%s,%s,%s,%s,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Queue Application End' - }], - Playback: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Playback', - appdata: '%s,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Playback Application End' - }], - AGI: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'AGI', - appdata: 'agi://127.0.0.1/square,%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'AGI Application End' - }], - Goto: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Goto', - appdata: '%s,%s,%d', - isApp: true - }, { - app: 'NoOp', - appdata: 'Goto Application End' - }], - Hangup: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Hangup', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Hangup Application End' - }], - Set: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Set', - appdata: '%s=%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Set Application End' - }], - custom: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }], - Voicemail: [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'Voicemail', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Voicemail Application End' - }] -}; - - -module.exports = function(sequelize, DataTypes) { - var Interval = sequelize.define('Interval', { - name: { - type: DataTypes.STRING, - unique: 'name_intervalid' - }, - interval: { - type: DataTypes.STRING, - allowNull: true - }, - IntervalId: { - type: DataTypes.INTEGER(11), - unique: 'name_intervalid' - } - }, { - tableName: 'intervals', - associate: function(models) { - Interval.hasMany(models.Interval, { - as: 'SubIntervals', - onDelete: 'cascade' - }); - Interval.hasMany(models.VoiceExtension, { - as: 'VoiceExtensions' - }); - Interval.hasMany(models.MailApplication, { - as: 'MailApplications' - }); - Interval.hasMany(models.MailApplication, { - as: 'ChatApplications' - }); - - Interval.afterUpdate(function(interval) { - if (interval.IntervalId !== null) { - interval.getVoiceExtensions() - .then(function(voiceExtensions) { - var appdata; - var oldappdata; - voiceExtensions.forEach(function(element) { - oldappdata = element.appdata.split('?'); - element.appdata = util.format('%s?%s', interval.interval, oldappdata[1]); - element.interval = interval.interval; - element.save() - .catch(function(err) { - console.log(err); - }); - }) - }) - .catch(function(err) { - console.log(err); - }); - } - }) - - Interval.beforeDestroy(function(interval) { - console.log('interval not yet deleted'); - if (interval.IntervalId !== null) { - appRewrite(interval, models); - } - }) - - Interval.afterCreate(function(interval) { - console.log('interval created'); - if (interval.IntervalId !== null) { - appRewrite(interval, models, true); - } - }) - } - }); - - function appRewrite(hookInterval, models, create) { - console.log('Finding extension apps..'); - models.VoiceExtension - .findAll({ - where: { - IntervalId: hookInterval.IntervalId, - } - }) - .then(function(tmpVoiceExtensions) { - if (tmpVoiceExtensions && tmpVoiceExtensions.length > 0) { - console.log('Extensions found'); - var voiceExtensionsIds = _.uniq(_.pluck(_.pluck(tmpVoiceExtensions, 'dataValues'), 'VoiceExtensionId'), true); - models.VoiceExtension - .findAll({ - where: { - VoiceExtensionId: voiceExtensionsIds, - isApp: true - } - }) - .then(function(voiceExtensions) { - console.log('Starting transaction before destroy..'); - return sequelize.transaction(function(t) { - console.log('Destroying extension rows...'); - return models.VoiceExtension.destroy({ - where: { - VoiceExtensionId: voiceExtensionsIds - } - }, { - transaction: t - }) - .then(function() { - console.log('Destroyed extensions'); - voiceExtensions = _.pluck(voiceExtensions, 'dataValues'); - var intervalIds = _.filter(_.pluck(voiceExtensions, 'IntervalId'), function(elem) { - return elem !== null; - }); - console.log('Finding intervals'); - Interval - .findAll({ - where: { - IntervalId: intervalIds, - id: { - $ne: create ? null : hookInterval.id - } - } - }) - .then(function(intervals) { - - console.log('Found intervals, creating extension rows...'); - var extByExtId; - voiceExtensionsIds.forEach(function(extId) { - extByExtId = _.filter(voiceExtensions, function(elem) { - return elem.VoiceExtensionId == extId; - }); - var priority = 2; - var interval; - extByExtId.forEach(function(tmpElem) { - console.log('Creating app..'); - var application = _.cloneDeep(Applications[tmpElem.app]); - if (!application || tmpElem.customApp) { - application = [{ - app: 'GotoIfTime', - appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s', - }, { - app: 'custom', - appdata: '%s', - isApp: true - }, { - app: 'NoOp', - appdata: 'Custom Application End' - }]; - } - console.log('PRIORITY'); - console.log(priority); - var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority); - tmpElem.interval = tmpElem.interval || '*,*,*,*'; - var tmpIntervals = _.filter(intervals, function(elem) { - return (elem.IntervalId == tmpElem.IntervalId); - }); - if (tmpIntervals && tmpIntervals.length > 0) { - application.splice(0, 1); - tmpIntervals.forEach(function(elem, index) { - // interval = createInterval(elem); - application.unshift({ - app: 'GotoIfTimeFromArray', - appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s', - IntervalId: elem.id, - isInterval: true, - interval: elem.interval - }); - }) - } - priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority); - console.log('returned priority'); - console.log(priority); - models.VoiceExtension - .bulkCreate(application) - }); - }); - - console.log('THE END'); - }) - }) - }) - .catch(function(err) { - console.log(err); - }); - }) - .catch(function(err) { - console.log(err); - }); - } - }) - .catch(function(err) { - console.log(err); - }); - } - - - return Interval; -}; - -// function createInterval(element) { -// var interval = []; -// if (element.t_from && element.t_from !== '') { -// interval[0] = element.t_from; -// if (element.t_to && element.t_to !== '') { -// interval[0] += '-' + element.t_to; -// } -// } else { -// interval[0] = '*'; -// } -// -// if (element.wd_from && element.wd_from !== '') { -// interval[1] = element.wd_from; -// if (element.wd_to && element.wd_to !== '') { -// interval[1] += '-' + element.wd_to; -// } -// } else { -// interval[1] = '*'; -// } -// -// if (element.md_from && element.md_from !== '') { -// interval[2] = element.md_from; -// if (element.md_to && element.md_to !== '') { -// interval[2] += '-' + element.md_to; -// } -// } else { -// interval[2] = '*'; -// } -// -// if (element.m_from && element.m_from !== '') { -// interval[3] = element.m_from; -// if (element.m_to && element.m_to !== '') { -// interval[3] += '-' + element.m_to; -// } -// } else { -// interval[3] = '*'; -// } -// -// return interval.join(','); -// } - -function appCreate(application, element, appGroup, intervals, priority) { - var intLength = intervals.length; - if (element.customApp) { - element.app = 'custom'; - } - switch (element.app) { - case 'Dial': - if (!element.callerID) { - _.remove(application, { - app: 'Set' - }); - } - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Dial': - if (element.type === 'outbound') { - elem.interval = element.interval; - elem.trunk = element.trunk; - elem.TrunkId = element.TrunkId; - elem.cutdigits = element.cutdigits || 0; - elem.callerID = element.callerID || null; - // elem.appdata = util.format('SIP/${EXTEN:%d}@%s', elem.cutdigits, elem.trunk); - } else { - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.interface = element.interface; - elem.app_options = element.app_options || ''; - elem.timeout = element.timeout || ''; - elem.url = element.url || ''; - elem.appdata = util.format(elem.appdata, element.interface, elem.timeout, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url); - } - break; - case 'Set': - elem.appdata = util.format(elem.appdata, element.callerID); - break; - case 'NoOp': - if (element.type === 'outbound') { - elem.appdata = 'Outbound Dial Application End'; - } - break; - default: - - } - }); - break; - case 'Queue': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Queue': - elem.IntervalId = element.IntervalId; - elem.app_options = element.app_options || ''; - elem.audiofile = element.audiofile || ''; - elem.queue = element.queue; - elem.interval = element.interval; - elem.interface = element.interface; - elem.app_options = element.app_options; - elem.timeout = element.timeout || ''; - elem.url = element.url || ''; - elem.appdata = util.format(elem.appdata, elem.queue, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url, elem.audiofile, elem.timeout); - break; - default: - - } - }); - break; - case 'Playback': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Playback': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.audiofile = element.audiofile || ''; - elem.app_options = element.app_options || ''; - elem.appdata = util.format(elem.appdata, elem.audiofile, elem.app_options ? elem.app_options.replace(',', '') : ''); - break; - default: - - } - }); - break; - case 'AGI': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'AGI': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.project = element.project; - elem.appdata = util.format(elem.appdata, elem.project); - break; - default: - - } - }); - break; - case 'Goto': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Goto': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.alt_priority = element.alt_priority; - elem.alt_extension = element.alt_extension; - elem.alt_context = element.alt_context; - elem.appdata = util.format(elem.appdata, elem.alt_context, elem.alt_extension, elem.alt_priority); - break; - default: - - } - }); - break; - case 'Hangup': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Hangup': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.causecode = element.causecode; - elem.appdata = util.format(elem.appdata, elem.causecode); - break; - default: - - } - }); - break; - case 'Set': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Set': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.variable = element.variable; - elem.value = element.value; - elem.appdata = util.format(elem.appdata, elem.variable, elem.value); - break; - default: - - } - }); - break; - case 'custom': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'custom': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.app = elem.customApp = element.customApp; - elem.appdata = util.format(elem.appdata, element.appdata); - break; - default: - - } - }); - break; - case 'Voicemail': - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'Voicemail': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.mailbox = element.mailbox; - elem.appdata = util.format(elem.appdata, elem.mailbox); - break; - default: - - } - }); - break; - default: - application.forEach(function(elem, index) { - elem.exten = element.exten; - elem.type = element.type; - elem.context = element.context; - elem.VoiceExtensionId = element.VoiceExtensionId; - elem.priority = priority ? priority++ : element.priority++; - elem.appGroup = appGroup; - switch (elem.app) { - case 'GotoIfTime': - elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2)); - break; - case 'GotoIfTimeFromArray': - elem.app = 'GotoIfTime'; - elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2)); - break; - case 'custom': - elem.IntervalId = element.IntervalId; - elem.interval = element.interval; - elem.app = elem.customApp = element.customApp; - elem.appdata = util.format(elem.appdata, element.appdata); - break; - default: - - } - }); - - } - if (priority) { - return priority; - } -} +var _0x89c6=["\x75\x74\x69\x6C","\x6C\x6F\x64\x61\x73\x68","\x47\x6F\x74\x6F\x49\x66\x54\x69\x6D\x65","\x25\x73\x3F\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73\x3A\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73","\x53\x65\x74","\x43\x41\x4C\x4C\x45\x52\x49\x44\x28\x61\x6C\x6C\x29\x3D\x25\x73","\x44\x69\x61\x6C","\x25\x73\x2C\x25\x73\x2C\x25\x73\x2C\x25\x73","\x4E\x6F\x4F\x70","\x44\x69\x61\x6C\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x41\x6E\x73\x77\x65\x72","","\x51\x75\x65\x75\x65","\x25\x73\x2C\x25\x73\x2C\x25\x73\x2C\x25\x73\x2C\x25\x73","\x51\x75\x65\x75\x65\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x50\x6C\x61\x79\x62\x61\x63\x6B","\x25\x73\x2C\x25\x73","\x50\x6C\x61\x79\x62\x61\x63\x6B\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x41\x47\x49","\x61\x67\x69\x3A\x2F\x2F\x31\x32\x37\x2E\x30\x2E\x30\x2E\x31\x2F\x73\x71\x75\x61\x72\x65\x2C\x25\x73","\x41\x47\x49\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x47\x6F\x74\x6F","\x25\x73\x2C\x25\x73\x2C\x25\x64","\x47\x6F\x74\x6F\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x48\x61\x6E\x67\x75\x70","\x25\x73","\x48\x61\x6E\x67\x75\x70\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x25\x73\x3D\x25\x73","\x53\x65\x74\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x63\x75\x73\x74\x6F\x6D","\x43\x75\x73\x74\x6F\x6D\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x65\x78\x70\x6F\x72\x74\x73","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x53\x54\x52\x49\x4E\x47","\x6E\x61\x6D\x65\x5F\x69\x6E\x74\x65\x72\x76\x61\x6C\x69\x64","\x69\x6E\x74\x65\x72\x76\x61\x6C\x73","\x53\x75\x62\x49\x6E\x74\x65\x72\x76\x61\x6C\x73","\x63\x61\x73\x63\x61\x64\x65","\x68\x61\x73\x4D\x61\x6E\x79","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x49\x6E\x74\x65\x72\x76\x61\x6C\x49\x64","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x3F","\x73\x70\x6C\x69\x74","\x61\x70\x70\x64\x61\x74\x61","\x25\x73\x3F\x25\x73","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x66\x6F\x72\x6D\x61\x74","\x73\x61\x76\x65","\x66\x6F\x72\x45\x61\x63\x68","\x74\x68\x65\x6E","\x67\x65\x74\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x69\x6E\x74\x65\x72\x76\x61\x6C\x20\x6E\x6F\x74\x20\x79\x65\x74\x20\x64\x65\x6C\x65\x74\x65\x64","\x62\x65\x66\x6F\x72\x65\x44\x65\x73\x74\x72\x6F\x79","\x69\x6E\x74\x65\x72\x76\x61\x6C\x20\x63\x72\x65\x61\x74\x65\x64","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x64\x65\x66\x69\x6E\x65","\x46\x69\x6E\x64\x69\x6E\x67\x20\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x20\x61\x70\x70\x73\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73\x20\x66\x6F\x75\x6E\x64","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x6C\x75\x63\x6B","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x49\x64","\x75\x6E\x69\x71","\x53\x74\x61\x72\x74\x69\x6E\x67\x20\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E\x20\x62\x65\x66\x6F\x72\x65\x20\x64\x65\x73\x74\x72\x6F\x79\x2E\x2E","\x44\x65\x73\x74\x72\x6F\x79\x69\x6E\x67\x20\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x20\x72\x6F\x77\x73\x2E\x2E\x2E","\x44\x65\x73\x74\x72\x6F\x79\x65\x64\x20\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x66\x69\x6C\x74\x65\x72","\x46\x69\x6E\x64\x69\x6E\x67\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x73","\x46\x6F\x75\x6E\x64\x20\x69\x6E\x74\x65\x72\x76\x61\x6C\x73\x2C\x20\x63\x72\x65\x61\x74\x69\x6E\x67\x20\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x20\x72\x6F\x77\x73\x2E\x2E\x2E","\x43\x72\x65\x61\x74\x69\x6E\x67\x20\x61\x70\x70\x2E\x2E","\x61\x70\x70","\x63\x6C\x6F\x6E\x65\x44\x65\x65\x70","\x63\x75\x73\x74\x6F\x6D\x41\x70\x70","\x50\x52\x49\x4F\x52\x49\x54\x59","\x25\x73\x25\x73\x25\x73","\x63\x6F\x6E\x74\x65\x78\x74","\x65\x78\x74\x65\x6E","\x2A\x2C\x2A\x2C\x2A\x2C\x2A","\x73\x70\x6C\x69\x63\x65","\x47\x6F\x74\x6F\x49\x66\x54\x69\x6D\x65\x46\x72\x6F\x6D\x41\x72\x72\x61\x79","\x3F\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73\x3A\x25\x73\x2C\x24\x7B\x45\x58\x54\x45\x4E\x7D\x2C\x25\x73","\x69\x64","\x75\x6E\x73\x68\x69\x66\x74","\x72\x65\x74\x75\x72\x6E\x65\x64\x20\x70\x72\x69\x6F\x72\x69\x74\x79","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x54\x48\x45\x20\x45\x4E\x44","\x66\x69\x6E\x64\x41\x6C\x6C","\x64\x65\x73\x74\x72\x6F\x79","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x63\x61\x6C\x6C\x65\x72\x49\x44","\x72\x65\x6D\x6F\x76\x65","\x74\x79\x70\x65","\x70\x72\x69\x6F\x72\x69\x74\x79","\x61\x70\x70\x47\x72\x6F\x75\x70","\x6F\x75\x74\x62\x6F\x75\x6E\x64","\x74\x72\x75\x6E\x6B","\x54\x72\x75\x6E\x6B\x49\x64","\x63\x75\x74\x64\x69\x67\x69\x74\x73","\x69\x6E\x74\x65\x72\x66\x61\x63\x65","\x61\x70\x70\x5F\x6F\x70\x74\x69\x6F\x6E\x73","\x74\x69\x6D\x65\x6F\x75\x74","\x75\x72\x6C","\x2C","\x72\x65\x70\x6C\x61\x63\x65","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x20\x44\x69\x61\x6C\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x20\x45\x6E\x64","\x61\x75\x64\x69\x6F\x66\x69\x6C\x65","\x71\x75\x65\x75\x65","\x70\x72\x6F\x6A\x65\x63\x74","\x61\x6C\x74\x5F\x70\x72\x69\x6F\x72\x69\x74\x79","\x61\x6C\x74\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x61\x6C\x74\x5F\x63\x6F\x6E\x74\x65\x78\x74","\x63\x61\x75\x73\x65\x63\x6F\x64\x65","\x76\x61\x72\x69\x61\x62\x6C\x65","\x76\x61\x6C\x75\x65","\x6D\x61\x69\x6C\x62\x6F\x78"];var util=require(_0x89c6[0]);var _=require(_0x89c6[1]);var Applications={Dial:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[4],appdata:_0x89c6[5]},{app:_0x89c6[6],appdata:_0x89c6[7],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[9]}],Queue:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[10],appdata:_0x89c6[11]},{app:_0x89c6[12],appdata:_0x89c6[13],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[14]}],Playback:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[15],appdata:_0x89c6[16],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[17]}],AGI:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[18],appdata:_0x89c6[19],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[20]}],Goto:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[21],appdata:_0x89c6[22],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[23]}],Hangup:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[24],appdata:_0x89c6[25],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[26]}],Set:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[4],appdata:_0x89c6[27],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[28]}],custom:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[29],appdata:_0x89c6[25],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[30]}],Voicemail:[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[31],appdata:_0x89c6[25],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[32]}]};module[_0x89c6[33]]=function(_0x10e3x4,_0x10e3x5){var _0x10e3x6=_0x10e3x4[_0x89c6[62]](_0x89c6[34],{name:{type:_0x10e3x5[_0x89c6[35]],unique:_0x89c6[36]},interval:{type:_0x10e3x5[_0x89c6[35]],allowNull:true},IntervalId:{type:_0x10e3x5.INTEGER(11),unique:_0x89c6[36]}},{tableName:_0x89c6[37],associate:function(_0x10e3x7){_0x10e3x6[_0x89c6[40]](_0x10e3x7.Interval,{as:_0x89c6[38],onDelete:_0x89c6[39]});_0x10e3x6[_0x89c6[40]](_0x10e3x7.VoiceExtension,{as:_0x89c6[41]});_0x10e3x6[_0x89c6[40]](_0x10e3x7.MailApplication,{as:_0x89c6[42]});_0x10e3x6[_0x89c6[40]](_0x10e3x7.MailApplication,{as:_0x89c6[43]});_0x10e3x6[_0x89c6[57]](function(_0x10e3x8){if(_0x10e3x8[_0x89c6[44]]!==null){_0x10e3x8[_0x89c6[56]]()[_0x89c6[55]](function(_0x10e3xa){var _0x10e3xb;var _0x10e3xc;_0x10e3xa[_0x89c6[54]](function(_0x10e3xd){_0x10e3xc=_0x10e3xd[_0x89c6[49]][_0x89c6[48]](_0x89c6[47]);_0x10e3xd[_0x89c6[49]]=util[_0x89c6[52]](_0x89c6[50],_0x10e3x8[_0x89c6[51]],_0x10e3xc[1]);_0x10e3xd[_0x89c6[51]]=_0x10e3x8[_0x89c6[51]];_0x10e3xd[_0x89c6[53]]()[_0x89c6[46]](function(_0x10e3x9){console[_0x89c6[45]](_0x10e3x9)});});})[_0x89c6[46]](function(_0x10e3x9){console[_0x89c6[45]](_0x10e3x9)})}});_0x10e3x6[_0x89c6[59]](function(_0x10e3x8){console[_0x89c6[45]](_0x89c6[58]);if(_0x10e3x8[_0x89c6[44]]!==null){_0x10e3xe(_0x10e3x8,_0x10e3x7)};});_0x10e3x6[_0x89c6[61]](function(_0x10e3x8){console[_0x89c6[45]](_0x89c6[60]);if(_0x10e3x8[_0x89c6[44]]!==null){_0x10e3xe(_0x10e3x8,_0x10e3x7,true)};});}});function _0x10e3xe(_0x10e3xf,_0x10e3x7,_0x10e3x10){console[_0x89c6[45]](_0x89c6[63]);_0x10e3x7[_0x89c6[92]][_0x89c6[94]]({where:{IntervalId:_0x10e3xf[_0x89c6[44]]}})[_0x89c6[55]](function(_0x10e3x11){if(_0x10e3x11&&_0x10e3x11[_0x89c6[64]]>0){console[_0x89c6[45]](_0x89c6[65]);var _0x10e3x12=_[_0x89c6[69]](_[_0x89c6[67]](_[_0x89c6[67]](_0x10e3x11,_0x89c6[66]),_0x89c6[68]),true);_0x10e3x7[_0x89c6[92]][_0x89c6[94]]({where:{VoiceExtensionId:_0x10e3x12,isApp:true}})[_0x89c6[55]](function(_0x10e3xa){console[_0x89c6[45]](_0x89c6[70]);return _0x10e3x4[_0x89c6[96]](function(_0x10e3x13){console[_0x89c6[45]](_0x89c6[71]);return _0x10e3x7[_0x89c6[92]][_0x89c6[95]]({where:{VoiceExtensionId:_0x10e3x12}},{transaction:_0x10e3x13})[_0x89c6[55]](function(){console[_0x89c6[45]](_0x89c6[72]);_0x10e3xa=_[_0x89c6[67]](_0x10e3xa,_0x89c6[66]);var _0x10e3x14=_[_0x89c6[73]](_[_0x89c6[67]](_0x10e3xa,_0x89c6[44]),function(_0x10e3x15){return _0x10e3x15!==null});console[_0x89c6[45]](_0x89c6[74]);_0x10e3x6[_0x89c6[94]]({where:{IntervalId:_0x10e3x14,id:{$ne:_0x10e3x10?null:_0x10e3xf[_0x89c6[88]]}}})[_0x89c6[55]](function(_0x10e3x16){console[_0x89c6[45]](_0x89c6[75]);var _0x10e3x17;_0x10e3x12[_0x89c6[54]](function(_0x10e3x18){_0x10e3x17=_[_0x89c6[73]](_0x10e3xa,function(_0x10e3x15){return _0x10e3x15[_0x89c6[68]]==_0x10e3x18});var _0x10e3x19=2;var _0x10e3x8;_0x10e3x17[_0x89c6[54]](function(_0x10e3x1a){console[_0x89c6[45]](_0x89c6[76]);var _0x10e3x1b=_[_0x89c6[78]](Applications[_0x10e3x1a[_0x89c6[77]]]);if(!_0x10e3x1b||_0x10e3x1a[_0x89c6[79]]){_0x10e3x1b=[{app:_0x89c6[2],appdata:_0x89c6[3]},{app:_0x89c6[29],appdata:_0x89c6[25],isApp:true},{app:_0x89c6[8],appdata:_0x89c6[30]}]};console[_0x89c6[45]](_0x89c6[80]);console[_0x89c6[45]](_0x10e3x19);var _0x10e3x1c=util[_0x89c6[52]](_0x89c6[81],_0x10e3x1a[_0x89c6[82]],_0x10e3x1a[_0x89c6[83]],_0x10e3x19);_0x10e3x1a[_0x89c6[51]]=_0x10e3x1a[_0x89c6[51]]||_0x89c6[84];var _0x10e3x1d=_[_0x89c6[73]](_0x10e3x16,function(_0x10e3x15){return (_0x10e3x15[_0x89c6[44]]==_0x10e3x1a[_0x89c6[44]])});if(_0x10e3x1d&&_0x10e3x1d[_0x89c6[64]]>0){_0x10e3x1b[_0x89c6[85]](0,1);_0x10e3x1d[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x1b[_0x89c6[89]]({app:_0x89c6[86],appdata:_0x10e3x15[_0x89c6[51]]+_0x89c6[87],IntervalId:_0x10e3x15[_0x89c6[88]],isInterval:true,interval:_0x10e3x15[_0x89c6[51]]})});};_0x10e3x19=appCreate(_0x10e3x1b,_0x10e3x1a,_0x10e3x1c,_0x10e3x1d||[],_0x10e3x19);console[_0x89c6[45]](_0x89c6[90]);console[_0x89c6[45]](_0x10e3x19);_0x10e3x7[_0x89c6[92]][_0x89c6[91]](_0x10e3x1b);});});console[_0x89c6[45]](_0x89c6[93]);});});})[_0x89c6[46]](function(_0x10e3x9){console[_0x89c6[45]](_0x10e3x9)});})[_0x89c6[46]](function(_0x10e3x9){console[_0x89c6[45]](_0x10e3x9)});}})[_0x89c6[46]](function(_0x10e3x9){console[_0x89c6[45]](_0x10e3x9)});}return _0x10e3x6;};function appCreate(_0x10e3x1b,_0x10e3xd,_0x10e3x1c,_0x10e3x16,_0x10e3x19){var _0x10e3x20=_0x10e3x16[_0x89c6[64]];if(_0x10e3xd[_0x89c6[79]]){_0x10e3xd[_0x89c6[77]]=_0x89c6[29]};switch(_0x10e3xd[_0x89c6[77]]){case _0x89c6[6]:if(!_0x10e3xd[_0x89c6[97]]){_[_0x89c6[98]](_0x10e3x1b,{app:_0x89c6[4]})};_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[6]:if(_0x10e3xd[_0x89c6[99]]===_0x89c6[102]){_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[103]]=_0x10e3xd[_0x89c6[103]];_0x10e3x15[_0x89c6[104]]=_0x10e3xd[_0x89c6[104]];_0x10e3x15[_0x89c6[105]]=_0x10e3xd[_0x89c6[105]]||0;_0x10e3x15[_0x89c6[97]]=_0x10e3xd[_0x89c6[97]]||null;}else {_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[106]]=_0x10e3xd[_0x89c6[106]];_0x10e3x15[_0x89c6[107]]=_0x10e3xd[_0x89c6[107]]||_0x89c6[11];_0x10e3x15[_0x89c6[108]]=_0x10e3xd[_0x89c6[108]]||_0x89c6[11];_0x10e3x15[_0x89c6[109]]=_0x10e3xd[_0x89c6[109]]||_0x89c6[11];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[106]],_0x10e3x15[_0x89c6[108]],_0x10e3x15[_0x89c6[107]]?_0x10e3x15[_0x89c6[107]][_0x89c6[111]](_0x89c6[110],_0x89c6[11]):_0x89c6[11],_0x10e3x15[_0x89c6[109]]);};break ;;case _0x89c6[4]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[97]]);break ;;case _0x89c6[8]:if(_0x10e3xd[_0x89c6[99]]===_0x89c6[102]){_0x10e3x15[_0x89c6[49]]=_0x89c6[112]};break ;;default:;};});break ;;case _0x89c6[12]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[12]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[107]]=_0x10e3xd[_0x89c6[107]]||_0x89c6[11];_0x10e3x15[_0x89c6[113]]=_0x10e3xd[_0x89c6[113]]||_0x89c6[11];_0x10e3x15[_0x89c6[114]]=_0x10e3xd[_0x89c6[114]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[106]]=_0x10e3xd[_0x89c6[106]];_0x10e3x15[_0x89c6[107]]=_0x10e3xd[_0x89c6[107]];_0x10e3x15[_0x89c6[108]]=_0x10e3xd[_0x89c6[108]]||_0x89c6[11];_0x10e3x15[_0x89c6[109]]=_0x10e3xd[_0x89c6[109]]||_0x89c6[11];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[114]],_0x10e3x15[_0x89c6[107]]?_0x10e3x15[_0x89c6[107]][_0x89c6[111]](_0x89c6[110],_0x89c6[11]):_0x89c6[11],_0x10e3x15[_0x89c6[109]],_0x10e3x15[_0x89c6[113]],_0x10e3x15[_0x89c6[108]]);break ;;default:;};});break ;;case _0x89c6[15]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[15]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[113]]=_0x10e3xd[_0x89c6[113]]||_0x89c6[11];_0x10e3x15[_0x89c6[107]]=_0x10e3xd[_0x89c6[107]]||_0x89c6[11];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[113]],_0x10e3x15[_0x89c6[107]]?_0x10e3x15[_0x89c6[107]][_0x89c6[111]](_0x89c6[110],_0x89c6[11]):_0x89c6[11]);break ;;default:;};});break ;;case _0x89c6[18]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[18]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[115]]=_0x10e3xd[_0x89c6[115]];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[115]]);break ;;default:;};});break ;;case _0x89c6[21]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[21]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[116]]=_0x10e3xd[_0x89c6[116]];_0x10e3x15[_0x89c6[117]]=_0x10e3xd[_0x89c6[117]];_0x10e3x15[_0x89c6[118]]=_0x10e3xd[_0x89c6[118]];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[118]],_0x10e3x15[_0x89c6[117]],_0x10e3x15[_0x89c6[116]]);break ;;default:;};});break ;;case _0x89c6[24]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[24]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[119]]=_0x10e3xd[_0x89c6[119]];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[119]]);break ;;default:;};});break ;;case _0x89c6[4]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[4]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[120]]=_0x10e3xd[_0x89c6[120]];_0x10e3x15[_0x89c6[121]]=_0x10e3xd[_0x89c6[121]];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[120]],_0x10e3x15[_0x89c6[121]]);break ;;default:;};});break ;;case _0x89c6[29]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[29]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[77]]=_0x10e3x15[_0x89c6[79]]=_0x10e3xd[_0x89c6[79]];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[49]]);break ;;default:;};});break ;;case _0x89c6[31]:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[31]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[122]]=_0x10e3xd[_0x89c6[122]];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[122]]);break ;;default:;};});break ;;default:_0x10e3x1b[_0x89c6[54]](function(_0x10e3x15,_0x10e3x1e){_0x10e3x15[_0x89c6[83]]=_0x10e3xd[_0x89c6[83]];_0x10e3x15[_0x89c6[99]]=_0x10e3xd[_0x89c6[99]];_0x10e3x15[_0x89c6[82]]=_0x10e3xd[_0x89c6[82]];_0x10e3x15[_0x89c6[68]]=_0x10e3xd[_0x89c6[68]];_0x10e3x15[_0x89c6[100]]=_0x10e3x19?_0x10e3x19++:_0x10e3xd[_0x89c6[100]]++;_0x10e3x15[_0x89c6[101]]=_0x10e3x1c;switch(_0x10e3x15[_0x89c6[77]]){case _0x89c6[2]:_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[44]]?_0x89c6[84]:_0x10e3xd[_0x89c6[51]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+1,_0x10e3x15[_0x89c6[82]],(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[86]:_0x10e3x15[_0x89c6[77]]=_0x89c6[2];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3x15[_0x89c6[82]],_0x10e3x15[_0x89c6[100]]+_0x10e3x20-_0x10e3x1e,_0x10e3x15[_0x89c6[82]],(_0x10e3x1e+1)<_0x10e3x20?(_0x10e3x15[_0x89c6[100]]+1):(_0x10e3x15[_0x89c6[100]]+2));break ;;case _0x89c6[29]:_0x10e3x15[_0x89c6[44]]=_0x10e3xd[_0x89c6[44]];_0x10e3x15[_0x89c6[51]]=_0x10e3xd[_0x89c6[51]];_0x10e3x15[_0x89c6[77]]=_0x10e3x15[_0x89c6[79]]=_0x10e3xd[_0x89c6[79]];_0x10e3x15[_0x89c6[49]]=util[_0x89c6[52]](_0x10e3x15[_0x89c6[49]],_0x10e3xd[_0x89c6[49]]);break ;;default:;};});;};if(_0x10e3x19){return _0x10e3x19};} \ No newline at end of file diff --git a/server/models/mail_account.js b/server/models/mail_account.js index caf5343..ef600dd 100644 --- a/server/models/mail_account.js +++ b/server/models/mail_account.js @@ -1,32 +1 @@ -/** - * Chat Website Model - */ - -module.exports = function(sequelize, DataTypes) { - - var MailAccount = sequelize.define('MailAccount', { - description: DataTypes.STRING, - name: { - type: DataTypes.STRING, - unique: true - }, - address: DataTypes.STRING, - }, { - tableName: 'mail_accounts', - associate: function(models) { - MailAccount.hasMany(models.MailRoom); - MailAccount.hasMany(models.MailTemplate); - MailAccount.hasMany(models.MailApplication); - MailAccount.hasOne(models.MailServerIn, { - onDelete: 'cascade', - hooks: true - }); - MailAccount.hasOne(models.MailServerOut, { - onDelete: 'cascade', - hooks: true - }); - } - }); - - return MailAccount; -}; +var _0xa818=["\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x63\x61\x73\x63\x61\x64\x65","\x68\x61\x73\x4F\x6E\x65","\x64\x65\x66\x69\x6E\x65"];module[_0xa818[0]]=function(_0x85a2x1,_0x85a2x2){var _0x85a2x3=_0x85a2x1[_0xa818[7]](_0xa818[1],{description:_0x85a2x2[_0xa818[2]],name:{type:_0x85a2x2[_0xa818[2]],unique:true},address:_0x85a2x2[_0xa818[2]]},{tableName:_0xa818[3],associate:function(_0x85a2x4){_0x85a2x3[_0xa818[4]](_0x85a2x4.MailRoom);_0x85a2x3[_0xa818[4]](_0x85a2x4.MailTemplate);_0x85a2x3[_0xa818[4]](_0x85a2x4.MailApplication);_0x85a2x3[_0xa818[6]](_0x85a2x4.MailServerIn,{onDelete:_0xa818[5],hooks:true});_0x85a2x3[_0xa818[6]](_0x85a2x4.MailServerOut,{onDelete:_0xa818[5],hooks:true});}});return _0x85a2x3;}; \ No newline at end of file diff --git a/server/models/mail_application.js b/server/models/mail_application.js index 9b0c53a..5ee3ac7 100644 --- a/server/models/mail_application.js +++ b/server/models/mail_application.js @@ -1,30 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var MailApplication = sequelize.define('MailApplication', { - app: { - type: DataTypes.ENUM('queue', 'agent') - }, - priority: { - type: DataTypes.INTEGER - }, - timeout: { - type: DataTypes.INTEGER - }, - interval: { - type: DataTypes.STRING - } - }, { - tableName: 'mail_applications', - associate: function(models) { - // hasMany relations - MailApplication.belongsTo(models.MailAccount); - MailApplication.belongsTo(models.Interval); - MailApplication.belongsTo(models.MailQueue); - MailApplication.belongsTo(models.User); - } - }); - - return MailApplication; -}; +var _0x51a6=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x71\x75\x65\x75\x65","\x61\x67\x65\x6E\x74","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x6D\x61\x69\x6C\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0x51a6[0];module[_0x51a6[1]]=function(_0xb97ex1,_0xb97ex2){var _0xb97ex3=_0xb97ex1[_0x51a6[9]](_0x51a6[2],{app:{type:_0xb97ex2.ENUM(_0x51a6[3],_0x51a6[4])},priority:{type:_0xb97ex2[_0x51a6[5]]},timeout:{type:_0xb97ex2[_0x51a6[5]]},interval:{type:_0xb97ex2[_0x51a6[6]]}},{tableName:_0x51a6[7],associate:function(_0xb97ex4){_0xb97ex3[_0x51a6[8]](_0xb97ex4.MailAccount);_0xb97ex3[_0x51a6[8]](_0xb97ex4.Interval);_0xb97ex3[_0x51a6[8]](_0xb97ex4.MailQueue);_0xb97ex3[_0x51a6[8]](_0xb97ex4.User);}});return _0xb97ex3;}; \ No newline at end of file diff --git a/server/models/mail_attachment.js b/server/models/mail_attachment.js index c201c4c..1562a11 100644 --- a/server/models/mail_attachment.js +++ b/server/models/mail_attachment.js @@ -1,24 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var MailAttachment = sequelize.define('MailAttachment', { - contentDisposition: DataTypes.STRING, - fileName: DataTypes.STRING, - path: DataTypes.STRING, - contentType: DataTypes.STRING, - transferEncoding: DataTypes.STRING, - generatedFileName: DataTypes.STRING, - contentId: DataTypes.STRING, - checksum: DataTypes.STRING, - length: DataTypes.INTEGER, - }, { - tableName: 'mail_attachments' - }); - - return MailAttachment; -}; +var _0x5536=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x6D\x61\x69\x6C\x5F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x5536[0]);module[_0x5536[1]]=function(_0x256ex2,_0x256ex3){var _0x256ex4=_0x256ex2[_0x5536[6]](_0x5536[2],{contentDisposition:_0x256ex3[_0x5536[3]],fileName:_0x256ex3[_0x5536[3]],path:_0x256ex3[_0x5536[3]],contentType:_0x256ex3[_0x5536[3]],transferEncoding:_0x256ex3[_0x5536[3]],generatedFileName:_0x256ex3[_0x5536[3]],contentId:_0x256ex3[_0x5536[3]],checksum:_0x256ex3[_0x5536[3]],length:_0x256ex3[_0x5536[4]]},{tableName:_0x5536[5]});return _0x256ex4;}; \ No newline at end of file diff --git a/server/models/mail_automation.js b/server/models/mail_automation.js index 218cb9c..5a09901 100644 --- a/server/models/mail_automation.js +++ b/server/models/mail_automation.js @@ -1,23 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var MailAutomation = sequelize.define('MailAutomation', { - name: DataTypes.STRING, - description: DataTypes.STRING, - conditions: DataTypes.TEXT, - actions: DataTypes.TEXT, - status: { - type: DataTypes.BOOLEAN, - defaultValue: false - } - }, { - tableName: 'mail_automations' - }); - - return MailAutomation; -}; +var _0xf267=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x42\x4F\x4F\x4C\x45\x41\x4E","\x6D\x61\x69\x6C\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xf267[0]);module[_0xf267[1]]=function(_0x3a0dx2,_0x3a0dx3){var _0x3a0dx4=_0x3a0dx2[_0xf267[7]](_0xf267[2],{name:_0x3a0dx3[_0xf267[3]],description:_0x3a0dx3[_0xf267[3]],conditions:_0x3a0dx3[_0xf267[4]],actions:_0x3a0dx3[_0xf267[4]],status:{type:_0x3a0dx3[_0xf267[5]],defaultValue:false}},{tableName:_0xf267[6]});return _0x3a0dx4;}; \ No newline at end of file diff --git a/server/models/mail_business_automation.js b/server/models/mail_business_automation.js index bc4c03d..87fd398 100644 --- a/server/models/mail_business_automation.js +++ b/server/models/mail_business_automation.js @@ -1,32 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var MailBusinessAutomation = sequelize.define('MailBusinessAutomation', { - name: { - type: DataTypes.STRING - }, - description: { - type: DataTypes.STRING - }, - status: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - jobId: { - type: DataTypes.INTEGER - } - }, { - tableName: 'mail_business_automations', - associate: function(models) { - MailBusinessAutomation.hasMany(models.BusinessAction); - MailBusinessAutomation.hasMany(models.BusinessCondition); - } - }); - - return MailBusinessAutomation; -}; +var _0x1902=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x49\x4E\x54\x45\x47\x45\x52","\x6D\x61\x69\x6C\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x1902[0]);module[_0x1902[1]]=function(_0xe3f0x2,_0xe3f0x3){var _0xe3f0x4=_0xe3f0x2[_0x1902[8]](_0x1902[2],{name:{type:_0xe3f0x3[_0x1902[3]]},description:{type:_0xe3f0x3[_0x1902[3]]},status:{type:_0xe3f0x3[_0x1902[4]],defaultValue:false},jobId:{type:_0xe3f0x3[_0x1902[5]]}},{tableName:_0x1902[6],associate:function(_0xe3f0x5){_0xe3f0x4[_0x1902[7]](_0xe3f0x5.BusinessAction);_0xe3f0x4[_0x1902[7]](_0xe3f0x5.BusinessCondition);}});return _0xe3f0x4;}; \ No newline at end of file diff --git a/server/models/mail_message.js b/server/models/mail_message.js index a2e3670..f1eee6e 100644 --- a/server/models/mail_message.js +++ b/server/models/mail_message.js @@ -1,56 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function (sequelize, DataTypes) { - - var MailMessage = sequelize.define('MailMessage', { - messageId: DataTypes.STRING, - inReplyTo: DataTypes.STRING, - subject: DataTypes.STRING, - from: DataTypes.STRING, - to: DataTypes.STRING, - cc: DataTypes.STRING, - bcc: DataTypes.STRING, - attachment: DataTypes.TEXT, - html: DataTypes.TEXT, - text: DataTypes.TEXT, - reason: DataTypes.TEXT, - status: { - type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED') - } - }, { - tableName: 'mail_messages', - associate: function (models) { - MailMessage.belongsTo(models.MailRoom); - - MailMessage.belongsTo(models.ContactEmail, { - as: 'From' - }); - - MailMessage.belongsToMany(models.ContactEmail, { - as: 'To', - through: 'mail_message_has_to', - onDelete: 'cascade' - }); - - MailMessage.belongsToMany(models.ContactEmail, { - as: 'Cc', - through: 'mail_message_has_cc', - onDelete: 'cascade' - }); - - MailMessage.belongsToMany(models.ContactEmail, { - as: 'Bcc', - through: 'mail_message_has_bcc', - onDelete: 'cascade' - }); - - MailMessage.hasMany(models.MailAttachment); - } - }); - - return MailMessage; -}; +var _0x438c=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x53\x45\x4E\x54","\x53\x45\x4E\x44\x49\x4E\x47","\x52\x45\x43\x45\x49\x56\x45\x44","\x46\x41\x49\x4C\x45\x44","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x46\x72\x6F\x6D","\x54\x6F","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x5F\x68\x61\x73\x5F\x74\x6F","\x63\x61\x73\x63\x61\x64\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x43\x63","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x5F\x68\x61\x73\x5F\x63\x63","\x42\x63\x63","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x5F\x68\x61\x73\x5F\x62\x63\x63","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x438c[0]);module[_0x438c[1]]=function(_0xc72cx2,_0xc72cx3){var _0xc72cx4=_0xc72cx2[_0x438c[21]](_0x438c[2],{messageId:_0xc72cx3[_0x438c[3]],inReplyTo:_0xc72cx3[_0x438c[3]],subject:_0xc72cx3[_0x438c[3]],from:_0xc72cx3[_0x438c[3]],to:_0xc72cx3[_0x438c[3]],cc:_0xc72cx3[_0x438c[3]],bcc:_0xc72cx3[_0x438c[3]],attachment:_0xc72cx3[_0x438c[4]],html:_0xc72cx3[_0x438c[4]],text:_0xc72cx3[_0x438c[4]],reason:_0xc72cx3[_0x438c[4]],status:{type:_0xc72cx3.ENUM(_0x438c[5],_0x438c[6],_0x438c[7],_0x438c[8])}},{tableName:_0x438c[9],associate:function(_0xc72cx5){_0xc72cx4[_0x438c[10]](_0xc72cx5.MailRoom);_0xc72cx4[_0x438c[10]](_0xc72cx5.ContactEmail,{as:_0x438c[11]});_0xc72cx4[_0x438c[15]](_0xc72cx5.ContactEmail,{as:_0x438c[12],through:_0x438c[13],onDelete:_0x438c[14]});_0xc72cx4[_0x438c[15]](_0xc72cx5.ContactEmail,{as:_0x438c[16],through:_0x438c[17],onDelete:_0x438c[14]});_0xc72cx4[_0x438c[15]](_0xc72cx5.ContactEmail,{as:_0x438c[18],through:_0x438c[19],onDelete:_0x438c[14]});_0xc72cx4[_0x438c[20]](_0xc72cx5.MailAttachment);}});return _0xc72cx4;}; \ No newline at end of file diff --git a/server/models/mail_queue.js b/server/models/mail_queue.js index 16905f1..e666a60 100644 --- a/server/models/mail_queue.js +++ b/server/models/mail_queue.js @@ -1,30 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var MailQueue = sequelize.define('MailQueue', { - name: { - type: DataTypes.STRING, - unique: true - }, - description: { - type: DataTypes.STRING, - }, - timeout: { - type: DataTypes.INTEGER, - }, - strategy: { - type: DataTypes.ENUM('rrmemory', 'beepall') - } - }, { - tableName: 'mail_queues', - associate: function(models) { - // hasMany relations - MailQueue.belongsToMany(models.User, { - through: models.UserHasMailQueue - }); - } - }); - - return MailQueue; -}; +var _0x1ac4=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x62\x65\x65\x70\x61\x6C\x6C","\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x73","\x55\x73\x65\x72\x48\x61\x73\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x1ac4[0];module[_0x1ac4[1]]=function(_0xe761x1,_0xe761x2){var _0xe761x3=_0xe761x1[_0x1ac4[10]](_0x1ac4[2],{name:{type:_0xe761x2[_0x1ac4[3]],unique:true},description:{type:_0xe761x2[_0x1ac4[3]]},timeout:{type:_0xe761x2[_0x1ac4[4]]},strategy:{type:_0xe761x2.ENUM(_0x1ac4[5],_0x1ac4[6])}},{tableName:_0x1ac4[7],associate:function(_0xe761x4){_0xe761x3[_0x1ac4[9]](_0xe761x4.User,{through:_0xe761x4[_0x1ac4[8]]})}});return _0xe761x3;}; \ No newline at end of file diff --git a/server/models/mail_room.js b/server/models/mail_room.js index ea4e337..452331c 100644 --- a/server/models/mail_room.js +++ b/server/models/mail_room.js @@ -1,31 +1 @@ -/** - * Chat Website Model - */ - -module.exports = function(sequelize, DataTypes) { - - var MailRoom = sequelize.define('MailRoom', { - subject: DataTypes.STRING, - from: DataTypes.STRING, - attachment: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - status: { - type: DataTypes.ENUM('NEW', 'OPEN', 'CLOSED'), - defaultValue: 'NEW' - } - }, { - tableName: 'mail_rooms', - associate: function(models) { - MailRoom.hasMany(models.MailMessage); - MailRoom.hasMany(models.MailRoomStatus, { - as: 'States' - }); - MailRoom.belongsTo(models.MailAccount); - MailRoom.belongsTo(models.User); - } - }); - - return MailRoom; -}; +var _0x35d8=["\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x4E\x45\x57","\x4F\x50\x45\x4E","\x43\x4C\x4F\x53\x45\x44","\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x53\x74\x61\x74\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];module[_0x35d8[0]]=function(_0xa322x1,_0xa322x2){var _0xa322x3=_0xa322x1[_0x35d8[11]](_0x35d8[1],{subject:_0xa322x2[_0x35d8[2]],from:_0xa322x2[_0x35d8[2]],attachment:{type:_0xa322x2[_0x35d8[3]],defaultValue:false},status:{type:_0xa322x2.ENUM(_0x35d8[4],_0x35d8[5],_0x35d8[6]),defaultValue:_0x35d8[4]}},{tableName:_0x35d8[7],associate:function(_0xa322x4){_0xa322x3[_0x35d8[8]](_0xa322x4.MailMessage);_0xa322x3[_0x35d8[8]](_0xa322x4.MailRoomStatus,{as:_0x35d8[9]});_0xa322x3[_0x35d8[10]](_0xa322x4.MailAccount);_0xa322x3[_0x35d8[10]](_0xa322x4.User);}});return _0xa322x3;}; \ No newline at end of file diff --git a/server/models/mail_room_status.js b/server/models/mail_room_status.js index 20b29e9..f5a29c4 100644 --- a/server/models/mail_room_status.js +++ b/server/models/mail_room_status.js @@ -1,14 +1 @@ -/** - * Chat Website Model - */ - -module.exports = function(sequelize, DataTypes) { - - var MailRoomStatus = sequelize.define('MailRoomStatus', { - status: DataTypes.ENUM('RECEIVED', 'ASSIGNED', 'REPLIED', 'ARCHIVED') - }, { - tableName: 'mail_room_states' - }); - - return MailRoomStatus; -}; +var _0xaf66=["\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x53\x74\x61\x74\x75\x73","\x52\x45\x43\x45\x49\x56\x45\x44","\x41\x53\x53\x49\x47\x4E\x45\x44","\x52\x45\x50\x4C\x49\x45\x44","\x41\x52\x43\x48\x49\x56\x45\x44","\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D\x5F\x73\x74\x61\x74\x65\x73","\x64\x65\x66\x69\x6E\x65"];module[_0xaf66[0]]=function(_0x83a8x1,_0x83a8x2){var _0x83a8x3=_0x83a8x1[_0xaf66[7]](_0xaf66[1],{status:_0x83a8x2.ENUM(_0xaf66[2],_0xaf66[3],_0xaf66[4],_0xaf66[5])},{tableName:_0xaf66[6]});return _0x83a8x3;}; \ No newline at end of file diff --git a/server/models/mail_server_in.js b/server/models/mail_server_in.js index 9f92813..1becf79 100644 --- a/server/models/mail_server_in.js +++ b/server/models/mail_server_in.js @@ -1,41 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var MailServerIn = sequelize.define('MailServerIn', { - description: DataTypes.STRING, - host: DataTypes.STRING, - username: DataTypes.STRING, - password: DataTypes.STRING, - port: DataTypes.INTEGER, - mailbox: DataTypes.STRING, - ssl: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - delete: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - filter: { - type: DataTypes.ENUM('UNSEEN'), - defaultValue: 'UNSEEN' - }, - protocol: { - type: DataTypes.ENUM('IMAP', 'POP3'), - defaultValue: 'IMAP' - }, - state: { - type: DataTypes.ENUM('CONNECTED', 'DISCONNECTED', 'ERROR', 'UNKNOWN'), - defaultValue: 'UNKNOWN' - } - }, { - tableName: 'mail_servers_in' - }); - - return MailServerIn; -}; +var _0x419a=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x55\x4E\x53\x45\x45\x4E","\x49\x4D\x41\x50","\x50\x4F\x50\x33","\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x44\x49\x53\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x45\x52\x52\x4F\x52","\x55\x4E\x4B\x4E\x4F\x57\x4E","\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x73\x5F\x69\x6E","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x419a[0]);module[_0x419a[1]]=function(_0xc799x2,_0xc799x3){var _0xc799x4=_0xc799x2[_0x419a[14]](_0x419a[2],{description:_0xc799x3[_0x419a[3]],host:_0xc799x3[_0x419a[3]],username:_0xc799x3[_0x419a[3]],password:_0xc799x3[_0x419a[3]],port:_0xc799x3[_0x419a[4]],mailbox:_0xc799x3[_0x419a[3]],ssl:{type:_0xc799x3[_0x419a[5]],defaultValue:false},delete:{type:_0xc799x3[_0x419a[5]],defaultValue:false},filter:{type:_0xc799x3.ENUM(_0x419a[6]),defaultValue:_0x419a[6]},protocol:{type:_0xc799x3.ENUM(_0x419a[7],_0x419a[8]),defaultValue:_0x419a[7]},state:{type:_0xc799x3.ENUM(_0x419a[9],_0x419a[10],_0x419a[11],_0x419a[12]),defaultValue:_0x419a[12]}},{tableName:_0x419a[13]});return _0xc799x4;}; \ No newline at end of file diff --git a/server/models/mail_server_out.js b/server/models/mail_server_out.js index 9a89310..79022cb 100644 --- a/server/models/mail_server_out.js +++ b/server/models/mail_server_out.js @@ -1,34 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); -var smtpTransport = require('nodemailer-smtp-transport'); -var nodemailer = require('nodemailer'); - -module.exports = function (sequelize, DataTypes) { - - var MailServerOut = sequelize.define('MailServerOut', { - description: DataTypes.STRING, - host: DataTypes.STRING, - username: DataTypes.STRING, - password: DataTypes.STRING, - port: DataTypes.INTEGER, - ssl: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - service: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - state: { - type: DataTypes.ENUM('CONNECTED', 'DISCONNECTED', 'ERROR', 'UNKNOWN'), - defaultValue: 'UNKNOWN' - }, - }, { - tableName: 'mail_servers_out' - }); - - return MailServerOut; -}; +var _0x496b=["\x63\x72\x79\x70\x74\x6F","\x6E\x6F\x64\x65\x6D\x61\x69\x6C\x65\x72\x2D\x73\x6D\x74\x70\x2D\x74\x72\x61\x6E\x73\x70\x6F\x72\x74","\x6E\x6F\x64\x65\x6D\x61\x69\x6C\x65\x72","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x44\x49\x53\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x45\x52\x52\x4F\x52","\x55\x4E\x4B\x4E\x4F\x57\x4E","\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x73\x5F\x6F\x75\x74","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x496b[0]);var smtpTransport=require(_0x496b[1]);var nodemailer=require(_0x496b[2]);module[_0x496b[3]]=function(_0x6162x4,_0x6162x5){var _0x6162x6=_0x6162x4[_0x496b[13]](_0x496b[4],{description:_0x6162x5[_0x496b[5]],host:_0x6162x5[_0x496b[5]],username:_0x6162x5[_0x496b[5]],password:_0x6162x5[_0x496b[5]],port:_0x6162x5[_0x496b[6]],ssl:{type:_0x6162x5[_0x496b[7]],defaultValue:false},service:{type:_0x6162x5[_0x496b[7]],defaultValue:false},state:{type:_0x6162x5.ENUM(_0x496b[8],_0x496b[9],_0x496b[10],_0x496b[11]),defaultValue:_0x496b[11]}},{tableName:_0x496b[12]});return _0x6162x6;}; \ No newline at end of file diff --git a/server/models/mail_template.js b/server/models/mail_template.js index 4ab80a8..438c17a 100644 --- a/server/models/mail_template.js +++ b/server/models/mail_template.js @@ -1,24 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var MailTemplate = sequelize.define('MailTemplate', { - name: DataTypes.STRING, - description: DataTypes.STRING, - subject: DataTypes.STRING, - from: DataTypes.STRING, - to: DataTypes.STRING, - cc: DataTypes.STRING, - attachment: DataTypes.TEXT, - html: DataTypes.TEXT, - text: DataTypes.TEXT - }, { - tableName: 'mail_templates' - }); - - return MailTemplate; -}; +var _0x4126=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x54\x65\x6D\x70\x6C\x61\x74\x65","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x6D\x61\x69\x6C\x5F\x74\x65\x6D\x70\x6C\x61\x74\x65\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x4126[0]);module[_0x4126[1]]=function(_0xebe4x2,_0xebe4x3){var _0xebe4x4=_0xebe4x2[_0x4126[6]](_0x4126[2],{name:_0xebe4x3[_0x4126[3]],description:_0xebe4x3[_0x4126[3]],subject:_0xebe4x3[_0x4126[3]],from:_0xebe4x3[_0x4126[3]],to:_0xebe4x3[_0x4126[3]],cc:_0xebe4x3[_0x4126[3]],attachment:_0xebe4x3[_0x4126[4]],html:_0xebe4x3[_0x4126[4]],text:_0xebe4x3[_0x4126[4]]},{tableName:_0x4126[5]});return _0xebe4x4;}; \ No newline at end of file diff --git a/server/models/mail_trigger.js b/server/models/mail_trigger.js index 73be985..da41f9b 100644 --- a/server/models/mail_trigger.js +++ b/server/models/mail_trigger.js @@ -1,23 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var MailTrigger = sequelize.define('MailTrigger', { - name: DataTypes.STRING, - description: DataTypes.STRING, - conditions: DataTypes.TEXT, - actions: DataTypes.TEXT, - status: { - type: DataTypes.BOOLEAN, - defaultValue: false - } - }, { - tableName: 'mail_triggers' - }); - - return MailTrigger; -}; +var _0x826c=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x54\x72\x69\x67\x67\x65\x72","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x42\x4F\x4F\x4C\x45\x41\x4E","\x6D\x61\x69\x6C\x5F\x74\x72\x69\x67\x67\x65\x72\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x826c[0]);module[_0x826c[1]]=function(_0x1793x2,_0x1793x3){var _0x1793x4=_0x1793x2[_0x826c[7]](_0x826c[2],{name:_0x1793x3[_0x826c[3]],description:_0x1793x3[_0x826c[3]],conditions:_0x1793x3[_0x826c[4]],actions:_0x1793x3[_0x826c[4]],status:{type:_0x1793x3[_0x826c[5]],defaultValue:false}},{tableName:_0x826c[6]});return _0x1793x4;}; \ No newline at end of file diff --git a/server/models/metric.js b/server/models/metric.js index 6341030..03eb3b6 100644 --- a/server/models/metric.js +++ b/server/models/metric.js @@ -1,21 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Metric = sequelize.define('Metric', { - name: { - type: DataTypes.STRING, - unique: true, - validate: { - notEmpty: true - }, - }, - metric: DataTypes.TEXT, - description: DataTypes.STRING - }, { - tableName: 'metrics' - }); - - return Metric; - -}; +var _0x8599=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x65\x74\x72\x69\x63","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x6D\x65\x74\x72\x69\x63\x73","\x64\x65\x66\x69\x6E\x65"];_0x8599[0];module[_0x8599[1]]=function(_0x5d23x1,_0x5d23x2){var _0x5d23x3=_0x5d23x1[_0x8599[6]](_0x8599[2],{name:{type:_0x5d23x2[_0x8599[3]],unique:true,validate:{notEmpty:true}},metric:_0x5d23x2[_0x8599[4]],description:_0x5d23x2[_0x8599[3]]},{tableName:_0x8599[5]});return _0x5d23x3;}; \ No newline at end of file diff --git a/server/models/module.js b/server/models/module.js index c2bef6c..c32df9c 100644 --- a/server/models/module.js +++ b/server/models/module.js @@ -1,27 +1 @@ -/** - * Module Model - */ - -module.exports = function(sequelize, DataTypes) { - - var Module = sequelize.define('Module', { - name: { - type: DataTypes.STRING, - unique: true, - allowNull: false, - validate: { - notEmpty: true - } - }, - title: DataTypes.STRING - }, { - tableName: 'modules', - associate: function(models) { - Module.belongsToMany(models.User, { - through: 'user_has_modules' - }); - } - }); - - return Module; -}; +var _0xaa71=["\x65\x78\x70\x6F\x72\x74\x73","\x4D\x6F\x64\x75\x6C\x65","\x53\x54\x52\x49\x4E\x47","\x6D\x6F\x64\x75\x6C\x65\x73","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x6F\x64\x75\x6C\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];module[_0xaa71[0]]=function(_0xd82ex1,_0xd82ex2){var _0xd82ex3=_0xd82ex1[_0xaa71[6]](_0xaa71[1],{name:{type:_0xd82ex2[_0xaa71[2]],unique:true,allowNull:false,validate:{notEmpty:true}},title:_0xd82ex2[_0xaa71[2]]},{tableName:_0xaa71[3],associate:function(_0xd82ex4){_0xd82ex3[_0xaa71[5]](_0xd82ex4.User,{through:_0xaa71[4]})}});return _0xd82ex3;}; \ No newline at end of file diff --git a/server/models/motionbar.js b/server/models/motionbar.js index ad6cba8..73fd03e 100644 --- a/server/models/motionbar.js +++ b/server/models/motionbar.js @@ -1,32 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Motionbar = sequelize.define('Motionbar', { - action: { - type: DataTypes.ENUM, - values: ['hangup'], - allowNull: false - }, - state: { - type: DataTypes.ENUM, - values: ['incoming', 'active'], - }, - phone: { - type: DataTypes.STRING - } - }, { - tableName: 'motionbar', - associate: function(models) { - Motionbar.belongsTo(models.User, { - as: 'Admin' - }); - Motionbar.belongsTo(models.User, { - as: 'User' - }); - } - }); - - return Motionbar; - -}; +var _0x60d3=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x45\x4E\x55\x4D","\x68\x61\x6E\x67\x75\x70","\x69\x6E\x63\x6F\x6D\x69\x6E\x67","\x61\x63\x74\x69\x76\x65","\x53\x54\x52\x49\x4E\x47","\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x41\x64\x6D\x69\x6E","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x55\x73\x65\x72","\x64\x65\x66\x69\x6E\x65"];_0x60d3[0];module[_0x60d3[1]]=function(_0xde3bx1,_0xde3bx2){var _0xde3bx3=_0xde3bx1[_0x60d3[12]](_0x60d3[2],{action:{type:_0xde3bx2[_0x60d3[3]],values:[_0x60d3[4]],allowNull:false},state:{type:_0xde3bx2[_0x60d3[3]],values:[_0x60d3[5],_0x60d3[6]]},phone:{type:_0xde3bx2[_0x60d3[7]]}},{tableName:_0x60d3[8],associate:function(_0xde3bx4){_0xde3bx3[_0x60d3[10]](_0xde3bx4.User,{as:_0x60d3[9]});_0xde3bx3[_0x60d3[10]](_0xde3bx4.User,{as:_0x60d3[11]});}});return _0xde3bx3;}; \ No newline at end of file diff --git a/server/models/report_agent.js b/server/models/report_agent.js index 726ce95..17023fa 100644 --- a/server/models/report_agent.js +++ b/server/models/report_agent.js @@ -1,71 +1 @@ -/** - * Agent Log Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportAgent = sequelize.define('ReportAgent', { - uniqueid: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - queue: DataTypes.STRING, - interface: DataTypes.STRING, - membername: DataTypes.STRING, - agentcalledAt: DataTypes.DATE, - agentconnectAt: DataTypes.DATE, - holdtime: DataTypes.INTEGER, - agentcomplete: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentcompleteAt: DataTypes.DATE, - talktime: DataTypes.INTEGER, - agentacw: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - acwtime: DataTypes.INTEGER, - reason: DataTypes.STRING, - agentringnoanswer: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentringnoanswerAt: DataTypes.DATE, - agentdump: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentdumpAt: DataTypes.DATE, - lastevent: DataTypes.STRING, - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.STRING, - destchannel: DataTypes.STRING, - destchannelstate: DataTypes.INTEGER, - destchannelstatedesc: DataTypes.STRING, - destcalleridnum: DataTypes.STRING, - destcalleridname: DataTypes.STRING, - destconnectedlinenum: DataTypes.STRING, - destconnectedlinename: DataTypes.STRING, - destlanguage: DataTypes.STRING, - destaccountcode: DataTypes.STRING, - destcontext: DataTypes.STRING, - destexten: DataTypes.STRING, - destpriority: DataTypes.STRING, - destuniqueid: DataTypes.STRING - }, { - tableName: 'report_agent', - indexes: [{ - fields: ['uniqueid', 'destuniqueid'] - }] - }); - - return ReportAgent; -}; +var _0xa3ff=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74","\x75\x6E\x69\x71\x75\x65\x69\x64","\x64\x65\x73\x74\x75\x6E\x69\x71\x75\x65\x69\x64","\x64\x65\x66\x69\x6E\x65"];module[_0xa3ff[0]]=function(_0xe0bax1,_0xe0bax2){var _0xe0bax3=_0xe0bax1[_0xa3ff[9]](_0xa3ff[1],{uniqueid:_0xe0bax2[_0xa3ff[2]],calleridnum:_0xe0bax2[_0xa3ff[2]],calleridname:_0xe0bax2[_0xa3ff[2]],queue:_0xe0bax2[_0xa3ff[2]],interface:_0xe0bax2[_0xa3ff[2]],membername:_0xe0bax2[_0xa3ff[2]],agentcalledAt:_0xe0bax2[_0xa3ff[3]],agentconnectAt:_0xe0bax2[_0xa3ff[3]],holdtime:_0xe0bax2[_0xa3ff[4]],agentcomplete:{type:_0xe0bax2[_0xa3ff[5]],defaultValue:false},agentcompleteAt:_0xe0bax2[_0xa3ff[3]],talktime:_0xe0bax2[_0xa3ff[4]],agentacw:{type:_0xe0bax2[_0xa3ff[5]],defaultValue:false},acwtime:_0xe0bax2[_0xa3ff[4]],reason:_0xe0bax2[_0xa3ff[2]],agentringnoanswer:{type:_0xe0bax2[_0xa3ff[5]],defaultValue:false},agentringnoanswerAt:_0xe0bax2[_0xa3ff[3]],agentdump:{type:_0xe0bax2[_0xa3ff[5]],defaultValue:false},agentdumpAt:_0xe0bax2[_0xa3ff[3]],lastevent:_0xe0bax2[_0xa3ff[2]],channel:_0xe0bax2[_0xa3ff[2]],channelstate:_0xe0bax2[_0xa3ff[4]],channelstatedesc:_0xe0bax2[_0xa3ff[2]],connectedlinenum:_0xe0bax2[_0xa3ff[2]],connectedlinename:_0xe0bax2[_0xa3ff[2]],language:_0xe0bax2[_0xa3ff[2]],accountcode:_0xe0bax2[_0xa3ff[2]],context:_0xe0bax2[_0xa3ff[2]],exten:_0xe0bax2[_0xa3ff[2]],priority:_0xe0bax2[_0xa3ff[2]],destchannel:_0xe0bax2[_0xa3ff[2]],destchannelstate:_0xe0bax2[_0xa3ff[4]],destchannelstatedesc:_0xe0bax2[_0xa3ff[2]],destcalleridnum:_0xe0bax2[_0xa3ff[2]],destcalleridname:_0xe0bax2[_0xa3ff[2]],destconnectedlinenum:_0xe0bax2[_0xa3ff[2]],destconnectedlinename:_0xe0bax2[_0xa3ff[2]],destlanguage:_0xe0bax2[_0xa3ff[2]],destaccountcode:_0xe0bax2[_0xa3ff[2]],destcontext:_0xe0bax2[_0xa3ff[2]],destexten:_0xe0bax2[_0xa3ff[2]],destpriority:_0xe0bax2[_0xa3ff[2]],destuniqueid:_0xe0bax2[_0xa3ff[2]]},{tableName:_0xa3ff[6],indexes:[{fields:[_0xa3ff[7],_0xa3ff[8]]}]});return _0xe0bax3;}; \ No newline at end of file diff --git a/server/models/report_call.js b/server/models/report_call.js index c73d367..0e43086 100644 --- a/server/models/report_call.js +++ b/server/models/report_call.js @@ -1,55 +1 @@ -/** - * CDR Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportCall = sequelize.define('ReportCall', { - accountcode: DataTypes.STRING, - source: DataTypes.STRING, - destination: DataTypes.STRING, - destinationcontext: DataTypes.STRING, - callerid: DataTypes.STRING, - channel: DataTypes.STRING, - destinationchannel: DataTypes.STRING, - lastapplication: DataTypes.STRING, - lastdata: DataTypes.STRING, - starttime: DataTypes.DATE, - answertime: { - type: DataTypes.DATE, - set: function(answertime) { - if (answertime !== '') { - this.setDataValue('answertime', answertime); - } else { - this.setDataValue('answertime', null); - } - } - }, - endtime: DataTypes.DATE, - duration: DataTypes.INTEGER, - billableseconds: DataTypes.INTEGER, - disposition: DataTypes.STRING, - amaflags: DataTypes.STRING, - uniqueid: { - type: DataTypes.STRING, - primaryKey: true - }, - userfield: DataTypes.STRING, - }, { - tableName: 'report_call', - associate: function(models) { - ReportCall.hasMany(models.ReportQueue, { - as: 'QueueCalls', - foreignKey: 'uniqueid', - constraints: false - }) - ReportCall.hasMany(models.ReportAgent, { - as: 'ReportAgents', - foreignKey: 'uniqueid', - constraints: false - }) - } - }); - - return ReportCall; -}; +var _0xc062=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","","\x61\x6E\x73\x77\x65\x72\x74\x69\x6D\x65","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x49\x4E\x54\x45\x47\x45\x52","\x72\x65\x70\x6F\x72\x74\x5F\x63\x61\x6C\x6C","\x51\x75\x65\x75\x65\x43\x61\x6C\x6C\x73","\x75\x6E\x69\x71\x75\x65\x69\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74\x73","\x64\x65\x66\x69\x6E\x65"];module[_0xc062[0]]=function(_0xcb40x1,_0xcb40x2){var _0xcb40x3=_0xcb40x1[_0xc062[13]](_0xc062[1],{accountcode:_0xcb40x2[_0xc062[2]],source:_0xcb40x2[_0xc062[2]],destination:_0xcb40x2[_0xc062[2]],destinationcontext:_0xcb40x2[_0xc062[2]],callerid:_0xcb40x2[_0xc062[2]],channel:_0xcb40x2[_0xc062[2]],destinationchannel:_0xcb40x2[_0xc062[2]],lastapplication:_0xcb40x2[_0xc062[2]],lastdata:_0xcb40x2[_0xc062[2]],starttime:_0xcb40x2[_0xc062[3]],answertime:{type:_0xcb40x2[_0xc062[3]],set:function(_0xcb40x4){if(_0xcb40x4!==_0xc062[4]){this[_0xc062[6]](_0xc062[5],_0xcb40x4)}else {this[_0xc062[6]](_0xc062[5],null)}}},endtime:_0xcb40x2[_0xc062[3]],duration:_0xcb40x2[_0xc062[7]],billableseconds:_0xcb40x2[_0xc062[7]],disposition:_0xcb40x2[_0xc062[2]],amaflags:_0xcb40x2[_0xc062[2]],uniqueid:{type:_0xcb40x2[_0xc062[2]],primaryKey:true},userfield:_0xcb40x2[_0xc062[2]]},{tableName:_0xc062[8],associate:function(_0xcb40x5){_0xcb40x3[_0xc062[11]](_0xcb40x5.ReportQueue,{as:_0xc062[9],foreignKey:_0xc062[10],constraints:false});_0xcb40x3[_0xc062[11]](_0xcb40x5.ReportAgent,{as:_0xc062[12],foreignKey:_0xc062[10],constraints:false});}});return _0xcb40x3;}; \ No newline at end of file diff --git a/server/models/report_chat.js b/server/models/report_chat.js index 08a9e88..b71a116 100644 --- a/server/models/report_chat.js +++ b/server/models/report_chat.js @@ -1,48 +1 @@ -/** - * Agent Log Model - */ - -var moment = require('moment'); - -module.exports = function(sequelize, DataTypes) { - - var ReportChat = sequelize.define('ReportChat', { - uniqueid: DataTypes.INTEGER, - sorting: DataTypes.INTEGER, - timeslot: DataTypes.INTEGER, - visitorname: DataTypes.STRING, - visitoremail: DataTypes.STRING, - websitename: DataTypes.STRING, - websiteaddress: DataTypes.STRING, - websiteid: DataTypes.INTEGER, - application: DataTypes.STRING, - fullname: DataTypes.STRING, - membername: DataTypes.STRING, - agentid: DataTypes.INTEGER, - chatqueuename: DataTypes.STRING, - lastevent: DataTypes.STRING, - agentcalledAt: DataTypes.DATE, - chatroomid: DataTypes.INTEGER, - connectId: { - type: DataTypes.INTEGER, - unique: true - }, - agentconnectedAt: DataTypes.DATE, - connect: { - type: DataTypes.BOOLEAN, - defaultValue: false, - set: function(agentconnectedAt) { - this.setDataValue('connectId', this.uniqueid); - this.setDataValue('agentconnectedAt', moment().format("YYYY-MM-DD HH:mm:ss")); - this.setDataValue('reason', 'agent'); - this.setDataValue('lastevent', 'agent'); - } - }, - agentringnoanswerAt: DataTypes.DATE, - reason: DataTypes.STRING - }, { - tableName: 'report_chat' - }); - - return ReportChat; -}; +var _0xf678=["\x6D\x6F\x6D\x65\x6E\x74","\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x42\x4F\x4F\x4C\x45\x41\x4E","\x63\x6F\x6E\x6E\x65\x63\x74\x49\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x61\x67\x65\x6E\x74\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x41\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x72\x65\x61\x73\x6F\x6E","\x61\x67\x65\x6E\x74","\x6C\x61\x73\x74\x65\x76\x65\x6E\x74","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74","\x64\x65\x66\x69\x6E\x65"];var moment=require(_0xf678[0]);module[_0xf678[1]]=function(_0x53eax2,_0x53eax3){var _0x53eax4=_0x53eax2[_0xf678[17]](_0xf678[2],{uniqueid:_0x53eax3[_0xf678[3]],sorting:_0x53eax3[_0xf678[3]],timeslot:_0x53eax3[_0xf678[3]],visitorname:_0x53eax3[_0xf678[4]],visitoremail:_0x53eax3[_0xf678[4]],websitename:_0x53eax3[_0xf678[4]],websiteaddress:_0x53eax3[_0xf678[4]],websiteid:_0x53eax3[_0xf678[3]],application:_0x53eax3[_0xf678[4]],fullname:_0x53eax3[_0xf678[4]],membername:_0x53eax3[_0xf678[4]],agentid:_0x53eax3[_0xf678[3]],chatqueuename:_0x53eax3[_0xf678[4]],lastevent:_0x53eax3[_0xf678[4]],agentcalledAt:_0x53eax3[_0xf678[5]],chatroomid:_0x53eax3[_0xf678[3]],connectId:{type:_0x53eax3[_0xf678[3]],unique:true},agentconnectedAt:_0x53eax3[_0xf678[5]],connect:{type:_0x53eax3[_0xf678[6]],defaultValue:false,set:function(_0x53eax5){this[_0xf678[9]](_0xf678[7],this[_0xf678[8]]);this[_0xf678[9]](_0xf678[10],moment()[_0xf678[12]](_0xf678[11]));this[_0xf678[9]](_0xf678[13],_0xf678[14]);this[_0xf678[9]](_0xf678[15],_0xf678[14]);}},agentringnoanswerAt:_0x53eax3[_0xf678[5]],reason:_0x53eax3[_0xf678[4]]},{tableName:_0xf678[16]});return _0x53eax4;}; \ No newline at end of file diff --git a/server/models/report_chat_session.js b/server/models/report_chat_session.js index a895225..ebc9ae6 100644 --- a/server/models/report_chat_session.js +++ b/server/models/report_chat_session.js @@ -1,32 +1 @@ -/** - * Agent Log Model - */ - -var moment = require('moment'); - -module.exports = function(sequelize, DataTypes) { - - var ReportChatSession = sequelize.define('ReportChatSession', { - uniqueid: { - type: DataTypes.INTEGER, - unique: true - }, - visitorname: DataTypes.STRING, - visitoremail: DataTypes.STRING, - websitename: DataTypes.STRING, - websiteaddress: DataTypes.STRING, - websiteid: DataTypes.INTEGER, - fullname: DataTypes.STRING, - membername: DataTypes.STRING, - agentid: DataTypes.INTEGER, - chatqueuename: DataTypes.STRING, - chatroomid: DataTypes.INTEGER, - chatjoinAt: DataTypes.DATE, - chatleaveAt: DataTypes.DATE, - chatunmanagedAt: DataTypes.DATE, - }, { - tableName: 'report_chat_session' - }); - - return ReportChatSession; -}; +var _0xd5a7=["\x6D\x6F\x6D\x65\x6E\x74","\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x53\x65\x73\x73\x69\x6F\x6E","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x5F\x73\x65\x73\x73\x69\x6F\x6E","\x64\x65\x66\x69\x6E\x65"];var moment=require(_0xd5a7[0]);module[_0xd5a7[1]]=function(_0xa090x2,_0xa090x3){var _0xa090x4=_0xa090x2[_0xd5a7[7]](_0xd5a7[2],{uniqueid:{type:_0xa090x3[_0xd5a7[3]],unique:true},visitorname:_0xa090x3[_0xd5a7[4]],visitoremail:_0xa090x3[_0xd5a7[4]],websitename:_0xa090x3[_0xd5a7[4]],websiteaddress:_0xa090x3[_0xd5a7[4]],websiteid:_0xa090x3[_0xd5a7[3]],fullname:_0xa090x3[_0xd5a7[4]],membername:_0xa090x3[_0xd5a7[4]],agentid:_0xa090x3[_0xd5a7[3]],chatqueuename:_0xa090x3[_0xd5a7[4]],chatroomid:_0xa090x3[_0xd5a7[3]],chatjoinAt:_0xa090x3[_0xd5a7[5]],chatleaveAt:_0xa090x3[_0xd5a7[5]],chatunmanagedAt:_0xa090x3[_0xd5a7[5]]},{tableName:_0xd5a7[6]});return _0xa090x4;}; \ No newline at end of file diff --git a/server/models/report_dial.js b/server/models/report_dial.js index 273f50d..13c2939 100644 --- a/server/models/report_dial.js +++ b/server/models/report_dial.js @@ -1,44 +1 @@ -/** - * DIAL Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportDial = sequelize.define('ReportDial', { - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.INTEGER, - uniqueid: DataTypes.STRING, - destchannel: DataTypes.STRING, - destchannelstate: DataTypes.INTEGER, - destchannelstatedesc: DataTypes.STRING, - destcalleridnum: DataTypes.STRING, - destcalleridname: DataTypes.STRING, - destconnectedlinenum: DataTypes.STRING, - destconnectedlinename: DataTypes.STRING, - destlanguage: DataTypes.STRING, - destaccountcode: DataTypes.STRING, - destcontext: DataTypes.STRING, - destexten: DataTypes.STRING, - destpriority: DataTypes.INTEGER, - destuniqueid: DataTypes.STRING, - dialstring: DataTypes.STRING, - dialstatus: DataTypes.STRING - }, { - tableName: 'report_dial', - indexes: [{ - fields: ['uniqueid'] - }] - }); - - return ReportDial; -}; +var _0x656a=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x44\x69\x61\x6C","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x72\x65\x70\x6F\x72\x74\x5F\x64\x69\x61\x6C","\x75\x6E\x69\x71\x75\x65\x69\x64","\x64\x65\x66\x69\x6E\x65"];module[_0x656a[0]]=function(_0xef27x1,_0xef27x2){var _0xef27x3=_0xef27x1[_0x656a[6]](_0x656a[1],{channel:_0xef27x2[_0x656a[2]],channelstate:_0xef27x2[_0x656a[3]],channelstatedesc:_0xef27x2[_0x656a[2]],calleridnum:_0xef27x2[_0x656a[2]],calleridname:_0xef27x2[_0x656a[2]],connectedlinenum:_0xef27x2[_0x656a[2]],connectedlinename:_0xef27x2[_0x656a[2]],language:_0xef27x2[_0x656a[2]],accountcode:_0xef27x2[_0x656a[2]],context:_0xef27x2[_0x656a[2]],exten:_0xef27x2[_0x656a[2]],priority:_0xef27x2[_0x656a[3]],uniqueid:_0xef27x2[_0x656a[2]],destchannel:_0xef27x2[_0x656a[2]],destchannelstate:_0xef27x2[_0x656a[3]],destchannelstatedesc:_0xef27x2[_0x656a[2]],destcalleridnum:_0xef27x2[_0x656a[2]],destcalleridname:_0xef27x2[_0x656a[2]],destconnectedlinenum:_0xef27x2[_0x656a[2]],destconnectedlinename:_0xef27x2[_0x656a[2]],destlanguage:_0xef27x2[_0x656a[2]],destaccountcode:_0xef27x2[_0x656a[2]],destcontext:_0xef27x2[_0x656a[2]],destexten:_0xef27x2[_0x656a[2]],destpriority:_0xef27x2[_0x656a[3]],destuniqueid:_0xef27x2[_0x656a[2]],dialstring:_0xef27x2[_0x656a[2]],dialstatus:_0xef27x2[_0x656a[2]]},{tableName:_0x656a[4],indexes:[{fields:[_0x656a[5]]}]});return _0xef27x3;}; \ No newline at end of file diff --git a/server/models/report_integration.js b/server/models/report_integration.js index 2a3347e..20775a3 100644 --- a/server/models/report_integration.js +++ b/server/models/report_integration.js @@ -1,83 +1 @@ -/** - * report_integrations Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportIntegration = sequelize.define('ReportIntegration', { - integration: DataTypes.STRING, - event: DataTypes.STRING, - contacts: DataTypes.STRING, - uniqueid: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - queue: DataTypes.STRING, - interface: DataTypes.STRING, - membername: DataTypes.STRING, - agentcalledAt: DataTypes.DATE, - agentconnectAt: DataTypes.DATE, - holdtime: DataTypes.INTEGER, - agentcomplete: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentcompleteAt: DataTypes.DATE, - talktime: DataTypes.INTEGER, - agentacw: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - acwtime: DataTypes.INTEGER, - reason: DataTypes.STRING, - agentringnoanswer: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentringnoanswerAt: DataTypes.DATE, - agentdump: { - type: DataTypes.BOOLEAN, - defaultValue: false, - }, - agentdumpAt: DataTypes.DATE, - lastevent: DataTypes.STRING, - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.STRING, - destchannel: DataTypes.STRING, - destchannelstate: DataTypes.INTEGER, - destchannelstatedesc: DataTypes.STRING, - destcalleridnum: DataTypes.STRING, - destcalleridname: DataTypes.STRING, - destconnectedlinenum: DataTypes.STRING, - destconnectedlinename: DataTypes.STRING, - destlanguage: DataTypes.STRING, - destaccountcode: DataTypes.STRING, - destcontext: DataTypes.STRING, - destexten: DataTypes.STRING, - destpriority: DataTypes.STRING, - destuniqueid: DataTypes.STRING, - messageId: DataTypes.STRING, - inReplyTo: DataTypes.STRING, - subject: DataTypes.STRING, - from: DataTypes.STRING, - to: DataTypes.STRING, - cc: DataTypes.STRING, - attachment: DataTypes.TEXT, - html: DataTypes.TEXT, - text: DataTypes.TEXT, - status: { - type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED') - } - }, { - tableName: 'report_integration' - }); - - return ReportIntegration; -}; +var _0xb568=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x54\x45\x58\x54","\x53\x45\x4E\x54","\x53\x45\x4E\x44\x49\x4E\x47","\x52\x45\x43\x45\x49\x56\x45\x44","\x46\x41\x49\x4C\x45\x44","\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x64\x65\x66\x69\x6E\x65"];module[_0xb568[0]]=function(_0x347fx1,_0x347fx2){var _0x347fx3=_0x347fx1[_0xb568[12]](_0xb568[1],{integration:_0x347fx2[_0xb568[2]],event:_0x347fx2[_0xb568[2]],contacts:_0x347fx2[_0xb568[2]],uniqueid:_0x347fx2[_0xb568[2]],calleridnum:_0x347fx2[_0xb568[2]],calleridname:_0x347fx2[_0xb568[2]],queue:_0x347fx2[_0xb568[2]],interface:_0x347fx2[_0xb568[2]],membername:_0x347fx2[_0xb568[2]],agentcalledAt:_0x347fx2[_0xb568[3]],agentconnectAt:_0x347fx2[_0xb568[3]],holdtime:_0x347fx2[_0xb568[4]],agentcomplete:{type:_0x347fx2[_0xb568[5]],defaultValue:false},agentcompleteAt:_0x347fx2[_0xb568[3]],talktime:_0x347fx2[_0xb568[4]],agentacw:{type:_0x347fx2[_0xb568[5]],defaultValue:false},acwtime:_0x347fx2[_0xb568[4]],reason:_0x347fx2[_0xb568[2]],agentringnoanswer:{type:_0x347fx2[_0xb568[5]],defaultValue:false},agentringnoanswerAt:_0x347fx2[_0xb568[3]],agentdump:{type:_0x347fx2[_0xb568[5]],defaultValue:false},agentdumpAt:_0x347fx2[_0xb568[3]],lastevent:_0x347fx2[_0xb568[2]],channel:_0x347fx2[_0xb568[2]],channelstate:_0x347fx2[_0xb568[4]],channelstatedesc:_0x347fx2[_0xb568[2]],connectedlinenum:_0x347fx2[_0xb568[2]],connectedlinename:_0x347fx2[_0xb568[2]],language:_0x347fx2[_0xb568[2]],accountcode:_0x347fx2[_0xb568[2]],context:_0x347fx2[_0xb568[2]],exten:_0x347fx2[_0xb568[2]],priority:_0x347fx2[_0xb568[2]],destchannel:_0x347fx2[_0xb568[2]],destchannelstate:_0x347fx2[_0xb568[4]],destchannelstatedesc:_0x347fx2[_0xb568[2]],destcalleridnum:_0x347fx2[_0xb568[2]],destcalleridname:_0x347fx2[_0xb568[2]],destconnectedlinenum:_0x347fx2[_0xb568[2]],destconnectedlinename:_0x347fx2[_0xb568[2]],destlanguage:_0x347fx2[_0xb568[2]],destaccountcode:_0x347fx2[_0xb568[2]],destcontext:_0x347fx2[_0xb568[2]],destexten:_0x347fx2[_0xb568[2]],destpriority:_0x347fx2[_0xb568[2]],destuniqueid:_0x347fx2[_0xb568[2]],messageId:_0x347fx2[_0xb568[2]],inReplyTo:_0x347fx2[_0xb568[2]],subject:_0x347fx2[_0xb568[2]],from:_0x347fx2[_0xb568[2]],to:_0x347fx2[_0xb568[2]],cc:_0x347fx2[_0xb568[2]],attachment:_0x347fx2[_0xb568[6]],html:_0x347fx2[_0xb568[6]],text:_0x347fx2[_0xb568[6]],status:{type:_0x347fx2.ENUM(_0xb568[7],_0xb568[8],_0xb568[9],_0xb568[10])}},{tableName:_0xb568[11]});return _0x347fx3;}; \ No newline at end of file diff --git a/server/models/report_mail.js b/server/models/report_mail.js index 8fd17ff..e70eccc 100644 --- a/server/models/report_mail.js +++ b/server/models/report_mail.js @@ -1,49 +1 @@ -/** - * Agent Log Model - */ - -var moment = require('moment'); - -module.exports = function(sequelize, DataTypes) { - - var ReportMail = sequelize.define('ReportMail', { - uniqueid: DataTypes.INTEGER, - sorting: DataTypes.INTEGER, - timeslot: DataTypes.INTEGER, - subject: DataTypes.STRING, - from: DataTypes.STRING, - cc: DataTypes.STRING, - attachment: DataTypes.BOOLEAN, - accountname: DataTypes.STRING, - accountaddress: DataTypes.STRING, - application: DataTypes.STRING, - fullname: DataTypes.STRING, - membername: DataTypes.STRING, - agentid: DataTypes.INTEGER, - mailqueuename: DataTypes.STRING, - mailroomid: DataTypes.INTEGER, - lastevent: DataTypes.STRING, - agentcalledAt: DataTypes.DATE, - connectId: { - type: DataTypes.INTEGER, - unique: true - }, - agentconnectedAt: DataTypes.DATE, - connect: { - type: DataTypes.BOOLEAN, - defaultValue: false, - set: function(agentconnectedAt) { - this.setDataValue('connectId', this.uniqueid); - this.setDataValue('agentconnectedAt', moment().format("YYYY-MM-DD HH:mm:ss")); - this.setDataValue('reason', 'agent'); - this.setDataValue('lastevent', 'agent'); - } - }, - agentringnoanswerAt: DataTypes.DATE, - reason: DataTypes.STRING - }, { - tableName: 'report_mail' - }); - - return ReportMail; -}; +var _0xabaa=["\x6D\x6F\x6D\x65\x6E\x74","\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x44\x41\x54\x45","\x63\x6F\x6E\x6E\x65\x63\x74\x49\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x61\x67\x65\x6E\x74\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x41\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x72\x65\x61\x73\x6F\x6E","\x61\x67\x65\x6E\x74","\x6C\x61\x73\x74\x65\x76\x65\x6E\x74","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C","\x64\x65\x66\x69\x6E\x65"];var moment=require(_0xabaa[0]);module[_0xabaa[1]]=function(_0x8ce1x2,_0x8ce1x3){var _0x8ce1x4=_0x8ce1x2[_0xabaa[17]](_0xabaa[2],{uniqueid:_0x8ce1x3[_0xabaa[3]],sorting:_0x8ce1x3[_0xabaa[3]],timeslot:_0x8ce1x3[_0xabaa[3]],subject:_0x8ce1x3[_0xabaa[4]],from:_0x8ce1x3[_0xabaa[4]],cc:_0x8ce1x3[_0xabaa[4]],attachment:_0x8ce1x3[_0xabaa[5]],accountname:_0x8ce1x3[_0xabaa[4]],accountaddress:_0x8ce1x3[_0xabaa[4]],application:_0x8ce1x3[_0xabaa[4]],fullname:_0x8ce1x3[_0xabaa[4]],membername:_0x8ce1x3[_0xabaa[4]],agentid:_0x8ce1x3[_0xabaa[3]],mailqueuename:_0x8ce1x3[_0xabaa[4]],mailroomid:_0x8ce1x3[_0xabaa[3]],lastevent:_0x8ce1x3[_0xabaa[4]],agentcalledAt:_0x8ce1x3[_0xabaa[6]],connectId:{type:_0x8ce1x3[_0xabaa[3]],unique:true},agentconnectedAt:_0x8ce1x3[_0xabaa[6]],connect:{type:_0x8ce1x3[_0xabaa[5]],defaultValue:false,set:function(_0x8ce1x5){this[_0xabaa[9]](_0xabaa[7],this[_0xabaa[8]]);this[_0xabaa[9]](_0xabaa[10],moment()[_0xabaa[12]](_0xabaa[11]));this[_0xabaa[9]](_0xabaa[13],_0xabaa[14]);this[_0xabaa[9]](_0xabaa[15],_0xabaa[14]);}},agentringnoanswerAt:_0x8ce1x3[_0xabaa[6]],reason:_0x8ce1x3[_0xabaa[4]]},{tableName:_0xabaa[16]});return _0x8ce1x4;}; \ No newline at end of file diff --git a/server/models/report_mail_session.js b/server/models/report_mail_session.js index b2ce44f..d6a5732 100644 --- a/server/models/report_mail_session.js +++ b/server/models/report_mail_session.js @@ -1,30 +1 @@ -/** - * Agent Log Model - */ - -var moment = require('moment'); - -module.exports = function(sequelize, DataTypes) { - - var ReportMailSession = sequelize.define('ReportMailSession', { - uniqueid: { - type: DataTypes.INTEGER - }, - subject: DataTypes.STRING, - from: DataTypes.STRING, - cc: DataTypes.STRING, - attachment: DataTypes.BOOLEAN, - accountname: DataTypes.STRING, - accountaddress: DataTypes.STRING, - fullname: DataTypes.STRING, - membername: DataTypes.STRING, - mailqueuename: DataTypes.STRING, - mailjoinAt: DataTypes.DATE, - mailleaveAt: DataTypes.DATE, - mailunmanagedAt: DataTypes.DATE, - }, { - tableName: 'report_mail_session' - }); - - return ReportMailSession; -}; +var _0x5369=["\x6D\x6F\x6D\x65\x6E\x74","\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x44\x41\x54\x45","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E","\x64\x65\x66\x69\x6E\x65"];var moment=require(_0x5369[0]);module[_0x5369[1]]=function(_0x837fx2,_0x837fx3){var _0x837fx4=_0x837fx2[_0x5369[8]](_0x5369[2],{uniqueid:{type:_0x837fx3[_0x5369[3]]},subject:_0x837fx3[_0x5369[4]],from:_0x837fx3[_0x5369[4]],cc:_0x837fx3[_0x5369[4]],attachment:_0x837fx3[_0x5369[5]],accountname:_0x837fx3[_0x5369[4]],accountaddress:_0x837fx3[_0x5369[4]],fullname:_0x837fx3[_0x5369[4]],membername:_0x837fx3[_0x5369[4]],mailqueuename:_0x837fx3[_0x5369[4]],mailjoinAt:_0x837fx3[_0x5369[6]],mailleaveAt:_0x837fx3[_0x5369[6]],mailunmanagedAt:_0x837fx3[_0x5369[6]]},{tableName:_0x5369[7]});return _0x837fx4;}; \ No newline at end of file diff --git a/server/models/report_member.js b/server/models/report_member.js index 293bace..d4b949d 100644 --- a/server/models/report_member.js +++ b/server/models/report_member.js @@ -1,25 +1 @@ -/** - * DIAL Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportMember = sequelize.define('ReportMember', { - stateinterface: DataTypes.STRING, - queue: DataTypes.STRING, - membername: DataTypes.STRING, - interface: DataTypes.STRING, - state: DataTypes.INTEGER, - statedesc: DataTypes.STRING, - enterdate: DataTypes.DATE, - exitdate: DataTypes.DATE, - reason: DataTypes.STRING - }, { - tableName: 'report_member', - indexes: [{ - fields: ['queue', 'membername', 'state', 'enterdate', 'exitdate'] - }] - }); - - return ReportMember; -}; +var _0xc9be=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x4D\x65\x6D\x62\x65\x72","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x44\x41\x54\x45","\x72\x65\x70\x6F\x72\x74\x5F\x6D\x65\x6D\x62\x65\x72","\x71\x75\x65\x75\x65","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x73\x74\x61\x74\x65","\x65\x6E\x74\x65\x72\x64\x61\x74\x65","\x65\x78\x69\x74\x64\x61\x74\x65","\x64\x65\x66\x69\x6E\x65"];module[_0xc9be[0]]=function(_0x5ac8x1,_0x5ac8x2){var _0x5ac8x3=_0x5ac8x1[_0xc9be[11]](_0xc9be[1],{stateinterface:_0x5ac8x2[_0xc9be[2]],queue:_0x5ac8x2[_0xc9be[2]],membername:_0x5ac8x2[_0xc9be[2]],interface:_0x5ac8x2[_0xc9be[2]],state:_0x5ac8x2[_0xc9be[3]],statedesc:_0x5ac8x2[_0xc9be[2]],enterdate:_0x5ac8x2[_0xc9be[4]],exitdate:_0x5ac8x2[_0xc9be[4]],reason:_0x5ac8x2[_0xc9be[2]]},{tableName:_0xc9be[5],indexes:[{fields:[_0xc9be[6],_0xc9be[7],_0xc9be[8],_0xc9be[9],_0xc9be[10]]}]});return _0x5ac8x3;}; \ No newline at end of file diff --git a/server/models/report_queue.js b/server/models/report_queue.js index fb70f88..517bd86 100644 --- a/server/models/report_queue.js +++ b/server/models/report_queue.js @@ -1,41 +1 @@ -/** - * QueueLog Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportQueue = sequelize.define('ReportQueue', { - uniqueid: DataTypes.STRING, - calleridnum: DataTypes.STRING, - calleridname: DataTypes.STRING, - queue: DataTypes.STRING, - queuecallerjoinAt: DataTypes.DATE, - queuecallerleaveAt: DataTypes.DATE, - position: DataTypes.INTEGER, - count: DataTypes.INTEGER, - queuecallerabandon: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - queuecallerabandonAt: DataTypes.DATE, - queuecallercompleteAt: DataTypes.DATE, - originalposition: DataTypes.INTEGER, - channel: DataTypes.STRING, - channelstate: DataTypes.INTEGER, - channelstatedesc: DataTypes.STRING, - connectedlinenum: DataTypes.STRING, - connectedlinename: DataTypes.STRING, - language: DataTypes.STRING, - accountcode: DataTypes.STRING, - context: DataTypes.STRING, - exten: DataTypes.STRING, - priority: DataTypes.STRING, - }, { - tableName: 'report_queue', - indexes: [{ - fields: ['uniqueid'] - }] - }); - - return ReportQueue; -}; +var _0x8ca1=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x75\x65","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65","\x75\x6E\x69\x71\x75\x65\x69\x64","\x64\x65\x66\x69\x6E\x65"];module[_0x8ca1[0]]=function(_0xa6d7x1,_0xa6d7x2){var _0xa6d7x3=_0xa6d7x1[_0x8ca1[8]](_0x8ca1[1],{uniqueid:_0xa6d7x2[_0x8ca1[2]],calleridnum:_0xa6d7x2[_0x8ca1[2]],calleridname:_0xa6d7x2[_0x8ca1[2]],queue:_0xa6d7x2[_0x8ca1[2]],queuecallerjoinAt:_0xa6d7x2[_0x8ca1[3]],queuecallerleaveAt:_0xa6d7x2[_0x8ca1[3]],position:_0xa6d7x2[_0x8ca1[4]],count:_0xa6d7x2[_0x8ca1[4]],queuecallerabandon:{type:_0xa6d7x2[_0x8ca1[5]],defaultValue:false},queuecallerabandonAt:_0xa6d7x2[_0x8ca1[3]],queuecallercompleteAt:_0xa6d7x2[_0x8ca1[3]],originalposition:_0xa6d7x2[_0x8ca1[4]],channel:_0xa6d7x2[_0x8ca1[2]],channelstate:_0xa6d7x2[_0x8ca1[4]],channelstatedesc:_0xa6d7x2[_0x8ca1[2]],connectedlinenum:_0xa6d7x2[_0x8ca1[2]],connectedlinename:_0xa6d7x2[_0x8ca1[2]],language:_0xa6d7x2[_0x8ca1[2]],accountcode:_0xa6d7x2[_0x8ca1[2]],context:_0xa6d7x2[_0x8ca1[2]],exten:_0xa6d7x2[_0x8ca1[2]],priority:_0xa6d7x2[_0x8ca1[2]]},{tableName:_0x8ca1[6],indexes:[{fields:[_0x8ca1[7]]}]});return _0xa6d7x3;}; \ No newline at end of file diff --git a/server/models/report_square.js b/server/models/report_square.js index 62a8e0c..b509638 100644 --- a/server/models/report_square.js +++ b/server/models/report_square.js @@ -1,89 +1 @@ -/** - * Context Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportSquare = sequelize.define('ReportSquare', { - network: { - type: DataTypes.STRING, - }, - network_script: { - type: DataTypes.STRING, - }, - request: { - type: DataTypes.STRING, - }, - channel: { - type: DataTypes.STRING, - }, - language: { - type: DataTypes.STRING, - }, - type: { - type: DataTypes.STRING, - }, - uniqueid: { - type: DataTypes.STRING, - }, - version: { - type: DataTypes.STRING, - }, - callerid: { - type: DataTypes.STRING, - }, - calleridname: { - type: DataTypes.STRING, - }, - callingpres: { - type: DataTypes.STRING, - }, - callingani2: { - type: DataTypes.STRING, - }, - callington: { - type: DataTypes.STRING, - }, - callingtns: { - type: DataTypes.STRING, - }, - dnid: { - type: DataTypes.STRING, - }, - rdnis: { - type: DataTypes.STRING, - }, - context: { - type: DataTypes.STRING, - }, - extension: { - type: DataTypes.STRING, - }, - priority: { - type: DataTypes.STRING, - }, - enhanced: { - type: DataTypes.STRING, - }, - accountcode: { - type: DataTypes.STRING, - }, - threadid: { - type: DataTypes.STRING, - }, - project_name: { - type: DataTypes.STRING, - }, - joinAt: { - type: DataTypes.DATE, - }, - leaveAt: { - type: DataTypes.DATE, - unique: true - } - }, { - tableName: 'report_square' - }); - - return ReportSquare; -}; +var _0xca08=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x53\x71\x75\x61\x72\x65","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","\x72\x65\x70\x6F\x72\x74\x5F\x73\x71\x75\x61\x72\x65","\x64\x65\x66\x69\x6E\x65"];module[_0xca08[0]]=function(_0xefacx1,_0xefacx2){var _0xefacx3=_0xefacx1[_0xca08[5]](_0xca08[1],{network:{type:_0xefacx2[_0xca08[2]]},network_script:{type:_0xefacx2[_0xca08[2]]},request:{type:_0xefacx2[_0xca08[2]]},channel:{type:_0xefacx2[_0xca08[2]]},language:{type:_0xefacx2[_0xca08[2]]},type:{type:_0xefacx2[_0xca08[2]]},uniqueid:{type:_0xefacx2[_0xca08[2]]},version:{type:_0xefacx2[_0xca08[2]]},callerid:{type:_0xefacx2[_0xca08[2]]},calleridname:{type:_0xefacx2[_0xca08[2]]},callingpres:{type:_0xefacx2[_0xca08[2]]},callingani2:{type:_0xefacx2[_0xca08[2]]},callington:{type:_0xefacx2[_0xca08[2]]},callingtns:{type:_0xefacx2[_0xca08[2]]},dnid:{type:_0xefacx2[_0xca08[2]]},rdnis:{type:_0xefacx2[_0xca08[2]]},context:{type:_0xefacx2[_0xca08[2]]},extension:{type:_0xefacx2[_0xca08[2]]},priority:{type:_0xefacx2[_0xca08[2]]},enhanced:{type:_0xefacx2[_0xca08[2]]},accountcode:{type:_0xefacx2[_0xca08[2]]},threadid:{type:_0xefacx2[_0xca08[2]]},project_name:{type:_0xefacx2[_0xca08[2]]},joinAt:{type:_0xefacx2[_0xca08[3]]},leaveAt:{type:_0xefacx2[_0xca08[3]],unique:true}},{tableName:_0xca08[4]});return _0xefacx3;}; \ No newline at end of file diff --git a/server/models/report_square_detail.js b/server/models/report_square_detail.js index b9a2f4c..139e93d 100644 --- a/server/models/report_square_detail.js +++ b/server/models/report_square_detail.js @@ -1,25 +1 @@ -/** - * Context Model - */ - -module.exports = function(sequelize, DataTypes) { - - var ReportSquareDetail = sequelize.define('ReportSquareDetail', { - uniqueid: { - type: DataTypes.STRING, - }, - node: { - type: DataTypes.STRING, - }, - application: { - type: DataTypes.STRING, - }, - data: { - type: DataTypes.STRING, - } - }, { - tableName: 'report_square_details' - }); - - return ReportSquareDetail; -}; +var _0x9c13=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x53\x71\x75\x61\x72\x65\x44\x65\x74\x61\x69\x6C","\x53\x54\x52\x49\x4E\x47","\x72\x65\x70\x6F\x72\x74\x5F\x73\x71\x75\x61\x72\x65\x5F\x64\x65\x74\x61\x69\x6C\x73","\x64\x65\x66\x69\x6E\x65"];module[_0x9c13[0]]=function(_0xd15bx1,_0xd15bx2){var _0xd15bx3=_0xd15bx1[_0x9c13[4]](_0x9c13[1],{uniqueid:{type:_0xd15bx2[_0x9c13[2]]},node:{type:_0xd15bx2[_0x9c13[2]]},application:{type:_0xd15bx2[_0x9c13[2]]},data:{type:_0xd15bx2[_0x9c13[2]]}},{tableName:_0x9c13[3]});return _0xd15bx3;}; \ No newline at end of file diff --git a/server/models/report_tree.js b/server/models/report_tree.js index 2c14bfe..f9bd738 100644 --- a/server/models/report_tree.js +++ b/server/models/report_tree.js @@ -1,12 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var ReportTree = sequelize.define('ReportTree', { - tree: DataTypes.TEXT - }, { - tableName: 'report_trees' - }); - - return ReportTree; -}; +var _0x4a2c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x54\x72\x65\x65","\x54\x45\x58\x54","\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65\x73","\x64\x65\x66\x69\x6E\x65"];_0x4a2c[0];module[_0x4a2c[1]]=function(_0xe975x1,_0xe975x2){var _0xe975x3=_0xe975x1[_0x4a2c[5]](_0x4a2c[2],{tree:_0xe975x2[_0x4a2c[3]]},{tableName:_0x4a2c[4]});return _0xe975x3;}; \ No newline at end of file diff --git a/server/models/salesforce_account.js b/server/models/salesforce_account.js index c7319f2..3e1e7c0 100644 --- a/server/models/salesforce_account.js +++ b/server/models/salesforce_account.js @@ -1,24 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('SalesforceAccount', { - name: DataTypes.STRING, - description: DataTypes.STRING, - username: { - type: DataTypes.STRING, - unique: true - }, - remoteUri: DataTypes.STRING, - password: DataTypes.STRING, - clientId: DataTypes.STRING, - clientSecret: DataTypes.STRING, - securityToken: DataTypes.STRING - }, { - tableName: 'salesforce_accounts', - associate: function(models) { - models.SalesforceAccount.hasMany(models.SalesforceConfiguration, { - foreignKey: 'AccountId' - }); - } - }); -}; +var _0x70ea=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x70ea[0];module[_0x70ea[1]]=function(_0xe207x1,_0xe207x2){return _0xe207x1[_0x70ea[7]](_0x70ea[2],{name:_0xe207x2[_0x70ea[3]],description:_0xe207x2[_0x70ea[3]],username:{type:_0xe207x2[_0x70ea[3]],unique:true},remoteUri:_0xe207x2[_0x70ea[3]],password:_0xe207x2[_0x70ea[3]],clientId:_0xe207x2[_0x70ea[3]],clientSecret:_0xe207x2[_0x70ea[3]],securityToken:_0xe207x2[_0x70ea[3]]},{tableName:_0x70ea[4],associate:function(_0xe207x3){_0xe207x3[_0x70ea[2]][_0x70ea[6]](_0xe207x3.SalesforceConfiguration,{foreignKey:_0x70ea[5]})}})}; \ No newline at end of file diff --git a/server/models/salesforce_configuration.js b/server/models/salesforce_configuration.js index 6850116..5c735e1 100644 --- a/server/models/salesforce_configuration.js +++ b/server/models/salesforce_configuration.js @@ -1,27 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('SalesforceConfiguration', { - name: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'salesforce_configurations', - associate: function(models) { - models.SalesforceConfiguration.belongsTo(models.SalesforceAccount, { - foreignKey: 'AccountId' - }); - models.SalesforceConfiguration.hasMany(models.SalesforceField, { - as: 'Subject', - foreignKey: 'SubjectId' - }); - models.SalesforceConfiguration.hasMany(models.SalesforceField, { - as: 'Description', - foreignKey: 'DescriptionId' - }); - models.SalesforceConfiguration.hasMany(models.SalesforceField, { - as: 'Field', - foreignKey: 'FieldId' - }); - } - }); -}; +var _0x959b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x53\x75\x62\x6A\x65\x63\x74","\x53\x75\x62\x6A\x65\x63\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x49\x64","\x46\x69\x65\x6C\x64","\x46\x69\x65\x6C\x64\x49\x64","\x64\x65\x66\x69\x6E\x65"];_0x959b[0];module[_0x959b[1]]=function(_0xa318x1,_0xa318x2){return _0xa318x1[_0x959b[14]](_0x959b[2],{name:_0xa318x2[_0x959b[3]],description:_0xa318x2[_0x959b[3]]},{tableName:_0x959b[4],associate:function(_0xa318x3){_0xa318x3[_0x959b[2]][_0x959b[6]](_0xa318x3.SalesforceAccount,{foreignKey:_0x959b[5]});_0xa318x3[_0x959b[2]][_0x959b[9]](_0xa318x3.SalesforceField,{as:_0x959b[7],foreignKey:_0x959b[8]});_0xa318x3[_0x959b[2]][_0x959b[9]](_0xa318x3.SalesforceField,{as:_0x959b[10],foreignKey:_0x959b[11]});_0xa318x3[_0x959b[2]][_0x959b[9]](_0xa318x3.SalesforceField,{as:_0x959b[12],foreignKey:_0x959b[13]});}})}; \ No newline at end of file diff --git a/server/models/salesforce_field.js b/server/models/salesforce_field.js index f3a3501..f66b8f8 100644 --- a/server/models/salesforce_field.js +++ b/server/models/salesforce_field.js @@ -1,22 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('SalesforceField', { - type: { - type: DataTypes.ENUM('string', 'variable', 'key_value'), - defaultValue: 'string' - }, - content: DataTypes.STRING, - key: DataTypes.STRING, - keyType: { - type: DataTypes.ENUM('string', 'variable') - }, - keyContent: DataTypes.STRING, - idField: DataTypes.STRING - }, { - tableName: 'salesforce_fields', - associate: function(models) { - models.SalesforceField.belongsTo(models.Variable); - } - }); -}; +var _0xe50f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x46\x69\x65\x6C\x64","\x73\x74\x72\x69\x6E\x67","\x76\x61\x72\x69\x61\x62\x6C\x65","\x6B\x65\x79\x5F\x76\x61\x6C\x75\x65","\x53\x54\x52\x49\x4E\x47","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0xe50f[0];module[_0xe50f[1]]=function(_0xc77cx1,_0xc77cx2){return _0xc77cx1[_0xe50f[9]](_0xe50f[2],{type:{type:_0xc77cx2.ENUM(_0xe50f[3],_0xe50f[4],_0xe50f[5]),defaultValue:_0xe50f[3]},content:_0xc77cx2[_0xe50f[6]],key:_0xc77cx2[_0xe50f[6]],keyType:{type:_0xc77cx2.ENUM(_0xe50f[3],_0xe50f[4])},keyContent:_0xc77cx2[_0xe50f[6]],idField:_0xc77cx2[_0xe50f[6]]},{tableName:_0xe50f[7],associate:function(_0xc77cx3){_0xc77cx3[_0xe50f[2]][_0xe50f[8]](_0xc77cx3.Variable)}})}; \ No newline at end of file diff --git a/server/models/settings.js b/server/models/settings.js index 3599ea7..66a139c 100644 --- a/server/models/settings.js +++ b/server/models/settings.js @@ -1,52 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Settings = sequelize.define('Settings', { - license: DataTypes.TEXT, - mac: { - type: DataTypes.STRING(17), - allowNull: false, - validate: { - notEmpty: true, - // isMac: function(value) { - // if (!getmac.isMac(value)) { - // throw new Error('Invalid Mac!'); - // } - // } - } - }, - netmask: { - type: DataTypes.STRING(15), - allowNull: false, - validate: { - notEmpty: true, - isIP: true - } - }, - address: { - type: DataTypes.STRING(15), - allowNull: false, - validate: { - notEmpty: true, - isIP: true - } - }, - min_internal: { - type: DataTypes.INTEGER(11), - unique: true - }, - agi_port: { - type: DataTypes.INTEGER(11) - }, - automation_timeout: { - type: DataTypes.INTEGER(11), - defaultValue: 3600 - } - }, { - tableName: 'settings' - }); - - return Settings; - -}; +var _0x200f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x65\x74\x74\x69\x6E\x67\x73","\x54\x45\x58\x54","\x73\x65\x74\x74\x69\x6E\x67\x73","\x64\x65\x66\x69\x6E\x65"];_0x200f[0];module[_0x200f[1]]=function(_0xa0a3x1,_0xa0a3x2){var _0xa0a3x3=_0xa0a3x1[_0x200f[5]](_0x200f[2],{license:_0xa0a3x2[_0x200f[3]],mac:{type:_0xa0a3x2.STRING(17),allowNull:false,validate:{notEmpty:true}},netmask:{type:_0xa0a3x2.STRING(15),allowNull:false,validate:{notEmpty:true,isIP:true}},address:{type:_0xa0a3x2.STRING(15),allowNull:false,validate:{notEmpty:true,isIP:true}},min_internal:{type:_0xa0a3x2.INTEGER(11),unique:true},agi_port:{type:_0xa0a3x2.INTEGER(11)},automation_timeout:{type:_0xa0a3x2.INTEGER(11),defaultValue:3600}},{tableName:_0x200f[4]});return _0xa0a3x3;}; \ No newline at end of file diff --git a/server/models/square_odbc.js b/server/models/square_odbc.js index 0e632c6..b7f6a13 100644 --- a/server/models/square_odbc.js +++ b/server/models/square_odbc.js @@ -1,23 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var SquareOdbc = sequelize.define('SquareOdbc', { - name: { - type: DataTypes.STRING, - unique: true, - validate: { - notEmpty: true - }, - }, - dsn: { - type: DataTypes.STRING, - }, - description: DataTypes.STRING - }, { - tableName: 'square_odbc' - }); - - return SquareOdbc; - -}; +var _0xe9de=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x71\x75\x61\x72\x65\x4F\x64\x62\x63","\x53\x54\x52\x49\x4E\x47","\x73\x71\x75\x61\x72\x65\x5F\x6F\x64\x62\x63","\x64\x65\x66\x69\x6E\x65"];_0xe9de[0];module[_0xe9de[1]]=function(_0x45c6x1,_0x45c6x2){var _0x45c6x3=_0x45c6x1[_0xe9de[5]](_0xe9de[2],{name:{type:_0x45c6x2[_0xe9de[3]],unique:true,validate:{notEmpty:true}},dsn:{type:_0x45c6x2[_0xe9de[3]]},description:_0x45c6x2[_0xe9de[3]]},{tableName:_0xe9de[4]});return _0x45c6x3;}; \ No newline at end of file diff --git a/server/models/square_project.js b/server/models/square_project.js index 9e68d35..211d0c5 100644 --- a/server/models/square_project.js +++ b/server/models/square_project.js @@ -1,28 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var SquareProject = sequelize.define('SquareProject', { - name: { - type: DataTypes.STRING, - unique: true, - validate: { - notEmpty: true - } - }, - description: DataTypes.STRING, - preproduction: { - type: DataTypes.TEXT, - length: 'long' - }, - production: { - type: DataTypes.TEXT, - length: 'long' - } - }, { - tableName: 'square_projects', - }); - - return SquareProject; - -}; +var _0xfb97=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x71\x75\x61\x72\x65\x50\x72\x6F\x6A\x65\x63\x74","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x6C\x6F\x6E\x67","\x73\x71\x75\x61\x72\x65\x5F\x70\x72\x6F\x6A\x65\x63\x74\x73","\x64\x65\x66\x69\x6E\x65"];_0xfb97[0];module[_0xfb97[1]]=function(_0x5c45x1,_0x5c45x2){var _0x5c45x3=_0x5c45x1[_0xfb97[7]](_0xfb97[2],{name:{type:_0x5c45x2[_0xfb97[3]],unique:true,validate:{notEmpty:true}},description:_0x5c45x2[_0xfb97[3]],preproduction:{type:_0x5c45x2[_0xfb97[4]],length:_0xfb97[5]},production:{type:_0x5c45x2[_0xfb97[4]],length:_0xfb97[5]}},{tableName:_0xfb97[6]});return _0x5c45x3;}; \ No newline at end of file diff --git a/server/models/sugarcrm_account.js b/server/models/sugarcrm_account.js index 318d984..e1d2b74 100644 --- a/server/models/sugarcrm_account.js +++ b/server/models/sugarcrm_account.js @@ -1,20 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('SugarcrmAccount', { - name: DataTypes.STRING, - description: DataTypes.STRING, - username: { - type: DataTypes.STRING - }, - remoteUri: DataTypes.STRING, - password: DataTypes.STRING - }, { - tableName: 'sugarcrm_accounts', - associate: function(models) { - models.SugarcrmAccount.hasMany(models.SugarcrmConfiguration, { - foreignKey: 'AccountId' - }); - } - }); -}; +var _0x3b26=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x75\x67\x61\x72\x63\x72\x6D\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x3b26[0];module[_0x3b26[1]]=function(_0xbda8x1,_0xbda8x2){return _0xbda8x1[_0x3b26[7]](_0x3b26[2],{name:_0xbda8x2[_0x3b26[3]],description:_0xbda8x2[_0x3b26[3]],username:{type:_0xbda8x2[_0x3b26[3]]},remoteUri:_0xbda8x2[_0x3b26[3]],password:_0xbda8x2[_0x3b26[3]]},{tableName:_0x3b26[4],associate:function(_0xbda8x3){_0xbda8x3[_0x3b26[2]][_0x3b26[6]](_0xbda8x3.SugarcrmConfiguration,{foreignKey:_0x3b26[5]})}})}; \ No newline at end of file diff --git a/server/models/sugarcrm_configuration.js b/server/models/sugarcrm_configuration.js index cae512a..d66f076 100644 --- a/server/models/sugarcrm_configuration.js +++ b/server/models/sugarcrm_configuration.js @@ -1,27 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('SugarcrmConfiguration', { - name: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'sugarcrm_configurations', - associate: function(models) { - models.SugarcrmConfiguration.belongsTo(models.SugarcrmAccount, { - foreignKey: 'AccountId' - }); - models.SugarcrmConfiguration.hasMany(models.SugarcrmField, { - as: 'Subject', - foreignKey: 'SubjectId' - }); - models.SugarcrmConfiguration.hasMany(models.SugarcrmField, { - as: 'Description', - foreignKey: 'DescriptionId' - }); - models.SugarcrmConfiguration.hasMany(models.SugarcrmField, { - as: 'Field', - foreignKey: 'FieldId' - }); - } - }); -}; +var _0x431f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x75\x67\x61\x72\x63\x72\x6D\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x53\x75\x62\x6A\x65\x63\x74","\x53\x75\x62\x6A\x65\x63\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x49\x64","\x46\x69\x65\x6C\x64","\x46\x69\x65\x6C\x64\x49\x64","\x64\x65\x66\x69\x6E\x65"];_0x431f[0];module[_0x431f[1]]=function(_0xbd83x1,_0xbd83x2){return _0xbd83x1[_0x431f[14]](_0x431f[2],{name:_0xbd83x2[_0x431f[3]],description:_0xbd83x2[_0x431f[3]]},{tableName:_0x431f[4],associate:function(_0xbd83x3){_0xbd83x3[_0x431f[2]][_0x431f[6]](_0xbd83x3.SugarcrmAccount,{foreignKey:_0x431f[5]});_0xbd83x3[_0x431f[2]][_0x431f[9]](_0xbd83x3.SugarcrmField,{as:_0x431f[7],foreignKey:_0x431f[8]});_0xbd83x3[_0x431f[2]][_0x431f[9]](_0xbd83x3.SugarcrmField,{as:_0x431f[10],foreignKey:_0x431f[11]});_0xbd83x3[_0x431f[2]][_0x431f[9]](_0xbd83x3.SugarcrmField,{as:_0x431f[12],foreignKey:_0x431f[13]});}})}; \ No newline at end of file diff --git a/server/models/sugarcrm_field.js b/server/models/sugarcrm_field.js index 7998058..46e7298 100644 --- a/server/models/sugarcrm_field.js +++ b/server/models/sugarcrm_field.js @@ -1,22 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - return sequelize.define('SugarcrmField', { - type: { - type: DataTypes.ENUM('string', 'variable', 'key_value'), - defaultValue: 'string' - }, - content: DataTypes.STRING, - key: DataTypes.STRING, - keyType: { - type: DataTypes.ENUM('string', 'variable') - }, - keyContent: DataTypes.STRING, - idField: DataTypes.STRING - }, { - tableName: 'sugarcrm_fields', - associate: function(models) { - models.SugarcrmField.belongsTo(models.Variable); - } - }); -}; +var _0x56c2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x53\x75\x67\x61\x72\x63\x72\x6D\x46\x69\x65\x6C\x64","\x73\x74\x72\x69\x6E\x67","\x76\x61\x72\x69\x61\x62\x6C\x65","\x6B\x65\x79\x5F\x76\x61\x6C\x75\x65","\x53\x54\x52\x49\x4E\x47","\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0x56c2[0];module[_0x56c2[1]]=function(_0x7f9ax1,_0x7f9ax2){return _0x7f9ax1[_0x56c2[9]](_0x56c2[2],{type:{type:_0x7f9ax2.ENUM(_0x56c2[3],_0x56c2[4],_0x56c2[5]),defaultValue:_0x56c2[3]},content:_0x7f9ax2[_0x56c2[6]],key:_0x7f9ax2[_0x56c2[6]],keyType:{type:_0x7f9ax2.ENUM(_0x56c2[3],_0x56c2[4])},keyContent:_0x7f9ax2[_0x56c2[6]],idField:_0x7f9ax2[_0x56c2[6]]},{tableName:_0x56c2[7],associate:function(_0x7f9ax3){_0x7f9ax3[_0x56c2[2]][_0x56c2[8]](_0x7f9ax3.Variable)}})}; \ No newline at end of file diff --git a/server/models/tag.js b/server/models/tag.js index 0c3135a..5628ee8 100644 --- a/server/models/tag.js +++ b/server/models/tag.js @@ -1,22 +1 @@ -/** - * tag Model - */ - -module.exports = function(sequelize, DataTypes) { - - var Tag = sequelize.define('Tag', { - name: { - type: DataTypes.STRING, - unique: true - } - }, { - tableName: 'tags', - // associate: function(models) { - // Tag.belongsToMany(models.Contact, { - // through: 'contact_tags' - // }); - // } - }); - - return Tag; -}; +var _0x449b=["\x65\x78\x70\x6F\x72\x74\x73","\x54\x61\x67","\x53\x54\x52\x49\x4E\x47","\x74\x61\x67\x73","\x64\x65\x66\x69\x6E\x65"];module[_0x449b[0]]=function(_0x3120x1,_0x3120x2){var _0x3120x3=_0x3120x1[_0x449b[4]](_0x449b[1],{name:{type:_0x3120x2[_0x449b[2]],unique:true}},{tableName:_0x449b[3]});return _0x3120x3;}; \ No newline at end of file diff --git a/server/models/team.js b/server/models/team.js index 8310113..01ca4dd 100644 --- a/server/models/team.js +++ b/server/models/team.js @@ -1,32 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var Team = sequelize.define('Team', { - name: { - type: DataTypes.STRING, - allowNull: false, - unique: true - }, - description: { - type: DataTypes.STRING - }, - defaultEntry: { - type: DataTypes.BOOLEAN, - defaultValue: 0 - } - }, { - tableName: 'teams', - associate: function(models) { - Team.belongsToMany(models.User, { - through: models.UserHasTeam - }); - } - }); - - return Team; -}; +var _0x585f=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x54\x65\x61\x6D","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x74\x65\x61\x6D\x73","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x585f[0]);module[_0x585f[1]]=function(_0xa714x2,_0xa714x3){var _0xa714x4=_0xa714x2[_0x585f[8]](_0x585f[2],{name:{type:_0xa714x3[_0x585f[3]],allowNull:false,unique:true},description:{type:_0xa714x3[_0x585f[3]]},defaultEntry:{type:_0xa714x3[_0x585f[4]],defaultValue:0}},{tableName:_0x585f[5],associate:function(_0xa714x5){_0xa714x4[_0x585f[7]](_0xa714x5.User,{through:_0xa714x5[_0x585f[6]]})}});return _0xa714x4;}; \ No newline at end of file diff --git a/server/models/trigger.js b/server/models/trigger.js index 10b80e7..e0fd0f5 100644 --- a/server/models/trigger.js +++ b/server/models/trigger.js @@ -1,24 +1 @@ -/** - * User Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var Trigger = sequelize.define('Trigger', { - name: DataTypes.STRING, - channel: DataTypes.STRING, - description: DataTypes.STRING, - conditions: DataTypes.TEXT, - actions: DataTypes.TEXT, - status: { - type: DataTypes.BOOLEAN, - defaultValue: false - } - }, { - tableName: 'triggers' - }); - - return Trigger; -}; +var _0x9df6=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x54\x72\x69\x67\x67\x65\x72","\x53\x54\x52\x49\x4E\x47","\x54\x45\x58\x54","\x42\x4F\x4F\x4C\x45\x41\x4E","\x74\x72\x69\x67\x67\x65\x72\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x9df6[0]);module[_0x9df6[1]]=function(_0x827cx2,_0x827cx3){var _0x827cx4=_0x827cx2[_0x9df6[7]](_0x9df6[2],{name:_0x827cx3[_0x9df6[3]],channel:_0x827cx3[_0x9df6[3]],description:_0x827cx3[_0x9df6[3]],conditions:_0x827cx3[_0x9df6[4]],actions:_0x827cx3[_0x9df6[4]],status:{type:_0x827cx3[_0x9df6[5]],defaultValue:false}},{tableName:_0x9df6[6]});return _0x827cx4;}; \ No newline at end of file diff --git a/server/models/trunk.js b/server/models/trunk.js index 5f3bf67..c2ce756 100644 --- a/server/models/trunk.js +++ b/server/models/trunk.js @@ -1,341 +1 @@ -'use strict'; - -var crypto = require('crypto'); -var md5 = require('md5'); -var _ = require('lodash'); - -module.exports = function(sequelize, DataTypes) { - var Trunk = sequelize.define('Trunk', { - name: { - type: DataTypes.STRING, - unique: true, - validate: { - notEmpty: true - }, - }, - port: { - type: DataTypes.INTEGER(5), - allowNull: true, - }, - defaultuser: { - type: DataTypes.STRING, - allowNull: true, - }, - host: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'dynamic' - }, - type: { - type: DataTypes.ENUM('friend', 'user', 'peer'), - allowNull: true, - defaultValue: 'friend' - }, - context: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'from-sip' - }, - permit: { - type: DataTypes.STRING, - allowNull: true, - }, - deny: { - type: DataTypes.STRING, - allowNull: true, - }, - secret: { - type: DataTypes.STRING, - allowNull: true, - }, - transport: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'udp' - }, - dtmfmode: { - type: DataTypes.ENUM('rfc2833', 'info', 'shortinfo', 'inband', - 'auto'), - allowNull: true, - defaultValue: 'rfc2833' - }, - directmedia: { - type: DataTypes.ENUM('yes', 'no', 'nonat', 'update'), - allowNull: true, - defaultValue: 'no' - }, - nat: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'force_rport,comedia' - }, - language: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'en' - }, - disallow: { - type: DataTypes.STRING, - allowNull: true, - }, - allow: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'alaw;ulaw;gsm' - }, - insecure: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'port,invite' - }, - trustrpid: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - progressinband: { - type: DataTypes.ENUM('yes', 'no', 'never'), - allowNull: true, - }, - promiscredir: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - useclientcode: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - accountcode: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - setvar: { - type: DataTypes.STRING, - allowNull: true, - }, - otherFields: { - type: DataTypes.STRING, - allowNull: true, - }, - callerid: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: '"" <>' - }, - amaflags: { - type: DataTypes.STRING, - allowNull: true, - }, - callcounter: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - busylevel: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - allowoverlap: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - allowsubscribe: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - maxcallbitrate: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - rfc2833compensate: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - t38pt_usertpsource: { - type: DataTypes.STRING, - allowNull: true, - }, - regexten: { - type: DataTypes.STRING, - allowNull: true, - }, - fromdomain: { - type: DataTypes.STRING, - allowNull: true, - }, - fromuser: { - type: DataTypes.STRING, - allowNull: true, - }, - qualify: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - defaultip: { - type: DataTypes.STRING, - allowNull: true, - }, - rtptimeout: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - rtpholdtimeout: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - sendrpid: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - outboundproxy: { - type: DataTypes.STRING, - allowNull: true, - }, - callbackextension: { - type: DataTypes.STRING, - allowNull: true, - }, - qualifyfreq: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - constantssrc: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - contactpermit: { - type: DataTypes.STRING, - allowNull: true, - }, - contactdeny: { - type: DataTypes.STRING, - allowNull: true, - }, - usereqphone: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - textsupport: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - faxdetect: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - buggymwi: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - auth: { - type: DataTypes.STRING, - allowNull: true, - }, - fullname: { - type: DataTypes.STRING, - allowNull: true, - }, - trunkname: { - type: DataTypes.STRING, - allowNull: true, - }, - cid_number: { - type: DataTypes.STRING, - allowNull: true, - }, - callingpres: { - type: DataTypes.ENUM('ALLOWED_NOT_SCREENED', - 'ALLOWED_PASSED_SCREEN', 'ALLOWED_FAILED_SCREEN', 'ALLOWED', - 'PROHIB_NOT_SCREENED', 'PROHIB_PASSED_SCREEN', - 'PROHIB_FAILED_SCREEN', 'PROHIB'), - allowNull: true, - }, - mohinterpret: { - type: DataTypes.STRING, - allowNull: true, - }, - mohsuggest: { - type: DataTypes.STRING, - allowNull: true, - }, - subscribemwi: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - vmexten: { - type: DataTypes.STRING, - allowNull: true, - }, - description: { - type: DataTypes.STRING, - allowNull: true, - }, - autoframing: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - limitonpeers: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - rtpkeepalive: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - "call-limit": { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: null - }, - g726nonstandard: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - ignoresdpversion: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - allowtransfer: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - dynamic: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - encryption: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - registry: { - type: DataTypes.STRING, - allowNull: true, - } - - }, { - tableName: 'trunks', - getterMethods: { - // profile: function() { - // return { - // name: this.name, - // role: this.role - // } - // } - }, - associate: function(models) { - // BELOGNS TO MANY - Trunk.hasMany(models.VoiceExtension, { - foreignKey: 'TrunkId' - }); - - - } - }); - - return Trunk; -} +var _0xf634=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x63\x72\x79\x70\x74\x6F","\x6D\x64\x35","\x6C\x6F\x64\x61\x73\x68","\x65\x78\x70\x6F\x72\x74\x73","\x54\x72\x75\x6E\x6B","\x53\x54\x52\x49\x4E\x47","\x64\x79\x6E\x61\x6D\x69\x63","\x66\x72\x69\x65\x6E\x64","\x75\x73\x65\x72","\x70\x65\x65\x72","\x66\x72\x6F\x6D\x2D\x73\x69\x70","\x75\x64\x70","\x72\x66\x63\x32\x38\x33\x33","\x69\x6E\x66\x6F","\x73\x68\x6F\x72\x74\x69\x6E\x66\x6F","\x69\x6E\x62\x61\x6E\x64","\x61\x75\x74\x6F","\x79\x65\x73","\x6E\x6F","\x6E\x6F\x6E\x61\x74","\x75\x70\x64\x61\x74\x65","\x66\x6F\x72\x63\x65\x5F\x72\x70\x6F\x72\x74\x2C\x63\x6F\x6D\x65\x64\x69\x61","\x65\x6E","\x61\x6C\x61\x77\x3B\x75\x6C\x61\x77\x3B\x67\x73\x6D","\x70\x6F\x72\x74\x2C\x69\x6E\x76\x69\x74\x65","\x6E\x65\x76\x65\x72","\x22\x22\x20\x3C\x3E","\x41\x4C\x4C\x4F\x57\x45\x44\x5F\x4E\x4F\x54\x5F\x53\x43\x52\x45\x45\x4E\x45\x44","\x41\x4C\x4C\x4F\x57\x45\x44\x5F\x50\x41\x53\x53\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x41\x4C\x4C\x4F\x57\x45\x44\x5F\x46\x41\x49\x4C\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x41\x4C\x4C\x4F\x57\x45\x44","\x50\x52\x4F\x48\x49\x42\x5F\x4E\x4F\x54\x5F\x53\x43\x52\x45\x45\x4E\x45\x44","\x50\x52\x4F\x48\x49\x42\x5F\x50\x41\x53\x53\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x50\x52\x4F\x48\x49\x42\x5F\x46\x41\x49\x4C\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x50\x52\x4F\x48\x49\x42","\x74\x72\x75\x6E\x6B\x73","\x54\x72\x75\x6E\x6B\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0xf634[0];var crypto=require(_0xf634[1]);var md5=require(_0xf634[2]);var _=require(_0xf634[3]);module[_0xf634[4]]=function(_0xc4e3x4,_0xc4e3x5){var _0xc4e3x6=_0xc4e3x4[_0xf634[39]](_0xf634[5],{name:{type:_0xc4e3x5[_0xf634[6]],unique:true,validate:{notEmpty:true}},port:{type:_0xc4e3x5.INTEGER(5),allowNull:true},defaultuser:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},host:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[7]},type:{type:_0xc4e3x5.ENUM(_0xf634[8],_0xf634[9],_0xf634[10]),allowNull:true,defaultValue:_0xf634[8]},context:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[11]},permit:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},deny:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},secret:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},transport:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[12]},dtmfmode:{type:_0xc4e3x5.ENUM(_0xf634[13],_0xf634[14],_0xf634[15],_0xf634[16],_0xf634[17]),allowNull:true,defaultValue:_0xf634[13]},directmedia:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19],_0xf634[20],_0xf634[21]),allowNull:true,defaultValue:_0xf634[19]},nat:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[22]},language:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[23]},disallow:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},allow:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[24]},insecure:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[25]},trustrpid:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true,defaultValue:_0xf634[19]},progressinband:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19],_0xf634[26]),allowNull:true},promiscredir:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},useclientcode:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},accountcode:{type:_0xc4e3x5.INTEGER(11),allowNull:true},setvar:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},otherFields:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},callerid:{type:_0xc4e3x5[_0xf634[6]],allowNull:true,defaultValue:_0xf634[27]},amaflags:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},callcounter:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true,defaultValue:_0xf634[18]},busylevel:{type:_0xc4e3x5.INTEGER(11),allowNull:true},allowoverlap:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},allowsubscribe:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},maxcallbitrate:{type:_0xc4e3x5.INTEGER(11),allowNull:true},rfc2833compensate:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},t38pt_usertpsource:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},regexten:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},fromdomain:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},fromuser:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},qualify:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true,defaultValue:_0xf634[18]},defaultip:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},rtptimeout:{type:_0xc4e3x5.INTEGER(11),allowNull:true},rtpholdtimeout:{type:_0xc4e3x5.INTEGER(11),allowNull:true},sendrpid:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true,defaultValue:_0xf634[19]},outboundproxy:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},callbackextension:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},qualifyfreq:{type:_0xc4e3x5.INTEGER(11),allowNull:true},constantssrc:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},contactpermit:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},contactdeny:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},usereqphone:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true,defaultValue:_0xf634[19]},textsupport:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},faxdetect:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},buggymwi:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},auth:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},fullname:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},trunkname:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},cid_number:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},callingpres:{type:_0xc4e3x5.ENUM(_0xf634[28],_0xf634[29],_0xf634[30],_0xf634[31],_0xf634[32],_0xf634[33],_0xf634[34],_0xf634[35]),allowNull:true},mohinterpret:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},mohsuggest:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},subscribemwi:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},vmexten:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},description:{type:_0xc4e3x5[_0xf634[6]],allowNull:true},autoframing:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},limitonpeers:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true,defaultValue:_0xf634[18]},rtpkeepalive:{type:_0xc4e3x5.INTEGER(11),allowNull:true},"\x63\x61\x6C\x6C\x2D\x6C\x69\x6D\x69\x74":{type:_0xc4e3x5.INTEGER(11),allowNull:true,defaultValue:null},g726nonstandard:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},ignoresdpversion:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},allowtransfer:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},dynamic:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true},encryption:{type:_0xc4e3x5.ENUM(_0xf634[18],_0xf634[19]),allowNull:true,defaultValue:_0xf634[19]},registry:{type:_0xc4e3x5[_0xf634[6]],allowNull:true}},{tableName:_0xf634[36],getterMethods:{},associate:function(_0xc4e3x7){_0xc4e3x6[_0xf634[38]](_0xc4e3x7.VoiceExtension,{foreignKey:_0xf634[37]})}});return _0xc4e3x6;}; \ No newline at end of file diff --git a/server/models/update.js b/server/models/update.js index ba48b5d..6d682dd 100644 --- a/server/models/update.js +++ b/server/models/update.js @@ -1,13 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Update = sequelize.define('Update', { - name: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'updates' - }); - - return Update; -}; +var _0x6e35=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x55\x70\x64\x61\x74\x65","\x53\x54\x52\x49\x4E\x47","\x75\x70\x64\x61\x74\x65\x73","\x64\x65\x66\x69\x6E\x65"];_0x6e35[0];module[_0x6e35[1]]=function(_0xe2e8x1,_0xe2e8x2){var _0xe2e8x3=_0xe2e8x1[_0x6e35[5]](_0x6e35[2],{name:_0xe2e8x2[_0x6e35[3]],description:_0xe2e8x2[_0x6e35[3]]},{tableName:_0x6e35[4]});return _0xe2e8x3;}; \ No newline at end of file diff --git a/server/models/upload.js b/server/models/upload.js index 1bf2723..6edca5f 100644 --- a/server/models/upload.js +++ b/server/models/upload.js @@ -1,38 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Upload = sequelize.define('Upload', { - name: DataTypes.STRING, - save_name: DataTypes.STRING, - display_name: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: '', - validate: { - notEmpty: { - msg: "The name cannot be empty!" - } // don't allow empty strings - } - }, - description: DataTypes.STRING, - original_path: DataTypes.STRING, - original_format: DataTypes.STRING, - original_duration: DataTypes.FLOAT, - original_sampleCount: DataTypes.BIGINT, - original_channelCount: DataTypes.INTEGER, - original_bitRate: DataTypes.BIGINT, - original_sampleRate: DataTypes.INTEGER, - converted_path: DataTypes.STRING, - converted_format: DataTypes.STRING, - converted_duration: DataTypes.FLOAT, - converted_sampleCount: DataTypes.BIGINT, - converted_channelCount: DataTypes.INTEGER, - converted_bitRate: DataTypes.BIGINT, - converted_sampleRate: DataTypes.INTEGER - }, { - tableName: 'upload' - }); - - return Upload; -}; +var _0x19eb=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x55\x70\x6C\x6F\x61\x64","\x53\x54\x52\x49\x4E\x47","","\x54\x68\x65\x20\x6E\x61\x6D\x65\x20\x63\x61\x6E\x6E\x6F\x74\x20\x62\x65\x20\x65\x6D\x70\x74\x79\x21","\x46\x4C\x4F\x41\x54","\x42\x49\x47\x49\x4E\x54","\x49\x4E\x54\x45\x47\x45\x52","\x75\x70\x6C\x6F\x61\x64","\x64\x65\x66\x69\x6E\x65"];_0x19eb[0];module[_0x19eb[1]]=function(_0xb96cx1,_0xb96cx2){var _0xb96cx3=_0xb96cx1[_0x19eb[10]](_0x19eb[2],{name:_0xb96cx2[_0x19eb[3]],save_name:_0xb96cx2[_0x19eb[3]],display_name:{type:_0xb96cx2[_0x19eb[3]],allowNull:false,defaultValue:_0x19eb[4],validate:{notEmpty:{msg:_0x19eb[5]}}},description:_0xb96cx2[_0x19eb[3]],original_path:_0xb96cx2[_0x19eb[3]],original_format:_0xb96cx2[_0x19eb[3]],original_duration:_0xb96cx2[_0x19eb[6]],original_sampleCount:_0xb96cx2[_0x19eb[7]],original_channelCount:_0xb96cx2[_0x19eb[8]],original_bitRate:_0xb96cx2[_0x19eb[7]],original_sampleRate:_0xb96cx2[_0x19eb[8]],converted_path:_0xb96cx2[_0x19eb[3]],converted_format:_0xb96cx2[_0x19eb[3]],converted_duration:_0xb96cx2[_0x19eb[6]],converted_sampleCount:_0xb96cx2[_0x19eb[7]],converted_channelCount:_0xb96cx2[_0x19eb[8]],converted_bitRate:_0xb96cx2[_0x19eb[7]],converted_sampleRate:_0xb96cx2[_0x19eb[8]]},{tableName:_0x19eb[9]});return _0xb96cx3;}; \ No newline at end of file diff --git a/server/models/user.js b/server/models/user.js index 5a6b165..189e984 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -1,579 +1 @@ -'use strict'; - -var crypto = require('crypto'); -var md5 = require('md5'); -var _ = require('lodash'); - -module.exports = function(sequelize, DataTypes) { - var User = sequelize.define('User', { - name: { - type: DataTypes.STRING, - unique: true, - validate: { - notEmpty: true - }, - set: function(name) { - this.setDataValue('name', name); - this.setDataValue('defaultuser', name); - } - }, - email: { - type: DataTypes.STRING, - unique: true, - set: function(email) { - if (email) { - this.setDataValue('email', email.toLowerCase()); - } - - }, - defaultValue: null - }, - role: { - type: DataTypes.ENUM('admin', 'user', 'agent', 'telephone') - }, - password: { - type: DataTypes.STRING, - allowNull: false, - validate: { - notEmpty: true - }, - set: function(password) { - this.salt = this.makeSalt(); - this.setDataValue('password', this.encryptPassword(password)); - this.setDataValue('md5secret', this.md5Password(this.name + ':asterisk:' + password)); - } - }, - provider: { - type: DataTypes.STRING, - defaultValue: 'local' - }, - internal: { - type: DataTypes.INTEGER(11), - unique: true, - set: function(internal) { - this.setDataValue('internal', internal); - this.setDataValue('accountcode', internal); - } - }, - salt: { - type: DataTypes.STRING - }, - phone: { - type: DataTypes.STRING - }, - mobile: { - type: DataTypes.STRING - }, - address: { - type: DataTypes.STRING - }, - zipcode: { - type: DataTypes.STRING - }, - userpic: { - type: DataTypes.STRING - }, - city: { - type: DataTypes.STRING - }, - country: { - type: DataTypes.STRING - }, - facebookUserId: { - type: DataTypes.INTEGER - }, - twitterUserId: { - type: DataTypes.INTEGER - }, - twitterKey: { - type: DataTypes.STRING - }, - twitterSecret: { - type: DataTypes.STRING - }, - github: { - type: DataTypes.STRING - }, - openId: { - type: DataTypes.STRING - }, - online: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - lastLoginAt: { - type: DataTypes.DATE - }, - ipaddr: { - type: DataTypes.STRING, - allowNull: true, - }, - port: { - type: DataTypes.INTEGER(5), - allowNull: true, - }, - regseconds: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - defaultuser: { - type: DataTypes.STRING, - allowNull: true, - }, - fullcontact: { - type: DataTypes.STRING, - allowNull: true, - }, - regserver: { - type: DataTypes.STRING, - allowNull: true, - }, - useragent: { - type: DataTypes.STRING, - allowNull: true, - }, - lastms: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - host: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'dynamic' - }, - type: { - type: DataTypes.ENUM('friend', 'user', 'peer'), - allowNull: true, - defaultValue: 'friend' - }, - context: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'from-sip' - }, - permit: { - type: DataTypes.STRING, - allowNull: true, - }, - deny: { - type: DataTypes.STRING, - allowNull: true, - }, - secret: { - type: DataTypes.STRING, - allowNull: true, - }, - md5secret: { - type: DataTypes.STRING, - allowNull: true - }, - remotesecret: { - type: DataTypes.STRING, - allowNull: true, - }, - transport: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'udp' - }, - dtmfmode: { - type: DataTypes.ENUM('rfc2833', 'info', 'shortinfo', 'inband', - 'auto'), - allowNull: true, - defaultValue: 'rfc2833' - }, - directmedia: { - type: DataTypes.ENUM('yes', 'no', 'nonat', 'update'), - allowNull: true, - defaultValue: 'no' - }, - nat: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'force_rport,comedia' - }, - callgroup: { - type: DataTypes.STRING, - allowNull: true, - }, - pickupgroup: { - type: DataTypes.STRING, - allowNull: true, - }, - language: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'en' - }, - disallow: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'all' - }, - allow: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'alaw;ulaw;gsm' - }, - insecure: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'port,invite' - }, - trustrpid: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - progressinband: { - type: DataTypes.ENUM('yes', 'no', 'never'), - allowNull: true, - }, - promiscredir: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - useclientcode: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - accountcode: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - setvar: { - type: DataTypes.STRING, - allowNull: true, - }, - callerid: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: '"" <>' - }, - amaflags: { - type: DataTypes.STRING, - allowNull: true, - }, - callcounter: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - busylevel: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - allowoverlap: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - allowsubscribe: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - videosupport: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - maxcallbitrate: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - rfc2833compensate: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - mailbox: { - type: DataTypes.STRING, - allowNull: true, - }, - "session-timers": { - type: DataTypes.ENUM('accept', 'refuse', 'originate'), - allowNull: true, - }, - "session-expires": { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - "session-minse": { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - "session-refresher": { - type: DataTypes.ENUM('uac', 'uas'), - allowNull: true, - }, - t38pt_usertpsource: { - type: DataTypes.STRING, - allowNull: true, - }, - regexten: { - type: DataTypes.STRING, - allowNull: true, - }, - fromdomain: { - type: DataTypes.STRING, - allowNull: true, - }, - fromuser: { - type: DataTypes.STRING, - allowNull: true, - }, - qualify: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - defaultip: { - type: DataTypes.STRING, - allowNull: true, - }, - rtptimeout: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - rtpholdtimeout: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - sendrpid: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - outboundproxy: { - type: DataTypes.STRING, - allowNull: true, - }, - callbackextension: { - type: DataTypes.STRING, - allowNull: true, - }, - timert1: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - timerb: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - qualifyfreq: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - constantssrc: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - contactpermit: { - type: DataTypes.STRING, - allowNull: true, - }, - contactdeny: { - type: DataTypes.STRING, - allowNull: true, - }, - usereqphone: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - textsupport: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - faxdetect: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - buggymwi: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - auth: { - type: DataTypes.STRING, - allowNull: true, - }, - fullname: { - type: DataTypes.STRING, - allowNull: true, - }, - trunkname: { - type: DataTypes.STRING, - allowNull: true, - }, - cid_number: { - type: DataTypes.STRING, - allowNull: true, - }, - callingpres: { - type: DataTypes.ENUM('ALLOWED_NOT_SCREENED', - 'ALLOWED_PASSED_SCREEN', 'ALLOWED_FAILED_SCREEN', 'ALLOWED', - 'PROHIB_NOT_SCREENED', 'PROHIB_PASSED_SCREEN', - 'PROHIB_FAILED_SCREEN', 'PROHIB'), - allowNull: true, - }, - mohinterpret: { - type: DataTypes.STRING, - allowNull: true, - }, - mohsuggest: { - type: DataTypes.STRING, - allowNull: true, - }, - parkinglot: { - type: DataTypes.STRING, - allowNull: true, - }, - hasvoicemail: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - subscribemwi: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - vmexten: { - type: DataTypes.STRING, - allowNull: true, - }, - description: { - type: DataTypes.STRING, - allowNull: true, - }, - autoframing: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - limitonpeers: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - rtpkeepalive: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - "call-limit": { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: null - }, - g726nonstandard: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - ignoresdpversion: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - allowtransfer: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - dynamic: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - encryption: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - registry: { - type: DataTypes.STRING, - allowNull: true, - } - - }, { - tableName: 'users', - getterMethods: { - // profile: function() { - // return { - // name: this.name, - // role: this.role - // } - // } - }, - instanceMethods: { - /** - * Authenticate - check if the passwords are the same - * - * @param {String} plainText - * {function} callBack - * @api public - */ - authenticate: function(plainText) { - return this.encryptPassword(plainText) === this.password; - }, - /** - * Make salt - * - * @return {String} - * @api public - */ - makeSalt: function() { - return crypto.randomBytes(16).toString('base64'); - }, - /** - * Encrypt password - * - * @param {String} password - * @return {String} - * @api public - */ - encryptPassword: function(password) { - if (!password || !this.salt) return ''; - var salt = new Buffer(this.salt, 'base64'); - return crypto.pbkdf2Sync(password, salt, 10000, 64).toString( - 'base64'); - }, - /** - * md5 password - * - * @param {String} password - * @return {String} - * @api public - */ - md5Password: function(password) { - if (!password) return ''; - return md5(password); - } - }, - associate: function(models) { - // BELOGNS TO MANY - User.hasMany(models.ChatMessage); - User.hasMany(models.Contact); - User.belongsToMany(models.Module, { - through: 'user_has_modules' - }); - User.belongsToMany(models.Channel, { - through: 'user_has_channels' - }); - User.belongsToMany(models.Team, { - through: models.UserHasTeam - }); - User.belongsToMany(models.ChatRoom, { - through: models.UserHasChatRoom - }); - User.belongsToMany(models.MailQueue, { - through: models.UserHasMailQueue - }); - User.belongsToMany(models.ChatQueue, { - through: models.UserHasChatQueue - }); - User.belongsToMany(models.VoiceQueue, { - through: models.UserHasVoiceQueue - }); - User.hasMany(models.VoiceExtension, { - foreignKey: 'UserId', - as: 'UserExtensions', - onDelete: 'cascade' - }); - - - } - }); - - return User; -} +var _0x6d91=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x63\x72\x79\x70\x74\x6F","\x6D\x64\x35","\x6C\x6F\x64\x61\x73\x68","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72","\x53\x54\x52\x49\x4E\x47","\x6E\x61\x6D\x65","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x64\x65\x66\x61\x75\x6C\x74\x75\x73\x65\x72","\x65\x6D\x61\x69\x6C","\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x61\x64\x6D\x69\x6E","\x75\x73\x65\x72","\x61\x67\x65\x6E\x74","\x74\x65\x6C\x65\x70\x68\x6F\x6E\x65","\x73\x61\x6C\x74","\x6D\x61\x6B\x65\x53\x61\x6C\x74","\x70\x61\x73\x73\x77\x6F\x72\x64","\x65\x6E\x63\x72\x79\x70\x74\x50\x61\x73\x73\x77\x6F\x72\x64","\x6D\x64\x35\x73\x65\x63\x72\x65\x74","\x3A\x61\x73\x74\x65\x72\x69\x73\x6B\x3A","\x6D\x64\x35\x50\x61\x73\x73\x77\x6F\x72\x64","\x6C\x6F\x63\x61\x6C","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x61\x63\x63\x6F\x75\x6E\x74\x63\x6F\x64\x65","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x44\x41\x54\x45","\x64\x79\x6E\x61\x6D\x69\x63","\x66\x72\x69\x65\x6E\x64","\x70\x65\x65\x72","\x66\x72\x6F\x6D\x2D\x73\x69\x70","\x75\x64\x70","\x72\x66\x63\x32\x38\x33\x33","\x69\x6E\x66\x6F","\x73\x68\x6F\x72\x74\x69\x6E\x66\x6F","\x69\x6E\x62\x61\x6E\x64","\x61\x75\x74\x6F","\x79\x65\x73","\x6E\x6F","\x6E\x6F\x6E\x61\x74","\x75\x70\x64\x61\x74\x65","\x66\x6F\x72\x63\x65\x5F\x72\x70\x6F\x72\x74\x2C\x63\x6F\x6D\x65\x64\x69\x61","\x65\x6E","\x61\x6C\x6C","\x61\x6C\x61\x77\x3B\x75\x6C\x61\x77\x3B\x67\x73\x6D","\x70\x6F\x72\x74\x2C\x69\x6E\x76\x69\x74\x65","\x6E\x65\x76\x65\x72","\x22\x22\x20\x3C\x3E","\x61\x63\x63\x65\x70\x74","\x72\x65\x66\x75\x73\x65","\x6F\x72\x69\x67\x69\x6E\x61\x74\x65","\x75\x61\x63","\x75\x61\x73","\x41\x4C\x4C\x4F\x57\x45\x44\x5F\x4E\x4F\x54\x5F\x53\x43\x52\x45\x45\x4E\x45\x44","\x41\x4C\x4C\x4F\x57\x45\x44\x5F\x50\x41\x53\x53\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x41\x4C\x4C\x4F\x57\x45\x44\x5F\x46\x41\x49\x4C\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x41\x4C\x4C\x4F\x57\x45\x44","\x50\x52\x4F\x48\x49\x42\x5F\x4E\x4F\x54\x5F\x53\x43\x52\x45\x45\x4E\x45\x44","\x50\x52\x4F\x48\x49\x42\x5F\x50\x41\x53\x53\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x50\x52\x4F\x48\x49\x42\x5F\x46\x41\x49\x4C\x45\x44\x5F\x53\x43\x52\x45\x45\x4E","\x50\x52\x4F\x48\x49\x42","\x75\x73\x65\x72\x73","\x62\x61\x73\x65\x36\x34","\x72\x61\x6E\x64\x6F\x6D\x42\x79\x74\x65\x73","","\x70\x62\x6B\x64\x66\x32\x53\x79\x6E\x63","\x68\x61\x73\x4D\x61\x6E\x79","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x6F\x64\x75\x6C\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x73","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x55\x73\x65\x72\x48\x61\x73\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x55\x73\x65\x72\x49\x64","\x55\x73\x65\x72\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x63\x61\x73\x63\x61\x64\x65","\x64\x65\x66\x69\x6E\x65"];_0x6d91[0];var crypto=require(_0x6d91[1]);var md5=require(_0x6d91[2]);var _=require(_0x6d91[3]);module[_0x6d91[4]]=function(_0xab3dx4,_0xab3dx5){var _0xab3dx6=_0xab3dx4[_0x6d91[80]](_0x6d91[5],{name:{type:_0xab3dx5[_0x6d91[6]],unique:true,validate:{notEmpty:true},set:function(_0xab3dx7){this[_0x6d91[8]](_0x6d91[7],_0xab3dx7);this[_0x6d91[8]](_0x6d91[9],_0xab3dx7);}},email:{type:_0xab3dx5[_0x6d91[6]],unique:true,set:function(_0xab3dx8){if(_0xab3dx8){this[_0x6d91[8]](_0x6d91[10],_0xab3dx8[_0x6d91[11]]())}},defaultValue:null},role:{type:_0xab3dx5.ENUM(_0x6d91[12],_0x6d91[13],_0x6d91[14],_0x6d91[15])},password:{type:_0xab3dx5[_0x6d91[6]],allowNull:false,validate:{notEmpty:true},set:function(_0xab3dx9){this[_0x6d91[16]]=this[_0x6d91[17]]();this[_0x6d91[8]](_0x6d91[18],this[_0x6d91[19]](_0xab3dx9));this[_0x6d91[8]](_0x6d91[20],this[_0x6d91[22]](this[_0x6d91[7]]+_0x6d91[21]+_0xab3dx9));}},provider:{type:_0xab3dx5[_0x6d91[6]],defaultValue:_0x6d91[23]},internal:{type:_0xab3dx5.INTEGER(11),unique:true,set:function(_0xab3dxa){this[_0x6d91[8]](_0x6d91[24],_0xab3dxa);this[_0x6d91[8]](_0x6d91[25],_0xab3dxa);}},salt:{type:_0xab3dx5[_0x6d91[6]]},phone:{type:_0xab3dx5[_0x6d91[6]]},mobile:{type:_0xab3dx5[_0x6d91[6]]},address:{type:_0xab3dx5[_0x6d91[6]]},zipcode:{type:_0xab3dx5[_0x6d91[6]]},userpic:{type:_0xab3dx5[_0x6d91[6]]},city:{type:_0xab3dx5[_0x6d91[6]]},country:{type:_0xab3dx5[_0x6d91[6]]},facebookUserId:{type:_0xab3dx5[_0x6d91[26]]},twitterUserId:{type:_0xab3dx5[_0x6d91[26]]},twitterKey:{type:_0xab3dx5[_0x6d91[6]]},twitterSecret:{type:_0xab3dx5[_0x6d91[6]]},github:{type:_0xab3dx5[_0x6d91[6]]},openId:{type:_0xab3dx5[_0x6d91[6]]},online:{type:_0xab3dx5[_0x6d91[27]],defaultValue:false},lastLoginAt:{type:_0xab3dx5[_0x6d91[28]]},ipaddr:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},port:{type:_0xab3dx5.INTEGER(5),allowNull:true},regseconds:{type:_0xab3dx5.INTEGER(11),allowNull:true},defaultuser:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},fullcontact:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},regserver:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},useragent:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},lastms:{type:_0xab3dx5.INTEGER(11),allowNull:true},host:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[29]},type:{type:_0xab3dx5.ENUM(_0x6d91[30],_0x6d91[13],_0x6d91[31]),allowNull:true,defaultValue:_0x6d91[30]},context:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[32]},permit:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},deny:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},secret:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},md5secret:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},remotesecret:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},transport:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[33]},dtmfmode:{type:_0xab3dx5.ENUM(_0x6d91[34],_0x6d91[35],_0x6d91[36],_0x6d91[37],_0x6d91[38]),allowNull:true,defaultValue:_0x6d91[34]},directmedia:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40],_0x6d91[41],_0x6d91[42]),allowNull:true,defaultValue:_0x6d91[40]},nat:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[43]},callgroup:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},pickupgroup:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},language:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[44]},disallow:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[45]},allow:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[46]},insecure:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[47]},trustrpid:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true,defaultValue:_0x6d91[40]},progressinband:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40],_0x6d91[48]),allowNull:true},promiscredir:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},useclientcode:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},accountcode:{type:_0xab3dx5.INTEGER(11),allowNull:true},setvar:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},callerid:{type:_0xab3dx5[_0x6d91[6]],allowNull:true,defaultValue:_0x6d91[49]},amaflags:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},callcounter:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true,defaultValue:_0x6d91[39]},busylevel:{type:_0xab3dx5.INTEGER(11),allowNull:true},allowoverlap:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},allowsubscribe:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},videosupport:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},maxcallbitrate:{type:_0xab3dx5.INTEGER(11),allowNull:true},rfc2833compensate:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},mailbox:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},"\x73\x65\x73\x73\x69\x6F\x6E\x2D\x74\x69\x6D\x65\x72\x73":{type:_0xab3dx5.ENUM(_0x6d91[50],_0x6d91[51],_0x6d91[52]),allowNull:true},"\x73\x65\x73\x73\x69\x6F\x6E\x2D\x65\x78\x70\x69\x72\x65\x73":{type:_0xab3dx5.INTEGER(11),allowNull:true},"\x73\x65\x73\x73\x69\x6F\x6E\x2D\x6D\x69\x6E\x73\x65":{type:_0xab3dx5.INTEGER(11),allowNull:true},"\x73\x65\x73\x73\x69\x6F\x6E\x2D\x72\x65\x66\x72\x65\x73\x68\x65\x72":{type:_0xab3dx5.ENUM(_0x6d91[53],_0x6d91[54]),allowNull:true},t38pt_usertpsource:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},regexten:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},fromdomain:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},fromuser:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},qualify:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true,defaultValue:_0x6d91[39]},defaultip:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},rtptimeout:{type:_0xab3dx5.INTEGER(11),allowNull:true},rtpholdtimeout:{type:_0xab3dx5.INTEGER(11),allowNull:true},sendrpid:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true,defaultValue:_0x6d91[40]},outboundproxy:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},callbackextension:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},timert1:{type:_0xab3dx5.INTEGER(11),allowNull:true},timerb:{type:_0xab3dx5.INTEGER(11),allowNull:true},qualifyfreq:{type:_0xab3dx5.INTEGER(11),allowNull:true},constantssrc:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},contactpermit:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},contactdeny:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},usereqphone:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true,defaultValue:_0x6d91[40]},textsupport:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},faxdetect:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},buggymwi:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},auth:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},fullname:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},trunkname:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},cid_number:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},callingpres:{type:_0xab3dx5.ENUM(_0x6d91[55],_0x6d91[56],_0x6d91[57],_0x6d91[58],_0x6d91[59],_0x6d91[60],_0x6d91[61],_0x6d91[62]),allowNull:true},mohinterpret:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},mohsuggest:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},parkinglot:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},hasvoicemail:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},subscribemwi:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},vmexten:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},description:{type:_0xab3dx5[_0x6d91[6]],allowNull:true},autoframing:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},limitonpeers:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true,defaultValue:_0x6d91[39]},rtpkeepalive:{type:_0xab3dx5.INTEGER(11),allowNull:true},"\x63\x61\x6C\x6C\x2D\x6C\x69\x6D\x69\x74":{type:_0xab3dx5.INTEGER(11),allowNull:true,defaultValue:null},g726nonstandard:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},ignoresdpversion:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},allowtransfer:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},dynamic:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true},encryption:{type:_0xab3dx5.ENUM(_0x6d91[39],_0x6d91[40]),allowNull:true,defaultValue:_0x6d91[40]},registry:{type:_0xab3dx5[_0x6d91[6]],allowNull:true}},{tableName:_0x6d91[63],getterMethods:{},instanceMethods:{authenticate:function(_0xab3dxb){return this[_0x6d91[19]](_0xab3dxb)===this[_0x6d91[18]]},makeSalt:function(){return crypto[_0x6d91[65]](16).toString(_0x6d91[64])},encryptPassword:function(_0xab3dx9){if(!_0xab3dx9||!this[_0x6d91[16]]){return _0x6d91[66]};var _0xab3dxc= new Buffer(this[_0x6d91[16]],_0x6d91[64]);return crypto[_0x6d91[67]](_0xab3dx9,_0xab3dxc,10000,64).toString(_0x6d91[64]);},md5Password:function(_0xab3dx9){if(!_0xab3dx9){return _0x6d91[66]};return md5(_0xab3dx9);}},associate:function(_0xab3dxd){_0xab3dx6[_0x6d91[68]](_0xab3dxd.ChatMessage);_0xab3dx6[_0x6d91[68]](_0xab3dxd.Contact);_0xab3dx6[_0x6d91[70]](_0xab3dxd.Module,{through:_0x6d91[69]});_0xab3dx6[_0x6d91[70]](_0xab3dxd.Channel,{through:_0x6d91[71]});_0xab3dx6[_0x6d91[70]](_0xab3dxd.Team,{through:_0xab3dxd[_0x6d91[72]]});_0xab3dx6[_0x6d91[70]](_0xab3dxd.ChatRoom,{through:_0xab3dxd[_0x6d91[73]]});_0xab3dx6[_0x6d91[70]](_0xab3dxd.MailQueue,{through:_0xab3dxd[_0x6d91[74]]});_0xab3dx6[_0x6d91[70]](_0xab3dxd.ChatQueue,{through:_0xab3dxd[_0x6d91[75]]});_0xab3dx6[_0x6d91[70]](_0xab3dxd.VoiceQueue,{through:_0xab3dxd[_0x6d91[76]]});_0xab3dx6[_0x6d91[68]](_0xab3dxd.VoiceExtension,{foreignKey:_0x6d91[77],as:_0x6d91[78],onDelete:_0x6d91[79]});}});return _0xab3dx6;}; \ No newline at end of file diff --git a/server/models/user_has_chat_queue.js b/server/models/user_has_chat_queue.js index 30eb3c6..dda90ad 100644 --- a/server/models/user_has_chat_queue.js +++ b/server/models/user_has_chat_queue.js @@ -1,14 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var UserHasChatQueue = sequelize.define('UserHasChatQueue', {}, { - tableName: 'user_has_chat_queues' - }); - - return UserHasChatQueue; -}; +var _0x2f06=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x2f06[0]);module[_0x2f06[1]]=function(_0x8662x2,_0x8662x3){var _0x8662x4=_0x8662x2[_0x2f06[4]](_0x2f06[2],{},{tableName:_0x2f06[3]});return _0x8662x4;}; \ No newline at end of file diff --git a/server/models/user_has_chat_room.js b/server/models/user_has_chat_room.js index 277debd..f1eaedb 100644 --- a/server/models/user_has_chat_room.js +++ b/server/models/user_has_chat_room.js @@ -1,19 +1 @@ - -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var UserHasChatRoom = sequelize.define('UserHasChatRoom', { - LastMessageRead: { type: DataTypes.INTEGER, defaultValue: 0 }, - Hide: { type: DataTypes.BOOLEAN, defaultValue: false } - }, { - tableName: 'user_has_chat_rooms' - } - ); - - return UserHasChatRoom; -}; +var _0x167b=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x49\x4E\x54\x45\x47\x45\x52","\x42\x4F\x4F\x4C\x45\x41\x4E","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x167b[0]);module[_0x167b[1]]=function(_0xcb79x2,_0xcb79x3){var _0xcb79x4=_0xcb79x2[_0x167b[6]](_0x167b[2],{LastMessageRead:{type:_0xcb79x3[_0x167b[3]],defaultValue:0},Hide:{type:_0xcb79x3[_0x167b[4]],defaultValue:false}},{tableName:_0x167b[5]});return _0xcb79x4;}; \ No newline at end of file diff --git a/server/models/user_has_fax_queue.js b/server/models/user_has_fax_queue.js index 91ec6eb..dda0dc8 100644 --- a/server/models/user_has_fax_queue.js +++ b/server/models/user_has_fax_queue.js @@ -1,14 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var UserHasFaxQueue = sequelize.define('UserHasFaxQueue', {}, { - tableName: 'user_has_fax_queues' - }); - - return UserHasFaxQueue; -}; +var _0x3516=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x46\x61\x78\x51\x75\x65\x75\x65","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x3516[0]);module[_0x3516[1]]=function(_0xa2a3x2,_0xa2a3x3){var _0xa2a3x4=_0xa2a3x2[_0x3516[4]](_0x3516[2],{},{tableName:_0x3516[3]});return _0xa2a3x4;}; \ No newline at end of file diff --git a/server/models/user_has_mail_queue.js b/server/models/user_has_mail_queue.js index a4339b9..3e47fd8 100644 --- a/server/models/user_has_mail_queue.js +++ b/server/models/user_has_mail_queue.js @@ -1,14 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var UserHasMailQueue = sequelize.define('UserHasMailQueue', {}, { - tableName: 'user_has_mail_queues' - }); - - return UserHasMailQueue; -}; +var _0x1b02=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x1b02[0]);module[_0x1b02[1]]=function(_0x86b6x2,_0x86b6x3){var _0x86b6x4=_0x86b6x2[_0x1b02[4]](_0x1b02[2],{},{tableName:_0x1b02[3]});return _0x86b6x4;}; \ No newline at end of file diff --git a/server/models/user_has_team.js b/server/models/user_has_team.js index a0c38b6..04cffb6 100644 --- a/server/models/user_has_team.js +++ b/server/models/user_has_team.js @@ -1,14 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - - var UserHasTeam = sequelize.define('UserHasTeam', {}, { - tableName: 'user_has_teams' - }); - - return UserHasTeam; -}; +var _0xead9=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xead9[0]);module[_0xead9[1]]=function(_0xc99dx2,_0xc99dx3){var _0xc99dx4=_0xc99dx2[_0xead9[4]](_0xead9[2],{},{tableName:_0xead9[3]});return _0xc99dx4;}; \ No newline at end of file diff --git a/server/models/user_has_voice_queue.js b/server/models/user_has_voice_queue.js index 1ab8dfe..04e2ea1 100644 --- a/server/models/user_has_voice_queue.js +++ b/server/models/user_has_voice_queue.js @@ -1,116 +1 @@ -/** - * Chat Website Model - */ - -var crypto = require('crypto'); - -module.exports = function(sequelize, DataTypes) { - var UserHasVoiceQueue = sequelize.define('UserHasVoiceQueue', { - logged: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - loggedAt: { - type: DataTypes.DATE - }, - ringinuse: { - type: DataTypes.BOOLEAN - }, - penalty: { - type: DataTypes.INTEGER - }, - stateinterface: { - type: DataTypes.STRING - }, - queue: { - type: DataTypes.STRING - }, - membername: { - type: DataTypes.STRING - }, - interface: { - type: DataTypes.STRING - }, - membership: { - type: DataTypes.STRING - }, - callstaken: { - type: DataTypes.INTEGER - }, - lastcall: { - type: DataTypes.DATE, - set: function(lastcall) { - if (lastcall === '0') { - this.setDataValue('lastcall', null); - } else { - this.setDataValue('lastcall', sequelize.fn('FROM_UNIXTIME', lastcall, '%Y-%m-%d %H:%i:%s')); - } - } - }, - status: { - type: DataTypes.INTEGER, - set: function(status) { - this.setDataValue('status', status); - var detail = 'UNKNOWN'; - switch (status) { - case '0': - detail = 'UNKNOWN'; - break; - case '1': - detail = 'NOT_INUSE'; - break; - case '2': - detail = 'INUSE'; - break; - case '3': - detail = 'BUSY'; - break; - case '4': - detail = 'INVALID'; - break; - case '5': - detail = 'UNAVAILABLE'; - break; - case '6': - detail = 'RINGING'; - break; - case '7': - detail = 'RINGINUSE'; - break; - case '8': - detail = 'ONHOLD'; - break; - } - this.setDataValue('statusdesc', detail); - this.setDataValue('statusAt', sequelize.fn('NOW')) - }, - }, - statusdesc: { - type: DataTypes.STRING - }, - statusAt: { - type: DataTypes.DATE - }, - paused: { - type: DataTypes.BOOLEAN, - defaultValue: false, - set: function(paused) { - this.setDataValue('paused', parseInt(paused, 10) ? true : false); - } - }, - pausedAt: { - type: DataTypes.DATE - }, - reason: { - type: DataTypes.STRING - } - }, { - tableName: 'user_has_voice_queues', - indexes: [{ - name: 'membername', - fields: ['membername'] - }] - }); - - return UserHasVoiceQueue; -}; +var _0x7fb6=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x42\x4F\x4F\x4C\x45\x41\x4E","\x44\x41\x54\x45","\x49\x4E\x54\x45\x47\x45\x52","\x53\x54\x52\x49\x4E\x47","\x30","\x6C\x61\x73\x74\x63\x61\x6C\x6C","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x46\x52\x4F\x4D\x5F\x55\x4E\x49\x58\x54\x49\x4D\x45","\x25\x59\x2D\x25\x6D\x2D\x25\x64\x20\x25\x48\x3A\x25\x69\x3A\x25\x73","\x66\x6E","\x73\x74\x61\x74\x75\x73","\x55\x4E\x4B\x4E\x4F\x57\x4E","\x4E\x4F\x54\x5F\x49\x4E\x55\x53\x45","\x31","\x49\x4E\x55\x53\x45","\x32","\x42\x55\x53\x59","\x33","\x49\x4E\x56\x41\x4C\x49\x44","\x34","\x55\x4E\x41\x56\x41\x49\x4C\x41\x42\x4C\x45","\x35","\x52\x49\x4E\x47\x49\x4E\x47","\x36","\x52\x49\x4E\x47\x49\x4E\x55\x53\x45","\x37","\x4F\x4E\x48\x4F\x4C\x44","\x38","\x73\x74\x61\x74\x75\x73\x64\x65\x73\x63","\x73\x74\x61\x74\x75\x73\x41\x74","\x4E\x4F\x57","\x70\x61\x75\x73\x65\x64","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x73","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x7fb6[0]);module[_0x7fb6[1]]=function(_0xc82ex2,_0xc82ex3){var _0xc82ex4=_0xc82ex2[_0x7fb6[37]](_0x7fb6[2],{logged:{type:_0xc82ex3[_0x7fb6[3]],defaultValue:false},loggedAt:{type:_0xc82ex3[_0x7fb6[4]]},ringinuse:{type:_0xc82ex3[_0x7fb6[3]]},penalty:{type:_0xc82ex3[_0x7fb6[5]]},stateinterface:{type:_0xc82ex3[_0x7fb6[6]]},queue:{type:_0xc82ex3[_0x7fb6[6]]},membername:{type:_0xc82ex3[_0x7fb6[6]]},interface:{type:_0xc82ex3[_0x7fb6[6]]},membership:{type:_0xc82ex3[_0x7fb6[6]]},callstaken:{type:_0xc82ex3[_0x7fb6[5]]},lastcall:{type:_0xc82ex3[_0x7fb6[4]],set:function(_0xc82ex5){if(_0xc82ex5===_0x7fb6[7]){this[_0x7fb6[9]](_0x7fb6[8],null)}else {this[_0x7fb6[9]](_0x7fb6[8],_0xc82ex2[_0x7fb6[12]](_0x7fb6[10],_0xc82ex5,_0x7fb6[11]))}}},status:{type:_0xc82ex3[_0x7fb6[5]],set:function(_0xc82ex6){this[_0x7fb6[9]](_0x7fb6[13],_0xc82ex6);var _0xc82ex7=_0x7fb6[14];switch(_0xc82ex6){case _0x7fb6[7]:_0xc82ex7=_0x7fb6[14];break ;;case _0x7fb6[16]:_0xc82ex7=_0x7fb6[15];break ;;case _0x7fb6[18]:_0xc82ex7=_0x7fb6[17];break ;;case _0x7fb6[20]:_0xc82ex7=_0x7fb6[19];break ;;case _0x7fb6[22]:_0xc82ex7=_0x7fb6[21];break ;;case _0x7fb6[24]:_0xc82ex7=_0x7fb6[23];break ;;case _0x7fb6[26]:_0xc82ex7=_0x7fb6[25];break ;;case _0x7fb6[28]:_0xc82ex7=_0x7fb6[27];break ;;case _0x7fb6[30]:_0xc82ex7=_0x7fb6[29];break ;;};this[_0x7fb6[9]](_0x7fb6[31],_0xc82ex7);this[_0x7fb6[9]](_0x7fb6[32],_0xc82ex2[_0x7fb6[12]](_0x7fb6[33]));}},statusdesc:{type:_0xc82ex3[_0x7fb6[6]]},statusAt:{type:_0xc82ex3[_0x7fb6[4]]},paused:{type:_0xc82ex3[_0x7fb6[3]],defaultValue:false,set:function(_0xc82ex8){this[_0x7fb6[9]](_0x7fb6[34],parseInt(_0xc82ex8,10)?true:false)}},pausedAt:{type:_0xc82ex3[_0x7fb6[4]]},reason:{type:_0xc82ex3[_0x7fb6[6]]}},{tableName:_0x7fb6[35],indexes:[{name:_0x7fb6[36],fields:[_0x7fb6[36]]}]});return _0xc82ex4;}; \ No newline at end of file diff --git a/server/models/variable.js b/server/models/variable.js index 0786055..45c8802 100644 --- a/server/models/variable.js +++ b/server/models/variable.js @@ -1,27 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var Variable = sequelize.define('Variable', { - name: { - type: DataTypes.STRING, - unique: true, - validate: { - notEmpty: true - }, - }, - description: DataTypes.STRING - }, { - tableName: 'variables', - associate: function(models) { - Variable.hasMany(models.ZendeskField); - Variable.hasMany(models.DeskField); - Variable.hasMany(models.SalesforceField); - Variable.hasMany(models.FreshdeskField); - Variable.hasMany(models.SugarcrmField); - } - }); - - return Variable; - -}; +var _0x9caf=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x56\x61\x72\x69\x61\x62\x6C\x65","\x53\x54\x52\x49\x4E\x47","\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x9caf[0];module[_0x9caf[1]]=function(_0x7525x1,_0x7525x2){var _0x7525x3=_0x7525x1[_0x9caf[6]](_0x9caf[2],{name:{type:_0x7525x2[_0x9caf[3]],unique:true,validate:{notEmpty:true}},description:_0x7525x2[_0x9caf[3]]},{tableName:_0x9caf[4],associate:function(_0x7525x4){_0x7525x3[_0x9caf[5]](_0x7525x4.ZendeskField);_0x7525x3[_0x9caf[5]](_0x7525x4.DeskField);_0x7525x3[_0x9caf[5]](_0x7525x4.SalesforceField);_0x7525x3[_0x9caf[5]](_0x7525x4.FreshdeskField);_0x7525x3[_0x9caf[5]](_0x7525x4.SugarcrmField);}});return _0x7525x3;}; \ No newline at end of file diff --git a/server/models/voice_context.js b/server/models/voice_context.js index 56d2691..84fe72d 100644 --- a/server/models/voice_context.js +++ b/server/models/voice_context.js @@ -1,25 +1 @@ -/** - * Context Model - */ - -module.exports = function(sequelize, DataTypes) { - - var VoiceContext = sequelize.define('VoiceContext', { - name: { - type: DataTypes.STRING, - unique: true - }, - description: { - type: DataTypes.STRING, - allowNull: true, - }, - defaultEntry: { - type: DataTypes.BOOLEAN, - defaultValue: 0 - } - }, { - tableName: 'voice_contexts' - }); - - return VoiceContext; -}; +var _0x81dd=["\x65\x78\x70\x6F\x72\x74\x73","\x56\x6F\x69\x63\x65\x43\x6F\x6E\x74\x65\x78\x74","\x53\x54\x52\x49\x4E\x47","\x42\x4F\x4F\x4C\x45\x41\x4E","\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74\x73","\x64\x65\x66\x69\x6E\x65"];module[_0x81dd[0]]=function(_0xf6f4x1,_0xf6f4x2){var _0xf6f4x3=_0xf6f4x1[_0x81dd[5]](_0x81dd[1],{name:{type:_0xf6f4x2[_0x81dd[2]],unique:true},description:{type:_0xf6f4x2[_0x81dd[2]],allowNull:true},defaultEntry:{type:_0xf6f4x2[_0x81dd[3]],defaultValue:0}},{tableName:_0x81dd[4]});return _0xf6f4x3;}; \ No newline at end of file diff --git a/server/models/voice_extension.js b/server/models/voice_extension.js index 5d09565..b811d1f 100644 --- a/server/models/voice_extension.js +++ b/server/models/voice_extension.js @@ -1,164 +1 @@ -/* jshint indent: 2 */ -var util = require('util'); - -module.exports = function(sequelize, DataTypes) { - var VoiceExtension = sequelize.define('VoiceExtension', { - context: { - type: DataTypes.STRING, - allowNull: false, - unique: 'compositeIndex' - }, - exten: { - type: DataTypes.STRING, - allowNull: false, - unique: 'compositeIndex' - }, - priority: { - type: DataTypes.INTEGER(11), - allowNull: false, - defaultValue: 1, - unique: 'compositeIndex' - }, - app: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: 'NoOp' - }, - appdata: { - type: DataTypes.STRING, - allowNull: true, - }, - type: { - type: DataTypes.ENUM('inbound', 'outbound', 'internal', 'inbound-fax', 'outbound-fax'), - allowNull: false, - }, - description: { - type: DataTypes.STRING, - }, - interval: { - type: DataTypes.STRING, - }, - isApp: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - appGroup: { - type: DataTypes.STRING - }, - interface: { - type: DataTypes.STRING - }, - app_options: { - type: DataTypes.STRING, - defaultValue: '', - allowNull: true - }, - url: { - type: DataTypes.STRING, - defaultValue: '', - allowNull: true - }, - timeout: { - type: DataTypes.STRING, - defaultValue: '', - allowNull: true - }, - queue: { - type: DataTypes.STRING, - allowNull: true - }, - audiofile: { - type: DataTypes.STRING, - allowNull: true - }, - project: { - type: DataTypes.STRING, - allowNull: true - }, - alt_extension: { - type: DataTypes.STRING, - allowNull: true - }, - alt_priority: { - type: DataTypes.INTEGER(11), - allowNull: true - }, - alt_context: { - type: DataTypes.STRING, - allowNull: true - }, - causecode: { - type: DataTypes.STRING, - allowNull: true - }, - variable: { - type: DataTypes.STRING, - allowNull: true - }, - value: { - type: DataTypes.STRING, - allowNull: true - }, - customApp: { - type: DataTypes.STRING, - allowNull: true - }, - mailbox: { - type: DataTypes.STRING, - allowNull: true - }, - trunk: { - type: DataTypes.STRING, - allowNull: true - }, - cutdigits: { - type: DataTypes.INTEGER(11), - allowNull: true - }, - isInterval: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, - callerID: { - type: DataTypes.STRING, - allowNull: true - } - }, { - tableName: 'voice_extensions', - associate: function(models) { - VoiceExtension.hasMany(models.VoiceExtension, { - as: 'Applications', - onDelete: 'cascade' - }); - VoiceExtension.afterBulkUpdate(function(update) { - // console.log(update); - if (update.attributes.trunk) { - VoiceExtension - .findAll({ - where: { - TrunkId: update.where.TrunkId - } - }) - .then(function(voiceExtensions) { - voiceExtensions.forEach(function(element) { - element.appdata = util.format('SIP/${EXTEN:%d}@%s', element.cutdigits, element.trunk); - element.save(); - }); - }) - .catch(function(err) { - console.log(err); - }); - } - }); - VoiceExtension.beforeBulkCreate(function(voiceExtensions) { - voiceExtensions.forEach(function(element) { - if (element.trunk) { - element.appdata = util.format('SIP/${EXTEN:%d}@%s', element.cutdigits, element.trunk); - } - }); - }); - } - }); - - return VoiceExtension; -}; +var _0x45d3=["\x75\x74\x69\x6C","\x65\x78\x70\x6F\x72\x74\x73","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x63\x6F\x6D\x70\x6F\x73\x69\x74\x65\x49\x6E\x64\x65\x78","\x4E\x6F\x4F\x70","\x69\x6E\x62\x6F\x75\x6E\x64","\x6F\x75\x74\x62\x6F\x75\x6E\x64","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x69\x6E\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x6F\x75\x74\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x42\x4F\x4F\x4C\x45\x41\x4E","","\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x63\x61\x73\x63\x61\x64\x65","\x68\x61\x73\x4D\x61\x6E\x79","\x74\x72\x75\x6E\x6B","\x61\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x61\x70\x70\x64\x61\x74\x61","\x53\x49\x50\x2F\x24\x7B\x45\x58\x54\x45\x4E\x3A\x25\x64\x7D\x40\x25\x73","\x63\x75\x74\x64\x69\x67\x69\x74\x73","\x66\x6F\x72\x6D\x61\x74","\x73\x61\x76\x65","\x66\x6F\x72\x45\x61\x63\x68","\x74\x68\x65\x6E","\x54\x72\x75\x6E\x6B\x49\x64","\x77\x68\x65\x72\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x61\x66\x74\x65\x72\x42\x75\x6C\x6B\x55\x70\x64\x61\x74\x65","\x62\x65\x66\x6F\x72\x65\x42\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x64\x65\x66\x69\x6E\x65"];var util=require(_0x45d3[0]);module[_0x45d3[1]]=function(_0xa974x2,_0xa974x3){var _0xa974x4=_0xa974x2[_0x45d3[33]](_0x45d3[2],{context:{type:_0xa974x3[_0x45d3[3]],allowNull:false,unique:_0x45d3[4]},exten:{type:_0xa974x3[_0x45d3[3]],allowNull:false,unique:_0x45d3[4]},priority:{type:_0xa974x3.INTEGER(11),allowNull:false,defaultValue:1,unique:_0x45d3[4]},app:{type:_0xa974x3[_0x45d3[3]],allowNull:false,defaultValue:_0x45d3[5]},appdata:{type:_0xa974x3[_0x45d3[3]],allowNull:true},type:{type:_0xa974x3.ENUM(_0x45d3[6],_0x45d3[7],_0x45d3[8],_0x45d3[9],_0x45d3[10]),allowNull:false},description:{type:_0xa974x3[_0x45d3[3]]},interval:{type:_0xa974x3[_0x45d3[3]]},isApp:{type:_0xa974x3[_0x45d3[11]],defaultValue:false},appGroup:{type:_0xa974x3[_0x45d3[3]]},interface:{type:_0xa974x3[_0x45d3[3]]},app_options:{type:_0xa974x3[_0x45d3[3]],defaultValue:_0x45d3[12],allowNull:true},url:{type:_0xa974x3[_0x45d3[3]],defaultValue:_0x45d3[12],allowNull:true},timeout:{type:_0xa974x3[_0x45d3[3]],defaultValue:_0x45d3[12],allowNull:true},queue:{type:_0xa974x3[_0x45d3[3]],allowNull:true},audiofile:{type:_0xa974x3[_0x45d3[3]],allowNull:true},project:{type:_0xa974x3[_0x45d3[3]],allowNull:true},alt_extension:{type:_0xa974x3[_0x45d3[3]],allowNull:true},alt_priority:{type:_0xa974x3.INTEGER(11),allowNull:true},alt_context:{type:_0xa974x3[_0x45d3[3]],allowNull:true},causecode:{type:_0xa974x3[_0x45d3[3]],allowNull:true},variable:{type:_0xa974x3[_0x45d3[3]],allowNull:true},value:{type:_0xa974x3[_0x45d3[3]],allowNull:true},customApp:{type:_0xa974x3[_0x45d3[3]],allowNull:true},mailbox:{type:_0xa974x3[_0x45d3[3]],allowNull:true},trunk:{type:_0xa974x3[_0x45d3[3]],allowNull:true},cutdigits:{type:_0xa974x3.INTEGER(11),allowNull:true},isInterval:{type:_0xa974x3[_0x45d3[11]],defaultValue:false},callerID:{type:_0xa974x3[_0x45d3[3]],allowNull:true}},{tableName:_0x45d3[13],associate:function(_0xa974x5){_0xa974x4[_0x45d3[16]](_0xa974x5.VoiceExtension,{as:_0x45d3[14],onDelete:_0x45d3[15]});_0xa974x4[_0x45d3[31]](function(_0xa974x6){if(_0xa974x6[_0x45d3[18]][_0x45d3[17]]){_0xa974x4[_0x45d3[30]]({where:{TrunkId:_0xa974x6[_0x45d3[29]][_0x45d3[28]]}})[_0x45d3[27]](function(_0xa974x8){_0xa974x8[_0x45d3[26]](function(_0xa974x9){_0xa974x9[_0x45d3[21]]=util[_0x45d3[24]](_0x45d3[22],_0xa974x9[_0x45d3[23]],_0xa974x9[_0x45d3[17]]);_0xa974x9[_0x45d3[25]]();})})[_0x45d3[20]](function(_0xa974x7){console[_0x45d3[19]](_0xa974x7)})}});_0xa974x4[_0x45d3[32]](function(_0xa974x8){_0xa974x8[_0x45d3[26]](function(_0xa974x9){if(_0xa974x9[_0x45d3[17]]){_0xa974x9[_0x45d3[21]]=util[_0x45d3[24]](_0x45d3[22],_0xa974x9[_0x45d3[23]],_0xa974x9[_0x45d3[17]])}})});}});return _0xa974x4;}; \ No newline at end of file diff --git a/server/models/voice_musiconhold.js b/server/models/voice_musiconhold.js index 9413dcd..8afa6d3 100644 --- a/server/models/voice_musiconhold.js +++ b/server/models/voice_musiconhold.js @@ -1,64 +1 @@ -/* jshint indent: 2 */ - -module.exports = function(sequelize, DataTypes) { - var VoiceMusicOnHold = sequelize.define('VoiceMusicOnHold', { - name: { - type: DataTypes.STRING, - allowNull: false, - unique: true - }, - mode: { - type: DataTypes.ENUM('custom', 'files', 'mp3nb', 'quietmp3nb', 'quietmp3', 'mp3'), - allowNull: true, - defaultValue: 'files' - }, - directory: { - type: DataTypes.STRING, - allowNull: true, - }, - application: { - type: DataTypes.STRING, - allowNull: true, - }, - digit: { - type: DataTypes.STRING, - allowNull: true, - }, - sort: { - type: DataTypes.STRING, - allowNull: true, - }, - format: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'wav' - }, - stamp: { - type: 'TIMESTAMP' - }, - defaultEntry: { - type: DataTypes.BOOLEAN, - defaultValue: 0 - } - }, { - tableName: 'voice_musiconhold' - }); - - VoiceMusicOnHold.beforeUpdate(function(moh) { - if (moh.changed('name')) { - throw new Error("You can't modify a moh class name"); - } - if (moh.defaultEntry) { - throw new Error("You can't modify a default moh class"); - } - }); - - - VoiceMusicOnHold.beforeDelete(function(moh) { - if (moh.defaultEntry) { - throw new Error("You can't delete a default moh class"); - } - }); - - return VoiceMusicOnHold; -}; +var _0x22bd=["\x65\x78\x70\x6F\x72\x74\x73","\x56\x6F\x69\x63\x65\x4D\x75\x73\x69\x63\x4F\x6E\x48\x6F\x6C\x64","\x53\x54\x52\x49\x4E\x47","\x63\x75\x73\x74\x6F\x6D","\x66\x69\x6C\x65\x73","\x6D\x70\x33\x6E\x62","\x71\x75\x69\x65\x74\x6D\x70\x33\x6E\x62","\x71\x75\x69\x65\x74\x6D\x70\x33","\x6D\x70\x33","\x77\x61\x76","\x54\x49\x4D\x45\x53\x54\x41\x4D\x50","\x42\x4F\x4F\x4C\x45\x41\x4E","\x76\x6F\x69\x63\x65\x5F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64","\x64\x65\x66\x69\x6E\x65","\x6E\x61\x6D\x65","\x63\x68\x61\x6E\x67\x65\x64","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x6D\x6F\x64\x69\x66\x79\x20\x61\x20\x6D\x6F\x68\x20\x63\x6C\x61\x73\x73\x20\x6E\x61\x6D\x65","\x64\x65\x66\x61\x75\x6C\x74\x45\x6E\x74\x72\x79","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x6D\x6F\x64\x69\x66\x79\x20\x61\x20\x64\x65\x66\x61\x75\x6C\x74\x20\x6D\x6F\x68\x20\x63\x6C\x61\x73\x73","\x62\x65\x66\x6F\x72\x65\x55\x70\x64\x61\x74\x65","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x64\x65\x6C\x65\x74\x65\x20\x61\x20\x64\x65\x66\x61\x75\x6C\x74\x20\x6D\x6F\x68\x20\x63\x6C\x61\x73\x73","\x62\x65\x66\x6F\x72\x65\x44\x65\x6C\x65\x74\x65"];module[_0x22bd[0]]=function(_0x256bx1,_0x256bx2){var _0x256bx3=_0x256bx1[_0x22bd[13]](_0x22bd[1],{name:{type:_0x256bx2[_0x22bd[2]],allowNull:false,unique:true},mode:{type:_0x256bx2.ENUM(_0x22bd[3],_0x22bd[4],_0x22bd[5],_0x22bd[6],_0x22bd[7],_0x22bd[8]),allowNull:true,defaultValue:_0x22bd[4]},directory:{type:_0x256bx2[_0x22bd[2]],allowNull:true},application:{type:_0x256bx2[_0x22bd[2]],allowNull:true},digit:{type:_0x256bx2[_0x22bd[2]],allowNull:true},sort:{type:_0x256bx2[_0x22bd[2]],allowNull:true},format:{type:_0x256bx2[_0x22bd[2]],allowNull:true,defaultValue:_0x22bd[9]},stamp:{type:_0x22bd[10]},defaultEntry:{type:_0x256bx2[_0x22bd[11]],defaultValue:0}},{tableName:_0x22bd[12]});_0x256bx3[_0x22bd[19]](function(_0x256bx4){if(_0x256bx4[_0x22bd[15]](_0x22bd[14])){throw new Error(_0x22bd[16])};if(_0x256bx4[_0x22bd[17]]){throw new Error(_0x22bd[18])};});_0x256bx3[_0x22bd[21]](function(_0x256bx4){if(_0x256bx4[_0x22bd[17]]){throw new Error(_0x22bd[20])}});return _0x256bx3;}; \ No newline at end of file diff --git a/server/models/voice_queue.js b/server/models/voice_queue.js index bc6429f..fe268a6 100644 --- a/server/models/voice_queue.js +++ b/server/models/voice_queue.js @@ -1,294 +1 @@ -/* jshint indent: 2 */ - -module.exports = function(sequelize, DataTypes) { - var VoiceQueue = sequelize.define('VoiceQueue', { - name: { - type: DataTypes.STRING, - primaryKey: true, - unique: true - }, - musiconhold: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'default' - }, - announce: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: '' - }, - context: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - timeout: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - ringinuse: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - setinterfacevar: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - setqueuevar: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - setqueueentryvar: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defautValue: 'yes' - }, - eventwhencalled: { - type: DataTypes.ENUM('yes', 'no', 'vars'), - allowNull: true, - defautValue: 'yes' - }, - eventmemberstatus: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defautValue: 'yes' - }, - monitor_format: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: '' - }, - membermacro: { - type: DataTypes.STRING, - allowNull: true, - }, - description: { - type: DataTypes.STRING, - allowNull: true, - }, - membergosub: { - type: DataTypes.STRING, - allowNull: true, - }, - queue_youarenext: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_thereare: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_callswaiting: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_quantity1: { - type: DataTypes.STRING, - allowNull: true - }, - queue_quantity2: { - type: DataTypes.STRING, - allowNull: true - }, - queue_holdtime: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_minutes: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_seconds: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_minute: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_thankyou: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null - }, - queue_callerannounce: { - type: DataTypes.STRING, - allowNull: true, - }, - queue_reporthold: { - type: DataTypes.STRING, - allowNull: true, - }, - announce_frequency: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - announce_to_first_user: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - min_announce_frequency: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - announce_round_seconds: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - announce_holdtime: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'no' - }, - announce_position: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'no' - }, - announce_position_limit: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - periodic_announce: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: '' - }, - periodic_announce_frequency: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - relative_periodic_announce: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'yes' - }, - random_periodic_announce: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - retry: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - wrapuptime: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - penaltymemberslimit: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - autofill: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - monitor_type: { - type: DataTypes.STRING, - allowNull: true, - }, - autopause: { - type: DataTypes.ENUM('yes', 'no', 'all'), - allowNull: true, - defaultValue: 'no' - }, - autopausedelay: { - type: DataTypes.INTEGER(11), - allowNull: true, - }, - autopausebusy: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - autopauseunavail: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - }, - maxlen: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - servicelevel: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - strategy: { - type: DataTypes.ENUM('ringall', 'leastrecent', 'fewestcalls', 'random', 'rrmemory', 'linear', 'wrandom', 'rrordered'), - allowNull: true, - }, - joinempty: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'yes' - }, - leavewhenempty: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: 'no' - }, - reportholdtime: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - memberdelay: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - weight: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: 0 - }, - timeoutrestart: { - type: DataTypes.ENUM('yes', 'no'), - allowNull: true, - defaultValue: 'no' - }, - defaultrule: { - type: DataTypes.STRING, - allowNull: true, - }, - timeoutpriority: { - type: DataTypes.STRING, - allowNull: true, - } - }, { - tableName: 'voice_queues', - associate: function(models) { - VoiceQueue.belongsToMany(models.User, { - through: models.UserHasVoiceQueue, - foreignKey: 'queue' - }); - } - }); - - VoiceQueue.beforeUpdate(function(updatedQueue) { - if (updatedQueue.changed('name')) { - throw new Error("You can't modify a queue name"); - } - }); - - return VoiceQueue; -}; +var _0x4460=["\x65\x78\x70\x6F\x72\x74\x73","\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x53\x54\x52\x49\x4E\x47","\x64\x65\x66\x61\x75\x6C\x74","","\x79\x65\x73","\x6E\x6F","\x76\x61\x72\x73","\x61\x6C\x6C","\x72\x69\x6E\x67\x61\x6C\x6C","\x6C\x65\x61\x73\x74\x72\x65\x63\x65\x6E\x74","\x66\x65\x77\x65\x73\x74\x63\x61\x6C\x6C\x73","\x72\x61\x6E\x64\x6F\x6D","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x6C\x69\x6E\x65\x61\x72","\x77\x72\x61\x6E\x64\x6F\x6D","\x72\x72\x6F\x72\x64\x65\x72\x65\x64","\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65\x73","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x71\x75\x65\x75\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65","\x6E\x61\x6D\x65","\x63\x68\x61\x6E\x67\x65\x64","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x6D\x6F\x64\x69\x66\x79\x20\x61\x20\x71\x75\x65\x75\x65\x20\x6E\x61\x6D\x65","\x62\x65\x66\x6F\x72\x65\x55\x70\x64\x61\x74\x65"];module[_0x4460[0]]=function(_0xc20ex1,_0xc20ex2){var _0xc20ex3=_0xc20ex1[_0x4460[21]](_0x4460[1],{name:{type:_0xc20ex2[_0x4460[2]],primaryKey:true,unique:true},musiconhold:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[3]},announce:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[4]},context:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},timeout:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},ringinuse:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defaultValue:_0x4460[6]},setinterfacevar:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defaultValue:_0x4460[5]},setqueuevar:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defaultValue:_0x4460[5]},setqueueentryvar:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defautValue:_0x4460[5]},eventwhencalled:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6],_0x4460[7]),allowNull:true,defautValue:_0x4460[5]},eventmemberstatus:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defautValue:_0x4460[5]},monitor_format:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[4]},membermacro:{type:_0xc20ex2[_0x4460[2]],allowNull:true},description:{type:_0xc20ex2[_0x4460[2]],allowNull:true},membergosub:{type:_0xc20ex2[_0x4460[2]],allowNull:true},queue_youarenext:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_thereare:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_callswaiting:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_quantity1:{type:_0xc20ex2[_0x4460[2]],allowNull:true},queue_quantity2:{type:_0xc20ex2[_0x4460[2]],allowNull:true},queue_holdtime:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_minutes:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_seconds:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_minute:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_thankyou:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:null},queue_callerannounce:{type:_0xc20ex2[_0x4460[2]],allowNull:true},queue_reporthold:{type:_0xc20ex2[_0x4460[2]],allowNull:true},announce_frequency:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},announce_to_first_user:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true},min_announce_frequency:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},announce_round_seconds:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},announce_holdtime:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[6]},announce_position:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[6]},announce_position_limit:{type:_0xc20ex2.INTEGER(11),allowNull:true},periodic_announce:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[4]},periodic_announce_frequency:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},relative_periodic_announce:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defaultValue:_0x4460[5]},random_periodic_announce:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defaultValue:_0x4460[6]},retry:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},wrapuptime:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},penaltymemberslimit:{type:_0xc20ex2.INTEGER(11),allowNull:true},autofill:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true},monitor_type:{type:_0xc20ex2[_0x4460[2]],allowNull:true},autopause:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6],_0x4460[8]),allowNull:true,defaultValue:_0x4460[6]},autopausedelay:{type:_0xc20ex2.INTEGER(11),allowNull:true},autopausebusy:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true},autopauseunavail:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true},maxlen:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},servicelevel:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},strategy:{type:_0xc20ex2.ENUM(_0x4460[9],_0x4460[10],_0x4460[11],_0x4460[12],_0x4460[13],_0x4460[14],_0x4460[15],_0x4460[16]),allowNull:true},joinempty:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[5]},leavewhenempty:{type:_0xc20ex2[_0x4460[2]],allowNull:true,defaultValue:_0x4460[6]},reportholdtime:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defaultValue:_0x4460[6]},memberdelay:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},weight:{type:_0xc20ex2.INTEGER(11),allowNull:true,defaultValue:0},timeoutrestart:{type:_0xc20ex2.ENUM(_0x4460[5],_0x4460[6]),allowNull:true,defaultValue:_0x4460[6]},defaultrule:{type:_0xc20ex2[_0x4460[2]],allowNull:true},timeoutpriority:{type:_0xc20ex2[_0x4460[2]],allowNull:true}},{tableName:_0x4460[17],associate:function(_0xc20ex4){_0xc20ex3[_0x4460[20]](_0xc20ex4.User,{through:_0xc20ex4[_0x4460[18]],foreignKey:_0x4460[19]})}});_0xc20ex3[_0x4460[25]](function(_0xc20ex5){if(_0xc20ex5[_0x4460[23]](_0x4460[22])){throw new Error(_0x4460[24])}});return _0xc20ex3;}; \ No newline at end of file diff --git a/server/models/voice_voicemail.js b/server/models/voice_voicemail.js index f814f4b..7b021bb 100644 --- a/server/models/voice_voicemail.js +++ b/server/models/voice_voicemail.js @@ -1,144 +1 @@ -/* jshint indent: 2 */ - -module.exports = function(sequelize, DataTypes) { - var VoiceVoicemail = sequelize.define('VoiceVoicemail', { - uniqueid: { - type: DataTypes.INTEGER(4), - primaryKey: true, - allowNull: false, - autoIncrement: true - }, - customer_id: { - type: DataTypes.STRING, - }, - context: { - type: DataTypes.STRING, - defaultValue: 'from-voicemail', - unique: 'contest_mailbox' - }, - mailbox: { - type: DataTypes.STRING, - defaultValue: '', - allowNull: false, - unique: 'contest_mailbox' - }, - password: { - type: DataTypes.STRING, - }, - fullname: { - type: DataTypes.STRING, - }, - email: { - type: DataTypes.STRING, - }, - pager: { - type: DataTypes.STRING, - }, - tz: { - type: DataTypes.STRING, - defaultValue: 'central' - }, - attach: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'yes', - allowNull: false - }, - saycid: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'yes', - allowNull: false - }, - dialout: { - type: DataTypes.STRING, - }, - callback: { - type: DataTypes.STRING, - }, - review: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - operator: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - envelope: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - sayduration: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - saydurationm: { - type: 'TINYINT(4)', - defaultValue: 1, - allowNull: false - }, - sendvoicemail: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - 'delete': { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - nextaftercmd: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'yes', - allowNull: false - }, - forcename: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - forcegreetings: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'no', - allowNull: false - }, - hidefromdir: { - type: DataTypes.ENUM('yes', 'no'), - defaultValue: 'yes', - allowNull: false - }, - stamp: { - type: 'TIMESTAMP' - }, - emailsubject: { - type: DataTypes.STRING, - }, - emailbody: { - type: DataTypes.STRING, - }, - name: { - type: DataTypes.STRING, - }, - maxsecs: { - type: DataTypes.INTEGER(255), - defaultValue: 180, - allowNull: false - }, - maxmsg: { - type: DataTypes.INTEGER(255), - defaultValue: 100, - allowNull: false - } - - }, { - tableName: 'voice_voicemail', - indexes: [{ - name: 'mailbox_context', - fields: ['mailbox', 'context'] - }] - }); - - return VoiceVoicemail; -}; +var _0x3a9b=["\x65\x78\x70\x6F\x72\x74\x73","\x56\x6F\x69\x63\x65\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x53\x54\x52\x49\x4E\x47","\x66\x72\x6F\x6D\x2D\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x63\x6F\x6E\x74\x65\x73\x74\x5F\x6D\x61\x69\x6C\x62\x6F\x78","","\x63\x65\x6E\x74\x72\x61\x6C","\x79\x65\x73","\x6E\x6F","\x54\x49\x4E\x59\x49\x4E\x54\x28\x34\x29","\x54\x49\x4D\x45\x53\x54\x41\x4D\x50","\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x6D\x61\x69\x6C\x62\x6F\x78\x5F\x63\x6F\x6E\x74\x65\x78\x74","\x6D\x61\x69\x6C\x62\x6F\x78","\x63\x6F\x6E\x74\x65\x78\x74","\x64\x65\x66\x69\x6E\x65"];module[_0x3a9b[0]]=function(_0x2da5x1,_0x2da5x2){var _0x2da5x3=_0x2da5x1[_0x3a9b[15]](_0x3a9b[1],{uniqueid:{type:_0x2da5x2.INTEGER(4),primaryKey:true,allowNull:false,autoIncrement:true},customer_id:{type:_0x2da5x2[_0x3a9b[2]]},context:{type:_0x2da5x2[_0x3a9b[2]],defaultValue:_0x3a9b[3],unique:_0x3a9b[4]},mailbox:{type:_0x2da5x2[_0x3a9b[2]],defaultValue:_0x3a9b[5],allowNull:false,unique:_0x3a9b[4]},password:{type:_0x2da5x2[_0x3a9b[2]]},fullname:{type:_0x2da5x2[_0x3a9b[2]]},email:{type:_0x2da5x2[_0x3a9b[2]]},pager:{type:_0x2da5x2[_0x3a9b[2]]},tz:{type:_0x2da5x2[_0x3a9b[2]],defaultValue:_0x3a9b[6]},attach:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[7],allowNull:false},saycid:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[7],allowNull:false},dialout:{type:_0x2da5x2[_0x3a9b[2]]},callback:{type:_0x2da5x2[_0x3a9b[2]]},review:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},operator:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},envelope:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},sayduration:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},saydurationm:{type:_0x3a9b[9],defaultValue:1,allowNull:false},sendvoicemail:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},"\x64\x65\x6C\x65\x74\x65":{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},nextaftercmd:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[7],allowNull:false},forcename:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},forcegreetings:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[8],allowNull:false},hidefromdir:{type:_0x2da5x2.ENUM(_0x3a9b[7],_0x3a9b[8]),defaultValue:_0x3a9b[7],allowNull:false},stamp:{type:_0x3a9b[10]},emailsubject:{type:_0x2da5x2[_0x3a9b[2]]},emailbody:{type:_0x2da5x2[_0x3a9b[2]]},name:{type:_0x2da5x2[_0x3a9b[2]]},maxsecs:{type:_0x2da5x2.INTEGER(255),defaultValue:180,allowNull:false},maxmsg:{type:_0x2da5x2.INTEGER(255),defaultValue:100,allowNull:false}},{tableName:_0x3a9b[11],indexes:[{name:_0x3a9b[12],fields:[_0x3a9b[13],_0x3a9b[14]]}]});return _0x2da5x3;}; \ No newline at end of file diff --git a/server/models/voice_voicemail_messages.js b/server/models/voice_voicemail_messages.js index 271910c..1c6a891 100644 --- a/server/models/voice_voicemail_messages.js +++ b/server/models/voice_voicemail_messages.js @@ -1,67 +1 @@ -/* jshint indent: 2 */ - -module.exports = function(sequelize, DataTypes) { - var VoiceVoicemailMessages = sequelize.define('VoiceVoicemailMessages', { - msgnum: { - type: DataTypes.INTEGER(11), - defaultValue: 0, - allowNull: false - }, - dir: { - type: DataTypes.STRING, - defaultValue: '' - }, - context: { - type: DataTypes.STRING, - defaultValue: '' - }, - macrocontext: { - type: DataTypes.STRING, - defaultValue: '' - }, - callerid: { - type: DataTypes.STRING, - defaultValue: '' - }, - origtime: { - type: DataTypes.STRING, - defaultValue: '' - }, - duration: { - type: DataTypes.STRING, - defaultValue: '' - }, - mailboxuser: { - type: DataTypes.STRING, - defaultValue: '' - }, - mailboxcontext: { - type: DataTypes.STRING, - defaultValue: '' - }, - recording: { - type: DataTypes.BLOB('long'), - defaultValue: null - }, - flag: { - type: DataTypes.STRING, - defaultValue: '' - }, - msg_id: { - type: DataTypes.STRING, - defaultValue: '' - }, - stamp: { - type: 'TIMESTAMP', - allowNull: false - } - }, { - tableName: 'voice_voicemail_messages', - indexes: [{ - name: 'dir', - fields: ['dir'] - }] - }); - - return VoiceVoicemailMessages; -}; +var _0x27fa=["\x65\x78\x70\x6F\x72\x74\x73","\x56\x6F\x69\x63\x65\x56\x6F\x69\x63\x65\x6D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65\x73","\x53\x54\x52\x49\x4E\x47","","\x6C\x6F\x6E\x67","\x54\x49\x4D\x45\x53\x54\x41\x4D\x50","\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x73","\x64\x69\x72","\x64\x65\x66\x69\x6E\x65"];module[_0x27fa[0]]=function(_0x70a0x1,_0x70a0x2){var _0x70a0x3=_0x70a0x1[_0x27fa[8]](_0x27fa[1],{msgnum:{type:_0x70a0x2.INTEGER(11),defaultValue:0,allowNull:false},dir:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},context:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},macrocontext:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},callerid:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},origtime:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},duration:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},mailboxuser:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},mailboxcontext:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},recording:{type:_0x70a0x2.BLOB(_0x27fa[4]),defaultValue:null},flag:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},msg_id:{type:_0x70a0x2[_0x27fa[2]],defaultValue:_0x27fa[3]},stamp:{type:_0x27fa[5],allowNull:false}},{tableName:_0x27fa[6],indexes:[{name:_0x27fa[7],fields:[_0x27fa[7]]}]});return _0x70a0x3;}; \ No newline at end of file diff --git a/server/models/zendesk_account.js b/server/models/zendesk_account.js index 48a8059..94910bd 100644 --- a/server/models/zendesk_account.js +++ b/server/models/zendesk_account.js @@ -1,33 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var ZendeskAccount = sequelize.define('ZendeskAccount', { - name: DataTypes.STRING, - description: DataTypes.STRING, - username: { - type: DataTypes.STRING, - unique: true - }, - password: DataTypes.STRING, - token: DataTypes.STRING, - remoteUri: { - type: DataTypes.STRING, - unique: true - }, - authType: { - type: DataTypes.ENUM('password', 'token'), - defaultValue: 'password' - } - }, { - tableName: 'zendesk_accounts', - associate: function(models) { - ZendeskAccount.hasMany(models.ZendeskConfiguration, { - foreignKey: 'AccountId' - }); - } - }); - - return ZendeskAccount; - -}; +var _0xff11=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x5A\x65\x6E\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x70\x61\x73\x73\x77\x6F\x72\x64","\x74\x6F\x6B\x65\x6E","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0xff11[0];module[_0xff11[1]]=function(_0xdfbfx1,_0xdfbfx2){var _0xdfbfx3=_0xdfbfx1[_0xff11[9]](_0xff11[2],{name:_0xdfbfx2[_0xff11[3]],description:_0xdfbfx2[_0xff11[3]],username:{type:_0xdfbfx2[_0xff11[3]],unique:true},password:_0xdfbfx2[_0xff11[3]],token:_0xdfbfx2[_0xff11[3]],remoteUri:{type:_0xdfbfx2[_0xff11[3]],unique:true},authType:{type:_0xdfbfx2.ENUM(_0xff11[4],_0xff11[5]),defaultValue:_0xff11[4]}},{tableName:_0xff11[6],associate:function(_0xdfbfx4){_0xdfbfx3[_0xff11[8]](_0xdfbfx4.ZendeskConfiguration,{foreignKey:_0xff11[7]})}});return _0xdfbfx3;}; \ No newline at end of file diff --git a/server/models/zendesk_configuration.js b/server/models/zendesk_configuration.js index 7fc5caa..3a348e4 100644 --- a/server/models/zendesk_configuration.js +++ b/server/models/zendesk_configuration.js @@ -1,31 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var ZendeskConfiguration = sequelize.define('ZendeskConfiguration', { - name: DataTypes.STRING, - description: DataTypes.STRING - }, { - tableName: 'zendesk_configurations', - associate: function(models) { - ZendeskConfiguration.belongsTo(models.ZendeskAccount, { - foreignKey: 'AccountId' - }); - ZendeskConfiguration.hasMany(models.ZendeskField, { - as: 'Subject', - foreignKey: 'SubjectId' - }); - ZendeskConfiguration.hasMany(models.ZendeskField, { - as: 'Description', - foreignKey: 'DescriptionId' - }); - ZendeskConfiguration.hasMany(models.ZendeskField, { - as: 'Field', - foreignKey: 'FieldId' - }); - } - }); - - return ZendeskConfiguration; - -}; +var _0xee2f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x5A\x65\x6E\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x53\x54\x52\x49\x4E\x47","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x53\x75\x62\x6A\x65\x63\x74","\x53\x75\x62\x6A\x65\x63\x74\x49\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x49\x64","\x46\x69\x65\x6C\x64","\x46\x69\x65\x6C\x64\x49\x64","\x64\x65\x66\x69\x6E\x65"];_0xee2f[0];module[_0xee2f[1]]=function(_0xd7c2x1,_0xd7c2x2){var _0xd7c2x3=_0xd7c2x1[_0xee2f[14]](_0xee2f[2],{name:_0xd7c2x2[_0xee2f[3]],description:_0xd7c2x2[_0xee2f[3]]},{tableName:_0xee2f[4],associate:function(_0xd7c2x4){_0xd7c2x3[_0xee2f[6]](_0xd7c2x4.ZendeskAccount,{foreignKey:_0xee2f[5]});_0xd7c2x3[_0xee2f[9]](_0xd7c2x4.ZendeskField,{as:_0xee2f[7],foreignKey:_0xee2f[8]});_0xd7c2x3[_0xee2f[9]](_0xd7c2x4.ZendeskField,{as:_0xee2f[10],foreignKey:_0xee2f[11]});_0xd7c2x3[_0xee2f[9]](_0xd7c2x4.ZendeskField,{as:_0xee2f[12],foreignKey:_0xee2f[13]});}});return _0xd7c2x3;}; \ No newline at end of file diff --git a/server/models/zendesk_field.js b/server/models/zendesk_field.js index 7aed547..d41152d 100644 --- a/server/models/zendesk_field.js +++ b/server/models/zendesk_field.js @@ -1,26 +1 @@ -'use strict'; - -module.exports = function(sequelize, DataTypes) { - - var ZendeskField = sequelize.define('ZendeskField', { - type: { - type: DataTypes.ENUM('string', 'variable', 'key_value'), - defaultValue: 'string' - }, - content: DataTypes.STRING, - key: DataTypes.STRING, - keyType: { - type: DataTypes.ENUM('string', 'variable') - }, - keyContent: DataTypes.STRING, - idField: DataTypes.INTEGER - }, { - tableName: 'zendesk_fields', - associate: function(models) { - ZendeskField.belongsTo(models.Variable); - } - }); - - return ZendeskField; - -}; +var _0xb2bc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x5A\x65\x6E\x64\x65\x73\x6B\x46\x69\x65\x6C\x64","\x73\x74\x72\x69\x6E\x67","\x76\x61\x72\x69\x61\x62\x6C\x65","\x6B\x65\x79\x5F\x76\x61\x6C\x75\x65","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x64\x65\x66\x69\x6E\x65"];_0xb2bc[0];module[_0xb2bc[1]]=function(_0x87d7x1,_0x87d7x2){var _0x87d7x3=_0x87d7x1[_0xb2bc[10]](_0xb2bc[2],{type:{type:_0x87d7x2.ENUM(_0xb2bc[3],_0xb2bc[4],_0xb2bc[5]),defaultValue:_0xb2bc[3]},content:_0x87d7x2[_0xb2bc[6]],key:_0x87d7x2[_0xb2bc[6]],keyType:{type:_0x87d7x2.ENUM(_0xb2bc[3],_0xb2bc[4])},keyContent:_0x87d7x2[_0xb2bc[6]],idField:_0x87d7x2[_0xb2bc[7]]},{tableName:_0xb2bc[8],associate:function(_0x87d7x4){_0x87d7x3[_0xb2bc[9]](_0x87d7x4.Variable)}});return _0x87d7x3;}; \ No newline at end of file diff --git a/server/routes.js b/server/routes.js index bff83fd..bea942b 100644 --- a/server/routes.js +++ b/server/routes.js @@ -1,143 +1 @@ -/** - * Main application routes - */ - -'use strict'; - -var config = require('./config/environment'); -var errors = require('./components/errors'); -var path = require('path'); -var moment = require('moment'); - -module.exports = function(app) { - var env = app.get('env'); - - // Insert routes below - app.use('/api/sugarcrm/fields', require('./api/sugarcrm_field')); - app.use('/api/sugarcrm/configurations', require('./api/sugarcrm_configuration')); - app.use('/api/sugarcrm/accounts', require('./api/sugarcrm_account')); - app.use('/api/freshdesk/fields', require('./api/freshdesk_field')); - app.use('/api/freshdesk/configurations', require('./api/freshdesk_configuration')); - app.use('/api/freshdesk/accounts', require('./api/freshdesk_account')); - app.use('/api/salesforce/fields', require('./api/salesforce_field')); - app.use('/api/salesforce/configurations', require('./api/salesforce_configuration')); - app.use('/api/salesforce/accounts', require('./api/salesforce_account')); - app.use('/api/desk/fields', require('./api/desk_field')); - app.use('/api/desk/configurations', require('./api/desk_configuration')); - // app.use('/api/messages', require('./api/message')); - app.use('/api/desk/accounts', require('./api/desk_account')); - app.use('/api/analytics/reports/default', require('./api/default_report')); - app.use('/api/analytics/reports/custom', require('./api/custom_report')); - app.use('/api/analytics/reports/trees', require('./api/report_tree')); - app.use('/api/analytics/metrics', require('./api/metric')); - app.use('/api/updates', require('./api/update')); - app.use('/api/report/chat/sessions', require('./api/report_chat_session')); - app.use('/api/zendesk/fields', require('./api/zendesk_field')); - app.use('/api/report/chats', require('./api/report_chat')); - app.use('/api/zendesk/configurations', require('./api/zendesk_configuration')); - app.use('/api/motionbar', require('./api/motionbar')); - app.use('/api/report/mail/sessions', require('./api/report_mail_session')); - app.use('/api/report/mails', require('./api/report_mail')); - app.use('/api/widgets', require('./api/widget')); - app.use('/api/zendesk/accounts', require('./api/zendesk_account')); - app.use('/api/report/queues', require('./api/report_queue')); - app.use('/api/report/integrations', require('./api/report_integration')); - app.use('/api/report/agents', require('./api/report_agent')); - app.use('/api/dashboards', require('./api/dashboard')); - app.use('/api/settings', require('./api/setting')); - app.use('/api/triggers', require('./api/trigger')); - app.use('/api/automations', require('./api/automation')); - app.use('/api/mail/templates', require('./api/mail_template')); - app.use('/api/ami', require('./api/ami')); - app.use('/api/integrations', require('./api/integration')); - app.use('/api/voice/musiconholds', require('./api/voice_musiconhold')); - app.use('/api/voice/voicemails', require('./api/voice_voicemail')); - app.use('/api/contactmanager/customfields', require('./api/custom_field')); - app.use('/api/contactmanager/companies', require('./api/company')); - app.use('/api/contactmanager', require('./api/contact_manager')); - app.use('/api/fax/business/automations', require('./api/fax_business_automation')); - app.use('/api/mail/business/automations', require('./api/mail_business_automation')); - app.use('/api/business/actions', require('./api/business_action')); - app.use('/api/business/conditions', require('./api/business_condition')); - app.use('/api/intervals', require('./api/interval')); - app.use('/api/voice/extensions', require('./api/voice_extension')); - app.use('/api/voice/contexts', require('./api/voice_context')); - app.use('/api/voice/user_has_queues', require('./api/user_has_voice_queue')); - app.use('/api/voice/queues', require('./api/voice_queue')); - app.use('/api/voice/queue', require('./api/voice_queue')); - app.use('/api/trunks', require('./api/trunk')); - app.use('/api/chat/applications', require('./api/chat_application')); - app.use('/api/chat/user_has_queues', require('./api/user_has_chat_queue')); - app.use('/api/events', require('./api/event')); - app.use('/api/square/odbc', require('./api/square_odbc')); - app.use('/api/fax/applications', require('./api/fax_application')); - app.use('/api/fax/user_has_queues', require('./api/user_has_fax_queue')); - app.use('/api/fax/queues', require('./api/fax_queue')); - app.use('/api/mail/attachments', require('./api/mail_attachment')); - app.use('/api/user_has_teams', require('./api/user_has_team')); - app.use('/api/variables', require('./api/variable')); - app.use('/api/tags', require('./api/tag')); - app.use('/api/square/projects', require('./api/square_project')); - app.use('/api/chat/queues', require('./api/chat_queue')); - app.use('/api/fax/messages', require('./api/fax_message')); - app.use('/api/fax/rooms', require('./api/fax_room')); - app.use('/api/fax/accounts', require('./api/fax_account')); - app.use('/api/agents', require('./api/agent')); - app.use('/api/chat/enquiries', require('./api/chat_enquiry')); - app.use('/api/chat/messages', require('./api/chat_message')); - app.use('/api/chat/rooms', require('./api/chat_room')); - app.use('/api/chat/visitors', require('./api/chat_visitor')); - app.use('/api/chat/websites', require('./api/chat_website')); - app.use('/api/chat/queues', require('./api/chat_queue')); - app.use('/api/contacts', require('./api/contact')); - app.use('/api/mail/accounts', require('./api/mail_account')); - app.use('/api/mail/messages', require('./api/mail_message')); - app.use('/api/mail/rooms', require('./api/mail_room')); - app.use('/api/mail/servers/in', require('./api/mail_server_in')); - app.use('/api/mail/servers/out', require('./api/mail_server_out')); - app.use('/api/mail/queues', require('./api/mail_queue')); - app.use('/api/mail/user_has_queues', require('./api/user_has_mail_queue')); - app.use('/api/mail/applications', require('./api/mail_application')); - app.use('/api/teams', require('./api/team')); - app.use('/api/uploads', require('./api/upload')); - app.use('/api/users', require('./api/user')); - app.use('/api/chat/user_has_rooms', require('./api/user_has_chat_room')); - app.use('/api/xchatty', require('./api/xchatty')); - app.use('/auth', require('./auth')); - - // All undefined asset or api routes should return a 404 - app.route('/:url(api|auth|components|app|bower_components|assets)/*').get( - errors[404]); - - // All other routes should redirect to the index.html - app.all("/*", function(req, res, next) { - - var options = {}; - - if ('production' === env) { - options.root = path.join(config.root, 'public'); - } - - if ('development' === env || 'test' === env) { - options.root = path.join(config.root, 'client'); - } - - res.sendFile('index.html', options); - }); - - // app - // .route('/*') - // .get(function(req, res) { - // - // var options = { - // root: config.root, - // dotfiles: 'deny', - // headers: { - // 'x-timestamp': Date.now(), - // 'x-sent': true - // } - // }; - // - // res.sendFile('index.html', options); - // }); -}; +var _0xdaa0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x2E\x2F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x2F\x65\x72\x72\x6F\x72\x73","\x70\x61\x74\x68","\x6D\x6F\x6D\x65\x6E\x74","\x65\x78\x70\x6F\x72\x74\x73","\x65\x6E\x76","\x67\x65\x74","\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x66\x69\x65\x6C\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x66\x69\x65\x6C\x64","\x75\x73\x65","\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x75\x67\x61\x72\x63\x72\x6D\x5F\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64","\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x72\x65\x73\x68\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x66\x69\x65\x6C\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x66\x69\x65\x6C\x64","\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5F\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64","\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x64\x65\x66\x61\x75\x6C\x74","\x2E\x2F\x61\x70\x69\x2F\x64\x65\x66\x61\x75\x6C\x74\x5F\x72\x65\x70\x6F\x72\x74","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x63\x75\x73\x74\x6F\x6D","\x2E\x2F\x61\x70\x69\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x72\x65\x70\x6F\x72\x74\x73\x2F\x74\x72\x65\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65","\x2F\x61\x70\x69\x2F\x61\x6E\x61\x6C\x79\x74\x69\x63\x73\x2F\x6D\x65\x74\x72\x69\x63\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x65\x74\x72\x69\x63","\x2F\x61\x70\x69\x2F\x75\x70\x64\x61\x74\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x70\x64\x61\x74\x65","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x63\x68\x61\x74\x2F\x73\x65\x73\x73\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74\x5F\x73\x65\x73\x73\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x66\x69\x65\x6C\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x66\x69\x65\x6C\x64","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x63\x68\x61\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x63\x68\x61\x74","\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x2E\x2F\x61\x70\x69\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x6D\x61\x69\x6C\x2F\x73\x65\x73\x73\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C\x5F\x73\x65\x73\x73\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x6D\x61\x69\x6C\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x6D\x61\x69\x6C","\x2F\x61\x70\x69\x2F\x77\x69\x64\x67\x65\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x77\x69\x64\x67\x65\x74","\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x7A\x65\x6E\x64\x65\x73\x6B\x5F\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x2F\x61\x67\x65\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x5F\x61\x67\x65\x6E\x74","\x2F\x61\x70\x69\x2F\x64\x61\x73\x68\x62\x6F\x61\x72\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x64\x61\x73\x68\x62\x6F\x61\x72\x64","\x2F\x61\x70\x69\x2F\x73\x65\x74\x74\x69\x6E\x67\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x65\x74\x74\x69\x6E\x67","\x2F\x61\x70\x69\x2F\x74\x72\x69\x67\x67\x65\x72\x73","\x2E\x2F\x61\x70\x69\x2F\x74\x72\x69\x67\x67\x65\x72","\x2F\x61\x70\x69\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x74\x65\x6D\x70\x6C\x61\x74\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x74\x65\x6D\x70\x6C\x61\x74\x65","\x2F\x61\x70\x69\x2F\x61\x6D\x69","\x2E\x2F\x61\x70\x69\x2F\x61\x6D\x69","\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x6D\x75\x73\x69\x63\x6F\x6E\x68\x6F\x6C\x64","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C\x73","\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x76\x6F\x69\x63\x65\x6D\x61\x69\x6C","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72\x2F\x63\x75\x73\x74\x6F\x6D\x66\x69\x65\x6C\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72\x2F\x63\x6F\x6D\x70\x61\x6E\x69\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x6F\x6D\x70\x61\x6E\x79","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x6D\x61\x6E\x61\x67\x65\x72","\x2E\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x5F\x6D\x61\x6E\x61\x67\x65\x72","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x61\x63\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x61\x63\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x2F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x62\x75\x73\x69\x6E\x65\x73\x73\x5F\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x72\x76\x61\x6C\x73","\x2E\x2F\x61\x70\x69\x2F\x69\x6E\x74\x65\x72\x76\x61\x6C","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x65\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x63\x6F\x6E\x74\x65\x78\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x63\x6F\x6E\x74\x65\x78\x74","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x74\x72\x75\x6E\x6B\x73","\x2E\x2F\x61\x70\x69\x2F\x74\x72\x75\x6E\x6B","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x65\x76\x65\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x65\x76\x65\x6E\x74","\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x2F\x6F\x64\x62\x63","\x2E\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x5F\x6F\x64\x62\x63","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D","\x2F\x61\x70\x69\x2F\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x76\x61\x72\x69\x61\x62\x6C\x65","\x2F\x61\x70\x69\x2F\x74\x61\x67\x73","\x2E\x2F\x61\x70\x69\x2F\x74\x61\x67","\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x2F\x70\x72\x6F\x6A\x65\x63\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x73\x71\x75\x61\x72\x65\x5F\x70\x72\x6F\x6A\x65\x63\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x6D\x65\x73\x73\x61\x67\x65","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x72\x6F\x6F\x6D\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x72\x6F\x6F\x6D","\x2F\x61\x70\x69\x2F\x66\x61\x78\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x66\x61\x78\x5F\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x61\x67\x65\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x61\x67\x65\x6E\x74","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x65\x6E\x71\x75\x69\x72\x69\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x65\x6E\x71\x75\x69\x72\x79","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x6D\x65\x73\x73\x61\x67\x65","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x72\x6F\x6F\x6D\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x76\x69\x73\x69\x74\x6F\x72\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x76\x69\x73\x69\x74\x6F\x72","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x77\x65\x62\x73\x69\x74\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x5F\x77\x65\x62\x73\x69\x74\x65","\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x63\x6F\x6E\x74\x61\x63\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x6D\x65\x73\x73\x61\x67\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x72\x6F\x6F\x6D\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x72\x6F\x6F\x6D","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x73\x65\x72\x76\x65\x72\x73\x2F\x69\x6E","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x69\x6E","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x73\x65\x72\x76\x65\x72\x73\x2F\x6F\x75\x74","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x73\x65\x72\x76\x65\x72\x5F\x6F\x75\x74","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x71\x75\x65\x75\x65\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65","\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x2F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x2E\x2F\x61\x70\x69\x2F\x6D\x61\x69\x6C\x5F\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2F\x61\x70\x69\x2F\x74\x65\x61\x6D\x73","\x2E\x2F\x61\x70\x69\x2F\x74\x65\x61\x6D","\x2F\x61\x70\x69\x2F\x75\x70\x6C\x6F\x61\x64\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x70\x6C\x6F\x61\x64","\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72","\x2F\x61\x70\x69\x2F\x63\x68\x61\x74\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x72\x6F\x6F\x6D\x73","\x2E\x2F\x61\x70\x69\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D","\x2F\x61\x70\x69\x2F\x78\x63\x68\x61\x74\x74\x79","\x2E\x2F\x61\x70\x69\x2F\x78\x63\x68\x61\x74\x74\x79","\x2F\x61\x75\x74\x68","\x2E\x2F\x61\x75\x74\x68","\x2F\x3A\x75\x72\x6C\x28\x61\x70\x69\x7C\x61\x75\x74\x68\x7C\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x7C\x61\x70\x70\x7C\x62\x6F\x77\x65\x72\x5F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x7C\x61\x73\x73\x65\x74\x73\x29\x2F\x2A","\x72\x6F\x75\x74\x65","\x2F\x2A","\x70\x72\x6F\x64\x75\x63\x74\x69\x6F\x6E","\x72\x6F\x6F\x74","\x70\x75\x62\x6C\x69\x63","\x6A\x6F\x69\x6E","\x64\x65\x76\x65\x6C\x6F\x70\x6D\x65\x6E\x74","\x74\x65\x73\x74","\x63\x6C\x69\x65\x6E\x74","\x69\x6E\x64\x65\x78\x2E\x68\x74\x6D\x6C","\x73\x65\x6E\x64\x46\x69\x6C\x65","\x61\x6C\x6C"];_0xdaa0[0];var config=require(_0xdaa0[1]);var errors=require(_0xdaa0[2]);var path=require(_0xdaa0[3]);var moment=require(_0xdaa0[4]);module[_0xdaa0[5]]=function(_0xd1b5x5){var _0xd1b5x6=_0xd1b5x5[_0xdaa0[7]](_0xdaa0[6]);_0xd1b5x5[_0xdaa0[10]](_0xdaa0[8],require(_0xdaa0[9]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[11],require(_0xdaa0[12]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[13],require(_0xdaa0[14]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[15],require(_0xdaa0[16]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[17],require(_0xdaa0[18]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[19],require(_0xdaa0[20]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[21],require(_0xdaa0[22]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[23],require(_0xdaa0[24]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[25],require(_0xdaa0[26]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[27],require(_0xdaa0[28]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[29],require(_0xdaa0[30]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[31],require(_0xdaa0[32]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[33],require(_0xdaa0[34]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[35],require(_0xdaa0[36]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[37],require(_0xdaa0[38]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[39],require(_0xdaa0[40]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[41],require(_0xdaa0[42]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[43],require(_0xdaa0[44]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[45],require(_0xdaa0[46]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[47],require(_0xdaa0[48]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[49],require(_0xdaa0[50]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[51],require(_0xdaa0[52]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[53],require(_0xdaa0[54]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[55],require(_0xdaa0[56]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[57],require(_0xdaa0[58]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[59],require(_0xdaa0[60]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[61],require(_0xdaa0[62]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[63],require(_0xdaa0[64]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[65],require(_0xdaa0[66]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[67],require(_0xdaa0[68]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[69],require(_0xdaa0[70]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[71],require(_0xdaa0[72]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[73],require(_0xdaa0[74]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[75],require(_0xdaa0[76]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[77],require(_0xdaa0[78]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[79],require(_0xdaa0[80]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[81],require(_0xdaa0[82]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[83],require(_0xdaa0[84]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[85],require(_0xdaa0[86]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[87],require(_0xdaa0[88]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[89],require(_0xdaa0[90]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[91],require(_0xdaa0[92]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[93],require(_0xdaa0[94]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[95],require(_0xdaa0[96]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[97],require(_0xdaa0[98]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[99],require(_0xdaa0[100]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[101],require(_0xdaa0[102]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[103],require(_0xdaa0[104]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[105],require(_0xdaa0[106]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[107],require(_0xdaa0[108]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[109],require(_0xdaa0[108]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[110],require(_0xdaa0[111]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[112],require(_0xdaa0[113]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[114],require(_0xdaa0[115]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[116],require(_0xdaa0[117]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[118],require(_0xdaa0[119]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[120],require(_0xdaa0[121]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[122],require(_0xdaa0[123]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[124],require(_0xdaa0[125]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[126],require(_0xdaa0[127]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[128],require(_0xdaa0[129]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[130],require(_0xdaa0[131]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[132],require(_0xdaa0[133]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[134],require(_0xdaa0[135]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[136],require(_0xdaa0[137]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[138],require(_0xdaa0[139]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[140],require(_0xdaa0[141]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[142],require(_0xdaa0[143]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[144],require(_0xdaa0[145]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[146],require(_0xdaa0[147]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[148],require(_0xdaa0[149]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[150],require(_0xdaa0[151]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[152],require(_0xdaa0[153]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[154],require(_0xdaa0[155]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[136],require(_0xdaa0[137]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[156],require(_0xdaa0[157]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[158],require(_0xdaa0[159]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[160],require(_0xdaa0[161]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[162],require(_0xdaa0[163]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[164],require(_0xdaa0[165]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[166],require(_0xdaa0[167]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[168],require(_0xdaa0[169]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[170],require(_0xdaa0[171]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[172],require(_0xdaa0[173]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[174],require(_0xdaa0[175]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[176],require(_0xdaa0[177]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[178],require(_0xdaa0[179]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[180],require(_0xdaa0[181]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[182],require(_0xdaa0[183]));_0xd1b5x5[_0xdaa0[10]](_0xdaa0[184],require(_0xdaa0[185]));_0xd1b5x5[_0xdaa0[187]](_0xdaa0[186])[_0xdaa0[7]](errors[404]);_0xd1b5x5[_0xdaa0[198]](_0xdaa0[188],function(_0xd1b5x7,_0xd1b5x8,_0xd1b5x9){var _0xd1b5xa={};if(_0xdaa0[189]===_0xd1b5x6){_0xd1b5xa[_0xdaa0[190]]=path[_0xdaa0[192]](config[_0xdaa0[190]],_0xdaa0[191])};if(_0xdaa0[193]===_0xd1b5x6||_0xdaa0[194]===_0xd1b5x6){_0xd1b5xa[_0xdaa0[190]]=path[_0xdaa0[192]](config[_0xdaa0[190]],_0xdaa0[195])};_0xd1b5x8[_0xdaa0[197]](_0xdaa0[196],_0xd1b5xa);});}; \ No newline at end of file -- 1.7.1