2022-06-09 22:57:36 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class WebhookPolicy < ApplicationPolicy
|
|
|
|
def index?
|
2022-07-05 03:41:40 +03:00
|
|
|
role.can?(:manage_webhooks)
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
2022-07-05 03:41:40 +03:00
|
|
|
role.can?(:manage_webhooks)
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def show?
|
2022-07-05 03:41:40 +03:00
|
|
|
role.can?(:manage_webhooks)
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
2023-06-22 15:52:25 +03:00
|
|
|
role.can?(:manage_webhooks) && record.required_permissions.all? { |permission| role.can?(permission) }
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def enable?
|
2022-07-05 03:41:40 +03:00
|
|
|
role.can?(:manage_webhooks)
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def disable?
|
2022-07-05 03:41:40 +03:00
|
|
|
role.can?(:manage_webhooks)
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def rotate_secret?
|
2022-07-05 03:41:40 +03:00
|
|
|
role.can?(:manage_webhooks)
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
2023-06-22 15:52:25 +03:00
|
|
|
role.can?(:manage_webhooks) && record.required_permissions.all? { |permission| role.can?(permission) }
|
2022-06-09 22:57:36 +03:00
|
|
|
end
|
|
|
|
end
|