Created
August 16, 2017 16:00
-
-
Save darkwing/a09ed836ef4c7e61e8e32ca837cb29e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Bugzilla::Extension::PhabBugz::WebService; | |
use 5.10.1; | |
use strict; | |
use warnings; | |
use base qw(Bugzilla::WebService); | |
use Bugzilla::Attachment; | |
use Bugzilla::Bug; | |
use Bugzilla::BugMail; | |
use Bugzilla::Constants; | |
use Bugzilla::Error; | |
use Bugzilla::User; | |
use Bugzilla::Util qw(correct_urlbase detaint_natural); | |
use Bugzilla::WebService::Constants; | |
use MIME::Base64 qw(decode_base64); | |
use constant PUBLIC_METHODS => qw( | |
revision | |
); | |
sub check_user_permission_for_bug { | |
my ($self, $params) = @_; | |
my $user = Bugzilla->login(LOGIN_REQUIRED); | |
my $target_user = Bugzilla::User->check({ id => $params->{user_id}, cache => 1 }); | |
return { | |
result => $target_user->can_see_bug($params->{bug_id}) | |
}; | |
} | |
sub rest_resources { | |
return [ | |
qr{^/phabbugz/check_bug/(\d+)/(\d+)$}, { | |
GET => { | |
method => 'check_user_permission_for_bug', | |
params => sub { | |
return { bug_id => $_[0], user_id => $_[1] }; | |
} | |
} | |
} | |
]; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment