Skip to content

Conversation

@Twelveeee
Copy link
Contributor

@Twelveeee Twelveeee commented Nov 5, 2025

本次更新新增了对 RSSHub 访问密钥(AccessKey)的配置支持。该配置项的主要作用是:当 RSSHub 服务启用了基于访问密钥的访问控制机制时,用户可通过配置该密钥实现授权访问。此功能特别适用于 ZenFeed 与 RSSHub 服务部署在不同服务器上的场景,能够有效提升跨服务访问的安全性与便捷性。


This update introduces support for configuring the RSSHub AccessKey. The primary purpose of this configuration is to enable authorized access to RSSHub when it has access control enabled via an AccessKey. This feature is particularly useful in scenarios where ZenFeed and RSSHub are deployed on different servers, enhancing both security and convenience for cross-service access.

Sourcery 摘要

通过扩展配置模式、更新抓取器逻辑以将密钥附加到 URL,并添加相应的文档和测试,引入对 RSSHub 访问密钥的支持。

新功能:

  • 添加 RSSHubAccessKey 配置以启用对 RSSHub 的授权访问

改进:

  • 在构建 RSS feed URL 时,将提供的访问密钥作为查询参数附加
  • 将全局 RSSHubAccessKey 设置传播到每个 RSS 抓取源

文档:

  • 在英文和中文配置文件中记录 scrape.rsshub_access_key 字段

测试:

  • 添加单元测试以验证使用 RSSHub 访问密钥的 URL 构建,针对 RSSHub 端点和直接 feed URL
Original summary in English

Summary by Sourcery

Introduce support for an RSSHub access key by extending the config schema, updating the scraper logic to append the key to URLs, and adding corresponding documentation and tests

New Features:

  • Add RSSHubAccessKey configuration to enable authorized access to RSSHub

Enhancements:

  • Append the provided access key as a query parameter when constructing RSS feed URLs
  • Propagate the global RSSHubAccessKey setting into each RSS scrape source

Documentation:

  • Document the scrape.rsshub_access_key field in both English and Chinese configuration files

Tests:

  • Add unit tests to verify URL construction with the RSSHub access key for both RSSHub endpoints and direct feed URLs

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 5, 2025

审阅者指南

通过扩展配置模式、通过抓取管理器传递密钥、在 URL 验证中将其作为查询参数附加,并用更新的测试和文档覆盖该功能,引入对 RSSHub AccessKey 的支持。

从配置传递 RSSHubAccessKey 到 RSS 请求的序列图

sequenceDiagram
    participant Config
    participant ScrapeManager
    participant ScrapeSourceRSS
    participant RSSHub
    Config->>ScrapeManager: Provide RSSHubAccessKey
    ScrapeManager->>ScrapeSourceRSS: Set RSSHubAccessKey field
    ScrapeSourceRSS->>ScrapeSourceRSS: Validate() appends key to URL
    ScrapeSourceRSS->>RSSHub: Request with key as query parameter
Loading

更新后的 Scrape 和 ScrapeSourceRSS 实体的 ER 图

erDiagram
    Scrape {
        string RSSHubEndpoint
        string RSSHubAccessKey
    }
    ScrapeSource {
    }
    ScrapeSourceRSS {
        string URL
        string RSSHubEndpoint
        string RSSHubRoutePath
        string RSSHubAccessKey
    }
    Scrape ||--o{ ScrapeSource : contains
    ScrapeSource ||--|{ ScrapeSourceRSS : has
Loading

更新后的 ScrapeSourceRSS 和 Scrape 配置的类图

classDiagram
    class Scrape {
        Past: timeutil.Duration
        Interval: timeutil.Duration
        RSSHubEndpoint: string
        RSSHubAccessKey: string
        Sources: []ScrapeSource
    }
    class ScrapeSource {
        RSS: ScrapeSourceRSS
    }
    class ScrapeSourceRSS {
        URL: string
        RSSHubEndpoint: string
        RSSHubRoutePath: string
        RSSHubAccessKey: string
    }
    Scrape --> ScrapeSource
    ScrapeSource --> ScrapeSourceRSS
Loading

文件级别变更

变更 详情 文件
将 RSSHubAccessKey 引入抓取配置和传播中
  • 将 RSSHubAccessKey 字段添加到 Scrape 结构体
  • 在 ScrapeSourceRSS 结构体中包含 RSSHubAccessKey
  • 将 RSSHubAccessKey 从全局配置传播到管理器中的抓取器
pkg/config/config.go
pkg/scrape/scraper/rss.go
pkg/scrape/manager.go
在 RSS URL 验证中将访问密钥作为查询参数附加
  • 检查 AccessKey 是否非空以及是否不存在现有密钥参数
  • 相应地将 '?key=...' 或 '&key=...' 附加到 URL
pkg/scrape/scraper/rss.go
为 RSS 阅读器创建中的 RSSHubAccessKey 处理添加测试
  • 为带有端点、路由路径和 AccessKey 的 RSSHub 添加测试用例
  • 为带有 AccessKey 的通用 URL 添加测试用例
pkg/scrape/scraper/rss_test.go
更新文档以包含 RSSHubAccessKey 配置字段
  • 在英文文档中添加 rsshub_access_key 条目
  • 在中文文档中添加 rsshub_access_key 条目
docs/config.md
docs/config-zh.md

提示和命令

与 Sourcery 互动

  • 触发新评论: 在拉取请求上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评论。
  • 从评论生成 GitHub issue: 回复 Sourcery 的评论,请求它从该评论创建一个 issue。您也可以回复评论并加上 @sourcery-ai issue 来创建 issue。
  • 生成拉取请求标题: 随时在拉取请求标题的任意位置写入 @sourcery-ai 来生成标题。您也可以在拉取请求上评论 @sourcery-ai title 来随时(重新)生成标题。
  • 生成拉取请求摘要: 随时在拉取请求正文的任意位置写入 @sourcery-ai summary,以在您希望的位置生成 PR 摘要。您也可以在拉取请求上评论 @sourcery-ai summary 来随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求上评论 @sourcery-ai guide 来随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求上评论 @sourcery-ai resolve 来解决所有 Sourcery 评论。如果您已经处理了所有评论并且不想再看到它们,这会很有用。
  • 驳回所有 Sourcery 评论: 在拉取请求上评论 @sourcery-ai dismiss 来驳回所有现有的 Sourcery 评论。如果您想重新开始新的评论,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的评论!

自定义您的体验

访问您的 仪表盘 以:

  • 启用或禁用评论功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改评论语言。
  • 添加、删除或编辑自定义评论说明。
  • 调整其他评论设置。

获取帮助

Original review guide in English

Reviewer's Guide

Introduce support for RSSHub AccessKey by extending configuration schema, passing the key through the scrape manager, appending it as a query parameter in URL validation, and covering the feature with updated tests and documentation.

Sequence diagram for passing RSSHubAccessKey from config to RSS request

sequenceDiagram
    participant Config
    participant ScrapeManager
    participant ScrapeSourceRSS
    participant RSSHub
    Config->>ScrapeManager: Provide RSSHubAccessKey
    ScrapeManager->>ScrapeSourceRSS: Set RSSHubAccessKey field
    ScrapeSourceRSS->>ScrapeSourceRSS: Validate() appends key to URL
    ScrapeSourceRSS->>RSSHub: Request with key as query parameter
Loading

ER diagram for updated Scrape and ScrapeSourceRSS entities

erDiagram
    Scrape {
        string RSSHubEndpoint
        string RSSHubAccessKey
    }
    ScrapeSource {
    }
    ScrapeSourceRSS {
        string URL
        string RSSHubEndpoint
        string RSSHubRoutePath
        string RSSHubAccessKey
    }
    Scrape ||--o{ ScrapeSource : contains
    ScrapeSource ||--|{ ScrapeSourceRSS : has
Loading

Class diagram for updated ScrapeSourceRSS and Scrape configuration

classDiagram
    class Scrape {
        Past: timeutil.Duration
        Interval: timeutil.Duration
        RSSHubEndpoint: string
        RSSHubAccessKey: string
        Sources: []ScrapeSource
    }
    class ScrapeSource {
        RSS: ScrapeSourceRSS
    }
    class ScrapeSourceRSS {
        URL: string
        RSSHubEndpoint: string
        RSSHubRoutePath: string
        RSSHubAccessKey: string
    }
    Scrape --> ScrapeSource
    ScrapeSource --> ScrapeSourceRSS
Loading

File-Level Changes

Change Details Files
Introduce RSSHubAccessKey into scraping configuration and propagation
  • Add RSSHubAccessKey field to Scrape struct
  • Include RSSHubAccessKey in ScrapeSourceRSS struct
  • Propagate RSSHubAccessKey from global config to scraper in manager
pkg/config/config.go
pkg/scrape/scraper/rss.go
pkg/scrape/manager.go
Append access key as query parameter in RSS URL validation
  • Check for non-empty AccessKey and absence of existing key param
  • Append '?key=...' or '&key=...' to URL accordingly
pkg/scrape/scraper/rss.go
Add tests for RSSHubAccessKey handling in RSS reader creation
  • Add test case for RSSHub with endpoint, route path, and AccessKey
  • Add test case for generic URL with AccessKey
pkg/scrape/scraper/rss_test.go
Update documentation to include RSSHubAccessKey config field
  • Add entry for rsshub_access_key in English docs
  • Add entry for rsshub_access_key in Chinese docs
docs/config.md
docs/config-zh.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好 - 我已经审阅了你的更改 - 以下是一些反馈:

  • 考虑使用 net/url 包将访问密钥作为查询参数附加,而不是在 Validate() 中使用原始字符串拼接,这样可以更可靠地处理现有参数和 URL 编码。
  • 将 URL 构建逻辑(附加 ?key=)从 Validate() 中移出,放入专门的构造函数或设置方法中,以使验证无副作用且确定性。
  • 删除或取消注释 ScrapeSource 中被注释掉的 RSSHubAccessKey 字段,以保持代码和配置定义的一致性和清晰性。
AI 代理提示
请处理此代码审查中的评论:

## 总体评论
- 考虑使用 `net/url` 包将访问密钥作为查询参数附加,而不是在 `Validate()` 中使用原始字符串拼接,这样可以更可靠地处理现有参数和 URL 编码。
- 将 URL 构建逻辑(附加 `?key=`)从 `Validate()` 中移出,放入专门的构造函数或设置方法中,以使验证无副作用且确定性。
- 删除或取消注释 `ScrapeSource` 中被注释掉的 `RSSHubAccessKey` 字段,以保持代码和配置定义的一致性和清晰性。

Sourcery 对开源免费 - 如果您喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请点击每个评论上的 👍 或 👎,我将利用这些反馈来改进您的评论。
Original comment in English

Hey there - I've reviewed your changes - here's some feedback:

  • Consider using the net/url package to append the access key as a query parameter instead of raw string concatenation in Validate(), which will handle existing parameters and URL-encoding more reliably.
  • Move the URL‐building logic (appending ?key=) out of Validate() into a dedicated constructor or setup method to keep validation side‐effect-free and deterministic.
  • Remove or uncomment the commented-out RSSHubAccessKey field in ScrapeSource so the code and config definitions stay consistent and clear.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using the net/url package to append the access key as a query parameter instead of raw string concatenation in Validate(), which will handle existing parameters and URL-encoding more reliably.
- Move the URL‐building logic (appending `?key=`) out of Validate() into a dedicated constructor or setup method to keep validation side‐effect-free and deterministic.
- Remove or uncomment the commented-out RSSHubAccessKey field in ScrapeSource so the code and config definitions stay consistent and clear.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Twelveeee
Copy link
Contributor Author

@glidea 修复了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@glidea fixed

@glidea
Copy link
Owner

glidea commented Nov 6, 2025

佬 lint 没过

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Guy lint failed

@glidea glidea merged commit c03e4c8 into glidea:main Nov 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants