diff --git a/src/upgrades/4.0.0/announces_zset.js b/src/upgrades/4.0.0/announces_zset.js deleted file mode 100644 index 8330cc6dbd..0000000000 --- a/src/upgrades/4.0.0/announces_zset.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -const db = require('../../database'); -const batch = require('../../batch'); -const topics = require('../../topics'); - -module.exports = { - name: 'Save ActivityPub Announces in their own per-post sorted set', - timestamp: Date.UTC(2024, 4, 1), - method: async function () { - const { progress } = this; - const bulkOp = []; - - await batch.processSortedSet('topics:tid', async (tids) => { - await Promise.all(tids.map(async (tid) => { - const announces = await topics.events.find(tid, { - type: 'announce', - }); - - if (announces.length) { - await Promise.all(announces.map(async (eid) => { - const event = await db.getObject(`topicEvent:${eid}`); - if (['uid', 'pid', 'timestamp'].every(prop => event.hasOwnProperty(prop))) { - bulkOp.push([`pid:${event.pid}:announces`, event.timestamp, event.uid]); - } - })); - - await topics.events.purge(tid, announces); - } - })); - - progress.incr(tids.length); - }, { progress }); - - await db.sortedSetAddBulk(bulkOp); - }, -}; diff --git a/src/upgrades/4.0.0/fix_global_user_and_post_counts.js b/src/upgrades/4.0.0/fix_global_user_and_post_counts.js deleted file mode 100644 index f8facf9ae6..0000000000 --- a/src/upgrades/4.0.0/fix_global_user_and_post_counts.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -const db = require('../../database'); -const meta = require('../../meta'); - -module.exports = { - name: 'Fix global counts for users and posts due to faulty AP logic', - timestamp: Date.UTC(2024, 5, 25), - method: async () => { - if (!meta.config.activitypubEnabled) { - return; - } - - const counts = await db.sortedSetsCard(['users:joindate', 'posts:pid', 'topics:tid']); - await db.setObject('global', { - userCount: counts[0], - postCount: counts[1], - topicCount: counts[2], - }); - }, -}; diff --git a/src/upgrades/4.0.0/fix_topic_zsets_for_uncategorized.js b/src/upgrades/4.0.0/fix_topic_zsets_for_uncategorized.js deleted file mode 100644 index 4103cd81e1..0000000000 --- a/src/upgrades/4.0.0/fix_topic_zsets_for_uncategorized.js +++ /dev/null @@ -1,36 +0,0 @@ -// REMOVE THIS PRIOR TO 4.0 ALPHA - -'use strict'; - -const db = require('../../database'); - -module.exports = { - name: 'Fix topic sorted sets for uncategorized topics', - timestamp: Date.UTC(2024, 2, 26), - method: async function () { - const props = ['views', 'posts', 'votes']; - const { progress } = this; - const tids = await db.getSortedSetMembers('cid:-1:tids'); - progress.total = tids.length; - - const remove = []; - const add = []; - await Promise.all(props.map(async (prop) => { - const set = `topics:${prop}`; - const newSet = `topicsRemote:${prop}`; - - const scores = await db.sortedSetScores(set, tids); - scores.forEach((score, idx) => { - if (score !== null) { - remove.push([set, tids[idx]]); - add.push([newSet, score, tids[idx]]); - } - }); - })); - - await Promise.all([ - db.sortedSetRemoveBulk(remove), - db.sortedSetAddBulk(add), - ]); - }, -}; diff --git a/src/upgrades/4.0.0/follow_backreferences.js b/src/upgrades/4.0.0/follow_backreferences.js deleted file mode 100644 index bec02a7ee5..0000000000 --- a/src/upgrades/4.0.0/follow_backreferences.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -const db = require('../../database'); -const batch = require('../../batch'); -const activitypub = require('../../activitypub'); - -module.exports = { - name: 'Establish follow backreference sorted sets for remote users', - timestamp: Date.UTC(2024, 6, 19), - method: async function () { - const { progress } = this; - const bulkOp = []; - const now = Date.now(); - const reassert = []; - - await batch.processSortedSet('users:joindate', async (uids) => { - const [_followers, _following] = await Promise.all([ - db.getSortedSetsMembers(uids.map(uid => `followersRemote:${uid}`)), - db.getSortedSetsMembers(uids.map(uid => `followingRemote:${uid}`)), - ]); - - const toCheck = Array.from(new Set(_followers.flat().concat(_following.flat()))); - const asserted = await db.isSortedSetMembers('usersRemote:lastCrawled', toCheck); - reassert.push(...toCheck.filter((actor, idx) => !asserted[idx])); - - uids.forEach((uid, idx) => { - const followers = _followers[idx]; - if (followers.length) { - bulkOp.push(...followers.map(actor => [`followingRemote:${actor}`, now, uid])); - } - }); - - progress.incr(uids.length); - }, { progress }); - - await Promise.all([ - db.sortedSetAddBulk(bulkOp), - activitypub.actors.assert(Array.from(new Set(reassert))), - ]); - }, -}; diff --git a/src/upgrades/4.0.0/prune_user_inboxes.js b/src/upgrades/4.0.0/prune_user_inboxes.js deleted file mode 100644 index 7ea27d322e..0000000000 --- a/src/upgrades/4.0.0/prune_user_inboxes.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -const db = require('../../database'); -const batch = require('../../batch'); -const topics = require('../../topics'); - -module.exports = { - name: 'Prune deleted topics out of user inboxes', - timestamp: Date.UTC(2024, 6, 12), - method: async function () { - const { progress } = this; - - await batch.processSortedSet('users:joindate', async (uids) => { - const exists = await db.exists(uids.map(uid => `uid:${uid}:inbox`)); - const count = uids.length; - uids = uids.filter((uid, idx) => exists[idx]); - - await Promise.all(uids.map(async (uid) => { - const key = `uid:${uid}:inbox`; - const tids = await db.getSortedSetMembers(key); - const exists = await topics.exists(tids); - const toRemove = tids.filter((tid, idx) => !exists[idx]); - await db.sortedSetRemove(key, toRemove); - })); - - progress.incr(count); - }, { progress }); - }, -}; diff --git a/src/upgrades/4.0.0/remote_user_urls.js b/src/upgrades/4.0.0/remote_user_urls.js deleted file mode 100644 index 2b5ee8088a..0000000000 --- a/src/upgrades/4.0.0/remote_user_urls.js +++ /dev/null @@ -1,35 +0,0 @@ -// REMOVE THIS PRIOR TO 4.0 ALPHA - -'use strict'; - -const db = require('../../database'); -const activitypub = require('../../activitypub'); - -module.exports = { - name: 'Re-assert all existing actors to save URL into hash', - timestamp: Date.UTC(2024, 3, 4), - method: async function () { - const batch = require('../../batch'); - const { progress } = this; - const interval = 1500; - - let actorIds = await db.getSortedSetMembers('usersRemote:lastCrawled'); - progress.total = actorIds.length; - const existing = await db.getObjectValues('remoteUrl:uid'); - const exists = actorIds.map(actorId => existing.includes(actorId)); - actorIds = actorIds.filter((_, idx) => !exists[idx]); - - // Increment ones that were already completed - progress.incr(progress.total - actorIds.length); - - await batch.processArray(actorIds, async (ids) => { - try { - await activitypub.actors.assert(ids, { update: true }); - } catch (e) { - // noop - } - - progress.incr(ids.length); - }, { progress, interval }); - }, -}; diff --git a/src/upgrades/4.0.0/searchable_remote_users.js b/src/upgrades/4.0.0/searchable_remote_users.js deleted file mode 100644 index 7cc9abbfb8..0000000000 --- a/src/upgrades/4.0.0/searchable_remote_users.js +++ /dev/null @@ -1,30 +0,0 @@ -// REMOVE THIS PRIOR TO 4.0 ALPHA - -'use strict'; - -const db = require('../../database'); - -module.exports = { - name: 'Allow remote user profiles to be searched', - // remember, month is zero-indexed (so January is 0, December is 11) - timestamp: Date.UTC(2024, 2, 1), - method: async () => { - const ids = await db.getSortedSetMembers('usersRemote:lastCrawled'); - const data = await db.getObjectsFields(ids.map(id => `userRemote:${id}`), ['username', 'fullname']); - - const queries = data.reduce((memo, profile, idx) => { - if (profile && profile.username && profile.fullname) { - memo.zset.push(['ap.preferredUsername:sorted', 0, `${profile.username.toLowerCase()}:${ids[idx]}`]); - memo.zset.push(['ap.name:sorted', 0, `${profile.fullname.toLowerCase()}:${ids[idx]}`]); - memo.hash[profile.username.toLowerCase()] = ids[idx]; - } - - return memo; - }, { zset: [], hash: {} }); - - await Promise.all([ - db.sortedSetAddBulk(queries.zset), - db.setObject('handle:uid', queries.hash), - ]); - }, -};