Skip to content
Permalink
Browse files

[JENKINS-9694] bot permissions didn't apply for userstat command

  • Loading branch information...
kutzi committed May 17, 2011
1 parent 4044cfa commit fc92b63f40f68313582ea33f67d6184c218db5f8
Showing with 16 additions and 2 deletions.
  1. +16 −2 src/main/java/hudson/plugins/im/bot/UserStatCommand.java
@@ -2,6 +2,7 @@

import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.User;
import hudson.plugins.cigame.UserScoreProperty;
import hudson.plugins.im.Sender;
@@ -22,6 +23,12 @@ protected String getReply(Bot bot, Sender sender, String[] args) {
String userName = args[1];
User user = User.get(userName, false);
if (user != null) {

String checkPermission = checkPermission(user, sender);
if (checkPermission != null) {
return checkPermission;
}

StringBuilder buf = new StringBuilder();
buf.append(userName).append(":");

@@ -51,11 +58,18 @@ protected String getReply(Bot bot, Sender sender, String[] args) {
}
return buf.toString();
} else {
return "Don't know a user named " + userName;
return sender.getNickname() + ": don't know a user named " + userName;
}
}

@Override
private String checkPermission(User user, Sender sender) {
if (!user.hasPermission(Item.READ)) {
return sender.getNickname() + ": you may not read that user!";
}
return null;
}

@Override
public String getHelp() {
return " <username> - prints information about a Hudson user";
}

0 comments on commit fc92b63

Please sign in to comment.
You can’t perform that action at this time.