Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加blocklist支持 #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

添加blocklist支持 #8

wants to merge 1 commit into from

Conversation

CDN18
Copy link
Contributor

@CDN18 CDN18 commented Oct 23, 2024

此PR为wxwClub添加了基本的blocklist管理功能:

动机

昨天 board 公共留言板遭遇恶意用户发送多条骚扰信息。另外我在日常浏览中曾多次看到有用户抱怨board被滥用。所以实现并提出了此PR。如果通过测试并实装,希望能够减少对board的滥用。

新增功能

  1. 支持增删针对用户和实例的blocklist
  2. 支持全局屏蔽和针对特定club的屏蔽
  3. 提供cli command进行屏蔽管理
  4. 支持blocklist的导入和导出功能

实例屏蔽包括实例域名和该域名下所有子域,屏蔽检查发生在Club_Announce_Process时,对actor进行blocklist匹配。

数据库变更

创建新表users_blocksinstances_blocks。由于wxwClub目前只有单个SQL文件,不提供迁移支持,在创建新表的指令前添加了对应注释和日期以供区分。

  1. cli.php中添加了新的命令行选项,用于管理屏蔽列表
  2. src/function.php中实现了屏蔽相关的核心功能
  3. 更新了数据库结构,添加了users_blocksinstances_blocks
  4. 在活动处理逻辑中集成了屏蔽检查

CLI 变更

添加以下 CLI 命令来管理 blocklist:

  1. 添加单条屏蔽规则:
  • php cli.php block user <user> [<club>]
  • php cli.php block instance <instance> [<club>]
  1. 移除单条屏蔽规则:
  • php cli.php unblock user <user> [<club>]
  • php cli.php unblock instance <instance> [<club>]
  1. 列出屏蔽规则:
  • php cli.php list-blocks [<club>]
  1. 导出屏蔽规则:
  • php cli.php export-blocks [<club>]
  1. 批量导入屏蔽规则(支持去重):
  • php cli.php import-blocks <user|instance> <file_path> [<club>]

TODO

  1. 当前blocklist仅作静默过滤。后续应考虑发送Reject回应或在特定endpoint公开blocklist。
  2. 由于可运行多个wxwClub worker 队列,难以将数据库查询缓存到内存中,可能后续借助 redis 等会方便一些。

@CDN18
Copy link
Contributor Author

CDN18 commented Oct 23, 2024

我自行搭建实例测试了此 PR 的各项功能,均工作正常。

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.

1 participant