add post editing
This commit is contained in:
21
util.lua
21
util.lua
@ -242,6 +242,27 @@ function util.create_post(thread_id, user_id, content, markup_language)
|
||||
return post
|
||||
end
|
||||
|
||||
function util.update_post(post, new_content, markup_language)
|
||||
markup_language = markup_language or "babycode"
|
||||
db.query("BEGIN")
|
||||
|
||||
local parsed_content = ""
|
||||
if markup_language == "babycode" then
|
||||
parsed_content = babycode.to_html(new_content, html_escape)
|
||||
end
|
||||
|
||||
local revision = PostHistory:create({
|
||||
post_id = post.id,
|
||||
content = parsed_content,
|
||||
is_initial_revision = false,
|
||||
original_markup = new_content,
|
||||
markup_language = markup_language
|
||||
})
|
||||
|
||||
post:update({current_revision_id = revision.id})
|
||||
db.query("COMMIT")
|
||||
end
|
||||
|
||||
function util.transfer_and_delete_user(user)
|
||||
local deleted_user = Users:find({
|
||||
username = "DeletedUser",
|
||||
|
Reference in New Issue
Block a user