UNPKG

@taoya785/flow-bark

Version:

Bark notification plugin for activepieces

70 lines (63 loc) 1.86 kB
import { createAction, Property, } from '@activepieces/pieces-framework' import { auth } from '../auth' import { buildBarkUrl, sendBarkNotification } from '../common/utils' export const sendCriticalAction = createAction({ name: 'send_critical', displayName: '发送重要警告', description: '发送一个重要警告通知,会突破静音和勿扰模式', auth, requireAuth: true, props: { title: Property.ShortText({ displayName: '标题', description: '警告通知的标题', required: false, }), body: Property.LongText({ displayName: '内容', description: '警告通知的内容', required: true, }), sound: Property.StaticDropdown({ displayName: '提示音', description: '警告通知的提示音', required: false, defaultValue: 'alarm', options: { disabled: false, options: [ { label: '警报', value: 'alarm' }, { label: '预警', value: 'anticipate' }, { label: '铃声', value: 'bell' }, { label: '信号', value: 'horn' }, ], }, }), call: Property.Checkbox({ displayName: '连续响铃', description: '设置警告铃声是否循环播放', required: false, defaultValue: true, }), }, async run({ auth, propsValue }) { const { baseUrl, key } = auth const { title, body, sound, call } = propsValue // 构建推送URL const pushUrl = buildBarkUrl(baseUrl, key, title, undefined, body) // 构建参数 const params: Record<string, string> = { level: 'critical', // 重要警告级别 } if (sound) params.sound = sound if (call) params.call = '1' // 发送推送请求 const response = await sendBarkNotification(pushUrl, params) return response.body }, })