You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/01/10 17:22:21 UTC
[whimsy] 07/12: Add karma check
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch mod-gui
in repository https://gitbox.apache.org/repos/asf/whimsy.git
commit 7e345e70a97c6a9a16b0bbe1bf02e2c89b286e2a
Author: Sebb <se...@apache.org>
AuthorDate: Wed Jan 9 23:36:12 2019 +0000
Add karma check
---
www/moderation/desk/models/mailbox.rb | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/www/moderation/desk/models/mailbox.rb b/www/moderation/desk/models/mailbox.rb
index a1a3c35..1dc18a9 100644
--- a/www/moderation/desk/models/mailbox.rb
+++ b/www/moderation/desk/models/mailbox.rb
@@ -13,6 +13,7 @@ require 'yaml'
require_relative '../config.rb'
require_relative 'message.rb'
+require_relative 'auth.rb'
class Mailbox
@@ -181,7 +182,16 @@ class Mailbox
# Is the message visible to the caller?
# e.g. private and security lists are generally not visible to all
def self.message_visible?(message)
- message[:public] # || ASF member || PMC member
+ message[:public] and return true # shortcut because auth may be expensive
+ info = Auth.info({})
+ visible = info[:member]
+ visible ||= (message[:domain]||'').match(%r{^(.+)\.apache\.org$}) do |m|
+ group,_ = m.captures
+ # (P)PMC member?
+ groups = info[:project_owners] || []
+ groups.include? group
+ end
+ visible
end
def message_active?(status)