Page MenuHomePhabricator

D12489.id41726.diff
No OneTemporary

D12489.id41726.diff

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
@@ -59,7 +59,7 @@
...thickThreadTypes,
});
-export function assertThreadType(threadType: number): ThreadType {
+export function assertThinThreadType(threadType: number): ThinThreadType {
invariant(
threadType === 3 ||
threadType === 4 ||
@@ -71,10 +71,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

Mime Type
text/plain
Expires
Sun, Sep 29, 9:19 AM (22 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2199891
Default Alt Text
D12489.id41726.diff (4 KB)

Event Timeline