From c7fcdeb91c4d47a4cab6f9dd66d487fa0d858a13 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Pelkum Date: Sat, 29 Jan 2022 16:18:40 +0100 Subject: [PATCH] Include AutoDelete lifetime in /api/v2/info response --- API.md | 9 +++++---- internal/web/web.go | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/API.md b/API.md index f3a1670..3b99fd1 100644 --- a/API.md +++ b/API.md @@ -69,10 +69,11 @@ GET /api/v2/info none **Response:** -```json +```jsonc { "modificationTokens": true, "reports": true, + "pasteLifetime": -1, // The configured AutoDelete paste lifetime; -1 if AutoDelete is disabled "version": "dev" } ``` @@ -94,7 +95,7 @@ none "id": "paste_id", "content": "paste_content", "created": 0000000000, - "metadata": {}, + "metadata": {} } ``` @@ -121,7 +122,7 @@ POST /api/v2/pastes "content": "paste_content", "modificationToken": "raw_modification_token", "created": 0000000000, - "metadata": {}, + "metadata": {} } ``` @@ -147,7 +148,7 @@ PATCH /api/v2/pastes/{paste_id} "id": "paste_id", "content": "new_paste_content", "created": 0000000000, - "metadata": {}, + "metadata": {} } ``` diff --git a/internal/web/web.go b/internal/web/web.go index 047c958..497e78e 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -71,11 +71,16 @@ func Serve() error { v2Route := apiRoute.Group("/v2") { + pasteLifetime := int64(-1) + if config.Current.AutoDelete.Enabled { + pasteLifetime = config.Current.AutoDelete.Lifetime.Milliseconds() + } v2Route.GET("/info", func(ctx *fasthttp.RequestCtx) { jsonData, _ := json.Marshal(map[string]interface{}{ "version": static.Version, "modificationTokens": config.Current.ModificationTokens, "reports": config.Current.Reports.Reports, + "pasteLifetime": pasteLifetime, }) ctx.SetBody(jsonData) })