diff --git a/package.json b/package.json index 9796461..ae63556 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "taskcluster-lib-loader": "^10.0.1", "taskcluster-lib-monitor": "^10.0.0", "taskcluster-lib-pulse": "^11.1.0", + "taskcluster-lib-urls": "^12.0.0", "taskcluster-lib-validate": "^12.0.0", "typed-env-config": "^2.0.0" }, diff --git a/src/api.js b/src/api.js index a0a8b92..030bf17 100644 --- a/src/api.js +++ b/src/api.js @@ -4,9 +4,8 @@ const debug = require('debug')('notify'); const builder = new APIBuilder({ title: 'Notification Service', description: [ - 'The notification service, typically available at `notify.taskcluster.net`', - 'listens for tasks with associated notifications and handles requests to', - 'send emails and post pulse messages.', + 'The notification service listens for tasks with associated notifications', + 'and handles requests to send emails and post pulse messages.', ].join('\n'), serviceName: 'notify', apiVersion: 'v1', diff --git a/src/handler.js b/src/handler.js index 12434d4..db554fc 100644 --- a/src/handler.js +++ b/src/handler.js @@ -4,12 +4,23 @@ const assert = require('assert'); const taskcluster = require('taskcluster-client'); const jsone = require('json-e'); const {consume} = require('taskcluster-lib-pulse'); +const libUrls = require('taskcluster-lib-urls'); /** Handler listening for tasks that carries notifications */ class Handler { - constructor({notifier, monitor, routePrefix, ignoreTaskReasonResolved, pulseClient, queue, - queueEvents}) { - + constructor(options) { + const { + rootUrl, + notifier, + monitor, + routePrefix, + ignoreTaskReasonResolved, + pulseClient, + queue, + queueEvents, + } = options; + + this.rootUrl = rootUrl; this.queue = queue; this.notifier = notifier; this.monitor = monitor; @@ -63,8 +74,8 @@ class Handler { // Load task definition let taskId = status.taskId; let task = await this.queue.task(taskId); - let href = `https://tools.taskcluster.net/task-inspector/#${taskId}`; - let groupHref = `https://tools.taskcluster.net/task-group-inspector/#/${task.taskGroupId}`; + let href = libUrls.ui(this.rootUrl, `tasks/${taskId}`); + let groupHref = libUrls.ui(this.rootUrl, `groups/${taskId}/tasks`); let runCount = status.runs.length; debug(`Received message for ${taskId} with notify routes. Finding notifications.`); diff --git a/src/main.js b/src/main.js index fdb305b..24bdc0c 100644 --- a/src/main.js +++ b/src/main.js @@ -171,6 +171,7 @@ const load = loader({ requires: ['profile', 'cfg', 'monitor', 'notifier', 'pulseClient', 'queue', 'queueEvents'], setup: async ({cfg, monitor, notifier, pulseClient, queue, queueEvents}) => { let handler = new Handler({ + rootUrl: cfg.taskcluster.rootUrl, notifier, monitor: monitor.prefix('handler'), routePrefix: cfg.app.routePrefix, diff --git a/yarn.lock b/yarn.lock index 7e34a9f..b74f949 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3551,6 +3551,11 @@ taskcluster-lib-urls@^10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/taskcluster-lib-urls/-/taskcluster-lib-urls-10.0.0.tgz#ee4c687b4539171d8aef39b38a63c8b9bc82f82e" +taskcluster-lib-urls@^12.0.0: + version "12.0.0" + resolved "https://registry.yarnpkg.com/taskcluster-lib-urls/-/taskcluster-lib-urls-12.0.0.tgz#f56190eec9e9597d37a42ad0e7f461e8e0e6732b" + integrity sha512-OrEFE0m3p/+mGsmIwjttLhSKg3io6MpJLhYtPNjVSZA9Ix8Y5tprN3vM6a3MjWt5asPF6AKZsfT43cgpGwJB0g== + taskcluster-lib-validate@^11.0.1: version "11.0.2" resolved "https://registry.yarnpkg.com/taskcluster-lib-validate/-/taskcluster-lib-validate-11.0.2.tgz#e1270450c9f1e09ddd8ba2cb6be1123eac86a3a6"