Last active
April 16, 2020 09:46
-
-
Save psychobunny/5f0f25c6efdfc2df9d6d to your computer and use it in GitHub Desktop.
NodeBB patch - Remove OP and replace it with first reply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// paste this in https://github.com/NodeBB/NodeBB/blob/master/src/routes/debug.js | |
// and then don't forget to remove it! | |
router.get('/remove-op', function(req, res) { | |
var db = require('../database'), | |
async = require('async'); | |
db.getSortedSetRange('topics:tid', 0, -1, function(err, tids) { | |
async.eachLimit(tids, 50, function(tid, next) { | |
db.getSortedSetRange('tid:' + tid + ':posts', 0, 0, function(err, pid) { | |
if (err) { | |
throw new Error(err); | |
} | |
pid = pid[0]; | |
db.sortedSetRemove('tid:' + tid + ':posts', pid, function(err) { | |
if (err) { | |
throw new Error(err); | |
} | |
db.setObjectField('topic:' + tid, 'mainPid', pid, next); | |
}); | |
}); | |
}, function(err) { | |
if (err) { | |
throw new Error(err); | |
} | |
res.json({status: true}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment