Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32392436
D9825.1765336482.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D9825.1765336482.diff
View Options
diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js
--- a/keyserver/src/database/migration-config.js
+++ b/keyserver/src/database/migration-config.js
@@ -5,11 +5,13 @@
import bots from 'lib/facts/bots.js';
import genesis from 'lib/facts/genesis.js';
import { policyTypes } from 'lib/facts/policies.js';
+import { getRolePermissionBlobs } from 'lib/permissions/thread-permissions.js';
import { messageTypes } from 'lib/types/message-types-enum.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import { threadTypes } from 'lib/types/thread-types-enum.js';
import { permissionsToRemoveInMigration } from 'lib/utils/migration-utils.js';
+import createIDs from '../creators/id-creator.js';
import { dbQuery, SQL } from '../database/database.js';
import { processMessagesInDBForSearch } from '../database/search-utils.js';
import { deleteThread } from '../deleters/thread-deleters.js';
@@ -663,6 +665,48 @@
await dbQuery(updateQuery);
},
],
+ [
+ 52,
+ async () => {
+ const rolePermissions = getRolePermissionBlobs(
+ threadTypes.COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD,
+ );
+ const voicedPermissions = rolePermissions.Voiced;
+ const voicedRoleName = 'Voiced';
+ const permissionsBlob = JSON.stringify(voicedPermissions);
+
+ if (!voicedPermissions) {
+ return;
+ }
+
+ const [result] = await dbQuery(SQL`
+ SELECT id FROM threads
+ WHERE type = ${threadTypes.COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD}
+ OR type = ${threadTypes.COMMUNITY_SECRET_ANNOUNCEMENT_SUBTHREAD}
+ `);
+
+ const threads = result.map(row => row.id.toString());
+
+ const ids = await createIDs('roles', threads.length);
+
+ while (threads.length > 0) {
+ const batch = threads.splice(0, 10);
+ const newRows = [];
+ for (const threadID of batch) {
+ const id = ids.shift();
+ const time = Date.now();
+
+ newRows.push([id, threadID, voicedRoleName, permissionsBlob, time]);
+ }
+
+ const query = SQL`
+ INSERT INTO roles (id, thread, name, permissions, creation_time)
+ VALUES ${newRows}
+ `;
+ await dbQuery(query);
+ }
+ },
+ ],
]);
const newDatabaseVersion: number = Math.max(...migrations.keys());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 10, 3:14 AM (11 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5859987
Default Alt Text
D9825.1765336482.diff (2 KB)
Attached To
Mode
D9825: [keyserver] Migration to add Voiced role to announcement subchannels
Attached
Detach File
Event Timeline
Log In to Comment