feat: delete user with replace target
This commit is contained in:
@@ -128,8 +128,10 @@ module.exports = class CommentProvider extends Model {
|
||||
} else {
|
||||
WIKI.data.commentProvider = {
|
||||
...WIKI.data.commentProvider,
|
||||
...require(`../modules/comments/${commentProvider.key}/comment`)
|
||||
...require(`../modules/comments/${commentProvider.key}/comment`),
|
||||
config: commentProvider.config
|
||||
}
|
||||
await WIKI.data.commentProvider.init()
|
||||
}
|
||||
WIKI.data.commentProvider.config = commentProvider.config
|
||||
}
|
||||
|
@@ -613,9 +613,15 @@ module.exports = class User extends Model {
|
||||
*
|
||||
* @param {*} id User ID
|
||||
*/
|
||||
static async deleteUser (id) {
|
||||
static async deleteUser (id, replaceId) {
|
||||
const usr = await WIKI.models.users.query().findById(id)
|
||||
if (usr) {
|
||||
await WIKI.models.assets.query().patch({ authorId: replaceId }).where('authorId', id)
|
||||
await WIKI.models.comments.query().patch({ authorId: replaceId }).where('authorId', id)
|
||||
await WIKI.models.pageHistory.query().patch({ authorId: replaceId }).where('authorId', id)
|
||||
await WIKI.models.pages.query().patch({ authorId: replaceId }).where('authorId', id)
|
||||
await WIKI.models.pages.query().patch({ creatorId: replaceId }).where('creatorId', id)
|
||||
|
||||
await WIKI.models.userKeys.query().delete().where('userId', id)
|
||||
await WIKI.models.users.query().deleteById(id)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user