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:
@@ -293,6 +293,10 @@ func GetDraft(d *db.DB, id int64) (*Draft, error) {
|
||||
// published.
|
||||
var ErrNotEditable = errors.New("this draft can't be changed any more")
|
||||
|
||||
// ErrByHand is the answer to publishing or scheduling a Reddit draft: you
|
||||
// post those yourself.
|
||||
var ErrByHand = errors.New("Reddit posts are posted by hand: open the subreddit's submit page from the draft, post it there, then mark it as posted")
|
||||
|
||||
// UpdateDraft saves edited text.
|
||||
func UpdateDraft(d *db.DB, id int64, text string) error {
|
||||
text = strings.TrimSpace(text)
|
||||
@@ -370,9 +374,15 @@ func Schedule(d *db.DB, id int64, at time.Time) error {
|
||||
return errors.New("that's more than a year away")
|
||||
}
|
||||
res, err := d.Exec(`UPDATE drafts SET status = ?, publish_at = ?, error = '', updated_at = ?
|
||||
WHERE id = ? AND status IN (?, ?)`,
|
||||
StatusScheduled, formatTime(at), formatTime(time.Now()), id, StatusDraft, StatusFailed)
|
||||
return oneRow(res, err)
|
||||
WHERE id = ? AND status IN (?, ?) AND channel <> ?`,
|
||||
StatusScheduled, formatTime(at), formatTime(time.Now()), id, StatusDraft, StatusFailed, ChannelReddit)
|
||||
err = oneRow(res, err)
|
||||
if errors.Is(err, ErrNotEditable) {
|
||||
if dr, gerr := GetDraft(d, id); gerr == nil && dr.Channel == ChannelReddit {
|
||||
return ErrByHand
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Unschedule sends a scheduled draft back to Posts, to edit or drop.
|
||||
|
||||
Reference in New Issue
Block a user