API: getting one blog does not accept ?body=html, but getting all blogs does

Aperta
#829 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
go
Ambito
api, backend

Direzione di ricerca

Inizia individuando gli handler o i punti di ingresso per /api/collections/{alias}/posts e /api/collections/{alias}/posts/{slug}, quindi confronta il modo in cui ciascuna route legge il parametro di query body. Verifica che la risposta per un singolo post rispetti ?body=html come la risposta della collection e conferma che entrambe le route restituiscano ancora i dati previsti quando il parametro viene omesso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement
Describe the bug

When using the WriteFreely API to get all of a blog's posts, you can pass the parameter ?body=html to get HTML-formatted blog bodies.
/api/collections/test/posts?body=html

{
  "code": 200,
  "data": {
    "alias": "test",
    "title": "Test Blog",
    "description": "Hello, world!",
    "style_sheet": "",
    "public": true,
    "format": "blog",
    "views": 0,
    "url": "https://example.com/test/",
    "verification_link": "",
    "total_posts": 1,
    "posts": [
      {
        "id": "34hr3jrjjt",
        "slug": "test",
        "appearance": "norm",
        "language": "en",
        "rtl": false,
        "created": "2023-08-23T00:00:00-05:00",
        "updated": "2023-10-11T21:06:45-05:00",
        "title": "Test",
        "body": "<h1>This is a test.</h1>\n<a href="https://example.com/">Hello, world!</a>",
        "tags": [],
        "paid": false,
        "views": 1
      }
    ],
    "Format": null
  }
}

However, when getting one of a blog's posts, this parameter is no longer accepted and the body becomes Markdown.
/api/collections/test/posts/test?body=html

{
  "code": 200,
  "data": {
    "id": "34hr3jrjjt",
    "slug": "test",
    "appearance": "norm",
    "language": "en",
    "rtl": false,
    "created": "2023-08-23T00:00:00-05:00",
    "updated": "2023-10-11T21:06:45-05:00",
    "title": "Test",
    "body": "# This is a test.\n[Hello, world!](https://example.com/)",
    "tags": [],
    "paid": false,
    "views": 1
  }
}
Expected behavior

The API should accept the ?body=html parameter on both routes, so blogs can be returned in HTML, regardless of the method.

Application configuration
  • Single mode or Multi-user mode?: Multiple users
  • Database?: mysql
  • Open registration?: Invite-only
  • Federation enabled?: yes

Version or last commit: WriteFreely v0.14.0 on Ubuntu 22.04.3 LTS x86_64

Lingua principale
Go
Stelle
5.3k
Fork
413
Merge medio
3g 5h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di writefreely/writefreely

Tutte le issue di writefreely/writefreely

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.