Page MenuHomePhabricator

D9840.diff
No OneTemporary

D9840.diff

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

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)

Event Timeline