@inboxsdk/core 0.2.28-alpha.4 → 0.2.28-alpha.6
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/inboxsdk.js +1 -1
- package/package.json +5 -1
- package/src/inboxsdk-js/check-requirements.js +7 -3
- package/src/inboxsdk-js/header.js +1 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.js +5 -6
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.js +4 -3
- package/src/inboxsdk-js/inboxsdk-REMOTE.js +3 -1
- package/src/inboxsdk-js/inboxsdk-TEST.js +4 -3
- package/src/inboxsdk-js/inboxsdk.js +33 -39
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.js +15 -18
- package/src/inboxsdk.d.ts +2 -0
- package/src/injected-js/gmail/modify-suggestions.test.js +8 -9
- package/src/injected-js/gmail/setup-gmail-interceptor.js +340 -579
- package/src/injected-js/gmail/sync-compose-request-processor.test.js +39 -49
- package/src/injected-js/gmail/thread-identifier/click-and-get-popup-url.js +20 -33
- package/src/injected-js/gmail/thread-identifier/index.js +57 -93
- package/src/injected-js/gmail/thread-identifier/thread-row-parser.js +22 -31
- package/src/injected-js/gmail/thread-identifier/thread-row-parser.test.js +12 -28
- package/src/injected-js/inbox/setupAjaxInterceptor.js +64 -121
- package/src/injected-js/inbox/setupClickAndGetNewIframeSrc.js +53 -66
- package/src/injected-js/inbox/setupComposeViewDraftIDFinder.js +20 -36
- package/src/injected-js/inbox/setupInboxFakeWindowResizeListener.js +13 -13
- package/src/injected-js/main.js +11 -24
- package/src/injected-js/message-metadata-holder.js +52 -82
- package/src/injected-js/setup-data-exposer.js +89 -148
- package/src/injected-js/setup-error-silencer.js +21 -21
- package/src/injected-js/setup-event-reemitter.js +30 -22
- package/src/injected-js/setupInboxCustomViewLinkFixer.js +24 -29
- package/src/injected-js/setupPushStateListener.js +18 -11
- package/src/injected-js/xhr-helper.js +62 -65
- package/src/injected-js/xhr-proxy-factory.js +195 -445
- package/src/injected-js/xhr-proxy-factory.test.js +824 -991
- package/src/platform-implementation-js/constants/router.js +14 -9
- package/src/platform-implementation-js/constants/toolbars.js +8 -3
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.js +13 -13
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.js +115 -136
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.js +13 -14
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.js +27 -48
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.js +31 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.js +30 -40
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.js +10 -18
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.js +21 -28
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadFromSyncThreadId.js +33 -45
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/gmail-load-event.js +31 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.js +58 -65
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.js +40 -124
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.js +17 -22
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-draft-by-message-id.test.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.js +44 -80
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.js +19 -26
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.js +71 -147
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.js +91 -148
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.js +150 -166
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.test.js +70 -120
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.js +15 -15
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.js +44 -67
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.js +230 -379
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.test.js +121 -307
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.js +17 -24
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.js +41 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.js +30 -40
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.js +28 -60
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.js +61 -133
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.js +30 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.test.js +52 -46
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +354 -694
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.js +77 -93
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.js +35 -82
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.test.js +44 -94
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-global-icon-area.js +12 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-thread-icon-area.js +17 -29
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-to-icon-area.js +26 -26
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/index.js +391 -797
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view/monitor-top-banner-size-and-react.js +7 -9
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.js +60 -109
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-area-view.js +95 -135
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.js +103 -211
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.test.js +61 -61
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.js +17 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.js +188 -541
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-button.js +67 -135
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-compose-notice.js +27 -49
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-inner-sidebar.js +7 -13
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-outer-sidebar.js +9 -22
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-recipient-row.js +36 -63
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-tooltip-to-button.js +38 -113
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-app-button-toolbars-are-closed.js +11 -16
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-grouping-is-open.js +11 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/focus.js +8 -11
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/from-manager.js +27 -47
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-additional-action-toolbar.js +11 -24
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-address-changes-stream.js +59 -111
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-body-changes-stream.js +15 -14
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-formatting-area-offset-left.js +11 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-minimized-stream.js +18 -24
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-response-type-changes-stream.js +19 -23
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/insert-link-into-body.js +11 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/manage-button-grouping.js +141 -376
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/monitor-selection-range.js +17 -28
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/override-edit-subject.js +34 -70
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/position-formatting-toolbar.js +10 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/size-fixer.js +83 -137
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/update-insert-more-area-left.js +10 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.js +632 -1190
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view/get-updated-contact.js +29 -38
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.js +327 -617
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-processor.js +26 -49
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +188 -380
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.js +104 -194
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.js +382 -811
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view/add-icon-area.js +34 -58
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.js +330 -581
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.test.js +123 -277
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view/width-manager.js +15 -35
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.js +216 -571
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.js +152 -336
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.js +87 -211
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/inbox-dropdown-button-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-action-button-view.js +20 -29
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-label-view.js +41 -76
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.js +45 -99
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +76 -128
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-tooltip-view.js +128 -319
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.js +45 -78
- package/src/platform-implementation-js/dom-driver/inbox/__mocks__/getSidebarClassnames.js +8 -4
- package/src/platform-implementation-js/dom-driver/inbox/addNavItem.js +36 -54
- package/src/platform-implementation-js/dom-driver/inbox/addRecipientRow.js +35 -53
- package/src/platform-implementation-js/dom-driver/inbox/createLink.js +13 -15
- package/src/platform-implementation-js/dom-driver/inbox/createLink.test.js +15 -18
- package/src/platform-implementation-js/dom-driver/inbox/custom-style.js +14 -13
- package/src/platform-implementation-js/dom-driver/inbox/detection/appToolbarLocation/parser.js +14 -20
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentCard/parser.js +14 -13
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentOverlay/parser.js +35 -67
- package/src/platform-implementation-js/dom-driver/inbox/detection/chatSidebar/parser.js +16 -18
- package/src/platform-implementation-js/dom-driver/inbox/detection/compose/parser.js +68 -185
- package/src/platform-implementation-js/dom-driver/inbox/detection/message/parser.js +28 -56
- package/src/platform-implementation-js/dom-driver/inbox/detection/nativeDrawer/parser.js +12 -10
- package/src/platform-implementation-js/dom-driver/inbox/detection/searchBar/parser.js +16 -16
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread/parser.js +24 -35
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread-row/parser.js +37 -89
- package/src/platform-implementation-js/dom-driver/inbox/getComposeViewDriverLiveSet.js +56 -78
- package/src/platform-implementation-js/dom-driver/inbox/getInboxMessageIdForInboxThreadId.js +26 -32
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.js +52 -109
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.test.js +7 -8
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.js +16 -20
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.test.js +15 -16
- package/src/platform-implementation-js/dom-driver/inbox/inbox-butter-bar-driver.js +75 -83
- package/src/platform-implementation-js/dom-driver/inbox/inbox-driver.js +530 -822
- package/src/platform-implementation-js/dom-driver/inbox/inbox-page-communicator.js +48 -61
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.js +9 -12
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.test.js +12 -19
- package/src/platform-implementation-js/dom-driver/inbox/makePageParserTree.js +24 -33
- package/src/platform-implementation-js/dom-driver/inbox/pageParserOptions.js +201 -388
- package/src/platform-implementation-js/dom-driver/inbox/registerSearchSuggestionsProvider.js +249 -265
- package/src/platform-implementation-js/dom-driver/inbox/setupCustomAutocompleteSelectionHandling.js +84 -152
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.js +55 -67
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.test.js +43 -65
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxLabelView.js +31 -56
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxMoleViewDriver.js +191 -294
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarButtonView.js +32 -45
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarView.js +21 -39
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-sidebar-view.js +153 -240
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-button-view.js +75 -150
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-tooltip-view.js +20 -37
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-card-view.js +60 -114
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-overlay-view.js +47 -65
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-backdrop.js +41 -52
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-chat-sidebar-view.js +27 -36
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-button-view.js +52 -80
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-view.js +465 -649
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.js +37 -58
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.test.js +14 -26
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.js +118 -235
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dropdown-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dummy-route-view.js +28 -46
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-message-view.js +131 -202
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-modal-view.js +40 -80
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-route-view.js +35 -61
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-row-view.js +124 -221
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.js +125 -213
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.test.js +104 -126
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-tooltip-view.js +36 -51
- package/src/platform-implementation-js/dom-driver/inbox/views/inboxNavItemView.js +158 -297
- package/src/platform-implementation-js/dom-driver/inbox/waitForAnimationClickBlockerGone.js +21 -35
- package/src/platform-implementation-js/driver-common/compose/getDiscardStream.js +24 -43
- package/src/platform-implementation-js/driver-common/compose/getPresendingStream.js +39 -68
- package/src/platform-implementation-js/driver-common/getGmailMessageIdForSyncMessageId.js +14 -19
- package/src/platform-implementation-js/driver-common/getGmailThreadIdForRfcMessageId.js +27 -35
- package/src/platform-implementation-js/driver-common/getRfcMessageIdForSyncMessageId.js +16 -22
- package/src/platform-implementation-js/driver-common/getThreadIdFromMessageId.js +14 -14
- package/src/platform-implementation-js/driver-common/inboxAjax.js +12 -7
- package/src/platform-implementation-js/driver-common/requestGmailThread.js +19 -20
- package/src/platform-implementation-js/driver-common/sidebar/AppSidebar.js +197 -306
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.js +113 -161
- package/src/platform-implementation-js/driver-interfaces/compose-view-driver.js +1 -114
- package/src/platform-implementation-js/driver-interfaces/driver.js +1 -131
- package/src/platform-implementation-js/driver-interfaces/message-view-driver.js +4 -48
- package/src/platform-implementation-js/driver-interfaces/mole-view-driver.js +1 -29
- package/src/platform-implementation-js/driver-interfaces/route-view-driver.js +1 -32
- package/src/platform-implementation-js/driver-interfaces/thread-row-view-driver.js +1 -11
- package/src/platform-implementation-js/lib/array-to-lifetimes.js +43 -41
- package/src/platform-implementation-js/lib/array-to-lifetimes.test.js +139 -155
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.js +19 -38
- package/src/platform-implementation-js/lib/css-selector-escape.js +7 -3
- package/src/platform-implementation-js/lib/dom/element-view-mapper.js +8 -11
- package/src/platform-implementation-js/lib/dom/get-selection.js +23 -52
- package/src/platform-implementation-js/lib/dom/insert-html-at-cursor.js +69 -101
- package/src/platform-implementation-js/lib/dom/is-node-in-range.js +8 -10
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.js +15 -17
- package/src/platform-implementation-js/lib/dom/querySelectorOne.js +8 -11
- package/src/platform-implementation-js/lib/dom/set-css.js +7 -3
- package/src/platform-implementation-js/lib/dom/set-value-and-dispatch-event.js +9 -11
- package/src/platform-implementation-js/lib/dom/simulate-drag-and-drop.js +32 -33
- package/src/platform-implementation-js/lib/extract-contact-from-email-contact-string.test.js +23 -26
- package/src/platform-implementation-js/lib/handle-compose-link-chips.js +86 -149
- package/src/platform-implementation-js/lib/insert-link-chip-into-body.js +42 -57
- package/src/platform-implementation-js/lib/make-revocable-function.js +19 -21
- package/src/platform-implementation-js/lib/make-revocable-function.test.js +20 -22
- package/src/platform-implementation-js/lib/parseParamsFromRouteID.js +15 -17
- package/src/platform-implementation-js/lib/parseParamsFromRouteID.test.js +9 -18
- package/src/platform-implementation-js/lib/populateRouteID.js +8 -9
- package/src/platform-implementation-js/lib/populateRouteID.test.js +20 -19
- package/src/platform-implementation-js/lib/react/ElementContainer.js +23 -20
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.js +10 -9
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.test.js +13 -20
- package/src/platform-implementation-js/lib/routeIDmatchesHash.js +13 -18
- package/src/platform-implementation-js/lib/routeIDmatchesHash.test.js +11 -17
- package/src/platform-implementation-js/lib/shared-style.js +14 -13
- package/src/platform-implementation-js/lib/toItemWithLifetimeStream.js +18 -17
- package/src/platform-implementation-js/lib/toLiveSet.js +17 -15
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.js +6 -5
- package/src/platform-implementation-js/main.js +9 -24
- package/src/platform-implementation-js/namespaces/compose.js +37 -60
- package/src/platform-implementation-js/namespaces/conversations.js +52 -124
- package/src/platform-implementation-js/namespaces/global.js +27 -39
- package/src/platform-implementation-js/namespaces/keyboard.js +29 -33
- package/src/platform-implementation-js/namespaces/lists.js +25 -31
- package/src/platform-implementation-js/namespaces/modal.js +34 -28
- package/src/platform-implementation-js/namespaces/nav-menu.js +30 -45
- package/src/platform-implementation-js/namespaces/router.js +70 -137
- package/src/platform-implementation-js/namespaces/search.js +19 -17
- package/src/platform-implementation-js/namespaces/toolbars.js +71 -117
- package/src/platform-implementation-js/namespaces/user.js +36 -37
- package/src/platform-implementation-js/namespaces/widgets.js +54 -61
- package/src/platform-implementation-js/platform-implementation.js +98 -229
- package/src/platform-implementation-js/views/app-toolbar-button-view.js +26 -47
- package/src/platform-implementation-js/views/collapsible-section-view.js +66 -63
- package/src/platform-implementation-js/views/content-panel-view.js +28 -30
- package/src/platform-implementation-js/views/conversations/attachment-card-view.js +21 -44
- package/src/platform-implementation-js/views/conversations/custom-message-view.js +44 -104
- package/src/platform-implementation-js/views/conversations/message-view.js +131 -202
- package/src/platform-implementation-js/views/conversations/thread-view.js +75 -127
- package/src/platform-implementation-js/views/native-nav-item-view.js +32 -65
- package/src/platform-implementation-js/views/nav-item-view.js +51 -115
- package/src/platform-implementation-js/views/route-view/custom-route-view.js +25 -20
- package/src/platform-implementation-js/views/route-view/dummy-route-view-driver.js +18 -18
- package/src/platform-implementation-js/views/route-view/list-route-view.js +30 -52
- package/src/platform-implementation-js/views/route-view/route-view.js +24 -35
- package/src/platform-implementation-js/views/section-view.js +60 -52
- package/src/platform-implementation-js/views/thread-row-view.js +49 -74
- package/src/platform-implementation-js/widgets/drawer-view.js +29 -36
- package/src/platform-implementation-js/widgets/modal-view.js +39 -68
- package/src/platform-implementation-js/widgets/mole-view.js +22 -22
- package/src/platform-implementation-js/widgets/top-message-bar-view.js +13 -10
|
@@ -1,32 +1,31 @@
|
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = setupGmailInterceptor;
|
|
8
|
+
exports.setupGmailInterceptorOnFrames = setupGmailInterceptorOnFrames;
|
|
9
|
+
var _clone = _interopRequireDefault(require("lodash/clone"));
|
|
10
|
+
var _flatten = _interopRequireDefault(require("lodash/flatten"));
|
|
11
|
+
var _find = _interopRequireDefault(require("lodash/find"));
|
|
12
|
+
var _intersection = _interopRequireDefault(require("lodash/intersection"));
|
|
13
|
+
var _includes = _interopRequireDefault(require("lodash/includes"));
|
|
14
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
15
|
+
var _kefir = _interopRequireDefault(require("kefir"));
|
|
16
|
+
var logger = _interopRequireWildcard(require("../injected-logger"));
|
|
17
|
+
var _xhrProxyFactory = _interopRequireDefault(require("../xhr-proxy-factory"));
|
|
18
|
+
var _querystring = _interopRequireWildcard(require("querystring"));
|
|
19
|
+
var threadIdentifier = _interopRequireWildcard(require("./thread-identifier"));
|
|
20
|
+
var messageMetadataHolder = _interopRequireWildcard(require("../message-metadata-holder"));
|
|
21
|
+
var GmailResponseProcessor = _interopRequireWildcard(require("../../platform-implementation-js/dom-driver/gmail/gmail-response-processor"));
|
|
22
|
+
var GmailSyncResponseProcessor = _interopRequireWildcard(require("../../platform-implementation-js/dom-driver/gmail/gmail-sync-response-processor"));
|
|
23
|
+
var _quotedSplit = _interopRequireDefault(require("../../common/quoted-split"));
|
|
24
|
+
var _defer = _interopRequireDefault(require("../../common/defer"));
|
|
25
|
+
var _modifySuggestions = _interopRequireDefault(require("./modify-suggestions"));
|
|
26
|
+
var _syncComposeProcessor = require("./sync-compose-processor");
|
|
27
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
29
|
function logErrorExceptEventListeners(err, details) {
|
|
31
30
|
// Don't log Gmail's errors
|
|
32
31
|
if (details !== 'XMLHttpRequest event listener error') {
|
|
@@ -38,78 +37,62 @@ function logErrorExceptEventListeners(err, details) {
|
|
|
38
37
|
}, 1);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let jsFrame: ?WindowProxy = null;
|
|
44
|
-
|
|
40
|
+
function setupGmailInterceptor() {
|
|
41
|
+
let jsFrame = null;
|
|
45
42
|
const js_frame_element = top.document.getElementById('js_frame');
|
|
46
43
|
if (js_frame_element) {
|
|
47
44
|
jsFrame = js_frame_element.contentDocument.defaultView;
|
|
48
45
|
} else {
|
|
49
46
|
logger.eventSdkPassive('noJSFrameElementFound');
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
setupGmailInterceptorOnFrames(window, jsFrame);
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
// Split into a separate step to make it easy for tests to use.
|
|
56
|
-
|
|
57
|
-
mainFrame: WindowProxy,
|
|
58
|
-
jsFrame: ?WindowProxy
|
|
59
|
-
) {
|
|
52
|
+
function setupGmailInterceptorOnFrames(mainFrame, jsFrame) {
|
|
60
53
|
const main_wrappers = [],
|
|
61
54
|
js_frame_wrappers = [];
|
|
62
|
-
|
|
63
55
|
{
|
|
64
56
|
const main_originalXHR = mainFrame.XMLHttpRequest;
|
|
65
|
-
mainFrame.XMLHttpRequest =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
logError: logErrorExceptEventListeners,
|
|
70
|
-
}
|
|
71
|
-
);
|
|
57
|
+
mainFrame.XMLHttpRequest = (0, _xhrProxyFactory.default)(main_originalXHR, main_wrappers, {
|
|
58
|
+
logError: logErrorExceptEventListeners
|
|
59
|
+
});
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
if (jsFrame) {
|
|
75
62
|
const js_frame_originalXHR = jsFrame.XMLHttpRequest;
|
|
76
|
-
jsFrame.XMLHttpRequest =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{ logError: logErrorExceptEventListeners }
|
|
80
|
-
);
|
|
63
|
+
jsFrame.XMLHttpRequest = (0, _xhrProxyFactory.default)(js_frame_originalXHR, js_frame_wrappers, {
|
|
64
|
+
logError: logErrorExceptEventListeners
|
|
65
|
+
});
|
|
81
66
|
}
|
|
82
|
-
|
|
83
67
|
threadIdentifier.setup();
|
|
84
68
|
messageMetadataHolder.setup();
|
|
85
69
|
|
|
86
70
|
//email sending modifier/notifier
|
|
87
71
|
{
|
|
88
|
-
let modifiers
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
).onValue(({ detail }) => {
|
|
72
|
+
let modifiers = {};
|
|
73
|
+
_kefir.default.fromEvents(document, 'inboxSDKregisterComposeRequestModifier').onValue(_ref => {
|
|
74
|
+
let {
|
|
75
|
+
detail
|
|
76
|
+
} = _ref;
|
|
94
77
|
const keyId = detail.composeid || detail.draftID;
|
|
95
78
|
if (!modifiers[keyId]) {
|
|
96
79
|
modifiers[keyId] = [];
|
|
97
80
|
}
|
|
98
|
-
|
|
99
81
|
modifiers[keyId].push(detail.modifierId);
|
|
100
82
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
83
|
+
_kefir.default.fromEvents(document, 'inboxSDKunregisterComposeRequestModifier').onValue(_ref2 => {
|
|
84
|
+
let {
|
|
85
|
+
detail
|
|
86
|
+
} = _ref2;
|
|
87
|
+
const {
|
|
88
|
+
keyId,
|
|
89
|
+
modifierId
|
|
90
|
+
} = detail;
|
|
91
|
+
modifiers[keyId] = modifiers[keyId].filter(item => item !== modifierId);
|
|
108
92
|
if (modifiers[keyId].length === 0) {
|
|
109
93
|
delete modifiers[keyId];
|
|
110
94
|
}
|
|
111
95
|
});
|
|
112
|
-
|
|
113
96
|
js_frame_wrappers.push({
|
|
114
97
|
isRelevantTo: function (connection) {
|
|
115
98
|
return connection.params.act === 'sm';
|
|
@@ -117,50 +100,43 @@ export function setupGmailInterceptorOnFrames(
|
|
|
117
100
|
originalSendBodyLogger: function (connection, body) {
|
|
118
101
|
triggerEvent({
|
|
119
102
|
type: 'emailSending',
|
|
120
|
-
body: body
|
|
103
|
+
body: body
|
|
121
104
|
});
|
|
122
105
|
},
|
|
123
106
|
requestChanger: async function (connection, request) {
|
|
124
|
-
let composeParams =
|
|
107
|
+
let composeParams = _querystring.default.parse(request.body);
|
|
125
108
|
const composeid = composeParams.composeid;
|
|
126
109
|
const composeModifierIds = modifiers[composeParams.composeid];
|
|
127
|
-
|
|
128
110
|
if (!composeModifierIds || composeModifierIds.length === 0) {
|
|
129
111
|
return request;
|
|
130
112
|
}
|
|
131
|
-
|
|
132
113
|
for (let ii = 0; ii < composeModifierIds.length; ii++) {
|
|
133
114
|
const modifierId = composeModifierIds[ii];
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.map(({ detail }) => detail.composeParams)
|
|
146
|
-
.toPromise(Promise);
|
|
147
|
-
|
|
115
|
+
const modificationPromise = _kefir.default.fromEvents(document, 'inboxSDKcomposeRequestModified').filter(_ref3 => {
|
|
116
|
+
let {
|
|
117
|
+
detail
|
|
118
|
+
} = _ref3;
|
|
119
|
+
return detail.composeid === composeid && detail.modifierId === modifierId;
|
|
120
|
+
}).take(1).map(_ref4 => {
|
|
121
|
+
let {
|
|
122
|
+
detail
|
|
123
|
+
} = _ref4;
|
|
124
|
+
return detail.composeParams;
|
|
125
|
+
}).toPromise(Promise);
|
|
148
126
|
triggerEvent({
|
|
149
127
|
type: 'inboxSDKmodifyComposeRequest',
|
|
150
128
|
composeid,
|
|
151
129
|
modifierId,
|
|
152
130
|
composeParams: {
|
|
153
131
|
body: composeParams.body,
|
|
154
|
-
isPlainText: composeParams.ishtml !== '1'
|
|
155
|
-
}
|
|
132
|
+
isPlainText: composeParams.ishtml !== '1'
|
|
133
|
+
}
|
|
156
134
|
});
|
|
157
|
-
|
|
158
135
|
let newComposeParams = await modificationPromise;
|
|
159
136
|
composeParams = Object.assign({}, composeParams, newComposeParams);
|
|
160
137
|
}
|
|
161
|
-
|
|
162
138
|
return Object.assign({}, request, {
|
|
163
|
-
body: stringifyComposeParams(composeParams)
|
|
139
|
+
body: stringifyComposeParams(composeParams)
|
|
164
140
|
});
|
|
165
141
|
},
|
|
166
142
|
afterListeners: function (connection) {
|
|
@@ -168,19 +144,15 @@ export function setupGmailInterceptorOnFrames(
|
|
|
168
144
|
triggerEvent({
|
|
169
145
|
type: 'emailSent',
|
|
170
146
|
responseText: connection.originalResponseText,
|
|
171
|
-
originalSendBody: connection.originalSendBody
|
|
147
|
+
originalSendBody: connection.originalSendBody
|
|
172
148
|
});
|
|
173
|
-
|
|
174
149
|
if (connection.originalSendBody) {
|
|
175
|
-
const composeParams =
|
|
176
|
-
connection.originalSendBody
|
|
177
|
-
);
|
|
150
|
+
const composeParams = _querystring.default.parse(connection.originalSendBody);
|
|
178
151
|
delete modifiers[composeParams.composeid];
|
|
179
152
|
}
|
|
180
153
|
}
|
|
181
|
-
}
|
|
154
|
+
}
|
|
182
155
|
});
|
|
183
|
-
|
|
184
156
|
js_frame_wrappers.push({
|
|
185
157
|
isRelevantTo: function (connection) {
|
|
186
158
|
return connection.params.act === 'sd';
|
|
@@ -188,7 +160,7 @@ export function setupGmailInterceptorOnFrames(
|
|
|
188
160
|
originalSendBodyLogger: function (connection, body) {
|
|
189
161
|
triggerEvent({
|
|
190
162
|
type: 'emailDraftSaveSending',
|
|
191
|
-
body: body
|
|
163
|
+
body: body
|
|
192
164
|
});
|
|
193
165
|
},
|
|
194
166
|
afterListeners: function (connection) {
|
|
@@ -201,43 +173,30 @@ export function setupGmailInterceptorOnFrames(
|
|
|
201
173
|
method: connection.method,
|
|
202
174
|
url: connection.url,
|
|
203
175
|
params: connection.params,
|
|
204
|
-
responseType: connection.responseType
|
|
205
|
-
}
|
|
176
|
+
responseType: connection.responseType
|
|
177
|
+
}
|
|
206
178
|
});
|
|
207
179
|
}
|
|
208
|
-
}
|
|
180
|
+
}
|
|
209
181
|
});
|
|
210
|
-
|
|
211
182
|
{
|
|
212
183
|
// Sync API-based compose sending intercept
|
|
213
|
-
const currentSendConnectionIDs
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
> = new WeakMap();
|
|
217
|
-
const currentDraftSaveConnectionIDs: WeakMap<
|
|
218
|
-
XHRProxyConnectionDetails,
|
|
219
|
-
string
|
|
220
|
-
> = new WeakMap();
|
|
221
|
-
const currentFirstDraftSaveConnectionIDs: WeakMap<
|
|
222
|
-
XHRProxyConnectionDetails,
|
|
223
|
-
string
|
|
224
|
-
> = new WeakMap();
|
|
184
|
+
const currentSendConnectionIDs = new WeakMap();
|
|
185
|
+
const currentDraftSaveConnectionIDs = new WeakMap();
|
|
186
|
+
const currentFirstDraftSaveConnectionIDs = new WeakMap();
|
|
225
187
|
main_wrappers.push({
|
|
226
188
|
isRelevantTo(connection) {
|
|
227
189
|
return /sync(?:\/u\/\d+)?\/i\/s/.test(connection.url);
|
|
228
190
|
},
|
|
229
191
|
originalSendBodyLogger(connection) {
|
|
230
192
|
if (connection.originalSendBody) {
|
|
231
|
-
const composeRequestDetails = parseComposeRequestBody(
|
|
232
|
-
connection.originalSendBody
|
|
233
|
-
);
|
|
234
|
-
|
|
193
|
+
const composeRequestDetails = (0, _syncComposeProcessor.parseComposeRequestBody)(connection.originalSendBody);
|
|
235
194
|
if (!composeRequestDetails) {
|
|
236
195
|
return;
|
|
237
196
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
197
|
+
const {
|
|
198
|
+
draftID
|
|
199
|
+
} = composeRequestDetails;
|
|
241
200
|
switch (composeRequestDetails.type) {
|
|
242
201
|
case 'FIRST_DRAFT_SAVE':
|
|
243
202
|
currentFirstDraftSaveConnectionIDs.set(connection, draftID);
|
|
@@ -247,94 +206,76 @@ export function setupGmailInterceptorOnFrames(
|
|
|
247
206
|
break;
|
|
248
207
|
case 'SEND':
|
|
249
208
|
currentSendConnectionIDs.set(connection, draftID);
|
|
250
|
-
triggerEvent({
|
|
209
|
+
triggerEvent({
|
|
210
|
+
type: 'emailSending',
|
|
211
|
+
draftID
|
|
212
|
+
});
|
|
251
213
|
break;
|
|
252
214
|
}
|
|
253
215
|
}
|
|
254
216
|
},
|
|
255
217
|
requestChanger: async function (connection, request) {
|
|
256
|
-
const composeRequestDetails = parseComposeRequestBody(request.body);
|
|
257
|
-
if (!composeRequestDetails || composeRequestDetails.type !== 'SEND')
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
218
|
+
const composeRequestDetails = (0, _syncComposeProcessor.parseComposeRequestBody)(request.body);
|
|
219
|
+
if (!composeRequestDetails || composeRequestDetails.type !== 'SEND') return request;
|
|
220
|
+
const {
|
|
221
|
+
draftID,
|
|
222
|
+
body,
|
|
223
|
+
type
|
|
224
|
+
} = composeRequestDetails;
|
|
262
225
|
const composeModifierIds = modifiers[draftID];
|
|
263
|
-
if (!composeModifierIds || composeModifierIds.length === 0)
|
|
264
|
-
return request;
|
|
265
|
-
|
|
226
|
+
if (!composeModifierIds || composeModifierIds.length === 0) return request;
|
|
266
227
|
let newEmailBody = composeRequestDetails.body;
|
|
267
228
|
for (let ii = 0; ii < composeModifierIds.length; ii++) {
|
|
268
229
|
const modifierId = composeModifierIds[ii];
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
.
|
|
279
|
-
|
|
280
|
-
.toPromise(Promise);
|
|
281
|
-
|
|
230
|
+
const modificationPromise = _kefir.default.fromEvents(document, 'inboxSDKcomposeRequestModified').filter(_ref5 => {
|
|
231
|
+
let {
|
|
232
|
+
detail
|
|
233
|
+
} = _ref5;
|
|
234
|
+
return detail.draftID === draftID && detail.modifierId === modifierId;
|
|
235
|
+
}).take(1).map(_ref6 => {
|
|
236
|
+
let {
|
|
237
|
+
detail
|
|
238
|
+
} = _ref6;
|
|
239
|
+
return detail.composeParams;
|
|
240
|
+
}).toPromise(Promise);
|
|
282
241
|
triggerEvent({
|
|
283
242
|
type: 'inboxSDKmodifyComposeRequest',
|
|
284
243
|
draftID,
|
|
285
244
|
modifierId,
|
|
286
245
|
composeParams: {
|
|
287
246
|
body: newEmailBody,
|
|
288
|
-
isPlainText: false
|
|
289
|
-
}
|
|
247
|
+
isPlainText: false
|
|
248
|
+
}
|
|
290
249
|
});
|
|
291
|
-
|
|
292
250
|
const newComposeParams = await modificationPromise;
|
|
293
251
|
newEmailBody = newComposeParams.body;
|
|
294
252
|
}
|
|
295
|
-
|
|
296
253
|
return Object.assign({}, request, {
|
|
297
|
-
body: replaceBodyContentInComposeSendRequestBody(
|
|
298
|
-
request.body,
|
|
299
|
-
newEmailBody
|
|
300
|
-
),
|
|
254
|
+
body: (0, _syncComposeProcessor.replaceBodyContentInComposeSendRequestBody)(request.body, newEmailBody)
|
|
301
255
|
});
|
|
302
256
|
},
|
|
303
257
|
afterListeners(connection) {
|
|
304
|
-
if (
|
|
305
|
-
currentSendConnectionIDs.has(connection) ||
|
|
306
|
-
currentDraftSaveConnectionIDs.has(connection) ||
|
|
307
|
-
currentFirstDraftSaveConnectionIDs.has(connection)
|
|
308
|
-
) {
|
|
258
|
+
if (currentSendConnectionIDs.has(connection) || currentDraftSaveConnectionIDs.has(connection) || currentFirstDraftSaveConnectionIDs.has(connection)) {
|
|
309
259
|
const sendFailed = () => {
|
|
310
|
-
triggerEvent({
|
|
260
|
+
triggerEvent({
|
|
261
|
+
type: 'emailSendFailed',
|
|
262
|
+
draftID
|
|
263
|
+
});
|
|
311
264
|
currentSendConnectionIDs.delete(connection);
|
|
312
265
|
};
|
|
313
|
-
|
|
314
|
-
const draftID =
|
|
315
|
-
currentSendConnectionIDs.get(connection) ||
|
|
316
|
-
currentDraftSaveConnectionIDs.get(connection) ||
|
|
317
|
-
currentFirstDraftSaveConnectionIDs.get(connection);
|
|
318
|
-
|
|
266
|
+
const draftID = currentSendConnectionIDs.get(connection) || currentDraftSaveConnectionIDs.get(connection) || currentFirstDraftSaveConnectionIDs.get(connection);
|
|
319
267
|
if (connection.status !== 200 || !connection.originalResponseText) {
|
|
320
268
|
sendFailed();
|
|
321
269
|
return;
|
|
322
270
|
}
|
|
323
|
-
|
|
324
271
|
try {
|
|
325
|
-
const responsesParsed = parseComposeResponseBody(
|
|
326
|
-
connection.originalResponseText
|
|
327
|
-
);
|
|
328
|
-
|
|
272
|
+
const responsesParsed = (0, _syncComposeProcessor.parseComposeResponseBody)(connection.originalResponseText);
|
|
329
273
|
for (const responseParsed of responsesParsed) {
|
|
330
274
|
// If we're sending a draft, we only care about the response related to the draft we're sending.
|
|
331
275
|
if (draftID && !responseParsed.messageId.endsWith(draftID)) {
|
|
332
276
|
continue;
|
|
333
277
|
}
|
|
334
|
-
if (
|
|
335
|
-
responseParsed.type === 'FIRST_DRAFT_SAVE' ||
|
|
336
|
-
responseParsed.type === 'DRAFT_SAVE'
|
|
337
|
-
) {
|
|
278
|
+
if (responseParsed.type === 'FIRST_DRAFT_SAVE' || responseParsed.type === 'DRAFT_SAVE') {
|
|
338
279
|
triggerEvent({
|
|
339
280
|
draftID: draftID,
|
|
340
281
|
type: 'emailDraftReceived',
|
|
@@ -342,13 +283,11 @@ export function setupGmailInterceptorOnFrames(
|
|
|
342
283
|
threadID: responseParsed.threadId,
|
|
343
284
|
messageID: responseParsed.messageId,
|
|
344
285
|
oldMessageID: responseParsed.oldMessageId,
|
|
345
|
-
oldThreadID: responseParsed.oldThreadId
|
|
286
|
+
oldThreadID: responseParsed.oldThreadId
|
|
346
287
|
});
|
|
347
|
-
|
|
348
288
|
currentSendConnectionIDs.delete(connection);
|
|
349
289
|
currentDraftSaveConnectionIDs.delete(connection);
|
|
350
290
|
currentFirstDraftSaveConnectionIDs.delete(connection);
|
|
351
|
-
|
|
352
291
|
return;
|
|
353
292
|
} else if (responseParsed.type === 'SEND') {
|
|
354
293
|
triggerEvent({
|
|
@@ -358,44 +297,28 @@ export function setupGmailInterceptorOnFrames(
|
|
|
358
297
|
threadID: responseParsed.threadId,
|
|
359
298
|
messageID: responseParsed.messageId,
|
|
360
299
|
oldMessageID: responseParsed.oldMessageId,
|
|
361
|
-
oldThreadID: responseParsed.oldThreadId
|
|
300
|
+
oldThreadID: responseParsed.oldThreadId
|
|
362
301
|
});
|
|
363
|
-
|
|
364
302
|
currentSendConnectionIDs.delete(connection);
|
|
365
303
|
currentDraftSaveConnectionIDs.delete(connection);
|
|
366
304
|
currentFirstDraftSaveConnectionIDs.delete(connection);
|
|
367
|
-
|
|
368
305
|
return;
|
|
369
306
|
}
|
|
370
307
|
}
|
|
371
308
|
} catch (err) {
|
|
372
|
-
logger.eventSdkPassive(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
responseParseError: err,
|
|
376
|
-
}
|
|
377
|
-
);
|
|
309
|
+
logger.eventSdkPassive('connection.requestResponseParsingFailed', {
|
|
310
|
+
responseParseError: err
|
|
311
|
+
});
|
|
378
312
|
}
|
|
379
|
-
|
|
380
|
-
const originalResponse = JSON.parse(
|
|
381
|
-
connection.originalResponseText
|
|
382
|
-
);
|
|
313
|
+
const originalResponse = JSON.parse(connection.originalResponseText);
|
|
383
314
|
|
|
384
315
|
// TODO this function silently fails way too easily. Need to add better logging for it!
|
|
385
316
|
|
|
386
317
|
if (currentFirstDraftSaveConnectionIDs.has(connection)) {
|
|
387
|
-
const wrapper =
|
|
388
|
-
originalResponse[2] &&
|
|
389
|
-
originalResponse[2][6] &&
|
|
390
|
-
originalResponse[2][6][0] &&
|
|
391
|
-
originalResponse[2][6][0][1];
|
|
392
|
-
|
|
318
|
+
const wrapper = originalResponse[2] && originalResponse[2][6] && originalResponse[2][6][0] && originalResponse[2][6][0][1];
|
|
393
319
|
if (wrapper) {
|
|
394
|
-
const threadUpdate =
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
const messageUpdate =
|
|
398
|
-
threadUpdate && threadUpdate[5] && threadUpdate[5][0];
|
|
320
|
+
const threadUpdate = wrapper[3] && wrapper[3][7] && wrapper[3][7][1];
|
|
321
|
+
const messageUpdate = threadUpdate && threadUpdate[5] && threadUpdate[5][0];
|
|
399
322
|
if (threadUpdate && messageUpdate) {
|
|
400
323
|
triggerEvent({
|
|
401
324
|
draftID: draftID,
|
|
@@ -404,7 +327,7 @@ export function setupGmailInterceptorOnFrames(
|
|
|
404
327
|
threadID: threadUpdate[4].split('|')[0],
|
|
405
328
|
messageID: messageUpdate[1],
|
|
406
329
|
oldMessageID: messageUpdate[56],
|
|
407
|
-
oldThreadID: threadUpdate[20]
|
|
330
|
+
oldThreadID: threadUpdate[20]
|
|
408
331
|
});
|
|
409
332
|
} else {
|
|
410
333
|
logger.error(new Error('Could not parse draft save'));
|
|
@@ -412,63 +335,49 @@ export function setupGmailInterceptorOnFrames(
|
|
|
412
335
|
} else {
|
|
413
336
|
// pre-2019-05-29 handling
|
|
414
337
|
logger.eventSdkPassive('old compose draft id handling hit');
|
|
415
|
-
const oldWrapper =
|
|
416
|
-
originalResponse[2] &&
|
|
417
|
-
originalResponse[2][6] &&
|
|
418
|
-
originalResponse[2][6][1] &&
|
|
419
|
-
originalResponse[2][6][1][1];
|
|
420
|
-
|
|
338
|
+
const oldWrapper = originalResponse[2] && originalResponse[2][6] && originalResponse[2][6][1] && originalResponse[2][6][1][1];
|
|
421
339
|
if (oldWrapper) {
|
|
422
|
-
const saveUpdate =
|
|
423
|
-
oldWrapper[3] && oldWrapper[3][1] && oldWrapper[3][1][1];
|
|
424
|
-
|
|
340
|
+
const saveUpdate = oldWrapper[3] && oldWrapper[3][1] && oldWrapper[3][1][1];
|
|
425
341
|
if (saveUpdate) {
|
|
426
342
|
triggerEvent({
|
|
427
343
|
draftID: draftID,
|
|
428
344
|
type: 'emailDraftReceived',
|
|
429
345
|
rfcID: saveUpdate[14],
|
|
430
346
|
messageID: saveUpdate[1],
|
|
431
|
-
oldMessageID: saveUpdate[48]
|
|
432
|
-
|
|
433
|
-
: saveUpdate[56],
|
|
434
|
-
syncThreadID: oldWrapper[1],
|
|
347
|
+
oldMessageID: saveUpdate[48] ? new _bignumber.default(saveUpdate[48]).toString(16) : saveUpdate[56],
|
|
348
|
+
syncThreadID: oldWrapper[1]
|
|
435
349
|
});
|
|
436
350
|
}
|
|
437
351
|
}
|
|
438
352
|
}
|
|
439
353
|
} else {
|
|
440
|
-
|
|
354
|
+
var _originalResponse$, _sendUpdateMatch$, _sendUpdateMatch$$, _sendUpdateMatch$$$;
|
|
355
|
+
const updateList = (_originalResponse$ = originalResponse[2]) === null || _originalResponse$ === void 0 ? void 0 : _originalResponse$[6];
|
|
441
356
|
if (!updateList) {
|
|
442
357
|
sendFailed();
|
|
443
358
|
return;
|
|
444
359
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
(update) =>
|
|
448
|
-
|
|
449
|
-
update[1][3][7][1][5].find((message) =>
|
|
450
|
-
includes(message[1], draftID)
|
|
451
|
-
)
|
|
452
|
-
);
|
|
453
|
-
|
|
360
|
+
const sendUpdateMatch = updateList.find(update => {
|
|
361
|
+
var _update$, _update$$, _update$$$, _update$$$$, _update$$$$$, _update$$$$$$;
|
|
362
|
+
return ((_update$ = update[1]) === null || _update$ === void 0 ? void 0 : (_update$$ = _update$[3]) === null || _update$$ === void 0 ? void 0 : (_update$$$ = _update$$[7]) === null || _update$$$ === void 0 ? void 0 : (_update$$$$ = _update$$$[1]) === null || _update$$$$ === void 0 ? void 0 : (_update$$$$$ = _update$$$$[5]) === null || _update$$$$$ === void 0 ? void 0 : (_update$$$$$$ = _update$$$$$[0]) === null || _update$$$$$$ === void 0 ? void 0 : _update$$$$$$[14]) && update[1][3][7][1][5].find(message => (0, _includes.default)(message[1], draftID));
|
|
363
|
+
});
|
|
454
364
|
if (!sendUpdateMatch) {
|
|
455
365
|
if (currentSendConnectionIDs.has(connection)) {
|
|
456
|
-
const minimalSendUpdates = updateList.filter(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
366
|
+
const minimalSendUpdates = updateList.filter(update => {
|
|
367
|
+
var _update$2, _update$2$, _update$2$$;
|
|
368
|
+
return (_update$2 = update[1]) === null || _update$2 === void 0 ? void 0 : (_update$2$ = _update$2[3]) === null || _update$2$ === void 0 ? void 0 : (_update$2$$ = _update$2$[5]) === null || _update$2$$ === void 0 ? void 0 : _update$2$$[3];
|
|
369
|
+
});
|
|
460
370
|
if (minimalSendUpdates.length > 0) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
: undefined;
|
|
371
|
+
var _minimalSendUpdates$, _minimalSendUpdates$$, _minimalSendUpdates$$2, _minimalSendUpdates$2;
|
|
372
|
+
const threadID = minimalSendUpdates[0][1][1] ? minimalSendUpdates[0][1][1].replace(/\|.*$/, '') : undefined;
|
|
464
373
|
triggerEvent({
|
|
465
374
|
draftID,
|
|
466
375
|
type: 'emailSent',
|
|
467
376
|
threadID,
|
|
468
377
|
messageID:
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
378
|
+
//new compose
|
|
379
|
+
((_minimalSendUpdates$ = minimalSendUpdates[0][1][3]) === null || _minimalSendUpdates$ === void 0 ? void 0 : (_minimalSendUpdates$$ = _minimalSendUpdates$[5]) === null || _minimalSendUpdates$$ === void 0 ? void 0 : (_minimalSendUpdates$$2 = _minimalSendUpdates$$[5]) === null || _minimalSendUpdates$$2 === void 0 ? void 0 : _minimalSendUpdates$$2[0]) || ( //replies
|
|
380
|
+
(_minimalSendUpdates$2 = minimalSendUpdates[0][1][3][5][3]) === null || _minimalSendUpdates$2 === void 0 ? void 0 : _minimalSendUpdates$2[0])
|
|
472
381
|
});
|
|
473
382
|
} else {
|
|
474
383
|
sendFailed();
|
|
@@ -476,72 +385,49 @@ export function setupGmailInterceptorOnFrames(
|
|
|
476
385
|
} else {
|
|
477
386
|
sendFailed();
|
|
478
387
|
}
|
|
479
|
-
|
|
480
388
|
return;
|
|
481
389
|
}
|
|
482
|
-
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
const sendUpdate = sendUpdateWrapper[5].find((message) =>
|
|
486
|
-
message[1].includes(draftID)
|
|
487
|
-
);
|
|
488
|
-
|
|
390
|
+
const sendUpdateWrapper = (_sendUpdateMatch$ = sendUpdateMatch[1]) === null || _sendUpdateMatch$ === void 0 ? void 0 : (_sendUpdateMatch$$ = _sendUpdateMatch$[3]) === null || _sendUpdateMatch$$ === void 0 ? void 0 : (_sendUpdateMatch$$$ = _sendUpdateMatch$$[7]) === null || _sendUpdateMatch$$$ === void 0 ? void 0 : _sendUpdateMatch$$$[1];
|
|
391
|
+
const sendUpdate = sendUpdateWrapper[5].find(message => message[1].includes(draftID));
|
|
489
392
|
if (!sendUpdate) {
|
|
490
393
|
sendFailed();
|
|
491
394
|
return;
|
|
492
395
|
}
|
|
493
|
-
|
|
494
|
-
const isEmailSentResponse =
|
|
495
|
-
currentSendConnectionIDs.has(connection);
|
|
496
|
-
|
|
396
|
+
const isEmailSentResponse = currentSendConnectionIDs.has(connection);
|
|
497
397
|
if (!Array.isArray(sendUpdate[11])) {
|
|
498
398
|
logger.error(new Error('sendUpdate[11] was not an array'));
|
|
499
399
|
} else {
|
|
500
400
|
if (isEmailSentResponse) {
|
|
501
401
|
if (sendUpdate[11].indexOf('^r') >= 0) {
|
|
502
|
-
logger.error(
|
|
503
|
-
new Error('sendUpdate[11] unexpectedly contained "^r"')
|
|
504
|
-
);
|
|
402
|
+
logger.error(new Error('sendUpdate[11] unexpectedly contained "^r"'));
|
|
505
403
|
}
|
|
506
404
|
}
|
|
507
405
|
}
|
|
508
|
-
|
|
509
406
|
if (isEmailSentResponse) {
|
|
510
407
|
if (sendUpdate[22] !== undefined && sendUpdate[22] !== 3) {
|
|
511
|
-
logger.error(
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
);
|
|
408
|
+
logger.error(new Error('sendUpdate[22] was not expected value'), {
|
|
409
|
+
value: sendUpdate[22]
|
|
410
|
+
});
|
|
515
411
|
}
|
|
516
412
|
}
|
|
517
|
-
|
|
518
|
-
const threadID = sendUpdateWrapper[4]
|
|
519
|
-
? sendUpdateWrapper[4].replace(/\|.*$/, '')
|
|
520
|
-
: undefined;
|
|
521
|
-
|
|
413
|
+
const threadID = sendUpdateWrapper[4] ? sendUpdateWrapper[4].replace(/\|.*$/, '') : undefined;
|
|
522
414
|
triggerEvent({
|
|
523
415
|
draftID: draftID,
|
|
524
416
|
type: isEmailSentResponse ? 'emailSent' : 'emailDraftReceived',
|
|
525
417
|
rfcID: sendUpdate[14],
|
|
526
418
|
messageID: sendUpdate[1],
|
|
527
|
-
oldMessageID: sendUpdate[48]
|
|
528
|
-
? new BigNumber(sendUpdate[48]).toString(16)
|
|
529
|
-
: sendUpdate[56],
|
|
419
|
+
oldMessageID: sendUpdate[48] ? new _bignumber.default(sendUpdate[48]).toString(16) : sendUpdate[56],
|
|
530
420
|
threadID,
|
|
531
421
|
// It seems Gmail is A/B testing including gmailThreadID in response[20] and not including
|
|
532
422
|
// the encoded version of it in response[18], so pull it from [20] if [18] is not set.
|
|
533
|
-
oldThreadID:
|
|
534
|
-
sendUpdateWrapper[18] != null
|
|
535
|
-
? new BigNumber(sendUpdateWrapper[18]).toString(16)
|
|
536
|
-
: sendUpdateWrapper[20],
|
|
423
|
+
oldThreadID: sendUpdateWrapper[18] != null ? new _bignumber.default(sendUpdateWrapper[18]).toString(16) : sendUpdateWrapper[20]
|
|
537
424
|
});
|
|
538
425
|
}
|
|
539
|
-
|
|
540
426
|
currentSendConnectionIDs.delete(connection);
|
|
541
427
|
currentDraftSaveConnectionIDs.delete(connection);
|
|
542
428
|
currentFirstDraftSaveConnectionIDs.delete(connection);
|
|
543
429
|
}
|
|
544
|
-
}
|
|
430
|
+
}
|
|
545
431
|
});
|
|
546
432
|
}
|
|
547
433
|
}
|
|
@@ -562,10 +448,9 @@ export function setupGmailInterceptorOnFrames(
|
|
|
562
448
|
if (connection.status === 200) {
|
|
563
449
|
const search = connection.params.search;
|
|
564
450
|
const responseText = connection.originalResponseText;
|
|
565
|
-
|
|
566
451
|
threadIdentifier.processThreadListResponse(responseText);
|
|
567
452
|
}
|
|
568
|
-
}
|
|
453
|
+
}
|
|
569
454
|
});
|
|
570
455
|
}
|
|
571
456
|
|
|
@@ -577,15 +462,12 @@ export function setupGmailInterceptorOnFrames(
|
|
|
577
462
|
isRelevantTo(connection) {
|
|
578
463
|
return connection.params.view === 'cv';
|
|
579
464
|
},
|
|
580
|
-
|
|
581
465
|
originalResponseTextLogger(connection) {
|
|
582
466
|
if (connection.status === 200) {
|
|
583
|
-
const groupedMessages = GmailResponseProcessor.extractMessages(
|
|
584
|
-
connection.originalResponseText
|
|
585
|
-
);
|
|
467
|
+
const groupedMessages = GmailResponseProcessor.extractMessages(connection.originalResponseText);
|
|
586
468
|
messageMetadataHolder.add(groupedMessages);
|
|
587
469
|
}
|
|
588
|
-
}
|
|
470
|
+
}
|
|
589
471
|
});
|
|
590
472
|
}
|
|
591
473
|
|
|
@@ -596,26 +478,18 @@ export function setupGmailInterceptorOnFrames(
|
|
|
596
478
|
isRelevantTo: function (connection) {
|
|
597
479
|
return /sync(?:\/u\/\d+)?\/i\/bv/.test(connection.url);
|
|
598
480
|
},
|
|
599
|
-
|
|
600
481
|
originalResponseTextLogger(connection) {
|
|
601
482
|
if (connection.status === 200) {
|
|
602
|
-
const threads =
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
threadID: syncThread.syncThreadID,
|
|
609
|
-
messages: syncThread.extraMetaData.syncMessageData.map(
|
|
610
|
-
(syncMessage) => ({
|
|
611
|
-
date: syncMessage.date,
|
|
612
|
-
recipients: syncMessage.recipients,
|
|
613
|
-
})
|
|
614
|
-
),
|
|
483
|
+
const threads = GmailSyncResponseProcessor.extractThreadsFromSearchResponse(connection.originalResponseText);
|
|
484
|
+
messageMetadataHolder.add(threads.map(syncThread => ({
|
|
485
|
+
threadID: syncThread.syncThreadID,
|
|
486
|
+
messages: syncThread.extraMetaData.syncMessageData.map(syncMessage => ({
|
|
487
|
+
date: syncMessage.date,
|
|
488
|
+
recipients: syncMessage.recipients
|
|
615
489
|
}))
|
|
616
|
-
);
|
|
490
|
+
})));
|
|
617
491
|
}
|
|
618
|
-
}
|
|
492
|
+
}
|
|
619
493
|
});
|
|
620
494
|
|
|
621
495
|
// thread response
|
|
@@ -623,26 +497,18 @@ export function setupGmailInterceptorOnFrames(
|
|
|
623
497
|
isRelevantTo: function (connection) {
|
|
624
498
|
return /sync(?:\/u\/\d+)?\/i\/fd/.test(connection.url);
|
|
625
499
|
},
|
|
626
|
-
|
|
627
500
|
originalResponseTextLogger(connection) {
|
|
628
501
|
if (connection.status === 200) {
|
|
629
|
-
const threads =
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
threadID: syncThread.syncThreadID,
|
|
636
|
-
messages: syncThread.extraMetaData.syncMessageData.map(
|
|
637
|
-
(syncMessage) => ({
|
|
638
|
-
date: syncMessage.date,
|
|
639
|
-
recipients: syncMessage.recipients,
|
|
640
|
-
})
|
|
641
|
-
),
|
|
502
|
+
const threads = GmailSyncResponseProcessor.extractThreadsFromThreadResponse(connection.originalResponseText);
|
|
503
|
+
messageMetadataHolder.add(threads.map(syncThread => ({
|
|
504
|
+
threadID: syncThread.syncThreadID,
|
|
505
|
+
messages: syncThread.extraMetaData.syncMessageData.map(syncMessage => ({
|
|
506
|
+
date: syncMessage.date,
|
|
507
|
+
recipients: syncMessage.recipients
|
|
642
508
|
}))
|
|
643
|
-
);
|
|
509
|
+
})));
|
|
644
510
|
}
|
|
645
|
-
}
|
|
511
|
+
}
|
|
646
512
|
});
|
|
647
513
|
}
|
|
648
514
|
}
|
|
@@ -658,55 +524,42 @@ export function setupGmailInterceptorOnFrames(
|
|
|
658
524
|
let currentQuery;
|
|
659
525
|
let suggestionModifications;
|
|
660
526
|
let currentQueryDefer;
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
)
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
if (
|
|
686
|
-
suggestionModifications.filter(Boolean).length ===
|
|
687
|
-
Object.keys(providers).length
|
|
688
|
-
) {
|
|
689
|
-
if (currentQueryDefer == null) {
|
|
690
|
-
throw new Error('tried to resolve a null currentQueryDefer');
|
|
691
|
-
}
|
|
692
|
-
currentQueryDefer.resolve(flatten(suggestionModifications));
|
|
693
|
-
currentQueryDefer = currentQuery = suggestionModifications = null;
|
|
527
|
+
document.addEventListener('inboxSDKregisterSuggestionsModifier', function (_ref7) {
|
|
528
|
+
let {
|
|
529
|
+
detail
|
|
530
|
+
} = _ref7;
|
|
531
|
+
providers[detail.providerID] = {
|
|
532
|
+
position: Object.keys(providers).length
|
|
533
|
+
};
|
|
534
|
+
});
|
|
535
|
+
document.addEventListener('inboxSDKprovideSuggestions', function (_ref8) {
|
|
536
|
+
let {
|
|
537
|
+
detail
|
|
538
|
+
} = _ref8;
|
|
539
|
+
if (detail.query === currentQuery) {
|
|
540
|
+
const provider = providers[detail.providerID];
|
|
541
|
+
if (!provider) {
|
|
542
|
+
throw new Error('provider does not exist for providerID');
|
|
543
|
+
}
|
|
544
|
+
if (suggestionModifications == null) {
|
|
545
|
+
throw new Error('tried to modified a null suggestionModifications');
|
|
546
|
+
}
|
|
547
|
+
suggestionModifications[provider.position] = detail.suggestions;
|
|
548
|
+
if (suggestionModifications.filter(Boolean).length === Object.keys(providers).length) {
|
|
549
|
+
if (currentQueryDefer == null) {
|
|
550
|
+
throw new Error('tried to resolve a null currentQueryDefer');
|
|
694
551
|
}
|
|
552
|
+
currentQueryDefer.resolve((0, _flatten.default)(suggestionModifications));
|
|
553
|
+
currentQueryDefer = currentQuery = suggestionModifications = null;
|
|
695
554
|
}
|
|
696
555
|
}
|
|
697
|
-
);
|
|
698
|
-
|
|
556
|
+
});
|
|
699
557
|
main_wrappers.push({
|
|
700
558
|
isRelevantTo(connection) {
|
|
701
|
-
return (
|
|
702
|
-
Object.keys(providers).length > 0 &&
|
|
703
|
-
!!connection.url.match(/^\/cloudsearch\/request\?/) &&
|
|
704
|
-
connection.params.client == 'gmail' &&
|
|
705
|
-
connection.params.gs_ri == 'gmail'
|
|
706
|
-
);
|
|
559
|
+
return Object.keys(providers).length > 0 && !!connection.url.match(/^\/cloudsearch\/request\?/) && connection.params.client == 'gmail' && connection.params.gs_ri == 'gmail';
|
|
707
560
|
},
|
|
708
561
|
originalSendBodyLogger(connection, body) {
|
|
709
|
-
const parsedBody =
|
|
562
|
+
const parsedBody = _querystring.default.parse(body);
|
|
710
563
|
if (!parsedBody.request) {
|
|
711
564
|
return;
|
|
712
565
|
}
|
|
@@ -716,25 +569,24 @@ export function setupGmailInterceptorOnFrames(
|
|
|
716
569
|
}
|
|
717
570
|
currentQuery = query;
|
|
718
571
|
if (currentQueryDefer) currentQueryDefer.resolve();
|
|
719
|
-
currentQueryDefer =
|
|
572
|
+
currentQueryDefer = connection._defer = (0, _defer.default)();
|
|
720
573
|
suggestionModifications = [];
|
|
721
574
|
triggerEvent({
|
|
722
575
|
type: 'suggestionsRequest',
|
|
723
|
-
query: currentQuery
|
|
576
|
+
query: currentQuery
|
|
724
577
|
});
|
|
725
578
|
},
|
|
726
579
|
async responseTextChanger(connection, responseText) {
|
|
727
|
-
if (
|
|
728
|
-
const modifications = await
|
|
580
|
+
if (connection._defer && connection.status === 200) {
|
|
581
|
+
const modifications = await connection._defer.promise;
|
|
729
582
|
if (modifications) {
|
|
730
|
-
return
|
|
583
|
+
return (0, _modifySuggestions.default)(responseText, modifications);
|
|
731
584
|
}
|
|
732
585
|
}
|
|
733
586
|
return responseText;
|
|
734
|
-
}
|
|
587
|
+
}
|
|
735
588
|
});
|
|
736
589
|
}
|
|
737
|
-
|
|
738
590
|
{
|
|
739
591
|
// TODO: simplify this code
|
|
740
592
|
// the triggerEvent call should happen in the requestChanger callback
|
|
@@ -747,49 +599,27 @@ export function setupGmailInterceptorOnFrames(
|
|
|
747
599
|
// content script that contains a new query to substitute in.
|
|
748
600
|
const customSearchTerms = [];
|
|
749
601
|
let queryReplacement;
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
);
|
|
757
|
-
|
|
758
|
-
document.addEventListener(
|
|
759
|
-
'inboxSDKsearchReplacementReady',
|
|
760
|
-
function (event: any) {
|
|
761
|
-
if (queryReplacement.query === event.detail.query) {
|
|
762
|
-
queryReplacement.newQuery.resolve(event.detail.newQuery);
|
|
763
|
-
}
|
|
602
|
+
document.addEventListener('inboxSDKcreateCustomSearchTerm', function (event) {
|
|
603
|
+
customSearchTerms.push(event.detail.term);
|
|
604
|
+
});
|
|
605
|
+
document.addEventListener('inboxSDKsearchReplacementReady', function (event) {
|
|
606
|
+
if (queryReplacement.query === event.detail.query) {
|
|
607
|
+
queryReplacement.newQuery.resolve(event.detail.newQuery);
|
|
764
608
|
}
|
|
765
|
-
);
|
|
609
|
+
});
|
|
766
610
|
|
|
767
611
|
// classic Gmail API intercept
|
|
768
612
|
js_frame_wrappers.push({
|
|
769
613
|
isRelevantTo: function (connection) {
|
|
770
614
|
let customSearchTerm;
|
|
771
615
|
const params = connection.params;
|
|
772
|
-
if (
|
|
773
|
-
|
|
774
|
-
params.search &&
|
|
775
|
-
params.view === 'tl' &&
|
|
776
|
-
connection.url.match(/^\?/) &&
|
|
777
|
-
params.q &&
|
|
778
|
-
(customSearchTerm = intersection(
|
|
779
|
-
customSearchTerms,
|
|
780
|
-
quotedSplit(params.q)
|
|
781
|
-
)[0])
|
|
782
|
-
) {
|
|
783
|
-
if (
|
|
784
|
-
queryReplacement &&
|
|
785
|
-
queryReplacement.query === params.q &&
|
|
786
|
-
queryReplacement.start != params.start
|
|
787
|
-
) {
|
|
616
|
+
if (connection.method === 'POST' && params.search && params.view === 'tl' && connection.url.match(/^\?/) && params.q && (customSearchTerm = (0, _intersection.default)(customSearchTerms, (0, _quotedSplit.default)(params.q))[0])) {
|
|
617
|
+
if (queryReplacement && queryReplacement.query === params.q && queryReplacement.start != params.start) {
|
|
788
618
|
// If this is the same query that was made last, but just for a
|
|
789
619
|
// different page, then re-use the replacement query we got last time.
|
|
790
620
|
// Don't wait on the extension to come up with it again (and risk it
|
|
791
621
|
// giving an inconsistent answer between pages).
|
|
792
|
-
|
|
622
|
+
connection._queryReplacement = queryReplacement;
|
|
793
623
|
// Mark the old queryReplacement with this page now so we can tell on
|
|
794
624
|
// a later request whether the page was changed or the list refresh
|
|
795
625
|
// button was hit.
|
|
@@ -800,17 +630,16 @@ export function setupGmailInterceptorOnFrames(
|
|
|
800
630
|
// to after it's replaced in a moment.
|
|
801
631
|
queryReplacement.newQuery.resolve(queryReplacement.query);
|
|
802
632
|
}
|
|
803
|
-
queryReplacement =
|
|
633
|
+
queryReplacement = connection._queryReplacement = {
|
|
804
634
|
term: customSearchTerm,
|
|
805
635
|
query: params.q,
|
|
806
636
|
start: params.start,
|
|
807
|
-
newQuery:
|
|
637
|
+
newQuery: (0, _defer.default)()
|
|
808
638
|
};
|
|
809
|
-
|
|
810
639
|
triggerEvent({
|
|
811
640
|
type: 'searchQueryForReplacement',
|
|
812
641
|
term: customSearchTerm,
|
|
813
|
-
query: params.q
|
|
642
|
+
query: params.q
|
|
814
643
|
});
|
|
815
644
|
}
|
|
816
645
|
return true;
|
|
@@ -818,38 +647,30 @@ export function setupGmailInterceptorOnFrames(
|
|
|
818
647
|
return false;
|
|
819
648
|
},
|
|
820
649
|
requestChanger: function (connection, request) {
|
|
821
|
-
return
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
);
|
|
832
|
-
},
|
|
650
|
+
return connection._queryReplacement.newQuery.promise.then(function (newQuery) {
|
|
651
|
+
let newParams = (0, _clone.default)(connection.params);
|
|
652
|
+
newParams.q = newQuery;
|
|
653
|
+
return {
|
|
654
|
+
method: request.method,
|
|
655
|
+
url: '?' + (0, _querystring.stringify)(newParams),
|
|
656
|
+
body: request.body
|
|
657
|
+
};
|
|
658
|
+
});
|
|
659
|
+
}
|
|
833
660
|
});
|
|
834
661
|
|
|
835
662
|
// newer, sync API based request intercept
|
|
836
663
|
main_wrappers.push({
|
|
837
664
|
isRelevantTo: function (connection) {
|
|
838
|
-
return (
|
|
839
|
-
connection.method === 'POST' &&
|
|
840
|
-
/sync(?:\/u\/\d+)?\/i\/bv/.test(connection.url)
|
|
841
|
-
);
|
|
665
|
+
return connection.method === 'POST' && /sync(?:\/u\/\d+)?\/i\/bv/.test(connection.url);
|
|
842
666
|
},
|
|
843
667
|
requestChanger: function (connection, request) {
|
|
844
668
|
let customSearchTerm;
|
|
845
669
|
const body = JSON.parse(request.body);
|
|
846
|
-
|
|
847
670
|
let newFormat = false;
|
|
848
671
|
let payload, searchString, pageOffset;
|
|
849
|
-
|
|
850
672
|
if (Array.isArray(body)) {
|
|
851
673
|
newFormat = true;
|
|
852
|
-
|
|
853
674
|
payload = body[0];
|
|
854
675
|
searchString = payload[3];
|
|
855
676
|
pageOffset = payload[9];
|
|
@@ -858,26 +679,14 @@ export function setupGmailInterceptorOnFrames(
|
|
|
858
679
|
searchString = payload[4];
|
|
859
680
|
pageOffset = payload[10];
|
|
860
681
|
}
|
|
861
|
-
|
|
862
|
-
const isSyncAPISearchWithCustomTerm =
|
|
863
|
-
payload[newFormat ? 0 : 1] === 79 &&
|
|
864
|
-
typeof searchString === 'string' &&
|
|
865
|
-
(customSearchTerm = intersection(
|
|
866
|
-
customSearchTerms,
|
|
867
|
-
quotedSplit(searchString)
|
|
868
|
-
)[0]);
|
|
682
|
+
const isSyncAPISearchWithCustomTerm = payload[newFormat ? 0 : 1] === 79 && typeof searchString === 'string' && (customSearchTerm = (0, _intersection.default)(customSearchTerms, (0, _quotedSplit.default)(searchString))[0]);
|
|
869
683
|
if (!isSyncAPISearchWithCustomTerm) return Promise.resolve(request);
|
|
870
|
-
|
|
871
|
-
if (
|
|
872
|
-
queryReplacement &&
|
|
873
|
-
queryReplacement.query === searchString &&
|
|
874
|
-
queryReplacement.start != pageOffset
|
|
875
|
-
) {
|
|
684
|
+
if (queryReplacement && queryReplacement.query === searchString && queryReplacement.start != pageOffset) {
|
|
876
685
|
// If this is the same query that was made last, but just for a
|
|
877
686
|
// different page, then re-use the replacement query we got last time.
|
|
878
687
|
// Don't wait on the extension to come up with it again (and risk it
|
|
879
688
|
// giving an inconsistent answer between pages).
|
|
880
|
-
|
|
689
|
+
connection._queryReplacement = queryReplacement;
|
|
881
690
|
// Mark the old queryReplacement with this page now so we can tell on
|
|
882
691
|
// a later request whether the page was changed or the list refresh
|
|
883
692
|
// button was hit.
|
|
@@ -888,38 +697,33 @@ export function setupGmailInterceptorOnFrames(
|
|
|
888
697
|
// to after it's replaced in a moment.
|
|
889
698
|
queryReplacement.newQuery.resolve(queryReplacement.query);
|
|
890
699
|
}
|
|
891
|
-
queryReplacement =
|
|
700
|
+
queryReplacement = connection._queryReplacement = {
|
|
892
701
|
term: customSearchTerm,
|
|
893
702
|
query: searchString,
|
|
894
703
|
start: pageOffset,
|
|
895
|
-
newQuery:
|
|
704
|
+
newQuery: (0, _defer.default)()
|
|
896
705
|
};
|
|
897
|
-
|
|
898
706
|
triggerEvent({
|
|
899
707
|
type: 'searchQueryForReplacement',
|
|
900
708
|
term: customSearchTerm,
|
|
901
|
-
query: searchString
|
|
709
|
+
query: searchString
|
|
902
710
|
});
|
|
903
711
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
} else {
|
|
910
|
-
body[1][4] = newQuery;
|
|
911
|
-
}
|
|
912
|
-
return {
|
|
913
|
-
method: request.method,
|
|
914
|
-
url: request.url,
|
|
915
|
-
body: JSON.stringify(body),
|
|
916
|
-
};
|
|
712
|
+
return connection._queryReplacement.newQuery.promise.then(function (newQuery) {
|
|
713
|
+
if (newFormat) {
|
|
714
|
+
body[0][3] = newQuery;
|
|
715
|
+
} else {
|
|
716
|
+
body[1][4] = newQuery;
|
|
917
717
|
}
|
|
918
|
-
|
|
919
|
-
|
|
718
|
+
return {
|
|
719
|
+
method: request.method,
|
|
720
|
+
url: request.url,
|
|
721
|
+
body: JSON.stringify(body)
|
|
722
|
+
};
|
|
723
|
+
});
|
|
724
|
+
}
|
|
920
725
|
});
|
|
921
726
|
}
|
|
922
|
-
|
|
923
727
|
{
|
|
924
728
|
// Search results replacer.
|
|
925
729
|
// The content script tells us a search query to watch for. Whenever we see
|
|
@@ -928,96 +732,80 @@ export function setupGmailInterceptorOnFrames(
|
|
|
928
732
|
// the content script that contains new results to substitute in.
|
|
929
733
|
const customSearchQueries = [];
|
|
930
734
|
let customListJob;
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
if (
|
|
941
|
-
customListJob.query === event.detail.query &&
|
|
942
|
-
customListJob.start === event.detail.start
|
|
943
|
-
) {
|
|
944
|
-
const { newQuery, newStart } = event.detail;
|
|
945
|
-
|
|
735
|
+
document.addEventListener('inboxSDKcustomListRegisterQuery', event => {
|
|
736
|
+
customSearchQueries.push(event.detail.query);
|
|
737
|
+
});
|
|
738
|
+
document.addEventListener('inboxSDKcustomListNewQuery', event => {
|
|
739
|
+
if (customListJob.query === event.detail.query && customListJob.start === event.detail.start) {
|
|
740
|
+
const {
|
|
741
|
+
newQuery,
|
|
742
|
+
newStart
|
|
743
|
+
} = event.detail;
|
|
946
744
|
customListJob.newRequestParams.resolve({
|
|
947
745
|
query: newQuery,
|
|
948
|
-
start: newStart
|
|
746
|
+
start: newStart
|
|
949
747
|
});
|
|
950
748
|
}
|
|
951
749
|
});
|
|
952
|
-
|
|
953
|
-
document.addEventListener('inboxSDKcustomListResults', (event: any) => {
|
|
750
|
+
document.addEventListener('inboxSDKcustomListResults', event => {
|
|
954
751
|
if (customListJob.query === event.detail.query) {
|
|
955
752
|
customListJob.newResults.resolve(event.detail.newResults);
|
|
956
753
|
}
|
|
957
754
|
});
|
|
958
|
-
|
|
959
755
|
js_frame_wrappers.push({
|
|
960
756
|
isRelevantTo: function (connection) {
|
|
961
757
|
let customSearchQuery;
|
|
962
758
|
const params = connection.params;
|
|
963
|
-
if (
|
|
964
|
-
connection.method === 'POST' &&
|
|
965
|
-
params.search &&
|
|
966
|
-
params.view === 'tl' &&
|
|
967
|
-
connection.url.match(/^\?/) &&
|
|
968
|
-
params.q &&
|
|
969
|
-
!params.act &&
|
|
970
|
-
(customSearchQuery = find(customSearchQueries, (x) => x === params.q))
|
|
971
|
-
) {
|
|
759
|
+
if (connection.method === 'POST' && params.search && params.view === 'tl' && connection.url.match(/^\?/) && params.q && !params.act && (customSearchQuery = (0, _find.default)(customSearchQueries, x => x === params.q))) {
|
|
972
760
|
if (customListJob) {
|
|
973
761
|
// Resolve the old one with something because no one else is going
|
|
974
762
|
// to after it's replaced in a moment.
|
|
975
763
|
customListJob.newRequestParams.resolve({
|
|
976
764
|
query: customListJob.query,
|
|
977
|
-
start: customListJob.start
|
|
765
|
+
start: customListJob.start
|
|
978
766
|
});
|
|
979
767
|
customListJob.newResults.resolve(null);
|
|
980
768
|
}
|
|
981
|
-
customListJob =
|
|
769
|
+
customListJob = connection._customListJob = {
|
|
982
770
|
query: params.q,
|
|
983
771
|
start: +params.start,
|
|
984
|
-
newRequestParams:
|
|
985
|
-
newResults:
|
|
772
|
+
newRequestParams: (0, _defer.default)(),
|
|
773
|
+
newResults: (0, _defer.default)()
|
|
986
774
|
};
|
|
987
775
|
triggerEvent({
|
|
988
776
|
type: 'searchForReplacement',
|
|
989
777
|
query: customListJob.query,
|
|
990
|
-
start: customListJob.start
|
|
778
|
+
start: customListJob.start
|
|
991
779
|
});
|
|
992
780
|
return true;
|
|
993
781
|
}
|
|
994
782
|
return false;
|
|
995
783
|
},
|
|
996
784
|
requestChanger: function (connection, request) {
|
|
997
|
-
return
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
785
|
+
return connection._customListJob.newRequestParams.promise.then(_ref9 => {
|
|
786
|
+
let {
|
|
787
|
+
query,
|
|
788
|
+
start
|
|
789
|
+
} = _ref9;
|
|
790
|
+
const newParams = (0, _clone.default)(connection.params);
|
|
791
|
+
newParams.q = query;
|
|
792
|
+
newParams.start = start;
|
|
793
|
+
return {
|
|
794
|
+
method: request.method,
|
|
795
|
+
url: '?' + (0, _querystring.stringify)(newParams),
|
|
796
|
+
body: request.body
|
|
797
|
+
};
|
|
798
|
+
});
|
|
1009
799
|
},
|
|
1010
800
|
responseTextChanger: function (connection, response) {
|
|
1011
801
|
triggerEvent({
|
|
1012
802
|
type: 'searchResultsResponse',
|
|
1013
|
-
query:
|
|
1014
|
-
start:
|
|
1015
|
-
response
|
|
803
|
+
query: connection._customListJob.query,
|
|
804
|
+
start: connection._customListJob.start,
|
|
805
|
+
response
|
|
1016
806
|
});
|
|
1017
|
-
return
|
|
1018
|
-
|
|
1019
|
-
);
|
|
1020
|
-
},
|
|
807
|
+
return connection._customListJob.newResults.promise.then(newResults => newResults === null ? response : newResults);
|
|
808
|
+
}
|
|
1021
809
|
});
|
|
1022
810
|
|
|
1023
811
|
// Sync API-based custom thread list interception
|
|
@@ -1029,7 +817,7 @@ export function setupGmailInterceptorOnFrames(
|
|
|
1029
817
|
// to after it's replaced in a moment.
|
|
1030
818
|
customListJob.newRequestParams.resolve({
|
|
1031
819
|
query: customListJob.query,
|
|
1032
|
-
start: customListJob.start
|
|
820
|
+
start: customListJob.start
|
|
1033
821
|
});
|
|
1034
822
|
customListJob.newResults.resolve(null);
|
|
1035
823
|
}
|
|
@@ -1040,139 +828,113 @@ export function setupGmailInterceptorOnFrames(
|
|
|
1040
828
|
requestChanger: async function (connection, request) {
|
|
1041
829
|
if (request.body) {
|
|
1042
830
|
const parsedBody = JSON.parse(request.body);
|
|
1043
|
-
|
|
1044
831
|
const newFormat = Array.isArray(parsedBody);
|
|
1045
832
|
|
|
1046
833
|
// we are a search!
|
|
1047
|
-
const searchQuery =
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
: parsedBody && parsedBody[1] && parsedBody[1][4]) || '';
|
|
1051
|
-
|
|
1052
|
-
if (find(customSearchQueries, (x) => x === searchQuery)) {
|
|
1053
|
-
customListJob = (connection: any)._customListJob = {
|
|
834
|
+
const searchQuery = (newFormat ? parsedBody && parsedBody[0] && parsedBody[0][3] : parsedBody && parsedBody[1] && parsedBody[1][4]) || '';
|
|
835
|
+
if ((0, _find.default)(customSearchQueries, x => x === searchQuery)) {
|
|
836
|
+
customListJob = connection._customListJob = {
|
|
1054
837
|
query: searchQuery,
|
|
1055
838
|
start: newFormat ? parsedBody[0][9] : parsedBody[1][10],
|
|
1056
|
-
newRequestParams:
|
|
1057
|
-
newResults:
|
|
839
|
+
newRequestParams: (0, _defer.default)(),
|
|
840
|
+
newResults: (0, _defer.default)()
|
|
1058
841
|
};
|
|
1059
842
|
triggerEvent({
|
|
1060
843
|
type: 'searchForReplacement',
|
|
1061
844
|
query: customListJob.query,
|
|
1062
|
-
start: customListJob.start
|
|
845
|
+
start: customListJob.start
|
|
1063
846
|
});
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
return {
|
|
1076
|
-
method: request.method,
|
|
1077
|
-
url: request.url,
|
|
1078
|
-
body: JSON.stringify(parsedBody),
|
|
1079
|
-
};
|
|
847
|
+
return connection._customListJob.newRequestParams.promise.then(_ref10 => {
|
|
848
|
+
let {
|
|
849
|
+
query,
|
|
850
|
+
start
|
|
851
|
+
} = _ref10;
|
|
852
|
+
if (newFormat) {
|
|
853
|
+
parsedBody[0][3] = query;
|
|
854
|
+
parsedBody[0][9] = start;
|
|
855
|
+
} else {
|
|
856
|
+
parsedBody[1][4] = query;
|
|
857
|
+
parsedBody[1][10] = start;
|
|
1080
858
|
}
|
|
1081
|
-
|
|
859
|
+
return {
|
|
860
|
+
method: request.method,
|
|
861
|
+
url: request.url,
|
|
862
|
+
body: JSON.stringify(parsedBody)
|
|
863
|
+
};
|
|
864
|
+
});
|
|
1082
865
|
}
|
|
1083
866
|
}
|
|
1084
|
-
|
|
1085
867
|
return request;
|
|
1086
868
|
},
|
|
1087
869
|
responseTextChanger: async function (connection, response) {
|
|
1088
|
-
if (
|
|
870
|
+
if (connection._customListJob) {
|
|
1089
871
|
triggerEvent({
|
|
1090
872
|
type: 'searchResultsResponse',
|
|
1091
|
-
query:
|
|
1092
|
-
start:
|
|
1093
|
-
response
|
|
873
|
+
query: connection._customListJob.query,
|
|
874
|
+
start: connection._customListJob.start,
|
|
875
|
+
response
|
|
1094
876
|
});
|
|
1095
|
-
|
|
1096
|
-
return (connection: any)._customListJob.newResults.promise.then(
|
|
1097
|
-
(newResults) => (newResults === null ? response : newResults)
|
|
1098
|
-
);
|
|
877
|
+
return connection._customListJob.newResults.promise.then(newResults => newResults === null ? response : newResults);
|
|
1099
878
|
} else {
|
|
1100
879
|
return response;
|
|
1101
880
|
}
|
|
1102
|
-
}
|
|
881
|
+
}
|
|
1103
882
|
});
|
|
1104
883
|
}
|
|
1105
884
|
|
|
1106
885
|
// sync token savers
|
|
1107
886
|
{
|
|
1108
|
-
const saveBTAIHeader =
|
|
1109
|
-
|
|
1110
|
-
triggerEvent({
|
|
887
|
+
const saveBTAIHeader = header => {
|
|
888
|
+
document.head.setAttribute('data-inboxsdk-btai-header', header);
|
|
889
|
+
triggerEvent({
|
|
890
|
+
type: 'btaiHeaderReceived'
|
|
891
|
+
});
|
|
1111
892
|
};
|
|
1112
893
|
main_wrappers.push({
|
|
1113
894
|
isRelevantTo(connection) {
|
|
1114
|
-
return (
|
|
1115
|
-
/sync(?:\/u\/\d+)?\//.test(connection.url) &&
|
|
1116
|
-
!(document.head: any).hasAttribute('data-inboxsdk-btai-header')
|
|
1117
|
-
);
|
|
895
|
+
return /sync(?:\/u\/\d+)?\//.test(connection.url) && !document.head.hasAttribute('data-inboxsdk-btai-header');
|
|
1118
896
|
},
|
|
1119
897
|
originalSendBodyLogger(connection) {
|
|
1120
898
|
if (connection.headers['X-Gmail-BTAI']) {
|
|
1121
899
|
saveBTAIHeader(connection.headers['X-Gmail-BTAI']);
|
|
1122
900
|
}
|
|
1123
|
-
}
|
|
901
|
+
}
|
|
1124
902
|
});
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
(
|
|
1128
|
-
|
|
903
|
+
const saveXsrfTokenHeader = header => {
|
|
904
|
+
document.head.setAttribute('data-inboxsdk-xsrf-token', header);
|
|
905
|
+
triggerEvent({
|
|
906
|
+
type: 'xsrfTokenHeaderReceived'
|
|
907
|
+
});
|
|
1129
908
|
};
|
|
1130
909
|
main_wrappers.push({
|
|
1131
910
|
isRelevantTo(connection) {
|
|
1132
|
-
return (
|
|
1133
|
-
/sync(?:\/u\/\d+)?\//.test(connection.url) &&
|
|
1134
|
-
!(document.head: any).hasAttribute('data-inboxsdk-xsrf-token')
|
|
1135
|
-
);
|
|
911
|
+
return /sync(?:\/u\/\d+)?\//.test(connection.url) && !document.head.hasAttribute('data-inboxsdk-xsrf-token');
|
|
1136
912
|
},
|
|
1137
913
|
originalSendBodyLogger(connection) {
|
|
1138
914
|
if (connection.headers['X-Framework-Xsrf-Token']) {
|
|
1139
915
|
saveXsrfTokenHeader(connection.headers['X-Framework-Xsrf-Token']);
|
|
1140
916
|
}
|
|
1141
|
-
}
|
|
917
|
+
}
|
|
1142
918
|
});
|
|
1143
919
|
}
|
|
1144
920
|
}
|
|
1145
|
-
|
|
1146
921
|
function triggerEvent(detail) {
|
|
1147
|
-
document.dispatchEvent(
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
})
|
|
1153
|
-
);
|
|
922
|
+
document.dispatchEvent(new CustomEvent('inboxSDKajaxIntercept', {
|
|
923
|
+
bubbles: true,
|
|
924
|
+
cancelable: false,
|
|
925
|
+
detail
|
|
926
|
+
}));
|
|
1154
927
|
}
|
|
1155
|
-
|
|
1156
928
|
function stringifyComposeParams(inComposeParams) {
|
|
1157
|
-
const composeParams =
|
|
1158
|
-
const string = `=${stringifyComposeRecipientParam(
|
|
1159
|
-
composeParams.to,
|
|
1160
|
-
'to'
|
|
1161
|
-
)}&=${stringifyComposeRecipientParam(
|
|
1162
|
-
composeParams.cc,
|
|
1163
|
-
'cc'
|
|
1164
|
-
)}&=${stringifyComposeRecipientParam(composeParams.bcc, 'bcc')}`;
|
|
1165
|
-
|
|
929
|
+
const composeParams = (0, _clone.default)(inComposeParams);
|
|
930
|
+
const string = `=${stringifyComposeRecipientParam(composeParams.to, 'to')}&=${stringifyComposeRecipientParam(composeParams.cc, 'cc')}&=${stringifyComposeRecipientParam(composeParams.bcc, 'bcc')}`;
|
|
1166
931
|
delete composeParams.to;
|
|
1167
932
|
delete composeParams.bcc;
|
|
1168
933
|
delete composeParams.cc;
|
|
1169
|
-
|
|
1170
|
-
return string + '&' + querystring.stringify(composeParams);
|
|
934
|
+
return string + '&' + _querystring.default.stringify(composeParams);
|
|
1171
935
|
}
|
|
1172
|
-
|
|
1173
936
|
function stringifyComposeRecipientParam(value, paramType) {
|
|
1174
937
|
let string = '';
|
|
1175
|
-
|
|
1176
938
|
if (Array.isArray(value)) {
|
|
1177
939
|
for (let ii = 0; ii < value.length; ii++) {
|
|
1178
940
|
string += `&${paramType}=${encodeURIComponent(value[ii])}`;
|
|
@@ -1180,6 +942,5 @@ function stringifyComposeRecipientParam(value, paramType) {
|
|
|
1180
942
|
} else {
|
|
1181
943
|
string += `&${paramType}=${encodeURIComponent(value)}`;
|
|
1182
944
|
}
|
|
1183
|
-
|
|
1184
945
|
return string;
|
|
1185
|
-
}
|
|
946
|
+
}
|