mirror of
https://github.com/directus/directus.git
synced 2026-01-23 04:58:00 -05:00
Add Options to Flow Notification Operation (#19033)
* add collection and item options to notification opperation * Create stale-tips-relax.md * fix formatting --------- Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
6
.changeset/stale-tips-relax.md
Normal file
6
.changeset/stale-tips-relax.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@directus/app": patch
|
||||
"@directus/api": patch
|
||||
---
|
||||
|
||||
Added Collection and Item Options to Flows Notification Operation
|
||||
@@ -8,12 +8,17 @@ type Options = {
|
||||
subject: string;
|
||||
message?: unknown | null;
|
||||
permissions: string; // $public, $trigger, $full, or UUID of a role
|
||||
collection?: string;
|
||||
item?: string;
|
||||
};
|
||||
|
||||
export default defineOperationApi<Options>({
|
||||
id: 'notification',
|
||||
|
||||
handler: async ({ recipient, subject, message, permissions }, { accountability, database, getSchema }) => {
|
||||
handler: async (
|
||||
{ recipient, subject, message, permissions, collection, item },
|
||||
{ accountability, database, getSchema }
|
||||
) => {
|
||||
const schema = await getSchema({ database });
|
||||
let customAccountability: Accountability | null;
|
||||
|
||||
@@ -34,6 +39,8 @@ export default defineOperationApi<Options>({
|
||||
});
|
||||
|
||||
const messageString = message ? optionToString(message) : null;
|
||||
const collectionString = message ? optionToString(collection) : null;
|
||||
const itemString = message ? optionToString(item) : null;
|
||||
|
||||
const payload = toArray(recipient).map((userId) => {
|
||||
return {
|
||||
@@ -41,6 +48,8 @@ export default defineOperationApi<Options>({
|
||||
sender: customAccountability?.user ?? null,
|
||||
subject,
|
||||
message: messageString,
|
||||
collection: collectionString,
|
||||
item: itemString,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -2189,7 +2189,9 @@ operations:
|
||||
recipient: User
|
||||
recipient_placeholder: Enter a UUID...
|
||||
recipient_note: Add user UUID and press enter...
|
||||
item_note: Item Key or Relative URL
|
||||
message: Message
|
||||
subject: Subject
|
||||
request:
|
||||
name: Webhook / Request URL
|
||||
description: 'Make a request to a URL'
|
||||
|
||||
@@ -61,7 +61,7 @@ export default defineOperationApp({
|
||||
},
|
||||
{
|
||||
field: 'subject',
|
||||
name: '$t:title',
|
||||
name: '$t:operations.notification.subject',
|
||||
type: 'string',
|
||||
meta: {
|
||||
width: 'full',
|
||||
@@ -80,5 +80,27 @@ export default defineOperationApp({
|
||||
interface: 'input-rich-text-md',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'collection',
|
||||
name: '$t:collection',
|
||||
type: 'string',
|
||||
meta: {
|
||||
width: 'half',
|
||||
interface: 'system-collection',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'item',
|
||||
name: '$t:item',
|
||||
type: 'string',
|
||||
meta: {
|
||||
width: 'half',
|
||||
interface: 'input',
|
||||
options: {
|
||||
iconRight: 'vpn_key',
|
||||
},
|
||||
note: '$t:operations.notification.item_note',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user