|
|
|
@@ -190,22 +190,24 @@ module ProjectOperable |
|
|
|
end |
|
|
|
|
|
|
|
# 项目管理员(包含项目拥有者),权限:仓库设置、仓库可读可写 |
|
|
|
# 增加bot用户权限,已安装bot,当前bot用户即拥有权限,权限粒度待完善 |
|
|
|
def manager?(user) |
|
|
|
if owner.is_a?(User) |
|
|
|
managers.exists?(user_id: user.id) |
|
|
|
managers.exists?(user_id: user.id) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) |
|
|
|
elsif owner.is_a?(Organization) |
|
|
|
managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || (owner.is_only_admin?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) |
|
|
|
managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || (owner.is_only_admin?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) |
|
|
|
else |
|
|
|
false |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
# 项目开发者,可读可写权限 |
|
|
|
# 增加bot用户权限,已安装当前bot用户对应的bot即拥有权限,权限粒度待完善 |
|
|
|
def develper?(user) |
|
|
|
if owner.is_a?(User) |
|
|
|
developers.exists?(user_id: user.id) |
|
|
|
developers.exists?(user_id: user.id) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) |
|
|
|
elsif owner.is_a?(Organization) |
|
|
|
developers.exists?(user_id: user.id) || (owner.is_only_write?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) |
|
|
|
developers.exists?(user_id: user.id) || (owner.is_only_write?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) |
|
|
|
else |
|
|
|
false |
|
|
|
end |
|
|
|
|