From e7788b6dcaaa7116ad990320cf62b8467c644c6a Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 5 Nov 2009 01:50:55 +0100 Subject: [PATCH] Girocco::Notify: Include pusher info in json payload --- Girocco/Notify.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Girocco/Notify.pm b/Girocco/Notify.pm index a9f8c50..32c89bf 100644 --- a/Girocco/Notify.pm +++ b/Girocco/Notify.pm @@ -58,7 +58,15 @@ sub json_commit { } sub json { - my ($url, $proj, $ref, $oldrev, $newrev) = @_; + my ($url, $proj, $user, $ref, $oldrev, $newrev) = @_; + + my $pusher = {}; + if ($user) { + $pusher = { "name" => $user->{name} }; + if ($user->{name} ne 'mob') { + $pusher->{"email"} = $user->{email}; + } + } my $commits = []; @@ -66,6 +74,8 @@ sub json { push @$commits, json_commit($proj, $commit); } + # This is backwards-compatible with GitHub (except the GitHub-specific + # full project name construction sometimes performed in clients) my $payload = encode_json { "before" => $oldrev, "after" => $newrev, @@ -84,9 +94,13 @@ sub json { "owner" => { "name" => "", "email" => $proj->{email} } }, + # Girocco extension + "pusher" => $pusher, + "commits" => $commits }; + # print "$payload\n"; my $ua = LWP::UserAgent->new; $ua->timeout(5); $ua->post($url, { payload => $payload }); @@ -150,7 +164,7 @@ sub ref_change { # Next, send JSON packet to given URL if enabled. if ($proj->{notifyjson}) { - json($proj->{notifyjson}, $proj, $ref, $oldrev, $newrev); + json($proj->{notifyjson}, $proj, $user, $ref, $oldrev, $newrev); } } -- 2.11.4.GIT