File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
lib/algora_web/controllers/webhooks Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,13 @@ defmodule AlgoraWeb.Webhooks.GithubController do
1616
1717 def new ( conn , params ) do
1818 with { :ok , webhook } <- Webhook . new ( conn ) ,
19+ :ok <- ensure_human_author ( webhook , params ) ,
1920 { :ok , _ } <- process_commands ( webhook , params ) do
2021 conn |> put_status ( :accepted ) |> json ( % { status: "ok" } )
2122 else
23+ { :error , :bot_event } ->
24+ conn |> put_status ( :ok ) |> json ( % { status: "ok" } )
25+
2226 { :error , :missing_header } ->
2327 conn |> put_status ( :bad_request ) |> json ( % { error: "Missing header" } )
2428
@@ -35,6 +39,13 @@ defmodule AlgoraWeb.Webhooks.GithubController do
3539 conn |> put_status ( :internal_server_error ) |> json ( % { error: "Internal server error" } )
3640 end
3741
42+ defp ensure_human_author ( % Webhook { event: event } , params ) do
43+ case get_author ( event , params ) do
44+ % { "type" => "Bot" } -> { :error , :bot_event }
45+ _ -> :ok
46+ end
47+ end
48+
3849 # TODO: cache installation tokens
3950 # TODO: check org permissions on algora
4051 defp get_permissions ( author , % { "repository" => repository , "installation" => installation } ) do
You can’t perform that action at this time.
0 commit comments