1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | Object.defineProperty(exports, "__esModule", { value: true });
|
24 | const GraphQL = require("@atomist/automation-client/graph/graphQL");
|
25 | const HandlerResult_1 = require("@atomist/automation-client/HandlerResult");
|
26 | const Handlers_1 = require("@atomist/automation-client/Handlers");
|
27 | const logger_1 = require("@atomist/automation-client/internal/util/logger");
|
28 | let NotifyOnPush = class NotifyOnPush {
|
29 | handle(e, ctx) {
|
30 | logger_1.logger.info(`incoming event is ${JSON.stringify(e.data)}`);
|
31 | return Promise.all(e.data.Push.map(p => {
|
32 | if (p.repo && p.repo.channels && p.repo.channels.length > 0) {
|
33 | return ctx.messageClient.addressChannels(`Got a push with sha \`${p.after.sha}\``, p.repo.channels.map(c => c.name));
|
34 | }
|
35 | else {
|
36 | return HandlerResult_1.Success;
|
37 | }
|
38 | }))
|
39 | .then(() => HandlerResult_1.Success)
|
40 | .catch(() => HandlerResult_1.Failure);
|
41 | }
|
42 | };
|
43 | NotifyOnPush = __decorate([
|
44 | Handlers_1.EventHandler("notify repo channels when there is a push", GraphQL.subscriptionFromFile("graphql/push")),
|
45 | Handlers_1.Tags("push", "notification")
|
46 | ], NotifyOnPush);
|
47 | exports.NotifyOnPush = NotifyOnPush;
|
48 |
|
\ | No newline at end of file |