LinkedIn publishing works again; rename Inbox to Posts

LinkedIn:
- The API version was fixed at 202501, retired by LinkedIn (426
  NONEXISTENT_VERSION). It's now the month before last, stepping back a
  month (up to four) if LinkedIn says a version isn't active.
- The versioned Posts API needs a title for a link's article card (422).
  Supermarket reads the linked page's title and description and sends
  them, falling back to the page's address as the title.
Tested for real: a post with a link went out to the member's profile.

Inbox is now Posts: the menu, page, messages and docs; the page moves to
/posts, and /inbox redirects there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 12:50:06 -07:00
co-authored by Claude Opus 5.5
parent 7733672706
commit 4b2d791909
21 changed files with 273 additions and 73 deletions
+17
View File
@@ -15,6 +15,8 @@ import (
"regexp"
"strings"
"time"
"supermarket/internal/api/sitemap"
)
// Page is one page read.
@@ -266,3 +268,18 @@ func FindAccounts(links []string) Accounts {
}
return a
}
// PageInfo reads one page's title and description (its <title>, or
// og:title, and its meta or og:description), for a link's preview card.
func PageInfo(ctx context.Context, pageURL, userAgent string) (title, desc string, err error) {
u, err := Normalize(pageURL)
if err != nil {
return "", "", err
}
_, src, err := fetchPage(ctx, &http.Client{Timeout: 10 * time.Second}, u.String(), userAgent)
if err != nil {
return "", "", err
}
title, desc = sitemap.PageInfo(src)
return title, desc, nil
}
+12
View File
@@ -80,3 +80,15 @@ func TestNormalize(t *testing.T) {
t.Error("ftp accepted")
}
}
func TestPageInfo(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
w.Write([]byte(`<head><title>Widget 2 &amp; more</title><meta name="description" content="Faster widgets."></head>`))
}))
defer srv.Close()
title, desc, err := PageInfo(context.Background(), srv.URL+"/w", "test")
if err != nil || title != "Widget 2 & more" || desc != "Faster widgets." {
t.Errorf("got %q %q %v", title, desc, err)
}
}