Solved Cleaning downvotes by User X


  • Hi @baris ,

    Someone abused the downvoting system in our forum and therefore we would like to undo his/her downvotes.

    We have already banned the user, and its user id is 16289. Can you please give us a code to clean the downvotes by this user?

  • Community Rep

    @crazycells It would be nice if deleting the offending user account would also purge the db of all such user's influence. 🐕


  • @gotwf said in Cleaning downvotes by User X:

    @crazycells It would be nice if deleting the offending user account would also purge the db of all such user's influence. 🐕

    Actually, I am not sure what is happening then... But we prefer to ban them rather than deleting the account, since later the same trolls can re-open an account. We catch them using the trace they leave behind on the old accounts...

  • NodeBB

    /* globals require, console, process */
    
    'use strict';
    
    const nconf = require('nconf');
    
    nconf.file({
    	file: 'config.json',
    });
    nconf.defaults({
    	base_dir: __dirname,
    	views_dir: './build/public/templates',
    	upload_path: 'public/uploads',
    });
     
    const db = require('./src/database');
    
    const uid = '16289'; // replace with target uid
    
    db.init(function (err) {
    	if (err) {
    		console.log('NodeBB could not connect to your database. Error: ' + err.message);
    		process.exit();
    	}
     
    	undoVotes(function (err) {
    		if (err) {
    			console.error(err);
    			process.exit();
    		}
    
    		console.log('done');
    		process.exit();
    	});
    });
    
    async function undoVotes(callback) {
        const posts = require('./src/posts');
        const downvotedPids = await db.getSortedSetRange(`uid:${uid}:downvote`, 0, -1);
        for (const pid of downvotedPids) {
            await posts.unvote(pid, uid);
        }
        callback();
    }
    
    

  • @baris Thanks a lot. We run it on the NodeBB folder and it worked great.

  • Community Rep

    @crazycells Cool beans. 🐕

    @crazycells said in Cleaning downvotes by User X:

    But we prefer to ban them rather than deleting the account, since later the same trolls can re-open an account.

    True.

    Perchance are you using StopForumSpam? Iirc, it tracks email addresses for reported spammers. Or maybe that is Project Honeypot? Hmm.. Maybe both! Heh.

    Regardless, w/the code above you've the best of both worlds. Woot! 🦉


  • @gotwf said in Cleaning downvotes by User X:

    @crazycells Cool beans. 🐕

    @crazycells said in Cleaning downvotes by User X:

    But we prefer to ban them rather than deleting the account, since later the same trolls can re-open an account.

    True.

    Perchance are you using StopForumSpam? Iirc, it tracks email addresses for reported spammers. Or maybe that is Project Honeypot? Hmm.. Maybe both! Heh.

    Regardless, w/the code above you've the best of both worlds. Woot! 🦉

    Yes, this code helped a lot. We have both StopForumSpam and Honeypot activated; however, these people are not trolls in the classical sense. I do not think they are active in any other forums...

    We are the largest and only serious Turkish-American immigration forum, but there are tens of Facebook groups... These people fight with other members in other social platforms, mostly on other Facebook groups, then they take "revenge" in our forum 🙂

  • Topic has been marked as solved  crazycells crazycells 

Suggested Topics

  • 1
  • 3
  • 2
  • 3
  • 4
| |