Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
5 changes: 2 additions & 3 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
21 changes: 16 additions & 5 deletions src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.`);
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down