add deleting, promoting/demoting, guesting (soft banning) users
This commit is contained in:
18
util.lua
18
util.lua
@ -14,6 +14,9 @@ util.TransientUser = {
|
||||
is_admin = function (self)
|
||||
return false
|
||||
end,
|
||||
is_mod = function (self)
|
||||
return false
|
||||
end,
|
||||
is_guest = function (self)
|
||||
return true
|
||||
end,
|
||||
@ -116,7 +119,6 @@ function util.create_post(thread_id, user_id, content)
|
||||
|
||||
local revision = PostHistory:create({
|
||||
post_id = post.id,
|
||||
user_id = user_id,
|
||||
content = bb_content,
|
||||
is_initial_revision = true,
|
||||
})
|
||||
@ -127,4 +129,16 @@ function util.create_post(thread_id, user_id, content)
|
||||
return post
|
||||
end
|
||||
|
||||
return util
|
||||
function util.transfer_and_delete_user(user)
|
||||
local deleted_user = Users:find({
|
||||
username = "DeletedUser",
|
||||
})
|
||||
-- this needs to be atomic
|
||||
db.query("BEGIN")
|
||||
db.query('UPDATE "threads" SET "user_id" = ? WHERE "user_id" = ?', deleted_user.id, user.id)
|
||||
db.query('UPDATE "posts" SET "user_id" = ? WHERE "user_id" = ?', deleted_user.id, user.id)
|
||||
user:delete() -- uncomment later
|
||||
db.query("COMMIT")
|
||||
end
|
||||
|
||||
return util
|
||||
|
Reference in New Issue
Block a user