Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3356836
D12437.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D12437.diff
View Options
diff --git a/lib/shared/invite-links.js b/lib/shared/invite-links.js
--- a/lib/shared/invite-links.js
+++ b/lib/shared/invite-links.js
@@ -1,7 +1,9 @@
// @flow
+import type { AuthMetadata } from './identity-client-context.js';
import blobService from '../facts/blob-service.js';
import { getBlobFetchableURL } from '../utils/blob-service.js';
+import { createDefaultHTTPRequestHeaders } from '../utils/services-utils.js';
function inviteLinkBlobHash(secret: string): string {
return `invite_${secret}`;
@@ -14,10 +16,15 @@
async function getKeyserverOverrideForAnInviteLink(
secret: string,
+ authMetadata?: AuthMetadata,
): Promise<?KeyserverOverride> {
const blobURL = getBlobFetchableURL(inviteLinkBlobHash(secret));
+ const headers = authMetadata
+ ? createDefaultHTTPRequestHeaders(authMetadata)
+ : {};
const result = await fetch(blobURL, {
method: blobService.httpEndpoints.GET_BLOB.method,
+ headers,
});
if (result.status !== 200) {
return null;
diff --git a/native/navigation/deep-links-context-provider.react.js b/native/navigation/deep-links-context-provider.react.js
--- a/native/navigation/deep-links-context-provider.react.js
+++ b/native/navigation/deep-links-context-provider.react.js
@@ -2,6 +2,7 @@
import { useNavigation } from '@react-navigation/native';
import * as Application from 'expo-application';
+import invariant from 'invariant';
import * as React from 'react';
import { Linking, Platform } from 'react-native';
@@ -15,10 +16,12 @@
type ParsedDeepLinkData,
} from 'lib/facts/links.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
+import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import { getKeyserverOverrideForAnInviteLink } from 'lib/shared/invite-links.js';
import type { KeyserverOverride } from 'lib/shared/invite-links.js';
import type { SetState } from 'lib/types/hook-types.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import {
InviteLinkModalRouteName,
@@ -85,6 +88,10 @@
React.useState<?KeyserverOverride>(undefined);
const inviteLinkSecret = React.useRef<?string>(null);
+ const identityContext = React.useContext(IdentityClientContext);
+ invariant(identityContext, 'Identity context should be set');
+ const { getAuthMetadata } = identityContext;
+
const loggedIn = useSelector(isLoggedIn);
const dispatchActionPromise = useDispatchActionPromise();
const validateLink = useVerifyInviteLink(keyserverOverride);
@@ -106,11 +113,16 @@
}
if (parsedData.type === 'invite-link') {
+ let authMetadata;
+ if (usingCommServicesAccessToken) {
+ authMetadata = await getAuthMetadata();
+ }
+
const { secret } = parsedData.data;
inviteLinkSecret.current = secret;
try {
const newKeyserverOverride =
- await getKeyserverOverrideForAnInviteLink(secret);
+ await getKeyserverOverrideForAnInviteLink(secret, authMetadata);
setKeyserverOverride(newKeyserverOverride);
} catch (e) {
console.log('Error while downloading an invite link blob', e);
@@ -128,7 +140,7 @@
navigation.navigate(SecondaryDeviceQRCodeScannerRouteName);
}
})();
- }, [currentLink, loggedIn, navigation]);
+ }, [currentLink, getAuthMetadata, loggedIn, navigation]);
React.useEffect(() => {
const secret = inviteLinkSecret.current;
diff --git a/web/invite-links/invite-link-handler.react.js b/web/invite-links/invite-link-handler.react.js
--- a/web/invite-links/invite-link-handler.react.js
+++ b/web/invite-links/invite-link-handler.react.js
@@ -1,5 +1,6 @@
// @flow
+import invariant from 'invariant';
import * as React from 'react';
import {
@@ -9,12 +10,14 @@
import { useModalContext } from 'lib/components/modal-provider.react.js';
import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
+import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import {
getKeyserverOverrideForAnInviteLink,
type KeyserverOverride,
} from 'lib/shared/invite-links.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import AcceptInviteModal from './accept-invite-modal.react.js';
import { updateNavInfoActionType } from '../redux/action-types.js';
@@ -27,6 +30,10 @@
React.useState<?KeyserverOverride>(undefined);
const loggedIn = useSelector(isLoggedIn);
+ const identityContext = React.useContext(IdentityClientContext);
+ invariant(identityContext, 'Identity context should be set');
+ const { getAuthMetadata } = identityContext;
+
const dispatchActionPromise = useDispatchActionPromise();
const dispatch = useDispatch();
const { pushModal } = useModalContext();
@@ -42,9 +49,16 @@
setKeyserverOverride(undefined);
inviteLinkSecret.current = inviteSecret;
+ let authMetadata;
+ if (usingCommServicesAccessToken) {
+ authMetadata = await getAuthMetadata();
+ }
+
try {
- const newKeyserverOverride =
- await getKeyserverOverrideForAnInviteLink(inviteSecret);
+ const newKeyserverOverride = await getKeyserverOverrideForAnInviteLink(
+ inviteSecret,
+ authMetadata,
+ );
setKeyserverOverride(newKeyserverOverride);
} catch (e) {
console.error('Error while downloading an invite link blob', e);
@@ -58,7 +72,7 @@
);
}
})();
- }, [dispatch, inviteSecret, loggedIn, pushModal]);
+ }, [dispatch, getAuthMetadata, inviteSecret, loggedIn, pushModal]);
const validateLink = useVerifyInviteLink(keyserverOverride);
const threadInfos = useSelector(threadInfoSelector);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 9:00 PM (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577304
Default Alt Text
D12437.diff (5 KB)
Attached To
Mode
D12437: [lib][web][native] Send CSAT in getKeyserverOverrideForAnInviteLink
Attached
Detach File
Event Timeline
Log In to Comment