repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
56ac75e
parent
d2e32d0
author
Eric Bower
date
2024-03-15 18:24:14 +0000 UTC
chore(auth): pico+ activated rss feed item
1 files changed,  +18, -3
M auth/auth.go
+18, -3
 1@@ -292,15 +292,14 @@ func keyHandler(w http.ResponseWriter, r *http.Request) {
 2 
 3 func genFeedItem(now time.Time, expiresAt time.Time, warning time.Time, txt string) *feeds.Item {
 4 	if now.After(warning) {
 5-		realUrl := warning.Format("2006-01-02 15:04:05")
 6 		content := fmt.Sprintf(
 7 			"Your pico+ membership is going to expire on %s",
 8 			expiresAt.Format("2006-01-02 15:04:05"),
 9 		)
10 		return &feeds.Item{
11-			Id:          realUrl,
12+			Id:          fmt.Sprintf("%d", warning.Unix()),
13 			Title:       fmt.Sprintf("pico+ %s expiration notice", txt),
14-			Link:        &feeds.Link{Href: realUrl},
15+			Link:        &feeds.Link{Href: "https://pico.sh"},
16 			Content:     content,
17 			Created:     warning,
18 			Updated:     warning,
19@@ -344,6 +343,22 @@ func rssHandler(w http.ResponseWriter, r *http.Request) {
20 	if err != nil {
21 		// still want to send an empty feed
22 	} else {
23+		createdAt := ff.CreatedAt
24+		createdAtStr := createdAt.Format("2006-01-02 15:04:05")
25+		id := fmt.Sprintf("pico-plus-activated-%d", createdAt.Unix())
26+		content := `Thanks for joining pico+! You now have access to all our premium services for exactly one year.  We will send you pico+ expiration notifications through this RSS feed.  Go to <a href="https://pico.sh/getting-started#next-steps">pico.sh/getting-started#next-steps</a> to start using our services.`
27+		plus := &feeds.Item{
28+			Id:          id,
29+			Title:       fmt.Sprintf("pico+ membership activated on %s", createdAtStr),
30+			Link:        &feeds.Link{Href: "https://pico.sh"},
31+			Content:     content,
32+			Created:     *createdAt,
33+			Updated:     *createdAt,
34+			Description: content,
35+			Author:      &feeds.Author{Name: "team pico"},
36+		}
37+		feedItems = append(feedItems, plus)
38+
39 		oneMonthWarning := ff.ExpiresAt.AddDate(0, -1, 0)
40 		mo := genFeedItem(now, *ff.ExpiresAt, oneMonthWarning, "1-month")
41 		if mo != nil {