Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3157649
D10314.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10314.diff
View Options
diff --git a/lib/utils/thread-ops-utils.js b/lib/utils/thread-ops-utils.js
--- a/lib/utils/thread-ops-utils.js
+++ b/lib/utils/thread-ops-utils.js
@@ -5,6 +5,7 @@
import {
minimallyEncodedMemberInfoValidator,
minimallyEncodedRoleInfoValidator,
+ minimallyEncodedThreadCurrentUserInfoValidator,
} from '../permissions/minimally-encoded-thread-permissions-validators.js';
import type {
MinimallyEncodedMemberInfo,
@@ -15,6 +16,7 @@
decodeMinimallyEncodedRawThreadInfo,
minimallyEncodeMemberInfo,
minimallyEncodeRoleInfo,
+ minimallyEncodeThreadCurrentUserInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
import { assertThreadType } from '../types/thread-types-enum.js';
import {
@@ -23,6 +25,7 @@
type LegacyRawThreadInfo,
legacyRoleInfoValidator,
type RawThreadInfo,
+ threadCurrentUserInfoValidator,
} from '../types/thread-types.js';
function convertRawThreadInfoToClientDBThreadInfo(
@@ -75,6 +78,17 @@
{},
);
+ // 3. Validate and potentially minimally encode `rawCurrentUser`.
+ const rawCurrentUser = JSON.parse(clientDBThreadInfo.currentUser);
+ invariant(
+ minimallyEncodedThreadCurrentUserInfoValidator.is(rawCurrentUser) ||
+ threadCurrentUserInfoValidator.is(rawCurrentUser),
+ 'rawCurrentUser must be valid [MinimallyEncoded]ThreadCurrentUserInfo',
+ );
+ const minimallyEncodedCurrentUser = rawCurrentUser.minimallyEncoded
+ ? rawCurrentUser
+ : minimallyEncodeThreadCurrentUserInfo(rawCurrentUser);
+
let rawThreadInfo: MinimallyEncodedRawThreadInfo = {
minimallyEncoded: true,
id: clientDBThreadInfo.id,
@@ -88,7 +102,7 @@
community: clientDBThreadInfo.community,
members: minimallyEncodedMembers,
roles: minimallyEncodedRoles,
- currentUser: JSON.parse(clientDBThreadInfo.currentUser),
+ currentUser: minimallyEncodedCurrentUser,
repliesCount: clientDBThreadInfo.repliesCount,
pinnedCount: clientDBThreadInfo.pinnedCount,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 6, 8:47 PM (19 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2432206
Default Alt Text
D10314.diff (1 KB)
Attached To
Mode
D10314: [lib] Update `convertClientDBThreadInfoToRawThreadInfo` to validate `ThreadCurrentUserInfo`
Attached
Detach File
Event Timeline
Log In to Comment