UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

52 lines 2.08 kB
"use strict"; /* * Copyright © 2019 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.addressDestinations = exports.messageDestinationsFor = exports.addressChannelsFor = exports.AddressNoChannels = void 0; const MessageClient_1 = require("@atomist/automation-client/lib/spi/message/MessageClient"); /** * Throw away contents. Use when we know that there can be no linked channels. * @constructor */ const AddressNoChannels = async () => { return; }; exports.AddressNoChannels = AddressNoChannels; /** * Address the chat channels associated with this object. * Typically used to address channels associated with a repo. * @param {HasChannels} hasChannels * @param {HandlerContext} ctx * @return {AddressChannels} */ function addressChannelsFor(hasChannels, ctx) { if (hasChannels.channels && hasChannels.channels.length > 0) { return addressDestinations(ctx, ...messageDestinationsFor(hasChannels, ctx)); } else { return () => Promise.resolve(); } } exports.addressChannelsFor = addressChannelsFor; function messageDestinationsFor(hasChannels, ctx) { return hasChannels.channels.map(ch => MessageClient_1.addressSlackChannels(ch.team.id, ch.name)); } exports.messageDestinationsFor = messageDestinationsFor; function addressDestinations(ctx, ...destinations) { return (msg, opts) => ctx.messageClient.send(msg, destinations, opts); } exports.addressDestinations = addressDestinations; //# sourceMappingURL=addressChannels.js.map