Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3246378
D9810.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9810.diff
View Options
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -26,6 +26,7 @@
import ashoat from '../facts/ashoat.js';
import genesis from '../facts/genesis.js';
import { useLoggedInUserInfo } from '../hooks/account-hooks.js';
+import { hasPermission } from '../permissions/minimally-encoded-thread-permissions.js';
import {
permissionLookup,
getAllThreadPermissions,
@@ -52,6 +53,7 @@
type RobotextMessageInfo,
type ComposableMessageInfo,
} from '../types/message-types.js';
+import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
import { userRelationshipStatus } from '../types/relationship-types.js';
import {
threadPermissionPropagationPrefixes,
@@ -108,7 +110,7 @@
import { pendingThreadIDRegex } from '../utils/validation-utils.js';
function threadHasPermission(
- threadInfo: ?(ThreadInfo | RawThreadInfo),
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
permission: ThreadPermission,
): boolean {
if (!threadInfo) {
@@ -119,7 +121,9 @@
`${permission} can be disabled by a block, but threadHasPermission can't ` +
'check for a block on RawThreadInfo. Please pass in ThreadInfo instead!',
);
- if (!threadInfo.currentUser.permissions[permission]) {
+ if (threadInfo.minimallyEncoded) {
+ return hasPermission(threadInfo.currentUser.permissions, permission);
+ } else if (!threadInfo.currentUser.permissions[permission]) {
return false;
}
return threadInfo.currentUser.permissions[permission].value;
@@ -1276,12 +1280,12 @@
messageCreatorRelationship &&
relationshipBlockedInEitherDirection(messageCreatorRelationship);
- const hasPermission = threadHasPermission(
+ const hasCreateSidebarsPermission = threadHasPermission(
threadInfo,
threadPermissions.CREATE_SIDEBARS,
);
- return hasPermission && !creatorRelationshipHasBlock;
+ return hasCreateSidebarsPermission && !creatorRelationshipHasBlock;
}
function useSidebarExistsOrCanBeCreated(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 11:21 PM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2495756
Default Alt Text
D9810.diff (2 KB)
Attached To
Mode
D9810: [lib] Update `threadHasPermission` to support `MinimallyEncodedRawThreadInfo`
Attached
Detach File
Event Timeline
Log In to Comment