From 43327132cba34c6d769c99e8fab4569cafc7f712 Mon Sep 17 00:00:00 2001 From: Ben Klein Date: Fri, 17 Sep 2021 23:04:39 -0400 Subject: [PATCH] client: /post/id/* allowed to match for post tags --- client/metatags.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/metatags.lua b/client/metatags.lua index 799f6f50..bebd51e1 100644 --- a/client/metatags.lua +++ b/client/metatags.lua @@ -65,11 +65,13 @@ local function generate_meta_tags () add_meta_tag(og_media_prefix..":width", post_info.canvasWidth) add_meta_tag(og_media_prefix..":height", post_info.canvasHeight) end - elseif ngx.var.request_uri_path:match('^/post/([0-9]+)/?$') then -- Post metadata + elseif ngx.var.request_uri_path:match('^/post/([0-9]+)') then -- Post metadata -- check if posts are accessible to anonymous users: if server_info.config.privileges["posts:view"] == "anonymous" then + local match, err = ngx.re.match(ngx.var.request_uri_path, "^/post/(?[0-9]+)") + local post_id = match["post_id"] add_meta_tag("og:type", "article") - local post_info = cjson.decode((ngx.location.capture("/_internal_api"..ngx.var.request_uri_path)).body) + local post_info = cjson.decode((ngx.location.capture("/_internal_api/post/"..post_id)).body) add_meta_tag("og:title", server_info.config.name .. " - Post " .. post_info.id) add_meta_tag("twitter:title", server_info.config.name .. " - Post " .. post_info.id) add_meta_tag("article:published_time", post_info.creationTime)