diff --git a/pleroma-comments.lua b/pleroma-comments.lua index 5fa996e..2a4aba6 100644 --- a/pleroma-comments.lua +++ b/pleroma-comments.lua @@ -3,6 +3,12 @@ -- local https = "wget" local json = require("cjson") +function printTable(t) + for key, value in pairs(t) do + print(key, value) + end +end + function tokenizeString(inputString, delimiter) local tokens = {} for token in inputString:gmatch("[^" .. delimiter .. "]+") do @@ -43,6 +49,9 @@ function get_short_date(timestamp) end function write_comments(pleroma_posts, instance) + if #pleroma_posts == 0 then + return "" + end local template = [[

@@ -128,6 +137,7 @@ function Meta(meta) local c = write_comments(all_replies, "https://" .. host) meta["pleroma-comments"] = c meta["pleroma-comments-count"] = #c + meta["pleroma-has-comments"] = (#c > 0) meta["pleroma"] = newelem return meta end