Reddit: posted by hand, with the rules pasted

Reddit's API isn't open to apps like this one, so Supermarket no longer
signs in to Reddit, publishes or schedules there, or reads subreddits and
the account's posts. The internal/api/reddit client, Reddit's OAuth, its
keys and its Social accounts card are gone.

Supermarket still writes the post. Each Reddit draft in Posts has a box
for its subreddit's rules, with a link to them on Reddit: pasted once,
they're kept (subreddits.data, as pasted_rules) and given to the model
for later drafts. Open in Reddit saves the edits and opens the submit
page filled in; Copy title and Copy text (with the tagged source link)
cover a box that comes up empty; Mark as posted records it. Warnings come
from the pasted rules and the posts marked as posted. Fill's subreddit
suggestions are kept unchecked, and say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 11:48:54 -07:00
co-authored by Claude Opus 5.5
parent bae468e01c
commit 5451fe6d63
33 changed files with 382 additions and 1107 deletions
+6 -7
View File
@@ -10,7 +10,6 @@ import (
"time"
"supermarket/internal/ai"
"supermarket/internal/api/reddit"
"supermarket/internal/api/sitemap"
"supermarket/internal/content"
"supermarket/internal/db"
@@ -160,7 +159,7 @@ func (s *Server) entryData(e *inventory.Entry, showDismissed bool) (*entryPage,
seen := map[string]bool{}
for _, list := range [][]string{e.Subreddits, p.Accounts.Subreddits} {
for _, sr := range list {
if n := reddit.CleanName(sr); n != "" && !seen[strings.ToLower(n)] {
if n := content.CleanSubreddit(sr); n != "" && !seen[strings.ToLower(n)] {
seen[strings.ToLower(n)] = true
subs = append(subs, n)
}
@@ -322,15 +321,15 @@ func (s *Server) writeDrafts(r *http.Request, e *inventory.Entry, ids []string)
}
for _, ch := range ordered {
if ch == content.ChannelReddit {
req.Subreddit = reddit.CleanName(r.PostForm.Get("subreddit"))
req.Subreddit = content.CleanSubreddit(r.PostForm.Get("subreddit"))
if req.Subreddit == "" {
return errors.New("choose a subreddit for the Reddit post")
}
// The rules go into the prompt; without them the model is told
// to be careful, and Posts warns.
info, err := s.subreddit(r.Context(), req.Subreddit, false)
// The rules pasted for it go into the prompt; without them the
// model is told to be careful, and Posts asks for them.
info, err := content.GetSubreddit(s.DB, req.Subreddit)
if err != nil {
s.Log.Warn("reddit: couldn't read the subreddit's rules", "subreddit", req.Subreddit, "err", err)
s.Log.Error("reading a subreddit's rules", "subreddit", req.Subreddit, "err", err)
}
req.SubredditInfo = info
}