Skip to content

Instantly share code, notes, and snippets.

@darkwing
Created August 16, 2017 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkwing/a09ed836ef4c7e61e8e32ca837cb29e3 to your computer and use it in GitHub Desktop.
Save darkwing/a09ed836ef4c7e61e8e32ca837cb29e3 to your computer and use it in GitHub Desktop.
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