Commit 2c02fb4
Eric Bower
·
2026-01-08 10:23:53 -0500 EST
parent 190b37f
chore(feeds): add deprecation notice for free pico users
4 files changed,
+41,
-6
+10,
-1
| ... | ... | @@ -159,7 +159,16 @@ func Middleware(dbpool db.DB, cfg *shared.ConfigSite) pssh.SSHServerMiddleware { | |
| 159 | 159 | _, _ = fmt.Fprintf(sesh, "running feed post: %s\r\n", filename) | |
| 160 | 160 | logger.Info("run cmd", "filename", filename) | |
| 161 | 161 | fetcher := NewFetcher(dbpool, cfg) | |
| 162 | - | err = fetcher.RunPost(logger, user, post, true, time.Now().UTC()) | |
| 162 | + | ||
| 163 | + | isPicoPlus := false | |
| 164 | + | ff, _ := dbpool.FindFeature(user.ID, "plus") | |
| 165 | + | if ff != nil { | |
| 166 | + | if ff.IsValid() { | |
| 167 | + | isPicoPlus = true | |
| 168 | + | } | |
| 169 | + | } | |
| 170 | + | ||
| 171 | + | err = fetcher.RunPost(logger, user, isPicoPlus, post, true, time.Now().UTC()) | |
| 163 | 172 | if err != nil { | |
| 164 | 173 | _, _ = fmt.Fprintln(sesh.Stderr(), err) | |
| 165 | 174 | } |
+13,
-4
| ... | ... | @@ -70,6 +70,7 @@ type DigestFeed struct { | |
| 70 | 70 | DaysLeft string | |
| 71 | 71 | ShowBanner bool | |
| 72 | 72 | SizeWarning bool | |
| 73 | + | IsPicoPlus bool | |
| 73 | 74 | } | |
| 74 | 75 | ||
| 75 | 76 | type DigestOptions struct { |
| ... | ... | @@ -195,7 +196,7 @@ func (f *Fetcher) Validate(logger *slog.Logger, post *db.Post, parsed *shared.Li | |
| 195 | 196 | return nil | |
| 196 | 197 | } | |
| 197 | 198 | ||
| 198 | - | func (f *Fetcher) RunPost(logger *slog.Logger, user *db.User, post *db.Post, skipValidation bool, now time.Time) error { | |
| 199 | + | func (f *Fetcher) RunPost(logger *slog.Logger, user *db.User, isPicoPlus bool, post *db.Post, skipValidation bool, now time.Time) error { | |
| 199 | 200 | logger = logger.With("filename", post.Filename) | |
| 200 | 201 | logger.Info("running feed post") | |
| 201 | 202 |
| ... | ... | @@ -260,7 +261,7 @@ func (f *Fetcher) RunPost(logger *slog.Logger, user *db.User, post *db.Post, ski | |
| 260 | 261 | subject := fmt.Sprintf("%s feed digest", post.Filename) | |
| 261 | 262 | unsubURL := getUnsubURL(post) | |
| 262 | 263 | ||
| 263 | - | msgBody, err := f.FetchAll(logger, urls, parsed.InlineContent, user.Name, post) | |
| 264 | + | msgBody, err := f.FetchAll(logger, urls, parsed.InlineContent, user.Name, isPicoPlus, post) | |
| 264 | 265 | if err != nil { | |
| 265 | 266 | errForUser := err | |
| 266 | 267 |
| ... | ... | @@ -336,13 +337,20 @@ func (f *Fetcher) RunUser(user *db.User, now time.Time) error { | |
| 336 | 337 | if err != nil { | |
| 337 | 338 | return err | |
| 338 | 339 | } | |
| 340 | + | isPicoPlus := false | |
| 341 | + | ff, _ := f.db.FindFeature(user.ID, "plus") | |
| 342 | + | if ff != nil { | |
| 343 | + | if ff.IsValid() { | |
| 344 | + | isPicoPlus = true | |
| 345 | + | } | |
| 346 | + | } | |
| 339 | 347 | ||
| 340 | 348 | if len(posts.Data) > 0 { | |
| 341 | 349 | logger.Info("found feed posts", "len", len(posts.Data)) | |
| 342 | 350 | } | |
| 343 | 351 | ||
| 344 | 352 | for _, post := range posts.Data { | |
| 345 | - | err = f.RunPost(logger, user, post, false, now) | |
| 353 | + | err = f.RunPost(logger, user, isPicoPlus, post, false, now) | |
| 346 | 354 | if err != nil { | |
| 347 | 355 | logger.Error("run post failed", "err", err) | |
| 348 | 356 | } |
| ... | ... | @@ -471,7 +479,7 @@ func getUnsubURL(post *db.Post) string { | |
| 471 | 479 | return fmt.Sprintf("https://feeds.pico.sh/unsub/%s", post.ID) | |
| 472 | 480 | } | |
| 473 | 481 | ||
| 474 | - | func (f *Fetcher) FetchAll(logger *slog.Logger, urls []string, inlineContent bool, username string, post *db.Post) (*MsgBody, error) { | |
| 482 | + | func (f *Fetcher) FetchAll(logger *slog.Logger, urls []string, inlineContent bool, username string, isPicoPlus bool, post *db.Post) (*MsgBody, error) { | |
| 475 | 483 | logger.Info("fetching feeds", "inlineContent", inlineContent) | |
| 476 | 484 | fp := gofeed.NewParser() | |
| 477 | 485 | daysLeft := "" |
| ... | ... | @@ -490,6 +498,7 @@ func (f *Fetcher) FetchAll(logger *slog.Logger, urls []string, inlineContent boo | |
| 490 | 498 | DaysLeft: daysLeft, | |
| 491 | 499 | ShowBanner: showBanner, | |
| 492 | 500 | Options: DigestOptions{InlineContent: inlineContent}, | |
| 501 | + | IsPicoPlus: isPicoPlus, | |
| 493 | 502 | } | |
| 494 | 503 | feedItems, err := f.db.FindFeedItemsByPostID(post.ID) | |
| 495 | 504 | if err != nil { |
+12,
-1
| ... | ... | @@ -9,11 +9,21 @@ img { | |
| 9 | 9 | } | |
| 10 | 10 | </style> | |
| 11 | 11 | ||
| 12 | + | {{if .IsPicoPlus}} | |
| 13 | + | {{else}} | |
| 14 | + | <blockquote> | |
| 15 | + | <strong>NOTICE:</strong> Our email digest service is moving to our paid <strong>pico+</strong> plan on <strong>2026-01-22</strong> at which point we will stop sending you email digests. | |
| 16 | + | <a href="https://blog.pico.sh/ann-033-moving-rss-to-email-pico-plus">read out annoucement</a>. | |
| 17 | + | </blockquote> | |
| 18 | + | <br /> | |
| 19 | + | {{end}} | |
| 20 | + | ||
| 12 | 21 | {{if .SizeWarning}} | |
| 13 | 22 | <blockquote> | |
| 14 | - | <strong>NOTICE:</strong> This email is over the size limit (5MB). Inline content has been enabled to avoid email delivery issues. | |
| 23 | + | <strong>NOTICE:</strong> This email is over the size limit (5MB). Inline content has been disabled to avoid email delivery issues. | |
| 15 | 24 | We recommend splitting your RSS feeds into multiple digests. | |
| 16 | 25 | </blockquote> | |
| 26 | + | <br /> | |
| 17 | 27 | {{end}} | |
| 18 | 28 | ||
| 19 | 29 | {{if .ShowBanner}} |
| ... | ... | @@ -21,6 +31,7 @@ img { | |
| 21 | 31 | <strong>NOTICE:</strong> In order to keep this digest email active you must <a href="{{.KeepAliveURL}}">click this link</a>. | |
| 22 | 32 | You have {{.DaysLeft}} days left. | |
| 23 | 33 | </blockquote> | |
| 34 | + | </br /> | |
| 24 | 35 | {{end}} | |
| 25 | 36 | ||
| 26 | 37 | <div class="feeds"> |
| ... | ... | @@ -1,3 +1,9 @@ | |
| 1 | + | {{if .IsPicoPlus}} | |
| 2 | + | {{else}} | |
| 3 | + | > Our email digest service is moving to our paid **pico+** plan on **2026-01-22** at which point we will stop sending you email digests. | |
| 4 | + | > read our announcement: https://blog.pico.sh/ann-033-moving-rss-to-email-pico-plus | |
| 5 | + | {{end}} | |
| 6 | + | ||
| 1 | 7 | {{if .ShowBanner}} | |
| 2 | 8 | > In order to keep this digest email active you must click the link below. You have {{.DaysLeft}} days left. | |
| 3 | 9 | > {{.KeepAliveURL}} |