add post editing

This commit is contained in:
2025-05-24 00:11:27 +03:00
parent 738b4163a8
commit e7260090ac
10 changed files with 224 additions and 22 deletions

View File

@ -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",