Skip to content

Commit

Permalink
[FIXED JENKINS-8594] new option to allow the user's e-mail address to…
Browse files Browse the repository at this point in the history
… be used as the Jabber id
  • Loading branch information
kutzi committed Jun 26, 2011
1 parent 6980143 commit 47f9241
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
@@ -1,6 +1,7 @@
package hudson.plugins.jabber.im.transport;

import hudson.Extension;
import hudson.Util;
import hudson.model.User;
import hudson.plugins.im.DefaultIMMessageTarget;
import hudson.plugins.im.GroupChatIMMessageTarget;
Expand All @@ -15,6 +16,7 @@
import hudson.plugins.jabber.user.JabberUserProperty;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Mailer;
import hudson.tasks.Publisher;

import java.util.List;
Expand Down Expand Up @@ -106,7 +108,7 @@ public JabberPublisher(List<IMMessageTarget> targets, String notificationStrateg
}

@Override
public BuildStepDescriptor<Publisher> getDescriptor() {
public JabberPublisherDescriptor getDescriptor() {
return JabberPublisher.DESCRIPTOR;
}

Expand All @@ -122,9 +124,20 @@ protected String getPluginName() {

@Override
protected String getConfiguredIMId(User user) {
JabberUserProperty jabberUserProperty = (JabberUserProperty) user.getProperties().get(JabberUserProperty.DESCRIPTOR);
if (jabberUserProperty != null) {
return jabberUserProperty.getJid();
// if set, user property override all other settings:
JabberUserProperty jabberUserProperty = (JabberUserProperty) user.getProperties().get(JabberUserProperty.DESCRIPTOR);
if (jabberUserProperty != null) {
return jabberUserProperty.getJid();
}

if (getDescriptor().isEmailAddressAsJabberId()) {
Mailer.UserProperty mailProperty = user.getProperty(Mailer.UserProperty.class);
if (mailProperty != null) {
String emailAddress = mailProperty.getAddress();
if (Util.fixEmpty(emailAddress) != null) {
return emailAddress;
}
}
}
return null;
}
Expand Down
Expand Up @@ -69,6 +69,7 @@ public class JabberPublisherDescriptor extends BuildStepDescriptor<Publisher> im
public static final String PARAMETERNAME_COMMAND_PREFIX = PREFIX + "commandPrefix";
public static final String PARAMETERNAME_DEFAULT_ID_SUFFIX = PREFIX + "defaultIdSuffix";
public static final String PARAMETERNAME_SUBSCRIPTION_MODE = PREFIX + "subscriptionMode";
public static final String PARAMETERNAME_EMAIL_ADDRESS_AS_JABBERID = PREFIX + "emailAsJabberId";
public static final String[] PARAMETERVALUE_SUBSCRIPTION_MODE;
public static final String[] PARAMETERVALUE_PROXYTYPES;
static {
Expand Down Expand Up @@ -115,6 +116,7 @@ public class JabberPublisherDescriptor extends BuildStepDescriptor<Publisher> im
private String hudsonCiLogin;
private String hudsonCiPassword;
private String subscriptionMode = SubscriptionMode.accept_all.name();
private boolean emailAddressAsJabberId;

// Proxy parameters
private ProxyType proxyType = ProxyType.NONE;
Expand Down Expand Up @@ -433,6 +435,10 @@ public String getInitialGroupChats() {
return Util.fixEmptyAndTrim(this.initialGroupChats);
}

public boolean isEmailAddressAsJabberId() {
return emailAddressAsJabberId;
}

@Override
public String getDefaultIdSuffix() {
return this.defaultIdSuffix;
Expand Down Expand Up @@ -555,6 +561,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws hudson.mode
this.exposePresence = req.getParameter(PARAMETERNAME_PRESENCE) != null;
this.enableSASL = req.getParameter(PARAMETERNAME_SASL) != null;
this.subscriptionMode = Util.fixEmptyAndTrim(req.getParameter(PARAMETERNAME_SUBSCRIPTION_MODE));
this.emailAddressAsJabberId = req.getParameter(PARAMETERNAME_EMAIL_ADDRESS_AS_JABBERID) != null;
applyHostname(req, this.enabled);
applyPort(req, this.enabled);
applyNickname(req, this.enabled);
Expand Down
Expand Up @@ -33,6 +33,9 @@
<f:textbox name="${descriptor.PARAMETERNAME_DEFAULT_ID_SUFFIX}"
value="${descriptor.defaultIdSuffix}" />
</f:entry>
<f:entry title="E-mail address as Jabber ID" help="${base}/help-email-address-as-jabberid.html">
<f:checkbox name="${descriptor.PARAMETERNAME_EMAIL_ADDRESS_AS_JABBERID}" checked="${descriptor.emailAddressAsJabberId}"/>
</f:entry>
<f:entry title="Enable SASL authentication" help="${base}/help-sasl.html">
<f:checkbox name="${descriptor.PARAMETERNAME_SASL}" checked="${descriptor.enableSASL}"/>
</f:entry>
Expand Down

0 comments on commit 47f9241

Please sign in to comment.