Comparing version 0.2.16 to 0.2.17
@@ -79,2 +79,3 @@ var request = require("request"); | ||
if (hosts) { | ||
self._registrations = {}; | ||
self.logger.info("Registering plugin..."); | ||
@@ -92,5 +93,5 @@ process.once("SIGINT", function () { | ||
self.on("remote_plugin_installed", function (key, settings) { | ||
if (host.url === settings.baseUrl) { | ||
self.logger.info("Registered with " + host.url + "."); | ||
host.key = settings.clientKey; | ||
if (stripCredentials(host) === settings.baseUrl) { | ||
self.logger.info("Registered with " + settings.baseUrl + "."); | ||
self._registrations[host] = settings.clientKey; | ||
// @todo unsubscribe this webhook listener | ||
@@ -137,4 +138,4 @@ } | ||
var self = this; | ||
var hosts = this.config.hosts(); | ||
if (hosts) { | ||
if (self._registrations) { | ||
var hosts = _.keys(self._registrations); | ||
self.logger.info("Deregistering plugin..."); | ||
@@ -147,3 +148,5 @@ return Q.allResolved(hosts.map(_.bind(deregister, self))).then( | ||
// @todo is there an uninstall webhook we can listen for for parity with register? | ||
self.logger.info("Deregistered with host " + host.url + "."); | ||
var bareHost = stripCredentials(host); | ||
delete self._registrations[bareHost]; | ||
self.logger.info("Deregistered with host " + bareHost + "."); | ||
} | ||
@@ -204,2 +207,8 @@ }); | ||
function stripCredentials(url) { | ||
url = urls.parse(url); | ||
delete url.auth; | ||
return urls.format(url); | ||
} | ||
module.exports = function (app, logger) { | ||
@@ -206,0 +215,0 @@ if (!logger) logger = Logger(); |
@@ -42,3 +42,3 @@ var _ = require("underscore"); | ||
var row = result.rows[0]; | ||
if (row.hash) { | ||
if (row && row.hash) { | ||
var hs = row.hash; | ||
@@ -45,0 +45,0 @@ hstore.parse(hs, dfd.resolve); |
{ | ||
"name": "ap3", | ||
"version": "0.2.16", | ||
"version": "0.2.17", | ||
"description": "Helper package for Atlassian Plugins 3 add-ons running on Express", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34082
882