Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3245939
D9840.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
D9840.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,7 +26,11 @@
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 {
+ hasPermission,
+ permissionsToBitmaskHex,
+ threadPermissionsFromBitmaskHex,
+} from '../permissions/minimally-encoded-thread-permissions.js';
import {
permissionLookup,
getAllThreadPermissions,
@@ -57,6 +61,7 @@
MinimallyEncodedMemberInfo,
MinimallyEncodedRawThreadInfo,
MinimallyEncodedRoleInfo,
+ MinimallyEncodedThreadCurrentUserInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
import { userRelationshipStatus } from '../types/relationship-types.js';
import {
@@ -942,6 +947,28 @@
};
}
+function getMinimallyEncodedCurrentUser(
+ threadInfo: MinimallyEncodedRawThreadInfo,
+ viewerID: ?string,
+ userInfos: UserInfos,
+): MinimallyEncodedThreadCurrentUserInfo {
+ if (!threadFrozenDueToBlock(threadInfo, viewerID, userInfos)) {
+ return threadInfo.currentUser;
+ }
+ const decodedPermissions = threadPermissionsFromBitmaskHex(
+ threadInfo.currentUser.permissions,
+ );
+ const updatedPermissions = {
+ ...decodedPermissions,
+ ...disabledPermissions,
+ };
+ const encodedUpdatedPermissions = permissionsToBitmaskHex(updatedPermissions);
+ return {
+ ...threadInfo.currentUser,
+ permissions: encodedUpdatedPermissions,
+ };
+}
+
function threadIsWithBlockedUserOnly(
threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedRawThreadInfo,
viewerID: ?string,
@@ -1767,6 +1794,7 @@
pendingThreadType,
createRealThreadFromPendingThread,
getCurrentUser,
+ getMinimallyEncodedCurrentUser,
threadFrozenDueToBlock,
threadFrozenDueToViewerBlock,
rawThreadInfoFromServerThreadInfo,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 8:44 PM (19 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2488741
Default Alt Text
D9840.diff (1 KB)
Attached To
Mode
D9840: [lib] Introduce `getMinimallyEncodedCurrentUser`
Attached
Detach File
Event Timeline
Log In to Comment