Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3248821
D12489.id41525.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12489.id41525.diff
View Options
diff --git a/keyserver/src/updaters/thread-permission-updaters.js b/keyserver/src/updaters/thread-permission-updaters.js
--- a/keyserver/src/updaters/thread-permission-updaters.js
+++ b/keyserver/src/updaters/thread-permission-updaters.js
@@ -20,8 +20,8 @@
} from 'lib/types/thread-permission-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import {
- type ThreadType,
- assertThreadType,
+ type ThinThreadType,
+ assertThinThreadType,
} from 'lib/types/thread-types-enum.js';
import { updateTypes } from 'lib/types/update-types-enum.js';
import {
@@ -343,7 +343,7 @@
type RoleThreadResult = {
+roleColumnValue: string,
+depth: number,
- +threadType: ThreadType,
+ +threadType: ThinThreadType,
+parentThreadID: ?string,
+hasContainingThreadID: boolean,
+rolePermissions: ?ThreadRolePermissionsBlob,
@@ -366,7 +366,7 @@
return {
roleColumnValue: role.toString(),
depth: row.depth,
- threadType: assertThreadType(row.type),
+ threadType: assertThinThreadType(row.type),
parentThreadID: row.parent_thread_id
? row.parent_thread_id.toString()
: null,
@@ -389,7 +389,7 @@
return {
roleColumnValue: role,
depth: row.depth,
- threadType: assertThreadType(row.type),
+ threadType: assertThinThreadType(row.type),
parentThreadID: row.parent_thread_id
? row.parent_thread_id.toString()
: null,
@@ -413,7 +413,7 @@
return {
roleColumnValue: row.id.toString(),
depth: row.depth,
- threadType: assertThreadType(row.type),
+ threadType: assertThinThreadType(row.type),
parentThreadID: row.parent_thread_id
? row.parent_thread_id.toString()
: null,
@@ -591,7 +591,7 @@
+threadID: string,
+parentThreadID: string,
+containingThreadID: string,
- +threadType: ThreadType,
+ +threadType: ThinThreadType,
+depth: number,
+users: Map<string, DescendantUserInfo>,
};
@@ -645,7 +645,7 @@
threadID: descendantThreadID,
parentThreadID: row.parent_thread_id.toString(),
containingThreadID: row.containing_thread_id.toString(),
- threadType: assertThreadType(row.type),
+ threadType: assertThinThreadType(row.type),
depth: row.depth,
users: new Map(),
});
@@ -776,7 +776,7 @@
throw new ServerError('internal_error');
}
const [threadResult] = threadResults;
- const threadType = assertThreadType(threadResult.type);
+ const threadType = assertThinThreadType(threadResult.type);
const depth = threadResult.depth;
const hasContainingThreadID = threadResult.containing_thread_id !== null;
const parentThreadID = threadResult.parent_thread_id?.toString();
@@ -1376,7 +1376,7 @@
const allThreads = result.map(row => {
return {
id: row.id.toString(),
- type: assertThreadType(row.type),
+ type: assertThinThreadType(row.type),
depth: row.depth,
};
});
diff --git a/lib/types/thread-types-enum.js b/lib/types/thread-types-enum.js
--- a/lib/types/thread-types-enum.js
+++ b/lib/types/thread-types-enum.js
@@ -60,7 +60,7 @@
...thickThreadTypes,
});
-export function assertThreadType(threadType: number): ThreadType {
+export function assertThinThreadType(threadType: number): ThinThreadType {
invariant(
threadType === 3 ||
threadType === 4 ||
@@ -72,10 +72,43 @@
threadType === 10 ||
threadType === 11 ||
threadType === 12,
+ 'number is not ThinThreadType enum',
+ );
+ return threadType;
+}
+
+export function assertThickThreadType(threadType: number): ThickThreadType {
+ invariant(
+ threadType === 13 ||
+ threadType === 14 ||
+ threadType === 15 ||
+ threadType === 16,
+ 'number is not ThickThreadType enum',
+ );
+ return threadType;
+}
+
+export function assertThreadType(threadType: number): ThreadType {
+ invariant(
+ threadType === 3 ||
+ threadType === 4 ||
+ threadType === 5 ||
+ threadType === 6 ||
+ threadType === 7 ||
+ threadType === 8 ||
+ threadType === 9 ||
+ threadType === 10 ||
+ threadType === 11 ||
+ threadType === 12 ||
+ threadType === 13 ||
+ threadType === 14 ||
+ threadType === 15 ||
+ threadType === 16,
'number is not ThreadType enum',
);
return threadType;
}
+
export const threadTypeValidator: TRefinement<number> = tNumEnum(
values(threadTypes),
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 10:50 AM (5 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2497567
Default Alt Text
D12489.id41525.diff (4 KB)
Attached To
Mode
D12489: [keyserver][lib] Update thread type assertion functions for thick/thread distinction
Attached
Detach File
Event Timeline
Log In to Comment