summaryrefslogtreecommitdiff
path: root/lib/feature_groups/gitlab_team_members.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/feature_groups/gitlab_team_members.rb')
-rw-r--r--lib/feature_groups/gitlab_team_members.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/feature_groups/gitlab_team_members.rb b/lib/feature_groups/gitlab_team_members.rb
new file mode 100644
index 00000000000..7f4c597fddd
--- /dev/null
+++ b/lib/feature_groups/gitlab_team_members.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module FeatureGroups
+ class GitlabTeamMembers
+ GITLAB_COM_GROUP_ID = 6543
+
+ class << self
+ def enabled?(thing)
+ return false unless Gitlab.com?
+
+ team_member?(thing)
+ end
+
+ private
+
+ def team_member?(thing)
+ thing.is_a?(::User) && gitlab_com_member_ids.include?(thing.id)
+ end
+
+ def gitlab_com
+ @gitlab_com ||= ::Group.find(GITLAB_COM_GROUP_ID)
+ end
+
+ def gitlab_com_member_ids
+ Rails.cache.fetch("gitlab_team_members", expires_in: 1.hour) do
+ gitlab_com.members.pluck_user_ids.to_set
+ end
+ end
+ end
+ end
+end