Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2843589
D13256.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13256.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
@@ -394,9 +394,15 @@
memberIDs: $ReadOnlyArray<string>,
sourceMessageID: ?string,
): string {
- const pendingThreadKey = sourceMessageID
- ? `sidebar/${sourceMessageID}`
- : [...memberIDs].sort().join('+');
+ let pendingThreadKey;
+ if (sourceMessageID && threadTypeIsThick(threadType)) {
+ pendingThreadKey = `thick_sidebar/${sourceMessageID}`;
+ } else if (sourceMessageID) {
+ pendingThreadKey = `sidebar/${sourceMessageID}`;
+ } else {
+ pendingThreadKey = [...memberIDs].sort().join('+');
+ }
+
const pendingThreadTypeString = sourceMessageID ? '' : `type${threadType}/`;
return `pending/${pendingThreadTypeString}${pendingThreadKey}`;
}
@@ -415,13 +421,21 @@
if (!pendingThreadIDMatches) {
return null;
}
+
const [threadTypeString, threadKey] = pendingThreadIDMatches[1].split('/');
- const threadType =
- threadTypeString === 'sidebar'
- ? threadTypes.SIDEBAR
- : assertThreadType(Number(threadTypeString.replace('type', '')));
- const memberIDs = threadTypeString === 'sidebar' ? [] : threadKey.split('+');
- const sourceMessageID = threadTypeString === 'sidebar' ? threadKey : null;
+ let threadType;
+ if (threadTypeString === 'thick_sidebar') {
+ threadType = threadTypes.THICK_SIDEBAR;
+ } else if (threadTypeString === 'sidebar') {
+ threadType = threadTypes.SIDEBAR;
+ } else {
+ threadType = assertThreadType(Number(threadTypeString.replace('type', '')));
+ }
+
+ const threadTypeStringIsSidebar =
+ threadTypeString === 'sidebar' || threadTypeString === 'thick_sidebar';
+ const memberIDs = threadTypeStringIsSidebar ? [] : threadKey.split('+');
+ const sourceMessageID = threadTypeStringIsSidebar ? threadKey : null;
return {
threadType,
memberIDs,
diff --git a/lib/shared/thread-utils.test.js b/lib/shared/thread-utils.test.js
--- a/lib/shared/thread-utils.test.js
+++ b/lib/shared/thread-utils.test.js
@@ -3,6 +3,7 @@
import {
parsePendingThreadID,
threadInfoFromRawThreadInfo,
+ getPendingThreadID,
} from './thread-utils.js';
import { threadInfoValidator } from '../permissions/minimally-encoded-thread-permissions-validators.js';
import type { RawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
@@ -30,6 +31,15 @@
);
});
+ const thickSidebarResult = {
+ threadType: threadTypes.THICK_SIDEBAR,
+ memberIDs: [],
+ sourceMessageID: '12345',
+ };
+ expect(parsePendingThreadID('pending/thick_sidebar/12345')).toStrictEqual(
+ thickSidebarResult,
+ );
+
it('should return correct data for real pending sidebar ID', () => {
const pendingPersonalResult = {
threadType: threadTypes.GENESIS_PERSONAL,
@@ -195,3 +205,11 @@
expect(threadInfoValidator.is(threadInfo)).toBe(true);
});
});
+
+describe('getPendingThreadID', () => {
+ it('should return correct ID from thick sidebar input', () => {
+ expect(
+ getPendingThreadID(threadTypes.THICK_SIDEBAR, [], '12345'),
+ ).toStrictEqual('pending/thick_sidebar/12345');
+ });
+});
diff --git a/lib/utils/validation-utils.js b/lib/utils/validation-utils.js
--- a/lib/utils/validation-utils.js
+++ b/lib/utils/validation-utils.js
@@ -112,7 +112,7 @@
'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
const idSchemaRegex = `(?:(?:[0-9]+|${uuidRegex})\\|)?(?:[0-9]+|${uuidRegex})`;
-const pendingThreadIDRegex = `pending/(type[0-9]+/[0-9]+(\\+[0-9]+)*|sidebar/${idSchemaRegex})`;
+const pendingThreadIDRegex = `pending/(type[0-9]+/[0-9]+(\\+[0-9]+)*|(sidebar|thick_sidebar)/${idSchemaRegex})`;
const thickThreadIDRegex: RegExp = new RegExp(`^${uuidRegex}$`);
const chatNameMaxLength = 191;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 30, 5:37 PM (20 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2206111
Default Alt Text
D13256.diff (3 KB)
Attached To
Mode
D13256: Extend pending thread IDs to support thick sidebars
Attached
Detach File
Event Timeline
Log In to Comment