Remind before LinkedIn's sign-in expires, and stop posting once it has
LinkedIn tokens last 60 days and can't be renewed without signing in again. The expiry LinkedIn reports is now recorded (60 days from sign-in for older connections). The LinkedIn card says until when; from two weeks before, the Overview, the Inbox and the card remind you, with a Reconnect button. Once expired, LinkedIn counts as not connected, due posts come back to the Inbox saying why, and a 401 from LinkedIn reads "reconnect LinkedIn" instead of the raw error. Also fixes a leftover "Settings → Credentials" in a publish error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,7 +62,11 @@ func (s *Server) publishers() content.Publishers {
|
||||
pubs[content.ChannelX] = xPublisher{c}
|
||||
}
|
||||
if tok, urn := s.Secrets.Get(secrets.LinkedInAccessToken), s.Secrets.Get(secrets.LinkedInAuthorURN); tok != "" && urn != "" {
|
||||
pubs[content.ChannelLinkedIn] = linkedInPublisher{linkedin.New(tok, urn)}
|
||||
if e := s.linkedInExpiry(); e != nil && e.Expired() {
|
||||
pubs[content.ChannelLinkedIn] = expiredPublisher{*e}
|
||||
} else {
|
||||
pubs[content.ChannelLinkedIn] = linkedInPublisher{linkedin.New(tok, urn)}
|
||||
}
|
||||
}
|
||||
if c := s.redditUser(); c != nil {
|
||||
pubs[content.ChannelReddit] = redditPublisher{s: s, c: c}
|
||||
@@ -70,6 +74,15 @@ func (s *Server) publishers() content.Publishers {
|
||||
return pubs
|
||||
}
|
||||
|
||||
// expiredPublisher stands in for a network whose sign-in ran out: it posts
|
||||
// nothing and says so, rather than letting the network answer 401.
|
||||
type expiredPublisher struct{ e Expiry }
|
||||
|
||||
func (p expiredPublisher) Publish(context.Context, content.Post) (string, error) {
|
||||
return "", fmt.Errorf("%s's sign-in expired on %s: reconnect %s under Settings → Social accounts, then publish again",
|
||||
p.e.Network, p.e.At.Local().Format("2 Jan 2006"), p.e.Network)
|
||||
}
|
||||
|
||||
type xPublisher struct{ c *twitter.Client }
|
||||
|
||||
// Publish appends the source link to the post, as the old app did; X shows
|
||||
|
||||
Reference in New Issue
Block a user