Phase 10, part 7: posting accounts, and who may post to which

Social accounts become posting accounts: several per network, the
company's and each person's own, with their tokens kept per account. The
old sign-ins are adopted as the company's. Admins say who may post to which
(Settings → Posting accounts); a draft can go out from one account or a
copy to several, each recording who posted it and as what. Signing an
account out, or removing its owner, holds the posts scheduled to it and
tells whoever scheduled them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 09:26:34 -07:00
co-authored by Claude Opus 5.5
parent a4dd36f5a4
commit bb4772637c
31 changed files with 1758 additions and 325 deletions
+13 -6
View File
@@ -59,22 +59,29 @@ func TestLinkedInPageSettings(t *testing.T) {
t.Errorf("bad manual: %s", body)
}
// A LinkedIn draft offers the page, and the choice is saved.
// The sign-in is now the company's page account, posting as the page
// chosen.
postForm(h, "/settings/accounts/linkedin-page", url.Values{"org": {"urn:li:organization:111"}, "default": {"page"}})
pa := s.companyPage()
if pa == nil || pa.External != "urn:li:organization:111" || pa.Name != "Federated Computer" || s.Secrets.Has(secrets.LinkedInPageAccessToken) {
t.Fatalf("page account: %+v", pa)
}
// A LinkedIn draft offers it, and the choice is saved.
if _, err := content.CreateDrafts(s.DB, []content.Draft{{Channel: content.ChannelLinkedIn, Content: "Hello"}}); err != nil {
t.Fatal(err)
}
ds, _ := content.ListDrafts(s.DB, 1, content.StatusDraft)
body = do(h, http.MethodGet, "/posts", nil, nil).Body.String()
if !strings.Contains(body, `name="linkedin_as"`) || !strings.Contains(body, `<option value="page" selected>Federated Computer</option>`) {
want := `<input type="checkbox" name="accounts" value="` + strconv.FormatInt(pa.ID, 10) + `" checked> LinkedIn page Federated Computer`
if !strings.Contains(body, want) {
t.Errorf("posts: %s", body)
}
postForm(h, "/drafts/"+strconv.FormatInt(ds[0].ID, 10)+"/save", url.Values{"content": {"Hello"}, "linkedin_as": {""}})
if dr, _ := content.GetDraft(s.DB, ds[0].ID); dr.LinkedInAs != "" {
t.Errorf("switched: %q", dr.LinkedInAs)
postForm(h, "/drafts/"+strconv.FormatInt(ds[0].ID, 10)+"/save", url.Values{"content": {"Hello"}, "accounts": {strconv.FormatInt(pa.ID, 10)}})
if dr, _ := content.GetDraft(s.DB, ds[0].ID); dr.AccountID != pa.ID {
t.Errorf("chosen: %d", dr.AccountID)
}
// The page counts as LinkedIn being connected, even without the member sign-in.
if !s.connected()[content.ChannelLinkedIn] {
if !s.connected(localOwner)[content.ChannelLinkedIn] {
t.Error("LinkedIn not connected with only the page")
}
}