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
+20 -2
View File
@@ -10,6 +10,8 @@ import (
"rsc.io/qr"
"supermarket/internal/posting"
"supermarket/internal/secrets"
"supermarket/internal/users"
)
@@ -23,8 +25,12 @@ type accountData struct {
Zones []string
Emails []emailKind // the emails they may choose
Photos bool // there's file storage for a photo
Problem string // under the form it's about
Section string // which form: profile, password, two-factor
// Their own posting accounts, and the networks they can connect.
Posting []*posting.Account
Connectable []grant
Problem string // under the form it's about
Section string // which form: profile, password, two-factor
// Setting up two-factor sign-in.
Secret string
@@ -79,6 +85,18 @@ func (s *Server) renderAccount(w http.ResponseWriter, r *http.Request, v *viewer
return
}
d.U, d.Role, d.Zones, d.Emails, d.Photos = u, v.Member.Role, commonZones, emailsFor(v.Member), s.Files != nil
if v.Member.Can("content", true) {
d.Posting, _ = posting.OwnedBy(s.DB, u.ID)
if s.Secrets.Has(secrets.XClientID) {
d.Connectable = append(d.Connectable, grant{"x", "X"})
}
if s.Secrets.Has(secrets.LinkedInClientID) && s.Secrets.Has(secrets.LinkedInClientSecret) {
d.Connectable = append(d.Connectable, grant{"linkedin", "LinkedIn"})
}
if s.Secrets.Has(secrets.RedditClientID) && s.Secrets.Has(secrets.RedditClientSecret) {
d.Connectable = append(d.Connectable, grant{"reddit", "Reddit"})
}
}
for _, ss := range list {
d.Sessions = append(d.Sessions, sessionRow{Session: ss, This: ss.ID == v.Session.ID})
}