mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add notifications system and support user mentions in comments (#9861)
* v-menu de/activated onKeyDown. No List yet. * v-list * add user suggestion * uuids replaced * user-popover working * avatars flex row with usernames in suggestions * added space to end of uuid insert * autofocus + move caret to end of last insert * removed unnecessary setTimeout() * fixed filter 500 with ids * better fix * New translations en-US.yaml (French) (#9907) * New translations en-US.yaml (French) (#9912) * New translations en-US.yaml (French) (#9916) * New translations en-US.yaml (Russian) (#9918) * New translations en-US.yaml (Swedish) (#9920) * Email updates (#9921) * add from name for emails * updatd email template style * reset password email copy * updated logo to newest version * update invite email copy * decouple field template logic * push up styling * Start on new v-template-input * Add notifications API endpoints Squashed commit of the following: commit 9d86721ef795d03bc55693c0f99bde8e269d60e9 Merge: b4458c19f34131d06eAuthor: rijkvanzanten <rijkvanzanten@me.com> Date: Mon Nov 22 09:27:43 2021 -0500 Merge branch 'mentions' into mentions-api commit b4458c19f7c54f18fa415fc04c63642c2f5a17b0 Author: rijkvanzanten <rijkvanzanten@me.com> Date: Thu Nov 18 18:34:04 2021 -0500 Remove unused import commit e6a9d36bbfdf95cb18d29336da61ecb14b677934 Author: rijkvanzanten <rijkvanzanten@me.com> Date: Thu Nov 18 18:28:31 2021 -0500 Extract user mentions from comments commit b3e571a2daa287e1740a050096913662a57e9861 Merge: c93b833d2af2a6dd7fAuthor: rijkvanzanten <rijkvanzanten@me.com> Date: Thu Nov 18 17:39:52 2021 -0500 Merge branch 'mentions' into mentions-api commit c93b833d2b848e306c434b370d4e4e11967e85d0 Author: rijkvanzanten <rijkvanzanten@me.com> Date: Thu Nov 18 17:35:45 2021 -0500 Send emails w/ parsed MD commit 64bbd6596f20a07028d2387d60e33dfe4f91c032 Author: rijkvanzanten <rijkvanzanten@me.com> Date: Thu Nov 18 16:18:16 2021 -0500 Add notifications endpoint + permissions commit fba55c02dc9c303a38b1b958350684cccd3dd82c Author: rijkvanzanten <rijkvanzanten@me.com> Date: Thu Nov 18 15:33:28 2021 -0500 Add system data for notifications * push * Make v-template-input work * Add the two-way binding * submit button posting, not clearing text area * comment text area clearing on submit * Replace insertion correctly * Added scope support to LDAP group and user search (#9529) * Added scope support LDAP group and user search * Fixed linter screwing up my markdown * Update docs/configuration/config-options.md * Always return correct DN for user with sub scope * Fix indeterminate meta and schema property in advanded field creation (#9924) * Fix impossibility to save M2M (alterations not triggered) (#9992) * Fix alterations refactor * fix roles aggregate query (#9994) * Update iis.md (#9998) added the IIS URL Rewrite module as a requirement * New translations en-US.yaml (English, United Kingdom) (#10001) * Fix LDAP race condition (#9993) * Fix input ui * Revert changes to v-field-template * Update mentions permissions * Fix linter warnings * Optimize sending flow * Revert "Rename activity->notifications module (#9446)" This reverts commit428e5d4ea9. * Add notifications drawer * Update migrations * Improve constraints * Add email notifications toggle on users * Add docs, fix graphql support * Move caret-pos to devdeps * Remove unused new triggerKeyPressed system * Remove unused use-caret composable Co-authored-by: Nitwel <nitwel@arcor.de> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> Co-authored-by: Ben Haynes <ben@rngr.org> Co-authored-by: Aiden Foxx <aiden.foxx@sbab.se> Co-authored-by: Oreille <33065839+Oreilles@users.noreply.github.com> Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com> Co-authored-by: Paul Boudewijn <paul@helderinternet.nl>
This commit is contained in:
608
docs/reference/system/notifications.md
Normal file
608
docs/reference/system/notifications.md
Normal file
@@ -0,0 +1,608 @@
|
||||
---
|
||||
pageClass: page-reference
|
||||
---
|
||||
|
||||
# Notifications
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
> Notifications allow you to send/receive messages to/from other users of the platform.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
[[toc]]
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## The Notification Object
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
<div class="definitions">
|
||||
|
||||
`id` **integer**\
|
||||
Primary key of the revision.
|
||||
|
||||
`timestamp` **string**\
|
||||
Timestamp in ISO8601 when the notification was created.
|
||||
|
||||
`status` **string**\
|
||||
Current status of the notification. One of "inbox", "archived".
|
||||
|
||||
`recipient` **many-to-one**\
|
||||
User that received the notification.
|
||||
|
||||
`sender` **many-to-one**\
|
||||
User that sent the notification, if any.
|
||||
|
||||
`subject` **string**\
|
||||
Subject line of the message.
|
||||
|
||||
`message` **string**\
|
||||
Notification's message content. Will be sent in the email.
|
||||
|
||||
`collection` **string**\
|
||||
Collection this notification references.
|
||||
|
||||
`item` **string**\
|
||||
Primary key of the item this notification references.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 2,
|
||||
"timestamp": "2021-11-24T13:57:35Z",
|
||||
"status": "inbox",
|
||||
"recipient": "3EE34828-B43C-4FB2-A721-5151579B08EA",
|
||||
"sender": "497a495e-5529-4e46-8feb-2f35e9b85601",
|
||||
"subject": "You were mentioned in articles",
|
||||
"message": "\nHello admin@example.com,\n\rijk@directus.io has mentioned you in a comment:\n\n> Hello <em>admin@example.com</em>!\n\n<a href=\"http://localhost:8080/admin/content/articles/1\">Click here to view.</a>\n",
|
||||
"collection": "articles",
|
||||
"item": "1"
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## List Notifications
|
||||
|
||||
List all notifications that exist in Directus.
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Query Parameters
|
||||
|
||||
Supports all [global query parameters](/reference/query).
|
||||
|
||||
### Returns
|
||||
|
||||
An array of up to [limit](/reference/query/#limit) [notification objects](#the-notification-object). If no items are
|
||||
available, data will be an empty array.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
GET /notifications
|
||||
SEARCH /notifications
|
||||
```
|
||||
|
||||
[Learn more about SEARCH ->](/reference/introduction/#search-http-method)
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Query {
|
||||
notifications: [directus_notifications]
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
query {
|
||||
notifications {
|
||||
id
|
||||
recipient
|
||||
subject
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Retrieve a notification
|
||||
|
||||
List an existing notification by primary key.
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Query Parameters
|
||||
|
||||
Supports all [global query parameters](/reference/query).
|
||||
|
||||
### Returns
|
||||
|
||||
Returns the requested [notification object](#the-notification-object).
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
GET /notifications/:id
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```
|
||||
GET /notifications/42
|
||||
```
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Query {
|
||||
notifications_by_id(id: ID!): directus_notifications
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
query {
|
||||
notifications_by_id(id: 42) {
|
||||
id
|
||||
sender
|
||||
recipient
|
||||
message
|
||||
subject
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Create a Notification
|
||||
|
||||
Create a new notification.
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Query Parameters
|
||||
|
||||
Supports all [global query parameters](/reference/query).
|
||||
|
||||
### Request Body
|
||||
|
||||
A partial [notification object](#the-notification-object).
|
||||
|
||||
### Returns
|
||||
|
||||
Returns the [notification object](#the-notification-object) for the created notification.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
POST /notifications
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```json
|
||||
// POST /notifications
|
||||
|
||||
{
|
||||
"recipient": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
|
||||
"subject": "Hi there!"
|
||||
}
|
||||
```
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Mutation {
|
||||
create_notifications_item(data: create_directus_notifications_input!): directus_notifications
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
create_notifications_item(data: { recipient: "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca", subject: "Hi there!" }) {
|
||||
id
|
||||
recipient
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Create Multiple Notifications
|
||||
|
||||
Create multiple new notifications.
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Query Parameters
|
||||
|
||||
Supports all [global query parameters](/reference/query).
|
||||
|
||||
### Request Body
|
||||
|
||||
An array of partial [notification objects](#the-notification-object).
|
||||
|
||||
### Returns
|
||||
|
||||
Returns the [notification object](#the-notification-object) for the created notification.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
POST /notifications
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```json
|
||||
// POST /notifications
|
||||
|
||||
[
|
||||
{
|
||||
"collection": "directus_files",
|
||||
"recipient": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
|
||||
"message": "Hi there! You should check out these files"
|
||||
},
|
||||
{
|
||||
"collection": "articles",
|
||||
"recipient": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
|
||||
"message": "Hi there! You should check out these articles"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Mutation {
|
||||
create_notifications_items(data: [create_directus_notifications_input!]!): [directus_notifications]
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
create_notifications_items(
|
||||
data: [
|
||||
{
|
||||
collection: "directus_files"
|
||||
recipient: "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca"
|
||||
message: "Hi there! You should check out these files"
|
||||
}
|
||||
{
|
||||
collection: "articles"
|
||||
recipient: "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca"
|
||||
message: "Hi there! You should check out these articles"
|
||||
}
|
||||
]
|
||||
) {
|
||||
id
|
||||
recipient
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Update a Notification
|
||||
|
||||
Update an existing notification.
|
||||
|
||||
::: tip Email Notifications
|
||||
|
||||
Emails are only sent when the notification is created. Updated to an existing notification won't trigger a new
|
||||
notification email to be sent.
|
||||
|
||||
:::
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Query Parameters
|
||||
|
||||
Supports all [global query parameters](/reference/query).
|
||||
|
||||
### Request Body
|
||||
|
||||
A partial [notification object](#the-notification-object).
|
||||
|
||||
### Returns
|
||||
|
||||
Returns the [notification object](#the-notification-object) for the updated notification.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
PATCH /notifications/:id
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```json
|
||||
// PATCH /notifications/34
|
||||
|
||||
{
|
||||
"message": "This is my updated notification"
|
||||
}
|
||||
```
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Mutation {
|
||||
update_notifications_item(id: ID!, data: update_directus_notifications_input): directus_notifications
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
update_notifications_item(id: 32, data: { message: "This is my updated notification" }) {
|
||||
id
|
||||
message
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Update Multiple Notifications
|
||||
|
||||
Update multiple existing notifications.
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Query Parameters
|
||||
|
||||
Supports all [global query parameters](/reference/query).
|
||||
|
||||
### Request Body
|
||||
|
||||
<div class="definitions">
|
||||
|
||||
`keys` **Required**\
|
||||
Array of primary keys of the notifications you'd like to update.
|
||||
|
||||
`data` **Required**\
|
||||
Any of [the notification object](#the-notification-object)'s properties.
|
||||
|
||||
</div>
|
||||
|
||||
### Returns
|
||||
|
||||
Returns the [notification objects](#the-notification-object) for the updated notifications.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
PATCH /notifications
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```json
|
||||
// PATCH /notifications
|
||||
|
||||
{
|
||||
"keys": [15, 64],
|
||||
"data": {
|
||||
"message": "Updated message!"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Mutation {
|
||||
update_notifications_items(ids: [ID!]!, data: update_directus_notifications_input): [directus_notifications]
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
update_notifications_items(ids: [15, 64], data: { message: "Updated message!" }) {
|
||||
id
|
||||
recipient
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Delete a Notification
|
||||
|
||||
Delete an existing notification.
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Returns
|
||||
|
||||
Empty body.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
DELETE /notifications/:id
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```
|
||||
DELETE /notifications/34
|
||||
```
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Mutation {
|
||||
delete_notifications_item(id: ID!): delete_one
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
delete_notifications_item(id: 32) {
|
||||
id
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Delete Multiple Notifications
|
||||
|
||||
Delete multiple existing notifications.
|
||||
|
||||
<div class="two-up">
|
||||
<div class="left">
|
||||
|
||||
### Request Body
|
||||
|
||||
An array of notification primary keys
|
||||
|
||||
### Returns
|
||||
|
||||
Empty body.
|
||||
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
### REST API
|
||||
|
||||
```
|
||||
DELETE /notifications
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```json
|
||||
// DELETE /notifications
|
||||
[15, 251, 810]
|
||||
```
|
||||
|
||||
### GraphQL
|
||||
|
||||
```
|
||||
POST /graphql/system
|
||||
```
|
||||
|
||||
```graphql
|
||||
type Mutation {
|
||||
delete_notifications_items(ids: [ID!]!): delete_many
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
delete_notifications_items(ids: [15, 251, 810]) {
|
||||
ids
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user