Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
release more robust version of integration, prepare compatiblity with…
Browse files Browse the repository at this point in the history
… Zimbra 9 Zimlet
  • Loading branch information
Barry de Graaff committed Feb 19, 2020
1 parent 6380b9b commit 332feea
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 119 deletions.
17 changes: 0 additions & 17 deletions extension/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified extension/out/artifacts/extension_jar/extension.jar
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion extension/src/tk/barrydegraaff/rocket/Rocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc
case "createUser":
String password = newPassword();
if (this.createUser(zimbraAccount.getName(), zimbraAccount.getGivenName() + " " + zimbraAccount.getSn(), password, zimbraAccount.getName().replace("@", "."), zimbraAccount)) {
resp.setHeader("Content-Type", "text/plain");
responseWriter("ok", resp, password);
} else {
responseWriter("error", resp, null);
Expand Down Expand Up @@ -260,17 +261,20 @@ private void responseWriter(String action, HttpServletResponse resp, String mess
case "ok":
resp.setStatus(HttpServletResponse.SC_OK);
if (message == null) {
resp.setHeader("Content-Type", "text/plain");
resp.getWriter().write("OK");
} else {
resp.getWriter().write(message);
}
break;
case "unauthorized":
resp.setHeader("Content-Type", "text/html");
resp.setStatus(HttpServletResponse.SC_OK);
resp.getWriter().write("<html><head></head><body><div style=\"background-color:white;color:black;padding:10px\">Please <a target=\"_blank\" href=\"" + this.loginurl + "\">Log in</a>.</div></body>");
break;
case "error":
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.setHeader("Content-Type", "text/plain");
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
resp.getWriter().write("The request did not succeed successfully.");
break;
}
Expand Down
Empty file modified zimlet/com_zimbra_rocket/com_zimbra_rocket.css
100755 → 100644
Empty file.
87 changes: 6 additions & 81 deletions zimlet/com_zimbra_rocket/com_zimbra_rocket.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ ZimbraRocketZimlet.prototype.init = function () {
try {
var zimletInstance = appCtxt._zimletMgr.getZimletByName('com_zimbra_rocket').handlerObject;
zimletInstance.rocketurl = zimletInstance._zimletContext.getConfig("rocketurl");
zimletInstance.createRocketAccount = zimletInstance._zimletContext.getConfig("createRocketAccount");
zimletInstance.accountCreateInteger = zimletInstance._zimletContext.getConfig("accountCreateInteger");
zimletInstance.userAccountCreateInteger = zimletInstance.getUserProperty("accountCreateInteger")
zimletInstance.createRocketAccount = zimletInstance._zimletContext.getConfig("createRocketAccount");

if(!zimletInstance.userAccountCreateInteger)
{
Expand All @@ -21,15 +19,7 @@ ZimbraRocketZimlet.prototype.init = function () {

if(zimletInstance.createRocketAccount == "true")
{
if(parseInt(zimletInstance.accountCreateInteger) > parseInt(zimletInstance.userAccountCreateInteger))
{
zimletInstance.setUserProperty("accountCreateInteger", zimletInstance.accountCreateInteger, true);
ZimbraRocketZimlet.prototype.createAccount();
}
else
{
ZimbraRocketZimlet.prototype.setIframe();
}
ZimbraRocketZimlet.prototype.createAccount();
}
else
{
Expand All @@ -52,25 +42,6 @@ ZimbraRocketZimlet.prototype.setIframe = function()
} catch (err) { console.log (err)}
};

/* status method show a Zimbra status message
* */
ZimbraRocketZimlet.prototype.status = function(text, type) {
var transitions = [ ZmToast.FADE_IN, ZmToast.PAUSE, ZmToast.FADE_OUT ];
appCtxt.getAppController().setStatusMsg(text, type, null, transitions);
};

/* Called when the panel is double-clicked.
*/
ZimbraRocketZimlet.prototype.doubleClicked = function() {
this.singleClicked();
};

/* Called when the panel is single-clicked.
*/
ZimbraRocketZimlet.prototype.singleClicked = function() {

};

/**
* This method gets called by the Zimlet framework each time the application is opened or closed.
*
Expand Down Expand Up @@ -124,58 +95,12 @@ ZimbraRocketZimlet.prototype.createAccount = function()
console.log(err);
};

xhr.send();
xhr.onreadystatechange = function (oEvent)
xhr.onload = function (oEvent)
{
if (xhr.readyState === 4)
{
if (xhr.status === 200)
{
if(xhr.response)
{
var zimletInstance = appCtxt._zimletMgr.getZimletByName('com_zimbra_rocket').handlerObject;
zimletInstance._dialog = new ZmDialog( { title:'Your Rocket Chat Account is created', parent:zimletInstance.getShell(), standardButtons:[DwtDialog.OK_BUTTON], disposeOnPopDown:true } );
zimletInstance._dialog.setContent(
'<div style="width:450px; height:160px;">'+
'Your Rocket Chat account has been created!<br><br>'+
'Here are your credentials for the Rocket.Chat App on Android and iPhone:<br>'+
'<textarea style="width:100%" rows=2>Username: '+appCtxt.getActiveAccount().name.replace('@','.')+'\r\nPassword: '+xhr.response+'</textarea><br><br>'+
'Please store these credentials.<br>'+
'</div>'
);

zimletInstance._dialog.setButtonListener(DwtDialog.OK_BUTTON, new AjxListener(zimletInstance, zimletInstance._cancelBtn));
zimletInstance._dialog.setEnterListener(new AjxListener(zimletInstance, zimletInstance._cancelBtn));

document.getElementById(zimletInstance._dialog.__internalId+'_handle').style.backgroundColor = '#eeeeee';
document.getElementById(zimletInstance._dialog.__internalId+'_title').style.textAlign = 'center';
zimletInstance._dialog.popup();
ZimbraRocketZimlet.prototype.setIframe();
}
}
if (xhr.status === 500)
{
if(xhr.response)
{
ZimbraRocketZimlet.prototype.status("Could not create your Rocket Chat Account", ZmStatusView.LEVEL_CRITICAL);
ZimbraRocketZimlet.prototype.setIframe();
}
}

}
}
ZimbraRocketZimlet.prototype.setIframe();
};
xhr.send();
} catch (err) {
console.log(err);
}
};

ZimbraRocketZimlet.prototype._cancelBtn =
function() {
var zimletInstance = appCtxt._zimletMgr.getZimletByName('com_zimbra_rocket').handlerObject;

try{
zimletInstance._dialog.setContent('');
zimletInstance._dialog.popdown();
}
catch (err) {}
};
5 changes: 1 addition & 4 deletions zimlet/com_zimbra_rocket/com_zimbra_rocket.xml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<zimlet name="com_zimbra_rocket"
version="0.0.4"
version="0.0.5"
target="main compose-window view-window"
label="Zimbra Rocket"
description="Zimbra Rocket">
<include>com_zimbra_rocket.js</include>
<includeCSS>com_zimbra_rocket.css</includeCSS>
<handlerObject>com_zimbra_rocket_HandlerObject</handlerObject>
<userProperties>
<property type="string" label="" name="accountCreateInteger" rows="1"/>
</userProperties>
</zimlet>
17 changes: 1 addition & 16 deletions zimlet/com_zimbra_rocket/config_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,12 @@ rocketurl = the url to your rocket chat instance
The rocket Zimbra server extension automatically creates
accounts for each Zimbra account in Rocket, to enable account
creation set createRocketAccount = true
accountCreateInteger (for migration purposes)
Whenever the account has been created by Zimbra the accountCreateInteger
on the Users Zimlet userProperties is incremented. The Zimlet will not
re-attempt to create the users account, unless the accountCreateInteger
in the Users Zimlet userProperties is < the one set in the Zimlets configuration
template.
This will help you in case you want to run a fresh install of Rocket, but with
an existing deployment of Zimbra OR in case you merge multiple Zimbra instances
to a single instance. In which case you can increment the accountCreateInteger
in the configuration template to make sure all users have their account
created.
-->
<zimletConfig name="com_zimbra_rocket" version="1.0">
<global>
<property name="rocketurl">https://rocketserverhere.org/</property>
<property name="createRocketAccount">true</property>
<property name="accountCreateInteger">1</property>
</global>
</zimletConfig>

0 comments on commit 332feea

Please sign in to comment.