diff src/lib/Post.luan @ 56:7ce54f6d93f2

add change name
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 28 Nov 2022 22:00:43 -0700
parents 289718f121e4
children
line wrap: on
line diff
--- a/src/lib/Post.luan	Mon Nov 28 20:33:47 2022 -0700
+++ b/src/lib/Post.luan	Mon Nov 28 22:00:43 2022 -0700
@@ -46,7 +46,7 @@
 		id = doc.id
 		content = doc.content
 		date = doc.date
-		author_name = doc.post_author_name
+		author_id = doc.post_author_id
 		root_id = doc.post_root_id
 		is_root = doc.post_is_root == "true"
 
@@ -63,7 +63,7 @@
 		id = post.id
 		content = post.content or error()
 		date = long(post.date)
-		post_author_name = post.author_name or error()
+		post_author_id = long(post.author_id)
 		post_root_id = long(post.root_id)
 		post_is_root = post.is_root and "true" or nil
 
@@ -76,7 +76,7 @@
 function metatable.__index(post,key)
 	if key == "author" then
 		local User = require "site:/lib/User.luan"
-		return User.get_by_name(post.author_name)
+		return User.get_by_id(post.author_id)
 	end
 	if key == "subject_html" then
 		return post.subject and html_encode(post.subject)
@@ -106,7 +106,7 @@
 	function post.author_is_current()
 		local User = require "site:/lib/User.luan"
 		local user = User.current()
-		return user ~= nil and user.name == post.author_name
+		return user ~= nil and user.id == post.author_id
 	end
 
 	function post.ago(now)
@@ -140,7 +140,7 @@
 		local post = Post.new{
 			subject = subject or error()
 			content = content
-			author_name = author.name
+			author_id = author.id
 			is_root = true
 		}
 		post.root_id = -1