From ce080c6dcec309fa3bcfb922c834266166e57af4 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Mon, 31 Jul 2017 16:44:31 -0500 Subject: Bug 1383108 - Sync security groups with Phabricator push connector r=dkl --- extensions/PhabBugz/lib/Util.pm | 34 ++++++++++++++++++++++++++++++++++ extensions/PhabBugz/lib/WebService.pm | 3 ++- 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'extensions/PhabBugz/lib') diff --git a/extensions/PhabBugz/lib/Util.pm b/extensions/PhabBugz/lib/Util.pm index cbbca7eab..75c523ad5 100644 --- a/extensions/PhabBugz/lib/Util.pm +++ b/extensions/PhabBugz/lib/Util.pm @@ -20,6 +20,7 @@ use LWP::UserAgent; use base qw(Exporter); our @EXPORT = qw( + add_comment_to_revision create_revision_attachment create_private_revision_policy create_project @@ -29,6 +30,7 @@ our @EXPORT = qw( get_project_phid get_revisions_by_ids intersect + make_revision_private make_revision_public request set_project_members @@ -141,6 +143,23 @@ sub make_revision_public { }); } +sub make_revision_private { + my ($revision_phid) = @_; + return request('differential.revision.edit', { + transactions => [ + { + type => "view", + value => "admin" + }, + { + type => "edit", + value => "admin" + } + ], + objectIdentifier => $revision_phid + }); +} + sub edit_revision_policy { my ($revision_phid, $policy_phid, $subscribers) = @_; @@ -168,6 +187,21 @@ sub edit_revision_policy { return request('differential.revision.edit', $data); } +sub add_comment_to_revision { + my ($revision_phid, $comment) = @_; + + my $data = { + transactions => [ + { + type => 'comment', + value => $comment + } + ], + objectIdentifier => $revision_phid + }; + return request('differential.revision.edit', $data); +} + sub get_project_phid { my $project = shift; diff --git a/extensions/PhabBugz/lib/WebService.pm b/extensions/PhabBugz/lib/WebService.pm index 217ed18dc..11439ba70 100644 --- a/extensions/PhabBugz/lib/WebService.pm +++ b/extensions/PhabBugz/lib/WebService.pm @@ -17,6 +17,7 @@ use Bugzilla::Attachment; use Bugzilla::Bug; use Bugzilla::BugMail; use Bugzilla::Error; +use Bugzilla::Extension::Push::Util qw(is_public); use Bugzilla::User; use Bugzilla::Util qw(correct_urlbase detaint_natural); use Bugzilla::WebService::Constants; @@ -61,7 +62,7 @@ sub revision { # If bug is public then remove privacy policy my $result; - if (!@{ $bug->groups_in }) { + if (is_public($bug)) { $result = make_revision_public($revision_id); } # Else bug is private -- cgit v1.2.3-24-g4f1b