news-catalyst / next-tinynewsdemo

Frontend for Tiny News Collective organizations
https://next-tinynewsdemo.vercel.app
1 stars 0 forks source link

Newsletter archiving - edit Letterhead API request to accept maximum amount of newsletters #1304

Open chelsea-tnc opened 1 year ago

chelsea-tnc commented 1 year ago

Context: We have a deployment job that gets all newsletters for a site from the Letterhead API and saves them to the site's archive page. The LH API will return 10 results max, so if a site has more than 10 newsletters, only 10 are returned. We need to edit the query to get all newsletters. Ideally, when we switch to automated newsletter publishing (#1277), we should get the last N newsletters that were published since we last updated it and update the page with only what's changed.

Manual repro steps:

  1. Create a GET request to the LH API: https://api.tryletterhead.com/api/v2/channels/<CHANNEL_SLUG_GOES_HERE>/letters?api=true. You will need to use the LH API token for authorization and the channel slug for the specific site.
  2. Observe the size of the items list versus the total field. The total field includes all newsletters and welcome letters. However, items only shows 10 items. We need all items.

Suggested fix: LH suggested we set a large limit in the request to get all items (https://api.tryletterhead.com/api/v2/channels//letters?api=true&limit=999999).