mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
chore: remove now-unneeded v4 upgrade scripts
The deleted upgrade scripts were intended to be run on servers running pre-release versions of v4. Now that it has been merged into `develop`, those scripts are no longer needed.
This commit is contained in:
@@ -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);
|
||||
},
|
||||
};
|
||||
@@ -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],
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -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),
|
||||
]);
|
||||
},
|
||||
};
|
||||
@@ -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))),
|
||||
]);
|
||||
},
|
||||
};
|
||||
@@ -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 });
|
||||
},
|
||||
};
|
||||
@@ -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 });
|
||||
},
|
||||
};
|
||||
@@ -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),
|
||||
]);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user