From 7a12d375c15c9c14f516c1589ecf0e838472fbe0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 13 Mar 2025 21:26:34 +0800 Subject: [PATCH] :necktie: Drop sensitive posts from mastodon --- pkg/internal/services/mastodon/fetch.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/internal/services/mastodon/fetch.go b/pkg/internal/services/mastodon/fetch.go index f59955b..a4e1e32 100644 --- a/pkg/internal/services/mastodon/fetch.go +++ b/pkg/internal/services/mastodon/fetch.go @@ -21,10 +21,11 @@ type MastodomAttachment struct { } type MastodonPost struct { - ID string `json:"id"` - Content string `json:"content"` - URL string `json:"url"` - Account struct { + ID string `json:"id"` + Content string `json:"content"` + URL string `json:"url"` + Sensitive bool `json:"sensitive"` + Account struct { Acct string `json:"acct"` Username string `json:"username"` DisplayName string `json:"display_name"` @@ -84,6 +85,10 @@ func FetchTimeline(server string, limit int) ([]MastodonPost, error) { return nil, fmt.Errorf("failed to parse timeline JSON: %v", err) } + posts = lo.Filter(posts, func(item MastodonPost, index int) bool { + return !item.Sensitive + }) + for idx := range posts { posts[idx].Server = strings.Replace(strings.Replace(server, "https://", "", 1), "http://", "", 1) }