Skip to content

Commit eca91d5

Browse files
feat(rss): use server title and description for RSS feed, if configured (#4717)
1 parent ad2c5f0 commit eca91d5

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

server/router/rss/rss.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ type RSSService struct {
2626
Store *store.Store
2727
}
2828

29+
type RSSHeading struct {
30+
Title string
31+
Description string
32+
}
33+
2934
func NewRSSService(profile *profile.Profile, store *store.Store) *RSSService {
3035
return &RSSService{
3136
Profile: profile,
@@ -93,10 +98,14 @@ func (s *RSSService) GetUserRSS(c echo.Context) error {
9398
}
9499

95100
func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*store.Memo, baseURL string) (string, error) {
101+
rssHeading, err := getRSSHeading(s.Store, ctx)
102+
if err != nil {
103+
return "", err
104+
}
96105
feed := &feeds.Feed{
97-
Title: "Memos",
106+
Title: rssHeading.Title,
98107
Link: &feeds.Link{Href: baseURL},
99-
Description: "An open source, lightweight note-taking service. Easily capture and share your great thoughts.",
108+
Description: rssHeading.Description,
100109
Created: time.Now(),
101110
}
102111

@@ -150,3 +159,21 @@ func getRSSItemDescription(content string) (string, error) {
150159
result := renderer.NewHTMLRenderer().Render(nodes)
151160
return result, nil
152161
}
162+
163+
func getRSSHeading(store *store.Store, ctx context.Context) (RSSHeading, error) {
164+
settings, err := store.GetWorkspaceGeneralSetting(ctx)
165+
if err != nil {
166+
return RSSHeading{}, err
167+
}
168+
if settings == nil || settings.CustomProfile == nil {
169+
return RSSHeading{
170+
Title: "Memos",
171+
Description: "An open source, lightweight note-taking service. Easily capture and share your great thoughts.",
172+
}, nil
173+
}
174+
customProfile := settings.CustomProfile
175+
return RSSHeading{
176+
Title: customProfile.Title,
177+
Description: customProfile.Description,
178+
}, nil
179+
}

0 commit comments

Comments
 (0)