deleting posts of an account
Solved
Technical Support
-
Hi @baris , is there any code you can give us so that we can delete the posts by an account? (let's say user id:54321)
Additionally, on the profile options, when I click "delete content", it actually purges the content, not deletes it. On a thread, when I "delete" a post, it just makes the post invisible but the post stays there. I think it would make more sense to say "purge content"...
-
additionally, do spiders read the content of a deleted post? do they show up on google search results?
-
For deleting posts of a user something like this should work.
/* 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 = '123'; db.init(async (err) => { const meta = require('./src/meta'); await meta.configs.init(); if (err) { console.log(`NodeBB could not connect to your database. Error: ${err.message}`); process.exit(); } await deletePosts(); console.log('done'); process.exit(); }); async function deletePosts() { const pids = await db.getSortedSetRange(`uid:${uid}:posts`, 0, -1); const posts = require('./src/posts'); for (const pid of pids) { await posts.delete(pid, 1); } }
Replace the value of uid with the target user.
-
Copyright © 2024 NodeBB | Contributors