Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 11x 11x 11x 8x 6x 6x 6x 12x 12x 6x 6x 10x 10x 10x 10x 10x 10x 6x 6x 6x 6x 2x 2x 2x 11x 11x 4x 5x 5x 5x 5x 5x 2x 2x 4x 3x 3x 4x 4x 11x 193x 193x | import { getEmailhooks } from '@clevercloud/client/esm/api/v2/notification.js';
import { defineCommand } from '../../lib/define-command.js';
import { styleText } from '../../lib/style-text.js';
import { Logger } from '../../logger.js';
import { getOwnerAndApp } from '../../models/notification.js';
import { sendToApi } from '../../models/send-to-api.js';
import { humanJsonOutputFormatOption, listAllNotificationsOption, orgaIdOrNameOption } from '../global.options.js';
export const notifyEmailCommand = defineCommand({
description: 'Manage email notifications',
since: '0.6.1',
options: {
org: orgaIdOrNameOption,
listAll: listAllNotificationsOption,
format: humanJsonOutputFormatOption,
},
args: [],
async handler(options) {
const { org, listAll, format } = options;
const { ownerId, appId } = await getOwnerAndApp(org, org == null && !listAll);
const hooks = await getEmailhooks({ ownerId }).then(sendToApi);
const formattedHooks = hooks
.filter((hook) => {
const emptyScope = !hook.scope || hook.scope.length === 0;
return !appId || emptyScope || hook.scope.includes(appId);
})
.map((hook) => ({
id: hook.id,
name: hook.name,
ownerId: hook.ownerId,
services: hook.scope ?? [hook.ownerId],
events: hook.events ?? ['ALL'],
notified: hook.notified ? hook.notified.map(({ target }) => target ?? 'whole team') : ['whole team'],
}));
switch (format) {
case 'json': {
Logger.printJson(formattedHooks);
break;
}
case 'human':
default: {
formattedHooks.forEach((hook) => {
Logger.println(styleText('bold', hook.name ?? hook.id));
Logger.println(` id: ${hook.id}`);
Logger.println(` services: ${hook.services.join(', ')}`);
Logger.println(` events: ${hook.events.join(', ')}`);
if (hook.notified.length > 1) {
Logger.println(' to:');
hook.notified.forEach((target) => Logger.println(` ${target}`));
} else {
Logger.println(` to: ${hook.notified[0]}`);
}
});
}
}
},
});
|