[go: up one dir, main page]

Skip to content

Follow-up from adding broadcast messages to blocked webhooks

The following discussions from !205715 (merged) should be addressed:

  • @SamWord started a discussion: (+5 comments)

    Thought: I wonder if we'll need to implement some kind of way to delete broadcast messages on hooks that get updated (i.e. a user attempts to resolve the problem). An example scenario:

    • A group owner creates a group hook for push and pipeline events for their top-level group
    • Shortly after, they see a rate limit error on the group hook
    • They decide to break up the webhook so that the top-level webhook handles pipeline events only, and they create new webhooks for push events on only the most critical projects to avoid hitting the rate limit and missing important updates from those projects.
    • The owner dismisses the banner message since they fixed the issue.
    • Within the year, the number of pipeline events in the group rises or they make the webhook respond to another common event, causing it to hit rate limits again
    • Because the owner didn't delete the top-level group hook or change its name, the first broadcast message still exists as a future message, and we'd skip creating a new banner message because its message matches even though the owner fixed the original problem. Because the group owner already dismissed the original message, they won't see another rate limit banner message for a whole year, even if the root cause is different
  • @SamWord started a discussion: (+4 comments)

    Suggestion: For translations, it'd be best to not interpolate the hook type, though I think the name and ID section are fine to interpolate

Something like this should work:

def broadcast_message_params(reason)
  base_params = {
    starts_at: Time.current,
    ends_at: 3.months.from_now,
    dismissable: true,
    theme: "light-red"
  }

  # reason must be passed like this with punctuation: broadcast_message_params(s_("Webhook rate limit exceeded."))

   hook_info = format(s_("WebHooks|%{hook_name} (ID: %{hook_id})"), hook_name: hook.name, hook_id: hook.id)

   hook_params = case hook
                 when SystemHook
                   {
                      help_text: s_("WebHooks|Update or delete the following system hook:")
                      target_path: "/admin",
                      target_access_levels: []
                    }
                 when ProjectHook
                    {
                      help_text: s_("WebHooks|Update or delete the following project hook:")
                      target_path: "/#{hook.project.full_path}",
                      target_access_levels: [Gitlab::Access::OWNER]
                    }
                 when defined?(GroupHook) && GroupHook
                    {
                      help_text: s_("WebHooks|Update or delete the following group hook:")
                      target_path: "/#{hook.group.full_path}",
                      target_access_levels: [Gitlab::Access::OWNER]
                    }
                  end

    hook_params[:message] = [reason, hook_params.delete!(:help_text), hook_info].join(' ')

    base_params.merge(hook_params)
  end
Edited by Carla Drago