UNPKG

3.44 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright © 2020 Atomist, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17Object.defineProperty(exports, "__esModule", { value: true });
18const slack_messages_1 = require("@atomist/slack-messages");
19const util_1 = require("./util");
20/* eslint-disable @typescript-eslint/camelcase */
21function slackSuccessMessage(title, text, ctx, options = {}) {
22 const msg = {
23 attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/check-circle.gif?gif=${util_1.guid()}`, author_name: title, text, fallback: text, color: "#37A745", mrkdwn_in: ["text"], footer: slackFooter(ctx), ts: slackTs() }, options)],
24 };
25 return msg;
26}
27exports.slackSuccessMessage = slackSuccessMessage;
28function slackQuestionMessage(title, text, ctx, options = {}) {
29 const msg = {
30 attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/question.png`, author_name: title, text, fallback: text, color: "#B5B5B5", mrkdwn_in: ["text"], footer: slackFooter(ctx), ts: slackTs() }, options)],
31 };
32 return msg;
33}
34exports.slackQuestionMessage = slackQuestionMessage;
35function slackInfoMessage(title, text, ctx, options = {}) {
36 const msg = {
37 attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/info.png`, author_name: title, text, fallback: text, color: "#B5B5B5", mrkdwn_in: ["text"], footer: slackFooter(ctx), ts: slackTs() }, options)],
38 };
39 return msg;
40}
41exports.slackInfoMessage = slackInfoMessage;
42function slackWarningMessage(title, text, ctx, options = {}) {
43 const msg = {
44 attachments: [Object.assign({ author_icon: `https://images.atomist.com/rug/warning-yellow.png`, author_name: title, text, fallback: text, color: "#D7B958", mrkdwn_in: ["text"], footer: slackSupportLink(ctx), ts: slackTs() }, options)],
45 };
46 return msg;
47}
48exports.slackWarningMessage = slackWarningMessage;
49function slackErrorMessage(title, text, ctx, options = {}) {
50 const msg = {
51 attachments: [Object.assign({ author_icon: "https://images.atomist.com/rug/error-circle.png", author_name: title, text, fallback: text, color: "#BC3D33", mrkdwn_in: ["text"], footer: slackSupportLink(ctx), ts: slackTs() }, options)],
52 };
53 return msg;
54}
55exports.slackErrorMessage = slackErrorMessage;
56function slackSupportLink(ctx) {
57 const supportUrl = `https://atomist.typeform.com/to/yvnyOj?message_id=${Buffer.from(ctx.correlationId).toString("base64")}`;
58 return `${slackFooter(ctx)} \u00B7 ${slack_messages_1.url(supportUrl, "Support")}`;
59}
60exports.slackSupportLink = slackSupportLink;
61function slackFooter(ctx) {
62 return `${ctx.skill.namespace}/${ctx.skill.name}`;
63}
64exports.slackFooter = slackFooter;
65function slackTs() {
66 return Math.floor(Date.now() / 1000);
67}
68exports.slackTs = slackTs;
69function slackSeparator() {
70 return "\u00B7";
71}
72exports.slackSeparator = slackSeparator;
73//# sourceMappingURL=messages.js.map
\No newline at end of file