@chat21/chat21-ionic 2.0.13 → 3.0.5-9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/docker-community-push-latest.yml +22 -0
- package/.github/workflows/docker-image-tag-community-tag-push.yml +21 -0
- package/CHANGELOG.md +637 -212
- package/Dockerfile +1 -2
- package/LICENSE +21 -661
- package/README.md +40 -9
- package/angular.json +230 -0
- package/browserslist +12 -0
- package/config.xml +60 -47
- package/deploy_pre.sh +14 -12
- package/deploy_prod.sh +26 -6
- package/env.sample +28 -9
- package/ionic.config.json +2 -2
- package/karma.conf.js +31 -0
- package/nginx.conf +1 -1
- package/package.json +91 -105
- package/publish_pre.sh +33 -0
- package/publish_prod.sh +33 -0
- package/resources/Android/icon/drawable-hdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-ldpi-icon.png +0 -0
- package/resources/Android/icon/drawable-mdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xhdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xxhdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xxxhdpi-icon.png +0 -0
- package/resources/Android/icon.png +0 -0
- package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash.png +0 -0
- package/src/app/app-routing.module.ts +90 -0
- package/src/app/app.component.html +26 -0
- package/src/app/app.component.scss +11 -0
- package/src/app/app.component.spec.ts +47 -0
- package/src/app/app.component.ts +1154 -128
- package/src/app/app.module.ts +314 -135
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +143 -0
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.scss +335 -0
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.spec.ts +179 -0
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +303 -0
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +149 -0
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +199 -0
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.spec.ts +24 -0
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +97 -0
- package/src/app/chatlib/conversation-detail/message/avatar/avatar.component.html +17 -0
- package/src/app/chatlib/conversation-detail/message/avatar/avatar.component.scss +83 -0
- package/src/app/chatlib/conversation-detail/message/avatar/avatar.component.spec.ts +27 -0
- package/src/app/chatlib/conversation-detail/message/avatar/avatar.component.ts +43 -0
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +76 -0
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +51 -0
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.spec.ts +84 -0
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +215 -0
- package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.html +3 -0
- package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.scss +83 -0
- package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.spec.ts +25 -0
- package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.ts +37 -0
- package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.html +24 -0
- package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.scss +61 -0
- package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.spec.ts +25 -0
- package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.ts +30 -0
- package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.html +3 -0
- package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.scss +47 -0
- package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.spec.ts +25 -0
- package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.ts +29 -0
- package/src/app/chatlib/conversation-detail/message/frame/frame.component.html +3 -0
- package/{bin/chat21-ionic → src/app/chatlib/conversation-detail/message/frame/frame.component.scss} +0 -0
- package/src/app/chatlib/conversation-detail/message/frame/frame.component.spec.ts +25 -0
- package/src/app/chatlib/conversation-detail/message/frame/frame.component.ts +33 -0
- package/src/app/chatlib/conversation-detail/message/image/image.component.html +10 -0
- package/src/app/chatlib/conversation-detail/message/image/image.component.scss +34 -0
- package/src/app/chatlib/conversation-detail/message/image/image.component.spec.ts +35 -0
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +78 -0
- package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.html +2 -0
- package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.scss +15 -0
- package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.spec.ts +27 -0
- package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.ts +35 -0
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.html +56 -0
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.scss +169 -0
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.spec.ts +33 -0
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.ts +80 -0
- package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.html +18 -0
- package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.scss +27 -0
- package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.spec.ts +25 -0
- package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.ts +24 -0
- package/src/app/chatlib/conversation-detail/message/text/text.component.html +5 -0
- package/src/app/chatlib/conversation-detail/message/text/text.component.scss +26 -0
- package/src/app/chatlib/conversation-detail/message/text/text.component.spec.ts +33 -0
- package/src/app/chatlib/conversation-detail/message/text/text.component.ts +56 -0
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +154 -0
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +222 -0
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.spec.ts +24 -0
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +113 -0
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +46 -0
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.scss +200 -0
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.spec.ts +27 -0
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.ts +135 -0
- package/src/app/components/authentication/login/login.component.html +65 -0
- package/src/app/components/authentication/login/login.component.scss +85 -0
- package/src/app/components/authentication/login/login.component.spec.ts +24 -0
- package/src/app/components/authentication/login/login.component.ts +174 -0
- package/src/app/components/contacts-directory/contacts-directory.component.html +22 -0
- package/src/app/components/contacts-directory/contacts-directory.component.scss +123 -0
- package/src/app/components/contacts-directory/contacts-directory.component.spec.ts +24 -0
- package/src/app/components/contacts-directory/contacts-directory.component.ts +109 -0
- package/src/app/components/conversation-detail/bubble-day-message/bubble-day-message.component.html +3 -0
- package/src/app/components/conversation-detail/bubble-day-message/bubble-day-message.component.scss +21 -0
- package/src/app/components/conversation-detail/bubble-day-message/bubble-day-message.component.spec.ts +24 -0
- package/src/app/components/conversation-detail/bubble-day-message/bubble-day-message.component.ts +14 -0
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.html +54 -0
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.scss +98 -0
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.spec.ts +24 -0
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.ts +84 -0
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.html +30 -0
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.scss +83 -0
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.spec.ts +24 -0
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.ts +68 -0
- package/src/app/components/conversation-detail/bubble-system-message/bubble-system-message.component.html +3 -0
- package/src/app/components/conversation-detail/bubble-system-message/bubble-system-message.component.scss +10 -0
- package/src/app/components/conversation-detail/bubble-system-message/bubble-system-message.component.spec.ts +24 -0
- package/src/app/components/conversation-detail/bubble-system-message/bubble-system-message.component.ts +14 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +71 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +161 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.spec.ts +24 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +133 -0
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +64 -0
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +124 -0
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.spec.ts +25 -0
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +685 -0
- package/src/app/components/conversation-detail/option-header/option-header.component.html +13 -0
- package/src/app/components/conversation-detail/option-header/option-header.component.scss +0 -0
- package/src/app/components/conversation-detail/option-header/option-header.component.spec.ts +24 -0
- package/src/app/components/conversation-detail/option-header/option-header.component.ts +24 -0
- package/src/app/components/conversation-info/advanced-info-accordion/advanced-info-accordion.component.html +64 -0
- package/src/app/components/conversation-info/advanced-info-accordion/advanced-info-accordion.component.scss +135 -0
- package/src/app/components/conversation-info/advanced-info-accordion/advanced-info-accordion.component.spec.ts +24 -0
- package/src/app/components/conversation-info/advanced-info-accordion/advanced-info-accordion.component.ts +53 -0
- package/src/app/components/conversation-info/conversation-info.module.ts +13 -0
- package/src/app/components/conversation-info/info-content/info-content.component.html +18 -0
- package/src/app/components/conversation-info/info-content/info-content.component.scss +5 -0
- package/src/app/components/conversation-info/info-content/info-content.component.spec.ts +24 -0
- package/src/app/components/conversation-info/info-content/info-content.component.ts +395 -0
- package/src/app/components/conversation-info/info-direct/info-direct.component.html +57 -0
- package/src/app/components/conversation-info/info-direct/info-direct.component.scss +62 -0
- package/src/app/components/conversation-info/info-direct/info-direct.component.spec.ts +24 -0
- package/src/app/components/conversation-info/info-direct/info-direct.component.ts +67 -0
- package/src/app/components/conversation-info/info-group/info-group.component.html +115 -0
- package/src/app/components/conversation-info/info-group/info-group.component.scss +80 -0
- package/src/app/components/conversation-info/info-group/info-group.component.spec.ts +24 -0
- package/src/app/components/conversation-info/info-group/info-group.component.ts +218 -0
- package/src/app/components/conversation-info/info-support-group/info-support-group.component.html +6 -0
- package/src/app/components/conversation-info/info-support-group/info-support-group.component.scss +0 -0
- package/src/app/components/conversation-info/info-support-group/info-support-group.component.spec.ts +24 -0
- package/src/app/components/conversation-info/info-support-group/info-support-group.component.ts +29 -0
- package/src/app/components/ddp-header/ddp-header.component.html +31 -0
- package/src/app/components/ddp-header/ddp-header.component.scss +26 -0
- package/src/app/components/ddp-header/ddp-header.component.spec.ts +24 -0
- package/src/app/components/ddp-header/ddp-header.component.ts +33 -0
- package/src/app/components/image-viewer/image-viewer.component.html +23 -0
- package/src/app/components/image-viewer/image-viewer.component.scss +107 -0
- package/src/app/components/image-viewer/image-viewer.component.spec.ts +24 -0
- package/src/app/components/image-viewer/image-viewer.component.ts +38 -0
- package/src/app/components/project-item/project-item.component.html +147 -0
- package/src/app/components/project-item/project-item.component.scss +669 -0
- package/src/app/components/project-item/project-item.component.spec.ts +24 -0
- package/src/app/components/project-item/project-item.component.ts +350 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.html +12 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.scss +29 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.spec.ts +24 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +41 -0
- package/src/app/components/utils/user-presence/user-presence.component.html +2 -0
- package/src/app/components/utils/user-presence/user-presence.component.scss +24 -0
- package/src/app/components/utils/user-presence/user-presence.component.spec.ts +24 -0
- package/src/app/components/utils/user-presence/user-presence.component.ts +159 -0
- package/src/app/directives/autofocus.directive.ts +41 -0
- package/src/app/directives/html-entities-encode.pipe.spec.ts +8 -0
- package/src/app/directives/html-entities-encode.pipe.ts +17 -0
- package/src/app/directives/marked.pipe.spec.ts +8 -0
- package/src/app/directives/marked.pipe.ts +27 -0
- package/src/app/directives/safe-html.pipe.ts +16 -0
- package/src/app/pages/authentication/login/login-routing.module.ts +17 -0
- package/src/app/pages/authentication/login/login.module.ts +39 -0
- package/src/app/pages/authentication/login/login.page.html +7 -0
- package/src/app/pages/authentication/login/login.page.scss +5 -0
- package/src/app/pages/authentication/login/login.page.spec.ts +24 -0
- package/src/app/pages/authentication/login/login.page.ts +187 -0
- package/src/app/pages/contacts-directory/contacts-directory-routing.module.ts +17 -0
- package/src/app/pages/contacts-directory/contacts-directory.module.ts +42 -0
- package/src/app/pages/contacts-directory/contacts-directory.page.html +19 -0
- package/src/app/pages/contacts-directory/contacts-directory.page.scss +0 -0
- package/src/app/pages/contacts-directory/contacts-directory.page.spec.ts +24 -0
- package/src/app/pages/contacts-directory/contacts-directory.page.ts +125 -0
- package/src/app/pages/conversation-detail/conversation-detail-routing.module.ts +17 -0
- package/src/app/pages/conversation-detail/conversation-detail.module.ts +69 -0
- package/src/app/pages/conversation-detail/conversation-detail.page.html +191 -0
- package/src/app/pages/conversation-detail/conversation-detail.page.scss +492 -0
- package/src/app/pages/conversation-detail/conversation-detail.page.spec.ts +24 -0
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +1525 -0
- package/src/app/pages/conversations-list/conversations-list-routing.module.ts +17 -0
- package/src/app/pages/conversations-list/conversations-list.module.ts +43 -0
- package/src/app/pages/conversations-list/conversations-list.page.html +112 -0
- package/src/app/pages/conversations-list/conversations-list.page.scss +302 -0
- package/src/app/pages/conversations-list/conversations-list.page.spec.ts +24 -0
- package/src/app/pages/conversations-list/conversations-list.page.ts +1032 -0
- package/src/app/pages/details/details-routing.module.ts +17 -0
- package/src/app/pages/details/details.module.ts +21 -0
- package/src/app/pages/details/details.page.html +28 -0
- package/src/app/pages/details/details.page.scss +23 -0
- package/src/app/pages/details/details.page.spec.ts +24 -0
- package/src/app/pages/details/details.page.ts +65 -0
- package/src/app/pages/loader-preview/loader-preview-routing.module.ts +17 -0
- package/src/app/pages/loader-preview/loader-preview.module.ts +29 -0
- package/src/app/pages/loader-preview/loader-preview.page.html +62 -0
- package/src/app/pages/loader-preview/loader-preview.page.scss +117 -0
- package/src/app/pages/loader-preview/loader-preview.page.spec.ts +24 -0
- package/src/app/pages/loader-preview/loader-preview.page.ts +353 -0
- package/src/app/pages/profile-info/profile-info-routing.module.ts +17 -0
- package/src/app/pages/profile-info/profile-info.module.ts +41 -0
- package/src/app/pages/profile-info/profile-info.page.html +86 -0
- package/src/app/pages/profile-info/profile-info.page.scss +264 -0
- package/src/app/pages/profile-info/profile-info.page.spec.ts +24 -0
- package/src/app/pages/profile-info/profile-info.page.ts +223 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations-routing.module.ts +17 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.spec.ts +24 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +116 -0
- package/src/app/services/app-config.ts +107 -0
- package/src/app/services/canned-responses/canned-responses.service.spec.ts +12 -0
- package/src/app/services/canned-responses/canned-responses.service.ts +49 -0
- package/src/app/services/contacts/contacts.service.spec.ts +12 -0
- package/src/app/services/contacts/contacts.service.ts +172 -0
- package/src/app/services/events-service.ts +79 -0
- package/src/app/services/nav-proxy.service.spec.ts +12 -0
- package/src/app/services/nav-proxy.service.ts +80 -0
- package/src/app/services/network-service/network.service.spec.ts +12 -0
- package/src/app/services/network-service/network.service.ts +46 -0
- package/src/app/services/tiledesk/tiledesk.service.spec.ts +12 -0
- package/src/app/services/tiledesk/tiledesk.service.ts +99 -0
- package/src/app/services/websocket/websocket-js.ts +560 -0
- package/src/app/services/websocket/websocket.service.spec.ts +12 -0
- package/src/app/services/websocket/websocket.service.ts +292 -0
- package/src/app/shared/shared-conversation-info.module.ts +33 -0
- package/src/app/shared/shared.module.ts +130 -0
- package/src/{utils → app/utils}/constants.ts-e +0 -0
- package/src/app/utils/scrollbar-theme.directive.ts +63 -0
- package/src/assets/i18n/en.json +122 -38
- package/src/assets/i18n/it.json +101 -10
- package/src/assets/icon/favicon.ico +0 -0
- package/src/assets/icon/ionic_favicon.png +0 -0
- package/src/assets/images/f21ico-done.svg +1 -0
- package/src/assets/images/f21ico-done_all.svg +1 -0
- package/src/assets/images/f21ico-schedule.svg +1 -0
- package/src/assets/images/file-alt-solid.png +0 -0
- package/src/assets/images/no_conversation.jpg +0 -0
- package/src/assets/{img → images}/no_image.png +0 -0
- package/src/assets/js/chat21client.js +1027 -0
- package/src/assets/js/mqtt/4.1.0/mqtt.min.js +1 -0
- package/src/assets/js/mqtt/4.2.6/mqtt.min.js +1 -0
- package/src/assets/js/mqtt/4.2.8/mqtt.min.js +1 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/shapes.svg +1 -0
- package/src/assets/sounds/pling.mp3 +0 -0
- package/src/assets/transparent.png +0 -0
- package/src/chat-config-mqtt-ver-uploaded.json +22 -0
- package/src/chat-config-mqtt.json +26 -0
- package/src/chat-config-pre-test.json +32 -0
- package/src/chat-config-pre.json +23 -0
- package/src/chat-config-template.json +20 -6
- package/src/chat-config.json +30 -0
- package/src/{models → chat21-core/models}/conversation.ts +6 -2
- package/src/{models → chat21-core/models}/group.ts +7 -5
- package/src/{models → chat21-core/models}/message.ts +8 -8
- package/src/{models → chat21-core/models}/upload.ts +5 -5
- package/src/{models → chat21-core/models}/user.ts +2 -1
- package/src/chat21-core/providers/abstract/app-storage.service.spec.ts +15 -0
- package/src/chat21-core/providers/abstract/app-storage.service.ts +17 -0
- package/src/chat21-core/providers/abstract/archivedconversations-handler.service.spec.ts +13 -0
- package/src/chat21-core/providers/abstract/archivedconversations-handler.service.ts +34 -0
- package/src/chat21-core/providers/abstract/conversation-handler-builder.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/conversation-handler-builder.service.ts +11 -0
- package/src/chat21-core/providers/abstract/conversation-handler.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/conversation-handler.service.ts +43 -0
- package/src/chat21-core/providers/abstract/conversations-handler.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/conversations-handler.service.ts +42 -0
- package/src/chat21-core/providers/abstract/groups-handler.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/groups-handler.service.ts +28 -0
- package/src/chat21-core/providers/abstract/image-repo.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/image-repo.service.ts +26 -0
- package/src/chat21-core/providers/abstract/logger.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/logger.service.ts +16 -0
- package/src/chat21-core/providers/abstract/messagingAuth.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/messagingAuth.service.ts +54 -0
- package/src/chat21-core/providers/abstract/notifications.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/notifications.service.ts +31 -0
- package/src/chat21-core/providers/abstract/presence.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/presence.service.ts +34 -0
- package/src/chat21-core/providers/abstract/typing.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/typing.service.ts +31 -0
- package/src/chat21-core/providers/abstract/upload.service.spec.ts +12 -0
- package/src/chat21-core/providers/abstract/upload.service.ts +39 -0
- package/src/chat21-core/providers/chat-manager.ts +282 -0
- package/src/chat21-core/providers/custom-translate.service.spec.ts +12 -0
- package/src/chat21-core/providers/custom-translate.service.ts +42 -0
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +476 -0
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +376 -0
- package/src/chat21-core/providers/firebase/firebase-conversation-handler-builder.service.ts +19 -0
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +416 -0
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +570 -0
- package/src/chat21-core/providers/firebase/firebase-groups-handler.ts +303 -0
- package/src/chat21-core/providers/firebase/firebase-image-repo.ts +40 -0
- package/src/chat21-core/providers/firebase/firebase-init-service.ts +31 -0
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +246 -0
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +190 -0
- package/src/chat21-core/providers/firebase/firebase-typing.service.ts +93 -0
- package/src/chat21-core/providers/firebase/firebase-upload.service.ts +106 -0
- package/src/chat21-core/providers/localSessionStorage.ts +215 -0
- package/src/chat21-core/providers/logger/customLogger.ts +70 -0
- package/src/chat21-core/providers/logger/loggerInstance.ts +20 -0
- package/src/chat21-core/providers/mqtt/chat-service.ts +44 -0
- package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +707 -0
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +313 -0
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler-builder.service.ts +25 -0
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +446 -0
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +601 -0
- package/src/chat21-core/providers/mqtt/mqtt-groups-handler.ts +139 -0
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +122 -0
- package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +229 -0
- package/src/chat21-core/providers/mqtt/mqtt-typing.service.ts +93 -0
- package/src/chat21-core/providers/native/native-image-repo.ts +30 -0
- package/src/chat21-core/providers/native/native-upload-service.ts +85 -0
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.spec.ts +12 -0
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +211 -0
- package/src/chat21-core/utils/constants.ts +109 -0
- package/src/chat21-core/utils/user-typing/user-typing.component.html +6 -0
- package/src/chat21-core/utils/user-typing/user-typing.component.scss +62 -0
- package/src/chat21-core/utils/user-typing/user-typing.component.spec.ts +24 -0
- package/src/chat21-core/utils/user-typing/user-typing.component.ts +114 -0
- package/src/chat21-core/utils/utils-message.ts +117 -0
- package/src/chat21-core/utils/utils-user.ts +46 -0
- package/src/chat21-core/utils/utils.ts +893 -0
- package/src/firebase-messaging-sw-template.js +1 -1
- package/src/global.scss +585 -0
- package/src/index.html +71 -42
- package/src/main.ts +12 -0
- package/src/manifest.json +0 -11
- package/src/models/department.ts +12 -0
- package/src/polyfills.ts +73 -0
- package/src/test.ts +21 -0
- package/src/theme/variables.scss +236 -93
- package/src/variables.scss +30 -0
- package/src/zone-flags.ts +5 -0
- package/tsconfig.app.json +14 -0
- package/tsconfig.json +23 -18
- package/tsconfig.spec.json +19 -0
- package/tslint.json +84 -7
- package/app.json +0 -7
- package/curl +0 -1
- package/deploy_dev.sh +0 -28
- package/docs/changelog.html +0 -227
- package/docs/classes/ConversationModel.html +0 -1022
- package/docs/classes/GroupModel.html +0 -527
- package/docs/classes/MessageModel.html +0 -843
- package/docs/classes/UploadModel.html +0 -417
- package/docs/classes/UserModel.html +0 -728
- package/docs/classes/_DetailPage.html +0 -144
- package/docs/classes/_MasterPage.html +0 -144
- package/docs/components/ArchivedConversationsPage.html +0 -1024
- package/docs/components/ChatBubble.html +0 -327
- package/docs/components/DettaglioConversazionePage.html +0 -6060
- package/docs/components/ElasticTextarea.html +0 -619
- package/docs/components/InfoAdvancedPage.html +0 -656
- package/docs/components/InfoConversationPage.html +0 -5681
- package/docs/components/InfoMessagePage.html +0 -993
- package/docs/components/InfoUserPage.html +0 -1420
- package/docs/components/ListaConversazioniPage.html +0 -3576
- package/docs/components/LoginPage.html +0 -1457
- package/docs/components/MyApp.html +0 -1388
- package/docs/components/PlaceholderPage.html +0 -397
- package/docs/components/PopoverPage.html +0 -986
- package/docs/components/PopoverProfilePage.html +0 -639
- package/docs/components/ProfilePage.html +0 -1187
- package/docs/components/RegisterPage.html +0 -1271
- package/docs/components/ResetpwdPage.html +0 -1039
- package/docs/components/UpdateImageProfilePage.html +0 -997
- package/docs/components/UsersPage.html +0 -1297
- package/docs/coverage.html +0 -1421
- package/docs/dependencies.html +0 -210
- package/docs/directives/AutosizeDirective.html +0 -556
- package/docs/fonts/FontAwesome.otf +0 -0
- package/docs/fonts/fontawesome-webfont.eot +0 -0
- package/docs/fonts/fontawesome-webfont.svg +0 -685
- package/docs/fonts/fontawesome-webfont.ttf +0 -0
- package/docs/fonts/fontawesome-webfont.woff +0 -0
- package/docs/fonts/fontawesome-webfont.woff2 +0 -0
- package/docs/fonts/ionicons.eot +0 -0
- package/docs/fonts/ionicons.svg +0 -2090
- package/docs/fonts/ionicons.ttf +0 -0
- package/docs/fonts/ionicons.woff +0 -0
- package/docs/fonts/ionicons.woff2 +0 -0
- package/docs/fonts/roboto-v15-latin-300.eot +0 -0
- package/docs/fonts/roboto-v15-latin-300.svg +0 -314
- package/docs/fonts/roboto-v15-latin-300.ttf +0 -0
- package/docs/fonts/roboto-v15-latin-300.woff +0 -0
- package/docs/fonts/roboto-v15-latin-300.woff2 +0 -0
- package/docs/fonts/roboto-v15-latin-700.eot +0 -0
- package/docs/fonts/roboto-v15-latin-700.svg +0 -310
- package/docs/fonts/roboto-v15-latin-700.ttf +0 -0
- package/docs/fonts/roboto-v15-latin-700.woff +0 -0
- package/docs/fonts/roboto-v15-latin-700.woff2 +0 -0
- package/docs/fonts/roboto-v15-latin-italic.eot +0 -0
- package/docs/fonts/roboto-v15-latin-italic.svg +0 -323
- package/docs/fonts/roboto-v15-latin-italic.ttf +0 -0
- package/docs/fonts/roboto-v15-latin-italic.woff +0 -0
- package/docs/fonts/roboto-v15-latin-italic.woff2 +0 -0
- package/docs/fonts/roboto-v15-latin-regular.eot +0 -0
- package/docs/fonts/roboto-v15-latin-regular.svg +0 -308
- package/docs/fonts/roboto-v15-latin-regular.ttf +0 -0
- package/docs/fonts/roboto-v15-latin-regular.woff +0 -0
- package/docs/fonts/roboto-v15-latin-regular.woff2 +0 -0
- package/docs/graph/dependencies.svg +0 -870
- package/docs/images/compodoc-vectorise-inverted.png +0 -0
- package/docs/images/compodoc-vectorise-inverted.svg +0 -201
- package/docs/images/compodoc-vectorise.png +0 -0
- package/docs/images/compodoc-vectorise.svg +0 -201
- package/docs/images/coverage-badge-documentation.svg +0 -9
- package/docs/images/coverage-badge.svg +0 -9
- package/docs/images/favicon.ico +0 -0
- package/docs/index.html +0 -233
- package/docs/injectables/AppConfigProvider.html +0 -411
- package/docs/injectables/AuthService.html +0 -1016
- package/docs/injectables/ChatArchivedConversationsHandler.html +0 -1832
- package/docs/injectables/ChatContactsSynchronizer.html +0 -841
- package/docs/injectables/ChatConversationHandler.html +0 -1960
- package/docs/injectables/ChatConversationsHandler.html +0 -2584
- package/docs/injectables/ChatManager.html +0 -1779
- package/docs/injectables/ChatPresenceHandler.html +0 -1187
- package/docs/injectables/CustomTranslateService.html +0 -496
- package/docs/injectables/DatabaseProvider.html +0 -1444
- package/docs/injectables/GroupService.html +0 -1458
- package/docs/injectables/MessagingService.html +0 -1165
- package/docs/injectables/NavProxyService.html +0 -1028
- package/docs/injectables/TiledeskConversationProvider.html +0 -945
- package/docs/injectables/UploadService.html +0 -791
- package/docs/injectables/UserService.html +0 -1612
- package/docs/js/compodoc.js +0 -14
- package/docs/js/lazy-load-graphs.js +0 -44
- package/docs/js/libs/EventDispatcher.js +0 -5
- package/docs/js/libs/bootstrap-native.js +0 -2
- package/docs/js/libs/clipboard.min.js +0 -7
- package/docs/js/libs/custom-elements-es5-adapter.js +0 -15
- package/docs/js/libs/custom-elements.min.js +0 -38
- package/docs/js/libs/d3.v3.min.js +0 -2
- package/docs/js/libs/deep-iterator.js +0 -2
- package/docs/js/libs/es6-shim.min.js +0 -11
- package/docs/js/libs/htmlparser.js +0 -23
- package/docs/js/libs/innersvg.js +0 -9
- package/docs/js/libs/lit-html.js +0 -1
- package/docs/js/libs/prism.js +0 -14
- package/docs/js/libs/promise.min.js +0 -6
- package/docs/js/libs/svg-pan-zoom.min.js +0 -3
- package/docs/js/libs/tablesort.min.js +0 -6
- package/docs/js/libs/tablesort.number.min.js +0 -6
- package/docs/js/libs/vis.min.js +0 -46
- package/docs/js/libs/zepto.min.js +0 -2
- package/docs/js/menu-wc.js +0 -594
- package/docs/js/menu.js +0 -261
- package/docs/js/routes.js +0 -280
- package/docs/js/search/lunr.min.js +0 -6
- package/docs/js/search/search-lunr.js +0 -67
- package/docs/js/search/search.js +0 -268
- package/docs/js/search/search_index.js +0 -4
- package/docs/js/sourceCode.js +0 -58
- package/docs/js/svg-pan-zoom.controls.js +0 -53
- package/docs/js/tabs.js +0 -21
- package/docs/js/tree.js +0 -147
- package/docs/license.html +0 -664
- package/docs/miscellaneous/functions.html +0 -2417
- package/docs/miscellaneous/variables.html +0 -994
- package/docs/modules/AppModule/dependencies.svg +0 -454
- package/docs/modules/AppModule.html +0 -967
- package/docs/modules/ArchivedConversationsPageModule/dependencies.svg +0 -50
- package/docs/modules/ArchivedConversationsPageModule.html +0 -225
- package/docs/modules/DettaglioConversazionePageModule/dependencies.svg +0 -66
- package/docs/modules/DettaglioConversazionePageModule.html +0 -256
- package/docs/modules/InfoAdvancedPageModule/dependencies.svg +0 -50
- package/docs/modules/InfoAdvancedPageModule.html +0 -225
- package/docs/modules/InfoConversationPageModule/dependencies.svg +0 -50
- package/docs/modules/InfoConversationPageModule.html +0 -227
- package/docs/modules/InfoUserPageModule/dependencies.svg +0 -50
- package/docs/modules/InfoUserPageModule.html +0 -225
- package/docs/modules/ListaConversazioniPageModule/dependencies.svg +0 -66
- package/docs/modules/ListaConversazioniPageModule.html +0 -255
- package/docs/modules/LoginModule/dependencies.svg +0 -66
- package/docs/modules/LoginModule.html +0 -253
- package/docs/modules/PlaceholderPageModule/dependencies.svg +0 -66
- package/docs/modules/PlaceholderPageModule.html +0 -253
- package/docs/modules/PopoverPageModule/dependencies.svg +0 -66
- package/docs/modules/PopoverPageModule.html +0 -253
- package/docs/modules/PopoverProfilePageModule/dependencies.svg +0 -66
- package/docs/modules/PopoverProfilePageModule.html +0 -253
- package/docs/modules/ProfilePageModule/dependencies.svg +0 -66
- package/docs/modules/ProfilePageModule.html +0 -253
- package/docs/modules/RegisterModule/dependencies.svg +0 -66
- package/docs/modules/RegisterModule.html +0 -253
- package/docs/modules/ResetpwdModule/dependencies.svg +0 -66
- package/docs/modules/ResetpwdModule.html +0 -253
- package/docs/modules/UpdateImageProfilePageModule/dependencies.svg +0 -66
- package/docs/modules/UpdateImageProfilePageModule.html +0 -253
- package/docs/modules/UsersModule/dependencies.svg +0 -66
- package/docs/modules/UsersModule.html +0 -253
- package/docs/modules.html +0 -379
- package/docs/overview.html +0 -1033
- package/docs/styles/bootstrap-card.css +0 -219
- package/docs/styles/bootstrap.min.css +0 -5
- package/docs/styles/compodoc.css +0 -996
- package/docs/styles/font-awesome.min.css +0 -4
- package/docs/styles/ionicons.min.css +0 -11
- package/docs/styles/laravel.css +0 -69
- package/docs/styles/material.css +0 -109
- package/docs/styles/original.css +0 -47
- package/docs/styles/postmark.css +0 -224
- package/docs/styles/prism.css +0 -267
- package/docs/styles/readthedocs.css +0 -108
- package/docs/styles/reset.css +0 -48
- package/docs/styles/stripe.css +0 -65
- package/docs/styles/style.css +0 -7
- package/docs/styles/tablesort.css +0 -33
- package/docs/styles/vagrant.css +0 -96
- package/firebase-functions/.firebaserc +0 -5
- package/firebase-functions/firebase.json +0 -1
- package/firebase-functions/functions/index.js +0 -208
- package/firebase-functions/functions/package.json +0 -9
- package/google-services.json +0 -42
- package/hooks/README.md +0 -196
- package/resources/android/icon/drawable-hdpi-icon.png +0 -0
- package/resources/android/icon/drawable-ldpi-icon.png +0 -0
- package/resources/android/icon/drawable-mdpi-icon.png +0 -0
- package/resources/android/icon/drawable-xhdpi-icon.png +0 -0
- package/resources/android/icon/drawable-xxhdpi-icon.png +0 -0
- package/resources/android/icon/drawable-xxxhdpi-icon.png +0 -0
- package/resources/android/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/android/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/android/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/android/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/android/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/android/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/android/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/android/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/android/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/android/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/android/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/android/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/icon.png +0 -0
- package/resources/icon.png.md5 +0 -1
- package/resources/ios/icon/icon-1024.png +0 -0
- package/resources/ios/icon/icon-40.png +0 -0
- package/resources/ios/icon/icon-40@2x.png +0 -0
- package/resources/ios/icon/icon-40@3x.png +0 -0
- package/resources/ios/icon/icon-50.png +0 -0
- package/resources/ios/icon/icon-50@2x.png +0 -0
- package/resources/ios/icon/icon-60.png +0 -0
- package/resources/ios/icon/icon-60@2x.png +0 -0
- package/resources/ios/icon/icon-60@3x.png +0 -0
- package/resources/ios/icon/icon-72.png +0 -0
- package/resources/ios/icon/icon-72@2x.png +0 -0
- package/resources/ios/icon/icon-76.png +0 -0
- package/resources/ios/icon/icon-76@2x.png +0 -0
- package/resources/ios/icon/icon-83.5@2x.png +0 -0
- package/resources/ios/icon/icon-small.png +0 -0
- package/resources/ios/icon/icon-small@2x.png +0 -0
- package/resources/ios/icon/icon-small@3x.png +0 -0
- package/resources/ios/icon/icon.png +0 -0
- package/resources/ios/icon/icon@2x.png +0 -0
- package/resources/ios/splash/Default-568h@2x~iphone.png +0 -0
- package/resources/ios/splash/Default-667h.png +0 -0
- package/resources/ios/splash/Default-736h.png +0 -0
- package/resources/ios/splash/Default-Landscape-736h.png +0 -0
- package/resources/ios/splash/Default-Landscape@2x~ipad.png +0 -0
- package/resources/ios/splash/Default-Landscape@~ipadpro.png +0 -0
- package/resources/ios/splash/Default-Landscape~ipad.png +0 -0
- package/resources/ios/splash/Default-Portrait@2x~ipad.png +0 -0
- package/resources/ios/splash/Default-Portrait@~ipadpro.png +0 -0
- package/resources/ios/splash/Default-Portrait~ipad.png +0 -0
- package/resources/ios/splash/Default@2x~iphone.png +0 -0
- package/resources/ios/splash/Default@2x~universal~anyany.png +0 -0
- package/resources/ios/splash/Default~iphone.png +0 -0
- package/resources/splash.png +0 -0
- package/resources/splash.png.md5 +0 -1
- package/server.js +0 -7
- package/src/app/app.html +0 -56
- package/src/app/app.scss +0 -236
- package/src/app/main.ts +0 -9
- package/src/assets/chat-background.jpg +0 -0
- package/src/assets/chat21-ionic-pattern-2.svg +0 -5110
- package/src/assets/chat21-ionic-pattern.png +0 -0
- package/src/assets/chat21-ionic-pattern.svg +0 -1
- package/src/assets/download.svg +0 -1
- package/src/assets/dummyDump.sql +0 -1
- package/src/assets/icon/favicon_old.ico +0 -0
- package/src/assets/img/c21-down-gray.svg +0 -1
- package/src/assets/img/chat21-icon.png +0 -0
- package/src/assets/img/f21ico-attached.svg +0 -1
- package/src/assets/img/f21ico-close.svg +0 -1
- package/src/assets/img/f21ico-photo.svg +0 -1
- package/src/assets/img/ic_keyboard_arrow_down_black_24px.svg +0 -4
- package/src/assets/img/ic_keyboard_arrow_down_white_24px.svg +0 -4
- package/src/assets/img/icon.png +0 -0
- package/src/assets/message-mine.png +0 -0
- package/src/assets/message-other.png +0 -0
- package/src/assets/pling.mp3 +0 -0
- package/src/assets/splash.png +0 -0
- package/src/declarations.d.ts +0 -14
- package/src/directives/autosize/autosize.ts +0 -82
- package/src/environments/environment.pre.ts +0 -22
- package/src/environments/environment.prod.ts +0 -22
- package/src/environments/environment.ts +0 -21
- package/src/pages/_DetailPage.ts +0 -1
- package/src/pages/_MasterPage.ts +0 -1
- package/src/pages/archived-conversations/archived-conversations.html +0 -32
- package/src/pages/archived-conversations/archived-conversations.module.ts +0 -13
- package/src/pages/archived-conversations/archived-conversations.scss +0 -153
- package/src/pages/archived-conversations/archived-conversations.ts +0 -121
- package/src/pages/authentication/login/login.html +0 -58
- package/src/pages/authentication/login/login.module.ts +0 -16
- package/src/pages/authentication/login/login.scss +0 -121
- package/src/pages/authentication/login/login.ts +0 -221
- package/src/pages/authentication/register/register.html +0 -88
- package/src/pages/authentication/register/register.module.ts +0 -16
- package/src/pages/authentication/register/register.scss +0 -95
- package/src/pages/authentication/register/register.ts +0 -122
- package/src/pages/authentication/resetpwd/resetpwd.html +0 -40
- package/src/pages/authentication/resetpwd/resetpwd.module.ts +0 -16
- package/src/pages/authentication/resetpwd/resetpwd.scss +0 -102
- package/src/pages/authentication/resetpwd/resetpwd.ts +0 -93
- package/src/pages/components/chatBubble_old/chatBubble.scss +0 -83
- package/src/pages/components/chatBubble_old/chatBubble.ts +0 -30
- package/src/pages/components/elasticTextarea_old.ts +0 -46
- package/src/pages/dettaglio-conversazione/dettaglio-conversazione.html +0 -261
- package/src/pages/dettaglio-conversazione/dettaglio-conversazione.module.ts +0 -19
- package/src/pages/dettaglio-conversazione/dettaglio-conversazione.scss +0 -701
- package/src/pages/dettaglio-conversazione/dettaglio-conversazione.ts +0 -1395
- package/src/pages/index.ts +0 -5
- package/src/pages/info-advanced/info-advanced.html +0 -90
- package/src/pages/info-advanced/info-advanced.module.ts +0 -13
- package/src/pages/info-advanced/info-advanced.scss +0 -196
- package/src/pages/info-advanced/info-advanced.ts +0 -44
- package/src/pages/info-conversation/info-conversation.html +0 -225
- package/src/pages/info-conversation/info-conversation.module.ts +0 -15
- package/src/pages/info-conversation/info-conversation.scss +0 -444
- package/src/pages/info-conversation/info-conversation.ts +0 -1233
- package/src/pages/info-message/info-message.html +0 -74
- package/src/pages/info-message/info-message.module.ts +0 -13
- package/src/pages/info-message/info-message.scss +0 -216
- package/src/pages/info-message/info-message.ts +0 -89
- package/src/pages/info-user/info-user.html +0 -89
- package/src/pages/info-user/info-user.module.ts +0 -13
- package/src/pages/info-user/info-user.scss +0 -187
- package/src/pages/info-user/info-user.ts +0 -177
- package/src/pages/lista-conversazioni/lista-conversazioni.html +0 -88
- package/src/pages/lista-conversazioni/lista-conversazioni.module.ts +0 -18
- package/src/pages/lista-conversazioni/lista-conversazioni.scss +0 -245
- package/src/pages/lista-conversazioni/lista-conversazioni.ts +0 -736
- package/src/pages/placeholder/placeholder.html +0 -3
- package/src/pages/placeholder/placeholder.module.ts +0 -16
- package/src/pages/placeholder/placeholder.scss +0 -23
- package/src/pages/placeholder/placeholder.ts +0 -18
- package/src/pages/popover/popover.html +0 -27
- package/src/pages/popover/popover.module.ts +0 -16
- package/src/pages/popover/popover.scss +0 -23
- package/src/pages/popover/popover.ts +0 -95
- package/src/pages/popover-profile/popover-profile.html +0 -20
- package/src/pages/popover-profile/popover-profile.module.ts +0 -16
- package/src/pages/popover-profile/popover-profile.scss +0 -10
- package/src/pages/popover-profile/popover-profile.ts +0 -40
- package/src/pages/profile/profile.html +0 -54
- package/src/pages/profile/profile.module.ts +0 -16
- package/src/pages/profile/profile.scss +0 -45
- package/src/pages/profile/profile.ts +0 -108
- package/src/pages/update-image-profile/update-image-profile.html +0 -39
- package/src/pages/update-image-profile/update-image-profile.module.ts +0 -16
- package/src/pages/update-image-profile/update-image-profile.scss +0 -50
- package/src/pages/update-image-profile/update-image-profile.ts +0 -111
- package/src/pages/users/users.html +0 -55
- package/src/pages/users/users.module.ts +0 -16
- package/src/pages/users/users.scss +0 -10
- package/src/pages/users/users.ts +0 -222
- package/src/providers/app-config/app-config.ts +0 -33
- package/src/providers/auth-service.ts +0 -140
- package/src/providers/canned-responses-service/canned-responses-service.ts +0 -57
- package/src/providers/chat-archived-conversations-handler.ts +0 -283
- package/src/providers/chat-contacts-synchronizer.ts +0 -179
- package/src/providers/chat-conversation-handler.ts +0 -547
- package/src/providers/chat-conversations-handler.ts +0 -519
- package/src/providers/chat-manager/chat-manager.ts +0 -246
- package/src/providers/chat-presence-handler.ts +0 -188
- package/src/providers/database/database.ts +0 -214
- package/src/providers/group/group.ts +0 -243
- package/src/providers/messaging-service.ts +0 -267
- package/src/providers/nav-proxy.ts +0 -104
- package/src/providers/tiledesk-conversation/tiledesk-conversation.ts +0 -134
- package/src/providers/translate-service.ts +0 -61
- package/src/providers/upload-service/upload-service.ts +0 -117
- package/src/providers/user/user.ts +0 -320
- package/src/service-worker.js +0 -30
- package/src/utils/constants.ts +0 -73
- package/src/utils/utils.ts +0 -548
- package/src/videochat.php +0 -20
|
@@ -0,0 +1,1027 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Chat21Client
|
|
3
|
+
|
|
4
|
+
v0.1.9
|
|
5
|
+
|
|
6
|
+
@Author Andrea Sponziello
|
|
7
|
+
(c) Tiledesk 2020
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// let mqtt = require('mqtt');
|
|
11
|
+
// let axios = require('axios');
|
|
12
|
+
|
|
13
|
+
const _CLIENTADDED = "/clientadded"
|
|
14
|
+
const _CLIENTUPDATED = "/clientupdated"
|
|
15
|
+
const _CLIENTDELETED = "/clientdeleted"
|
|
16
|
+
const CALLBACK_TYPE_ON_MESSAGE_UPDATED_FOR_CONVERSATION = "onMessageUpdatedForConversation"
|
|
17
|
+
const CALLBACK_TYPE_ON_MESSAGE_ADDED_FOR_CONVERSATION = "onMessageAddedForConversation"
|
|
18
|
+
|
|
19
|
+
class Chat21Client {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
// console.log('CHAT21-CLIENT.JS HELLO ', mqtt)
|
|
22
|
+
this.client = null;
|
|
23
|
+
this.reconnections = 0 // just to check how many reconnections
|
|
24
|
+
this.client_id = this.uuidv4();
|
|
25
|
+
this.log = options._log ? true : false;
|
|
26
|
+
if (options && options.MQTTendpoint) {
|
|
27
|
+
if (options.MQTTendpoint.startsWith('/')) {
|
|
28
|
+
if (this.log) {
|
|
29
|
+
console.log("MQTTendpoint relative url");
|
|
30
|
+
}
|
|
31
|
+
var loc = window.location, new_uri;
|
|
32
|
+
if (loc.protocol === "https:") {
|
|
33
|
+
// new_uri = "wss:";
|
|
34
|
+
new_uri = "mqtt:";
|
|
35
|
+
|
|
36
|
+
} else {
|
|
37
|
+
// new_uri = "ws:";
|
|
38
|
+
new_uri = "mqtt:";
|
|
39
|
+
}
|
|
40
|
+
new_uri += "//" + loc.host;
|
|
41
|
+
// new_uri += loc.pathname + "/to/ws";
|
|
42
|
+
new_uri += options.MQTTendpoint;
|
|
43
|
+
this.endpoint = new_uri
|
|
44
|
+
} else {
|
|
45
|
+
this.endpoint = options.MQTTendpoint
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.endpoint = "ws://34.253.207.0:15675/ws"
|
|
51
|
+
}
|
|
52
|
+
this.APIendpoint = options.APIendpoint;
|
|
53
|
+
this.appid = options.appId;
|
|
54
|
+
if (this.log) {
|
|
55
|
+
console.log("final endpoint:", this.endpoint);
|
|
56
|
+
}
|
|
57
|
+
this.user_id = null;
|
|
58
|
+
this.jwt = null;
|
|
59
|
+
this.last_handler = 0;
|
|
60
|
+
|
|
61
|
+
// this.onMessageCallbacks = new Map();
|
|
62
|
+
// this.onConnectCallbacks = new Map();
|
|
63
|
+
|
|
64
|
+
this.onConversationAddedCallbacks = new Map();
|
|
65
|
+
this.onConversationUpdatedCallbacks = new Map();
|
|
66
|
+
this.onConversationDeletedCallbacks = new Map();
|
|
67
|
+
this.onArchivedConversationAddedCallbacks = new Map();
|
|
68
|
+
this.onArchivedConversationDeletedCallbacks = new Map();
|
|
69
|
+
this.onMessageAddedCallbacks = new Map();
|
|
70
|
+
this.onMessageUpdatedCallbacks = new Map();
|
|
71
|
+
this.onGroupUpdatedCallbacks = new Map();
|
|
72
|
+
this.callbackHandlers = new Map();
|
|
73
|
+
this.on_message_handler = null;
|
|
74
|
+
this.topic_inbox = null;
|
|
75
|
+
this.connected = false
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
subscribeToMyConversations() { // MESSAGES ETC.
|
|
79
|
+
// WILDCARS:
|
|
80
|
+
// MQTT: https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/
|
|
81
|
+
// RABBITMQ: https://www.cloudamqp.com/blog/2015-09-03-part4-rabbitmq-for-beginners-exchanges-routing-keys-bindings.html#topic-exchange
|
|
82
|
+
this.topic_inbox = 'apps/tilechat/users/' + this.user_id + "/#"
|
|
83
|
+
if (this.log) {
|
|
84
|
+
console.log("subscribing to:", this.user_id, "topic", this.topic_inbox);
|
|
85
|
+
}
|
|
86
|
+
this.client.subscribe(this.topic_inbox, (err) => {
|
|
87
|
+
if (this.log) {
|
|
88
|
+
console.log("subscribed to:", this.topic_inbox, " with err", err)
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
sendMessage(text, type, recipient_id, recipient_fullname, sender_fullname, attributes, metadata, channel_type, callback) {
|
|
94
|
+
// console.log("sendMessage:",text, recipient_id)
|
|
95
|
+
let dest_topic = `apps/${this.appid}/outgoing/users/${this.user_id}/messages/${recipient_id}/outgoing`
|
|
96
|
+
// console.log("dest_topic:", dest_topic)
|
|
97
|
+
let outgoing_message = {
|
|
98
|
+
text: text,
|
|
99
|
+
type: type,
|
|
100
|
+
recipient_fullname: recipient_fullname,
|
|
101
|
+
sender_fullname: sender_fullname,
|
|
102
|
+
attributes: attributes,
|
|
103
|
+
metadata: metadata,
|
|
104
|
+
channel_type: channel_type
|
|
105
|
+
}
|
|
106
|
+
// console.log("outgoing_message:", outgoing_message)
|
|
107
|
+
const payload = JSON.stringify(outgoing_message)
|
|
108
|
+
this.client.publish(dest_topic, payload, null, (err) => {
|
|
109
|
+
callback(err, outgoing_message)
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
basicMessageBuilder(text, type, recipient_fullname, sender_fullname, attributes, metadata, channel_type) {
|
|
114
|
+
let outgoing_message = {
|
|
115
|
+
text: text,
|
|
116
|
+
type: type,
|
|
117
|
+
recipient_fullname: recipient_fullname,
|
|
118
|
+
sender_fullname: sender_fullname,
|
|
119
|
+
attributes: attributes,
|
|
120
|
+
metadata: metadata,
|
|
121
|
+
channel_type: channel_type
|
|
122
|
+
}
|
|
123
|
+
return outgoing_message;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
sendMessageRaw(outgoing_message, recipient_id, callback) {
|
|
127
|
+
// callback - function (err)
|
|
128
|
+
// console.log("recipient_id:", recipient_id)
|
|
129
|
+
let dest_topic = `apps/${this.appid}/outgoing/users/${this.user_id}/messages/${recipient_id}/outgoing`
|
|
130
|
+
// console.log("dest_topic:", dest_topic)
|
|
131
|
+
// let outgoing_message = {
|
|
132
|
+
// text: text,
|
|
133
|
+
// type: type,
|
|
134
|
+
// recipient_fullname: recipient_fullname,
|
|
135
|
+
// sender_fullname: sender_fullname,
|
|
136
|
+
// attributes: attributes,
|
|
137
|
+
// metadata: metadata,
|
|
138
|
+
// channel_type: channel_type
|
|
139
|
+
// }
|
|
140
|
+
// console.log("outgoing_message:", outgoing_message)
|
|
141
|
+
const payload = JSON.stringify(outgoing_message)
|
|
142
|
+
this.client.publish(dest_topic, payload, null, (err) => {
|
|
143
|
+
callback(err, outgoing_message)
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
updateMessageStatus(messageId, conversWith, status, callback) {
|
|
148
|
+
// callback - function (err)
|
|
149
|
+
if (this.log) {
|
|
150
|
+
console.log("updating recipient_id:", messageId, "on conversWith", conversWith, "status", status)
|
|
151
|
+
}
|
|
152
|
+
// 'apps/tilechat/users/USER_ID/messages/CONVERS_WITH/MESSAGE_ID/update'
|
|
153
|
+
let dest_topic = `apps/${this.appid}/users/${this.user_id}/messages/${conversWith}/${messageId}/update`
|
|
154
|
+
if (this.log) {
|
|
155
|
+
console.log("update dest_topic:", dest_topic);
|
|
156
|
+
}
|
|
157
|
+
let message_patch = {
|
|
158
|
+
status: status
|
|
159
|
+
}
|
|
160
|
+
const payload = JSON.stringify(message_patch)
|
|
161
|
+
if (this.log) {
|
|
162
|
+
console.log("payload:", payload)
|
|
163
|
+
}
|
|
164
|
+
this.client.publish(dest_topic, payload, null, (err) => {
|
|
165
|
+
if (callback) {
|
|
166
|
+
callback(err, message_patch)
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
updateConversationIsNew(conversWith, is_new, callback) {
|
|
172
|
+
// callback - function (err)
|
|
173
|
+
if (this.log) {
|
|
174
|
+
console.log("updating conversation with:", conversWith, "is_new", is_new);
|
|
175
|
+
}
|
|
176
|
+
// 'apps/tilechat/users/USER_ID/conversations/CONVERS_WITH/update'
|
|
177
|
+
let dest_topic = `apps/${this.appid}/users/${this.user_id}/conversations/${conversWith}/update` //'apps/tilechat/users/' + this.user_id + '/conversations/' + conversWith + '/update'
|
|
178
|
+
if (this.log) {
|
|
179
|
+
console.log("update dest_topic:", dest_topic);
|
|
180
|
+
}
|
|
181
|
+
let patch = {
|
|
182
|
+
is_new: is_new
|
|
183
|
+
}
|
|
184
|
+
const payload = JSON.stringify(patch)
|
|
185
|
+
if (this.log) {
|
|
186
|
+
console.log("payload:", payload);
|
|
187
|
+
}
|
|
188
|
+
this.client.publish(dest_topic, payload, null, (err) => {
|
|
189
|
+
if (callback) {
|
|
190
|
+
callback(err)
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
groupCreate(name, group_id, members, callback) {
|
|
196
|
+
// example:
|
|
197
|
+
// {
|
|
198
|
+
// "group_id":"group-tiledeskteam",
|
|
199
|
+
// "group_name":"Tiledesk Team",
|
|
200
|
+
// "group_members":{
|
|
201
|
+
// "608bc83b3d0b3e494f4d0578":1,
|
|
202
|
+
// "608bc81f3d0b3e494f4d0575":1,
|
|
203
|
+
// "6067513cb64a9b1ba259839c":1
|
|
204
|
+
// }
|
|
205
|
+
// }
|
|
206
|
+
|
|
207
|
+
// callback - function (err)
|
|
208
|
+
if (this.log) {
|
|
209
|
+
console.log("creating group:", name, "id", group_id, "members", members)
|
|
210
|
+
}
|
|
211
|
+
// who creates the group is also group-owner
|
|
212
|
+
// ex.: http://localhost:8004/api/tilechat/04-ANDREASPONZIELLO/groups
|
|
213
|
+
// let data = {
|
|
214
|
+
// group_name: name,
|
|
215
|
+
// group_id: group_id,
|
|
216
|
+
// group_members: members
|
|
217
|
+
// }
|
|
218
|
+
// let headers = {
|
|
219
|
+
// "authorization": this.jwt,
|
|
220
|
+
// "Content-Type": "application/json;charset=UTF-8"
|
|
221
|
+
// }
|
|
222
|
+
|
|
223
|
+
const URL = `${this.APIendpoint}/${this.appid}/groups`
|
|
224
|
+
if (this.log) {
|
|
225
|
+
console.log("creating group...", URL)
|
|
226
|
+
}
|
|
227
|
+
let options = {
|
|
228
|
+
url: URL,
|
|
229
|
+
headers: {
|
|
230
|
+
"Authorization": this.jwt,
|
|
231
|
+
"Content-Type": "application/json;charset=UTF-8"
|
|
232
|
+
},
|
|
233
|
+
data: {
|
|
234
|
+
group_name: name,
|
|
235
|
+
group_id: group_id,
|
|
236
|
+
group_members: members
|
|
237
|
+
},
|
|
238
|
+
method: 'POST'
|
|
239
|
+
// url: options.url,
|
|
240
|
+
// headers: options.headers,
|
|
241
|
+
// json: options.json,
|
|
242
|
+
// method: options.method
|
|
243
|
+
}
|
|
244
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
245
|
+
if (err) {
|
|
246
|
+
callback(err, null);
|
|
247
|
+
}
|
|
248
|
+
else if (json && callback) {
|
|
249
|
+
callback(null, json);
|
|
250
|
+
}
|
|
251
|
+
}, this.log);
|
|
252
|
+
// var xmlhttp = new XMLHttpRequest();
|
|
253
|
+
// xmlhttp.open("POST", URL, true);
|
|
254
|
+
// xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
255
|
+
// xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
256
|
+
// xmlhttp.onreadystatechange = function() {
|
|
257
|
+
// if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
258
|
+
// try {
|
|
259
|
+
// const json = JSON.parse(xmlhttp.responseText)
|
|
260
|
+
// callback(null, json.result)
|
|
261
|
+
// }
|
|
262
|
+
// catch (err) {
|
|
263
|
+
// console.log("parsing json ERROR", err)
|
|
264
|
+
// callback(err, null)
|
|
265
|
+
// }
|
|
266
|
+
// }
|
|
267
|
+
// };
|
|
268
|
+
// xmlhttp.send(JSON.stringify(data));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
groupData(group_id, callback) {
|
|
272
|
+
const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}`
|
|
273
|
+
// console.log("creating group...", URL)
|
|
274
|
+
let options = {
|
|
275
|
+
url: URL,
|
|
276
|
+
headers: {
|
|
277
|
+
"Authorization": this.jwt,
|
|
278
|
+
"Content-Type": "application/json;charset=UTF-8"
|
|
279
|
+
},
|
|
280
|
+
method: 'GET'
|
|
281
|
+
}
|
|
282
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
283
|
+
if (err) {
|
|
284
|
+
callback(err, null);
|
|
285
|
+
}
|
|
286
|
+
else if (json && callback) {
|
|
287
|
+
callback(null, json);
|
|
288
|
+
}
|
|
289
|
+
}, this.log);
|
|
290
|
+
// const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}`
|
|
291
|
+
// console.log("getting group...", URL)
|
|
292
|
+
// var xmlhttp = new XMLHttpRequest();
|
|
293
|
+
// xmlhttp.open("GET", URL, true);
|
|
294
|
+
// xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
295
|
+
// xmlhttp.onreadystatechange = function() {
|
|
296
|
+
// if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
297
|
+
// try {
|
|
298
|
+
// const json = JSON.parse(xmlhttp.responseText)
|
|
299
|
+
// callback(null, json.result)
|
|
300
|
+
// }
|
|
301
|
+
// catch (err) {
|
|
302
|
+
// console.error("parsing json ERROR", err)
|
|
303
|
+
// callback(err, null)
|
|
304
|
+
// }
|
|
305
|
+
// }
|
|
306
|
+
// };
|
|
307
|
+
// xmlhttp.send(null);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
groupLeave(group_id, member_id, callback) {
|
|
311
|
+
if (this.log) {
|
|
312
|
+
console.log("leaving group:", group_id);
|
|
313
|
+
}
|
|
314
|
+
const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members/${member_id}`
|
|
315
|
+
if (this.log) {
|
|
316
|
+
console.log("leaving group:", URL)
|
|
317
|
+
}
|
|
318
|
+
let options = {
|
|
319
|
+
url: URL,
|
|
320
|
+
headers: {
|
|
321
|
+
"Authorization": this.jwt,
|
|
322
|
+
"Content-Type": "application/json;charset=UTF-8"
|
|
323
|
+
},
|
|
324
|
+
method: 'DELETE'
|
|
325
|
+
}
|
|
326
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
327
|
+
if (err) {
|
|
328
|
+
callback(err, null);
|
|
329
|
+
}
|
|
330
|
+
else if (callback) {
|
|
331
|
+
callback(null, json);
|
|
332
|
+
}
|
|
333
|
+
}, this.log);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
groupJoin(group_id, member_id, callback) {
|
|
337
|
+
if (this.log) {
|
|
338
|
+
console.log("leaving group:", group_id);
|
|
339
|
+
}
|
|
340
|
+
const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members`
|
|
341
|
+
if (this.log) {
|
|
342
|
+
console.log("joining group:", URL)
|
|
343
|
+
}
|
|
344
|
+
let options = {
|
|
345
|
+
url: URL,
|
|
346
|
+
headers: {
|
|
347
|
+
"Authorization": this.jwt,
|
|
348
|
+
"Content-Type": "application/json;charset=UTF-8"
|
|
349
|
+
},
|
|
350
|
+
data: {
|
|
351
|
+
member_id: member_id
|
|
352
|
+
},
|
|
353
|
+
method: 'POST'
|
|
354
|
+
}
|
|
355
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
356
|
+
if (err) {
|
|
357
|
+
callback(err, null);
|
|
358
|
+
}
|
|
359
|
+
else if (callback) {
|
|
360
|
+
callback(null, json);
|
|
361
|
+
}
|
|
362
|
+
}, this.log);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
groupSetMembers(group_id, members, callback) {
|
|
366
|
+
// example:
|
|
367
|
+
// {
|
|
368
|
+
// "members":{
|
|
369
|
+
// "608bc83b3d0b3e494f4d0578":1,
|
|
370
|
+
// "608bc81f3d0b3e494f4d0575":1,
|
|
371
|
+
// "6067513cb64a9b1ba259839c":1
|
|
372
|
+
// }
|
|
373
|
+
// }
|
|
374
|
+
if (this.log) {
|
|
375
|
+
console.log("setting group members of", group_id, "members", members)
|
|
376
|
+
}
|
|
377
|
+
const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members`
|
|
378
|
+
if (this.log) {
|
|
379
|
+
console.log("setting group members...", URL)
|
|
380
|
+
}
|
|
381
|
+
let options = {
|
|
382
|
+
url: URL,
|
|
383
|
+
headers: {
|
|
384
|
+
"Authorization": this.jwt,
|
|
385
|
+
"Content-Type": "application/json;charset=UTF-8"
|
|
386
|
+
},
|
|
387
|
+
data: {
|
|
388
|
+
members: members
|
|
389
|
+
},
|
|
390
|
+
method: 'PUT'
|
|
391
|
+
}
|
|
392
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
393
|
+
if (err) {
|
|
394
|
+
callback(err, null);
|
|
395
|
+
}
|
|
396
|
+
else if (json && callback) {
|
|
397
|
+
callback(null, json);
|
|
398
|
+
}
|
|
399
|
+
}, this.log);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
saveInstance(instance_id, data, callback) {
|
|
403
|
+
if (this.log) {
|
|
404
|
+
console.log("saving instance_id:", instance_id, "data", data);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// /:app_id/:user_id/instances/:instance_id
|
|
408
|
+
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/instances/${instance_id}`
|
|
409
|
+
if (this.log) {
|
|
410
|
+
console.log("saving instance...");
|
|
411
|
+
}
|
|
412
|
+
let options = {
|
|
413
|
+
url: URL,
|
|
414
|
+
headers: {
|
|
415
|
+
"Authorization": this.jwt,
|
|
416
|
+
"Content-Type": "application/json;charset=UTF-8"
|
|
417
|
+
},
|
|
418
|
+
data: data,
|
|
419
|
+
method: 'POST'
|
|
420
|
+
}
|
|
421
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
422
|
+
if (err) {
|
|
423
|
+
callback(err, null);
|
|
424
|
+
}
|
|
425
|
+
else if (json && callback) {
|
|
426
|
+
callback(null, json);
|
|
427
|
+
}
|
|
428
|
+
}, this.log);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
archiveConversation(conversWith, callback) {
|
|
432
|
+
// callback - function (err)
|
|
433
|
+
if (this.log) {
|
|
434
|
+
console.log("archiving conversation with:", conversWith)
|
|
435
|
+
}
|
|
436
|
+
// 'apps/tilechat/users/USER_ID/conversations/CONVERS_WITH/archive'
|
|
437
|
+
let dest_topic = 'apps/tilechat/users/' + this.user_id + '/conversations/' + conversWith + '/archive'
|
|
438
|
+
if (this.log) {
|
|
439
|
+
console.log("archive dest_topic:", dest_topic)
|
|
440
|
+
}
|
|
441
|
+
// let patch = {
|
|
442
|
+
// action: 'archive'
|
|
443
|
+
// }
|
|
444
|
+
const payload = JSON.stringify({})
|
|
445
|
+
// console.log("payload:", payload)
|
|
446
|
+
this.client.publish(dest_topic, payload, null, (err) => {
|
|
447
|
+
if (callback) {
|
|
448
|
+
callback(err)
|
|
449
|
+
}
|
|
450
|
+
})
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// onMessage(callback) {
|
|
454
|
+
// this.last_handler++
|
|
455
|
+
// this.onMessageCallbacks.set(this.last_handler, callback)
|
|
456
|
+
// return this.last_handler;
|
|
457
|
+
// }
|
|
458
|
+
|
|
459
|
+
onConversationAdded(callback) {
|
|
460
|
+
this.last_handler++
|
|
461
|
+
this.onConversationAddedCallbacks.set(this.last_handler, callback)
|
|
462
|
+
return this.last_handler;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
onConversationUpdated(callback) {
|
|
466
|
+
this.last_handler++
|
|
467
|
+
this.onConversationUpdatedCallbacks.set(this.last_handler, callback)
|
|
468
|
+
return this.last_handler;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
onConversationDeleted(callback) {
|
|
472
|
+
this.last_handler++
|
|
473
|
+
this.onConversationDeletedCallbacks.set(this.last_handler, callback)
|
|
474
|
+
return this.last_handler;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
onArchivedConversationAdded(callback) {
|
|
478
|
+
this.last_handler++
|
|
479
|
+
this.onArchivedConversationAddedCallbacks.set(this.last_handler, callback)
|
|
480
|
+
return this.last_handler;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
onArchivedConversationDeleted(callback) {
|
|
484
|
+
this.last_handler++
|
|
485
|
+
this.onArchivedConversationDeletedCallbacks.set(this.last_handler, callback)
|
|
486
|
+
return this.last_handler;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
onMessageAdded(callback) {
|
|
490
|
+
this.last_handler++
|
|
491
|
+
this.onMessageAddedCallbacks.set(this.last_handler, callback)
|
|
492
|
+
return this.last_handler;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
onMessageAddedInConversation(conversWith, callback) {
|
|
496
|
+
this.last_handler++
|
|
497
|
+
const callback_obj = {
|
|
498
|
+
"type": CALLBACK_TYPE_ON_MESSAGE_ADDED_FOR_CONVERSATION,
|
|
499
|
+
"conversWith": conversWith,
|
|
500
|
+
"callback": callback
|
|
501
|
+
}
|
|
502
|
+
this.callbackHandlers.set(this.last_handler, callback_obj)
|
|
503
|
+
// TODO (for performance): addToMessageAddedInConversationCallbacks(conversWith, this.last_handler)
|
|
504
|
+
|
|
505
|
+
// this.callbackHandlers = new Map();
|
|
506
|
+
// key: handler_id
|
|
507
|
+
// value: {
|
|
508
|
+
// "type": "messageAddedInConversation",
|
|
509
|
+
// "conversWith": "ID",
|
|
510
|
+
// "callback": callback
|
|
511
|
+
// }
|
|
512
|
+
return this.last_handler;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
onMessageUpdatedInConversation(conversWith, callback) {
|
|
516
|
+
this.last_handler++
|
|
517
|
+
const callback_obj = {
|
|
518
|
+
"type": CALLBACK_TYPE_ON_MESSAGE_UPDATED_FOR_CONVERSATION,
|
|
519
|
+
"conversWith": conversWith,
|
|
520
|
+
"callback": callback
|
|
521
|
+
}
|
|
522
|
+
this.callbackHandlers.set(this.last_handler, callback_obj)
|
|
523
|
+
|
|
524
|
+
// this.last_handler++
|
|
525
|
+
// callback_obj = {
|
|
526
|
+
// "conversWith": conversWith,
|
|
527
|
+
// "callback": callback
|
|
528
|
+
// }
|
|
529
|
+
// this.onMessageUpdatedCallbacks.set(this.last_handler, callback_obj)
|
|
530
|
+
return this.last_handler;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
onMessageUpdated(callback) {
|
|
534
|
+
this.last_handler += 1
|
|
535
|
+
this.onMessageUpdatedCallbacks.set(this.last_handler, callback)
|
|
536
|
+
return this.last_handler;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
onGroupUpdated(callback) {
|
|
540
|
+
this.last_handler += 1
|
|
541
|
+
this.onGroupUpdatedCallbacks.set(this.last_handler, callback)
|
|
542
|
+
return this.last_handler;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
removeOnMessageAddedHandler(handler) {
|
|
546
|
+
this.onMessageAddedCallbacks.delete(handler);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
removeOnGroupUpdatedHandler(handler) {
|
|
550
|
+
this.onGroupUpdatedCallbacks.delete(handler);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
start() {
|
|
554
|
+
if (this.on_message_handler) {
|
|
555
|
+
console.log("this.on_message_handler already subscribed. Reconnected num", this.reconnections)
|
|
556
|
+
return
|
|
557
|
+
}
|
|
558
|
+
this.subscribeToMyConversations()
|
|
559
|
+
// no more then one "on_message" handler, thanks.
|
|
560
|
+
this.on_message_handler = this.client.on('message', (topic, message) => {
|
|
561
|
+
// console.log("topic:" + topic + "\nmessage payload:" + message)
|
|
562
|
+
const _topic = this.parseTopic(topic)
|
|
563
|
+
if (!_topic) {
|
|
564
|
+
if (this.log) {
|
|
565
|
+
console.log("Invalid message topic:", topic);
|
|
566
|
+
}
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const conversWith = _topic.conversWith
|
|
570
|
+
try {
|
|
571
|
+
const message_json = JSON.parse(message.toString())
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
// TEMPORARILY DISABLED, ADDED-CONVERSATIONS ARE OBSERVED BY NEW MESSAGES.
|
|
575
|
+
// MOVED TO: this.onMessageAddedCallbacks
|
|
576
|
+
// if (this.onConversationAddedCallbacks) {
|
|
577
|
+
// if (topic.includes("/conversations/") && topic.endsWith(_CLIENTADDED)) {
|
|
578
|
+
// // map.forEach((value, key, map) =>)
|
|
579
|
+
// this.onConversationAddedCallbacks.forEach((callback, handler, map) => {
|
|
580
|
+
// callback(message_json, _topic)
|
|
581
|
+
// });
|
|
582
|
+
// }
|
|
583
|
+
// }
|
|
584
|
+
|
|
585
|
+
if (this.onConversationUpdatedCallbacks) {
|
|
586
|
+
// example topic: apps.tilechat.users.ME.conversations.CONVERS-WITH.clientdeleted
|
|
587
|
+
if (topic.includes("/conversations/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
588
|
+
if (this.log) {
|
|
589
|
+
console.log("conversation updated! /conversations/, topic:", topic)
|
|
590
|
+
}
|
|
591
|
+
// map.forEach((value, key, map) =>)
|
|
592
|
+
this.onConversationUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
593
|
+
callback(JSON.parse(message.toString()), topic)
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (this.onConversationDeletedCallbacks) {
|
|
599
|
+
if (topic.includes("/conversations/") && topic.endsWith(_CLIENTDELETED)) {
|
|
600
|
+
// map.forEach((value, key, map) =>)
|
|
601
|
+
if (this.log) {
|
|
602
|
+
console.log("conversation deleted! /conversations/, topic:", topic, message.toString() );
|
|
603
|
+
}
|
|
604
|
+
this.onConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
605
|
+
callback(JSON.parse(message.toString()), topic)
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (this.onArchivedConversationAddedCallbacks) {
|
|
611
|
+
if (topic.includes("/archived_conversations/") && topic.endsWith(_CLIENTADDED)) {
|
|
612
|
+
// map.forEach((value, key, map) =>)
|
|
613
|
+
this.onArchivedConversationAddedCallbacks.forEach((callback, handler, map) => {
|
|
614
|
+
callback(JSON.parse(message.toString()), topic)
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (this.onArchivedConversationDeletedCallbacks) {
|
|
620
|
+
if (topic.includes("/archived_conversations/") && topic.endsWith(_CLIENTDELETED)) {
|
|
621
|
+
// map.forEach((value, key, map) =>)
|
|
622
|
+
this.onArchivedConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
623
|
+
callback(JSON.parse(message.toString()), topic)
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// *********************************************************
|
|
629
|
+
// This snippet is important to get all messages and notify
|
|
630
|
+
// conversation > added (to create a conversation entry)
|
|
631
|
+
// *********************************************************
|
|
632
|
+
// if (this.onMessageAddedCallbacks) {
|
|
633
|
+
// console.log("ttttttttt")
|
|
634
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTADDED)) {
|
|
635
|
+
if (this.onMessageAddedCallbacks) {
|
|
636
|
+
this.onMessageAddedCallbacks.forEach((callback, handler, map) => {
|
|
637
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
// Observing conversations added from messages
|
|
641
|
+
// console.log("Observing conversations added from messages", message_json);
|
|
642
|
+
// if (this.onConversationAddedCallbacks) {
|
|
643
|
+
// console.log("callbacks ok........");
|
|
644
|
+
let update_conversation = true;
|
|
645
|
+
if (message_json.attributes && message_json.attributes.updateconversation == false) {
|
|
646
|
+
update_conversation = false
|
|
647
|
+
}
|
|
648
|
+
// console.log("update_conversation........", update_conversation);
|
|
649
|
+
if (update_conversation && this.onConversationAddedCallbacks) {
|
|
650
|
+
this.onConversationAddedCallbacks.forEach((callback, handler, map) => {
|
|
651
|
+
message_json.is_new = true;
|
|
652
|
+
const message_for_conv_string = JSON.stringify(message_json);
|
|
653
|
+
callback(JSON.parse(message_for_conv_string), _topic)
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
// }
|
|
657
|
+
}
|
|
658
|
+
// }
|
|
659
|
+
|
|
660
|
+
if (this.onMessageUpdatedCallbacks) {
|
|
661
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
662
|
+
this.onMessageUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
663
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
if (this.onGroupUpdatedCallbacks) {
|
|
669
|
+
if (topic.includes("/groups/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
670
|
+
this.onGroupUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
671
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// // ******* NEW!!
|
|
677
|
+
this.callbackHandlers.forEach((value, key, map) => {
|
|
678
|
+
const callback_obj = value
|
|
679
|
+
// callback_obj = {
|
|
680
|
+
// "type": "onMessageUpdatedForConversation",
|
|
681
|
+
// "conversWith": conversWith,
|
|
682
|
+
// "callback": callback
|
|
683
|
+
// }
|
|
684
|
+
const type = callback_obj.type
|
|
685
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTADDED)) {
|
|
686
|
+
if (this.log) { console.log("/messages/_CLIENTADDED") }
|
|
687
|
+
if (type === CALLBACK_TYPE_ON_MESSAGE_ADDED_FOR_CONVERSATION) {
|
|
688
|
+
if (conversWith === callback_obj.conversWith) {
|
|
689
|
+
if (this.log) { console.log("/messages/_CLIENTADDED on: ", conversWith)}
|
|
690
|
+
callback_obj.callback(JSON.parse(message.toString()), _topic)
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
695
|
+
if (this.log) {console.log("/messages/_CLIENTUPDATED")}
|
|
696
|
+
if (type === CALLBACK_TYPE_ON_MESSAGE_UPDATED_FOR_CONVERSATION) {
|
|
697
|
+
if (conversWith === callback_obj.conversWith) {
|
|
698
|
+
console.log("/messages/_CLIENTUPDATED on: ", conversWith)
|
|
699
|
+
callback_obj.callback(JSON.parse(message.toString()), _topic)
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
})
|
|
704
|
+
|
|
705
|
+
// if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
706
|
+
// this.onMessageUpdatedInConversationCallbacks.forEach((obj, handler, map) => {
|
|
707
|
+
// if (conversWith === obj.conversWith) {
|
|
708
|
+
// callback(message_json, _topic)
|
|
709
|
+
// }
|
|
710
|
+
// });
|
|
711
|
+
// }
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
}
|
|
715
|
+
catch (err) {
|
|
716
|
+
console.error("ERROR:", err)
|
|
717
|
+
}
|
|
718
|
+
})
|
|
719
|
+
// console.log("HANDLER_:", this.on_message_handler)
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
parseTopic(topic) {
|
|
723
|
+
var topic_parts = topic.split("/")
|
|
724
|
+
// /apps/tilechat/users/(ME)/messages/RECIPIENT_ID/ACTION
|
|
725
|
+
if (topic_parts.length >= 7) {
|
|
726
|
+
const app_id = topic_parts[1]
|
|
727
|
+
const sender_id = topic_parts[3]
|
|
728
|
+
const recipient_id = topic_parts[5]
|
|
729
|
+
const convers_with = recipient_id
|
|
730
|
+
const me = sender_id
|
|
731
|
+
const parsed = {
|
|
732
|
+
"conversWith": convers_with
|
|
733
|
+
}
|
|
734
|
+
return parsed
|
|
735
|
+
}
|
|
736
|
+
return null
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
lastArchivedConversations(callback) {
|
|
740
|
+
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/archived_conversations
|
|
741
|
+
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/archived_conversations`
|
|
742
|
+
if (this.log) {console.log("getting last archived conversations...", URL)}
|
|
743
|
+
var xmlhttp = new XMLHttpRequest();
|
|
744
|
+
xmlhttp.open("GET", URL, true);
|
|
745
|
+
xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
746
|
+
xmlhttp.onreadystatechange = function() {
|
|
747
|
+
// console.log("onreadystatechange!")
|
|
748
|
+
if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
749
|
+
try {
|
|
750
|
+
const json = JSON.parse(xmlhttp.responseText)
|
|
751
|
+
callback(null, json.result)
|
|
752
|
+
}
|
|
753
|
+
catch (err) {
|
|
754
|
+
console.error("parsing json ERROR", err)
|
|
755
|
+
callback(err, null)
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
xmlhttp.send(null);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
lastConversations(archived, callback) {
|
|
763
|
+
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations
|
|
764
|
+
const archived_url_part = archived ? '/archived' : '';
|
|
765
|
+
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/conversations` + archived_url_part;
|
|
766
|
+
if (this.log) {console.log("getting last convs...", URL);}
|
|
767
|
+
var xmlhttp = new XMLHttpRequest();
|
|
768
|
+
xmlhttp.open("GET", URL, true);
|
|
769
|
+
xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
770
|
+
xmlhttp.onreadystatechange = function() {
|
|
771
|
+
// console.log("onreadystatechange!")
|
|
772
|
+
if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
773
|
+
try {
|
|
774
|
+
const json = JSON.parse(xmlhttp.responseText)
|
|
775
|
+
callback(null, json.result)
|
|
776
|
+
}
|
|
777
|
+
catch (err) {
|
|
778
|
+
console.error("parsing json ERROR", err)
|
|
779
|
+
callback(err, null)
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
xmlhttp.send(null);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
conversationDetail(conversWith, callback) {
|
|
787
|
+
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations/CONVERS_WITH
|
|
788
|
+
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/conversations/${conversWith}`
|
|
789
|
+
console.log("getting conversation detail:", URL)
|
|
790
|
+
console.log("conversWith:", conversWith)
|
|
791
|
+
var xmlhttp = new XMLHttpRequest();
|
|
792
|
+
xmlhttp.open("GET", URL, true);
|
|
793
|
+
xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
794
|
+
xmlhttp.onreadystatechange = function() {
|
|
795
|
+
if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
796
|
+
try {
|
|
797
|
+
const json = JSON.parse(xmlhttp.responseText);
|
|
798
|
+
if (json && json.result && Array.isArray(json.result) && json.result.length ==1) {
|
|
799
|
+
callback(null, json.result[0]);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
callback({"message": "Incorrect conversation result."}, null);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
catch (err) {
|
|
806
|
+
console.error("parsing json ERROR", err);
|
|
807
|
+
callback(err, null);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
xmlhttp.send(null);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
lastMessages(convers_with, callback) {
|
|
815
|
+
// console.log("START: ", this.user_id)
|
|
816
|
+
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations
|
|
817
|
+
const URL = this.APIendpoint + "/" + this.appid + "/" + this.user_id + "/conversations/" + convers_with + "/messages"
|
|
818
|
+
// console.log("getting last messages", URL)
|
|
819
|
+
// console.log("END")
|
|
820
|
+
var xmlhttp = new XMLHttpRequest();
|
|
821
|
+
xmlhttp.open("GET", URL, true);
|
|
822
|
+
xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
823
|
+
xmlhttp.onreadystatechange = function() {
|
|
824
|
+
// console.log("onreadystatechange messages!")
|
|
825
|
+
if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
826
|
+
// console.log("xmlhttp...", xmlhttp.responseText)
|
|
827
|
+
try {
|
|
828
|
+
// console.log("parsing json messages")
|
|
829
|
+
const json = JSON.parse(xmlhttp.responseText)
|
|
830
|
+
callback(null, json.result)
|
|
831
|
+
}
|
|
832
|
+
catch (err) {
|
|
833
|
+
console.error("parsing json messages ERROR", err)
|
|
834
|
+
callback(err, null)
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
xmlhttp.send(null);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
static myrequest(options, callback, log) {
|
|
842
|
+
// url: options.url,
|
|
843
|
+
// headers: options.headers,
|
|
844
|
+
// data: options.data,
|
|
845
|
+
// method: options.method
|
|
846
|
+
if (log) {
|
|
847
|
+
console.log("HTTP Request:", options);
|
|
848
|
+
}
|
|
849
|
+
if (isBrowser()) {
|
|
850
|
+
let xmlhttp = new XMLHttpRequest();
|
|
851
|
+
xmlhttp.open(options.method, options.url, true);
|
|
852
|
+
Object.keys(options.headers).forEach((key) => {
|
|
853
|
+
xmlhttp.setRequestHeader(key, options.headers[key]);
|
|
854
|
+
});
|
|
855
|
+
xmlhttp.onreadystatechange = function() {
|
|
856
|
+
if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
857
|
+
try {
|
|
858
|
+
const json = JSON.parse(xmlhttp.responseText)
|
|
859
|
+
callback(null, null, json)
|
|
860
|
+
}
|
|
861
|
+
catch (err) {
|
|
862
|
+
console.error("parsing json ERROR", err)
|
|
863
|
+
callback(err, null)
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
if (options.method === 'POST') {
|
|
868
|
+
xmlhttp.send(JSON.stringify(options.data));
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
xmlhttp.send(null);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
axios(
|
|
876
|
+
{
|
|
877
|
+
url: options.url,
|
|
878
|
+
method: options.method,
|
|
879
|
+
data: options.data,
|
|
880
|
+
headers: options.headers
|
|
881
|
+
})
|
|
882
|
+
.then(function (response) {
|
|
883
|
+
if (log) {console.log("response.status:", response.status);}
|
|
884
|
+
if (callback) {
|
|
885
|
+
callback(null, response.headers, response.data);
|
|
886
|
+
}
|
|
887
|
+
})
|
|
888
|
+
.catch(function (error) {
|
|
889
|
+
console.error("Axios call error:", error);
|
|
890
|
+
if (callback) {
|
|
891
|
+
callback(error, null, null);
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
// request(
|
|
896
|
+
// {
|
|
897
|
+
// url: options.url,
|
|
898
|
+
// headers: options.headers,
|
|
899
|
+
// json: options.json,
|
|
900
|
+
// method: options.method
|
|
901
|
+
// },
|
|
902
|
+
// function(err, res, resbody) {
|
|
903
|
+
// if (log) {
|
|
904
|
+
// console.log("** For url:", options.url);
|
|
905
|
+
// console.log("** Options:", options);
|
|
906
|
+
// console.log("** Err:", err);
|
|
907
|
+
// console.log("** Response headers:\n", res.headers);
|
|
908
|
+
// console.log("** Response body:\n", res.body);
|
|
909
|
+
// }
|
|
910
|
+
// if (callback) {
|
|
911
|
+
// callback(err, res, resbody);
|
|
912
|
+
// }
|
|
913
|
+
// }
|
|
914
|
+
// );
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
connect(user_id, jwt, callback) {
|
|
920
|
+
this.user_id = user_id;
|
|
921
|
+
// console.log("userid:", this.user_id)
|
|
922
|
+
this.jwt = jwt
|
|
923
|
+
if (this.log) {
|
|
924
|
+
console.log("connecting user_id:", user_id)
|
|
925
|
+
console.log("using jwt token:", jwt)
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
if (this.client) {
|
|
929
|
+
this.client.end()
|
|
930
|
+
}
|
|
931
|
+
const presence_topic = 'apps/tilechat/users/' + this.user_id + '/presence/' + this.client_id
|
|
932
|
+
let options = {
|
|
933
|
+
keepalive: 10,
|
|
934
|
+
// protocolId: 'MQTT',
|
|
935
|
+
// protocolVersion: 4,
|
|
936
|
+
// clean: true,
|
|
937
|
+
reconnectPeriod: 1000,
|
|
938
|
+
// connectTimeout: 30 * 1000,
|
|
939
|
+
will: {
|
|
940
|
+
topic: presence_topic,
|
|
941
|
+
payload: '{"disconnected":true}',
|
|
942
|
+
qos: 1,
|
|
943
|
+
retain: true
|
|
944
|
+
},
|
|
945
|
+
clientId: this.client_id,
|
|
946
|
+
username: 'JWT',
|
|
947
|
+
password: jwt,
|
|
948
|
+
rejectUnauthorized: false
|
|
949
|
+
}
|
|
950
|
+
if (this.log) {console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)}
|
|
951
|
+
// client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
|
|
952
|
+
this.client = mqtt.connect(this.endpoint,options)
|
|
953
|
+
|
|
954
|
+
this.client.on('connect', // TODO if token is wrong it must reply with an error!
|
|
955
|
+
() => {
|
|
956
|
+
if (this.log) {console.log("chat client connected...")}
|
|
957
|
+
if (!this.connected) {
|
|
958
|
+
if (this.log) {console.log("Chat client first connection.")}
|
|
959
|
+
this.connected = true
|
|
960
|
+
this.start()
|
|
961
|
+
callback()
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
);
|
|
965
|
+
this.client.on('reconnect',
|
|
966
|
+
() => {
|
|
967
|
+
if (this.log) {console.log("Chat client reconnect event");}
|
|
968
|
+
}
|
|
969
|
+
);
|
|
970
|
+
this.client.on('close',
|
|
971
|
+
() => {
|
|
972
|
+
if (this.log) {console.log("Chat client close event");}
|
|
973
|
+
}
|
|
974
|
+
);
|
|
975
|
+
this.client.on('offline',
|
|
976
|
+
() => {
|
|
977
|
+
if (this.log) {console.log("Chat client offline event");}
|
|
978
|
+
}
|
|
979
|
+
);
|
|
980
|
+
this.client.on('error',
|
|
981
|
+
(error) => {
|
|
982
|
+
console.error("Chat client error event", error);
|
|
983
|
+
}
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
close(callback) {
|
|
988
|
+
if (this.topic_inbox) {
|
|
989
|
+
this.client.unsubscribe(this.topic_inbox, (err) => {
|
|
990
|
+
if (this.log) {console.log("unsubscribed from", this.topic_inbox);}
|
|
991
|
+
this.client.end(() => {
|
|
992
|
+
this.connected = false
|
|
993
|
+
// reset all subscriptions
|
|
994
|
+
this.onConversationAddedCallbacks = new Map();
|
|
995
|
+
this.onConversationUpdatedCallbacks = new Map();
|
|
996
|
+
this.onConversationDeletedCallbacks = new Map();
|
|
997
|
+
this.onArchivedConversationAddedCallbacks = new Map();
|
|
998
|
+
this.onArchivedConversationDeletedCallbacks = new Map();
|
|
999
|
+
this.onMessageAddedCallbacks = new Map();
|
|
1000
|
+
this.onMessageUpdatedCallbacks = new Map();
|
|
1001
|
+
this.onGroupUpdatedCallbacks = new Map();
|
|
1002
|
+
this.callbackHandlers = new Map();
|
|
1003
|
+
this.on_message_handler = null
|
|
1004
|
+
this.topic_inbox = null;
|
|
1005
|
+
if (callback) {
|
|
1006
|
+
callback();
|
|
1007
|
+
}
|
|
1008
|
+
})
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
uuidv4() {
|
|
1014
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
1015
|
+
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
1016
|
+
return v.toString(16);
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function isBrowser() {
|
|
1022
|
+
return true;
|
|
1023
|
+
// return false;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
export { Chat21Client }; // Browser
|
|
1027
|
+
// module.exports = { Chat21Client };
|