# Pull Request: SiteSetting 允许匿名用户为帖子进行点赞

**URL:** https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660
**Category:** Feature
**Tags:** completed
**Created:** [2023年六月16日 18:01 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660 "2023-06-16T18:01:18Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![meltingmettle\_gh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meltingmettle_gh/32/311873_2.png) [@meltingmettle\_gh](https://meta.discourse.org/u/meltingmettle_gh)
#### Post date: [2023年六月16日 18:01 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/1 "2023-06-16T18:01:18Z")

</div>

大家好，

我已提交一个 PR，允许匿名用户“点赞”帖子。这是一个 SiteSetting，管理员可以选择启用或禁用该功能。

可以请大家帮我进行代码审查吗？😄

> <https://github.com/discourse/discourse/pull/22131>
>
> This pull request adds a SiteSetting to allow admins to enable or disable anonym…ous liking.  
> 
> Changes:
> \- Add \`allow\_anonymous\_likes\` SiteSetting
> \- Tweak \`is\_my\_own?\` to recognize "like" post actions for anonymous users, since this behavior is required in order to allow anonymous users to remove their likes.
> \- Update post\_serializer to remove the \`:can\_act\` scope from anonymous users after \`post\_undo\_action\_window\_mins\` has closed.

背景：我参与了一个 501(c)3 组织，我们的账户都以真实姓名注册。  
我们鼓励匿名讨论，因为有些人想分享个人经历和敏感话题（例如心理健康、过去的痛苦回忆等）。匿名讨论非常丰富且有帮助，而添加匿名“点赞”功能将有助于我们衡量社区对某些话题的互动程度，在这些话题上，人们可能非常感同身受或表示赞同，但又不想公开自己的身份。

谢谢！！

---

<div class="post-metadata">

### Author: ![meltingmettle\_gh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meltingmettle_gh/32/311873_2.png) [@meltingmettle\_gh](https://meta.discourse.org/u/meltingmettle_gh)
#### Post date: [2023年六月20日 16:55 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/2 "2023-06-20T16:55:08Z")

</div>

有人能告诉我如何获得维护者审查和批准的流程吗？ 😃

谢谢！

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [2023年六月20日 17:55 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/5 "2023-06-20T17:55:21Z")

</div>

感谢您提交的 PR 和这个主题 @meltingmettle_gh，团队成员将很快审查该 PR。

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2023年六月23日 06:21 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/6 "2023-06-23T06:21:21Z")

</div>

您好，我们已审阅并留下了一些关于翻译和用户体验的评论。

---

<div class="post-metadata">

### Author: ![meltingmettle\_gh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meltingmettle_gh/32/311873_2.png) [@meltingmettle\_gh](https://meta.discourse.org/u/meltingmettle_gh)
#### Post date: [2023年七月12日 15:23 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/9 "2023-07-12T15:23:32Z")

</div>

您好！我已经更新了 PR，可以再次进行评审了。谢谢！

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2023年七月12日 16:48 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/10 "2023-07-12T16:48:33Z")

</div>

已审阅 – 仍需更多工作。感谢在此处提醒我！

---

<div class="post-metadata">

### Author: ![meltingmettle\_gh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meltingmettle_gh/32/311873_2.png) [@meltingmettle\_gh](https://meta.discourse.org/u/meltingmettle_gh)
#### Post date: [2023年七月13日 15:42 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/11 "2023-07-13T15:42:56Z")

</div>

我能否快速获得一个关于在哪里调用“disallow”图标的提示？我再看了一遍，但还是没弄明白。😅

来自 GH 评论：

> 你好 [@nattsw](https://github.com/nattsw)，感谢第二次审阅。我有点难以弄清楚“disallow”应该在哪里发生，因为 `post_undo_action_window_mins` 只在 `can_delete_post_action?` 中被引用，并且一旦 `post_undo_action_window_mins` 过期，该方法就会正确返回 false。
> 
> 然而，尽管该方法在窗口关闭后正确返回 false，但“disallow”符号并未出现，而且没有其他方法引用 `post_undo_action_window_mins`。我意识到 `can_delete_post_action?` 在页面加载时被调用，但我无法确定实际的“disallow”图标是在哪里被调用的。
> 
> 你能否指出调用“disallow”符号的代码块？谢谢！

> <https://github.com/discourse/discourse/pull/22131#issuecomment-1633386958>
>
> Hi @nattsw, thank you for the second review. I'm having a bit of trouble figuri…ng out where the disallow is supposed to happen since\`post\_undo\_action\_window\_mins\` is only referenced in \`can\_delete\_post\_action?\`, and the method is correctly returning false once the \`post\_undo\_action\_window\_mins\` has passed.
> 
> However, despite this method returning false correctly after the window has closed, the disallow symbol does not appear, but there is no other method that references \`post\_undo\_action\_window\_mins\`. I realize that \`can\_delete\_post\_action?\` is called when the page is loaded, but I can't quite locate where the actual disallow icon is invoked.
> 
> Could you please point me towards the block of code that calls the disallow symbol? Thank you!

---

<div class="post-metadata">

### Author: ![meltingmettle\_gh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meltingmettle_gh/32/311873_2.png) [@meltingmettle\_gh](https://meta.discourse.org/u/meltingmettle_gh)
#### Post date: [2023年七月18日 22:46 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/12 "2023-07-18T22:46:00Z")

</div>

感谢您的提示！非常有帮助！我已经推送了一个补丁，手动验证了行为，并增加了额外的测试覆盖。如果您有时间，可以再次进行评审。😃

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2023年七月21日 13:21 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/13 "2023-07-21T13:21:27Z")

</div>

非常感谢 Emmett 带来的这项功能，测试也很棒！我们期待您未来的贡献。

:git_merged:

抱歉，评审耽搁了！

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2023年七月26日 13:21 UTC](https://meta.discourse.org/t/pull-request-sitesetting-to-anonymous-users-to-like-posts/268660/14 "2023-07-26T13:21:16Z")

</div>

此主题已在 4 天后自动关闭。不再允许回复。
