Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3536516
D10314.id34584.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.id34584.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
Thu, Dec 26, 6:38 PM (11 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2707980
Default Alt Text
D10314.id34584.diff (1 KB)
Attached To
Mode
D10314: [lib] Update `convertClientDBThreadInfoToRawThreadInfo` to validate `ThreadCurrentUserInfo`
Attached
Detach File
Event Timeline
Log In to Comment