Skip to content

Commit

Permalink
Allow array of user IDs for Notify operation (#14694)
Browse files Browse the repository at this point in the history
* Allow array of user IDs for Notify operation

* Update app/src/operations/notification/index.ts

* use csv for all tags interfaces in Flow operations
  • Loading branch information
azrikahar committed Aug 18, 2022
1 parent a21b28b commit ad97b30
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
15 changes: 9 additions & 6 deletions api/src/operations/notification/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Accountability } from '@directus/shared/types';
import { defineOperationApi, optionToString } from '@directus/shared/utils';
import { defineOperationApi, optionToString, toArray } from '@directus/shared/utils';
import { NotificationsService } from '../../services';
import { getAccountabilityForRole } from '../../utils/get-accountability-for-role';

Expand Down Expand Up @@ -36,12 +36,15 @@ export default defineOperationApi<Options>({

const messageString = message ? optionToString(message) : null;

const result = await notificationsService.createOne({
recipient,
sender: customAccountability?.user ?? null,
subject,
message: messageString,
const payload = toArray(recipient).map((userId) => {
return {
recipient: userId,
sender: customAccountability?.user ?? null,
subject,
message: messageString,
};
});
const result = await notificationsService.createMany(payload);

return result;
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/lang/translations/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,6 @@ triggers:
collection_and_item: Collection & Item Pages
collection_only: Collection Page Only
item_only: Item Page Only
a_users_uuid: A User's Primary Key UUID...
a_flow_uuid: A Flow's Primary Key UUID...
any_string_or_json: Any string or JSON...
item_payload_placeholder: This is the JSON used to update the item's field values...
Expand Down Expand Up @@ -2106,8 +2105,9 @@ operations:
body: Body
notification:
name: Send Notification
description: Send an in-app notification to a user
description: Send an in-app notification to one or more users
recipient: User
recipient_placeholder: Add user UUID and press enter...
message: Message
request:
name: Webhook / Request URL
Expand Down
2 changes: 1 addition & 1 deletion app/src/operations/mail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineOperationApp({
{
field: 'to',
name: '$t:operations.mail.to',
type: 'string',
type: 'csv',
meta: {
width: 'full',
interface: 'tags',
Expand Down
6 changes: 3 additions & 3 deletions app/src/operations/notification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export default defineOperationApp({
{
field: 'recipient',
name: '$t:operations.notification.recipient',
type: 'string',
type: 'csv',
meta: {
width: 'half',
interface: 'input',
interface: 'tags',
options: {
iconRight: 'people_alt',
placeholder: '$t:a_users_uuid',
placeholder: '$t:operations.notification.recipient_placeholder',
},
},
},
Expand Down

0 comments on commit ad97b30

Please sign in to comment.