mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.3 KiB
33 lines
1.3 KiB
'use strict';
|
|
|
|
const { Accounts, Boards, Stats, Posts, Bans, Modlogs } = require(__dirname+'/../../db/')
|
|
, cache = require(__dirname+'/../../redis.js')
|
|
, deletePosts = require(__dirname+'/deletepost.js')
|
|
, uploadDirectory = require(__dirname+'/../../helpers/files/uploadDirectory.js')
|
|
, { remove } = require('fs-extra');
|
|
|
|
module.exports = async (uri, board) => {
|
|
|
|
//delete board
|
|
await Boards.deleteOne(uri);
|
|
//get all posts (should probably project to get files for deletin and anything else necessary)
|
|
const allPosts = await Posts.allBoardPosts(uri);
|
|
if (allPosts.length > 0) {
|
|
//delete posts and decrement images
|
|
await deletePosts(allPosts, uri, true);
|
|
}
|
|
await Promise.all([
|
|
Accounts.removeOwnedBoard(board.owner, uri), //remove board from owner account
|
|
board.settings.moderators.length > 0 ? Accounts.removeModBoard(board.settings.moderators) : void 0, //remove board from mods accounts
|
|
Modlogs.deleteBoard(uri), //modlogs for the board
|
|
Bans.deleteBoard(uri), //bans for the board
|
|
Stats.deleteBoard(uri), //stats for the board
|
|
remove(`${uploadDirectory}/html/${uri}/`), //html
|
|
remove(`${uploadDirectory}/json/${uri}/`), //json
|
|
remove(`${uploadDirectory}/banners/${uri}/`) //banners
|
|
]);
|
|
if (!board.unlisted) {
|
|
cache.set('webring_update', 1);
|
|
}
|
|
|
|
}
|
|
|