* Add retention support for `directus_activity` and `directus_revisions` (#23410) * add retention support * add changeset * add docs * rework imports * skip processing for no records * improve retention tests * improve tests * add error handling * remove redundant while condition in retention * improve error message * increase retention to 90 days * add lock * Use the action constant * Skip the full table count * Add false to disable in docs * Reduce batch to 500 for db compat * Add timeout to lock * skip revisions if activities is more frequent * Update docs/self-hosted/config-options.md Co-authored-by: Kevin Lewis <kvn@lws.io> * Update docs/self-hosted/config-options.md Co-authored-by: Kevin Lewis <kvn@lws.io> * RETENTION_TASKS are no longer constant * fix formatting for retentions enabled config option * reword RETENTION_SCHEDULE config option * add explicit return types and update to async for consistency * fix schedules tests to be async * update jsdoc to correctly indicate schedule job * add correct default value for retention schedules --------- Co-authored-by: ian <licitdev@gmail.com> Co-authored-by: Kevin Lewis <kvn@lws.io> * Removed outdated logic for versioning (#23749) * Extract comments to a separate table (#22295) * Add directus_comments migration * Add comments controller and service * Remove from activity * Update system-data and types * Refactor app with new endpoints * Expose service * Update app minimal permissions * Add collection translation * Define relations * Allow comment creation only if there's item read access * Patch for MSSQL double constraints issue * Fix users service test * Add sdk support * Update specs * Fix formatting * Fix specs error * Patch whoopsie * Remove obsolete GraphQL mutations * Update required fields * Remove unused vars * Allow edit and delete of legacy activity comments * Remove legacy comments from SDK * Add changeset * Batch upwards migration * Update SDK to use keysOrQuery Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> * Update implementation for keysOrQuery * Remove singleton check * Update SDK to use keysOrQuery 2 Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> * Update keysOrQuery typedoc * Fix import * Update migration timestamp * fixed import * Update api/src/utils/get-service.ts * utilize chunk processing in migration * formatting * only services extended from itemservice should be added * remove redundant checks from comment header * update comment service to v11 permission format * specify missing required fields * Mock comments in users test * Simplify migration and update date * WIP legacy access * Optimise imports * WIP app cleanup * Update loadUserPreviews typing Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Read legacy comments * Parse using comments service * Perform migration directly * Fix legacy app sort query which uses id * Migrate legacy comments in mutations * Reduce api semver * Update app recommended permissions * Recommend updating of comment only * replace hardcoded type with existing one * Allow users to update or delete their own comments Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Skip further access validation for non-existent collections * Check if collection exists before the admin check Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Fix incorrect legacy check Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Fix merging of count when db returns count as string type * Remove unused import --------- Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Consolidate content versioning (#22413) * Add migration * Use the new delta field * Add cast-json flag * Fix typing * Fetch existing deltas if version created during migration * Add changeset * Add version delta field into sdk schema * Update migration timestamp * Update versions.save() to return finalVersionDelta Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> * Sort on DB level * Update migration date * Disallow passing delta via create/update * Update docs & specs * Fix save response * Remove unnecessary access check Already checked by the subsequent itemsService.readOne call * Update changeset * Don't require update perms on versions for save * Optimize validateCreateData * update to new validateAccess * Update docs/reference/system/versions.md * Remove migration of delta * Rename to legacy * Add missed changes for Remove migration of delta in2e2f50fa67* Update docs/reference/system/versions.md --------- Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Update migration dates * api change should be major for versioning * Remove comment paths from activity reference * Added comments reference * Added directus_comments to table of system collections * The linter demands newline * Revert function renaming for patch semver * Use transaction in down migration for comments (#23715) * Remove outdated logic for versioning * Fix migration * Update api/src/database/migrations/20240924B-populate-versioning-deltas.ts * add changeset * reword changeset --------- Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> Co-authored-by: Kevin Lewis <kvn@lws.io> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> * Removed outdated logic for comments (#23748) * Extract comments to a separate table (#22295) * Add directus_comments migration * Add comments controller and service * Remove from activity * Update system-data and types * Refactor app with new endpoints * Expose service * Update app minimal permissions * Add collection translation * Define relations * Allow comment creation only if there's item read access * Patch for MSSQL double constraints issue * Fix users service test * Add sdk support * Update specs * Fix formatting * Fix specs error * Patch whoopsie * Remove obsolete GraphQL mutations * Update required fields * Remove unused vars * Allow edit and delete of legacy activity comments * Remove legacy comments from SDK * Add changeset * Batch upwards migration * Update SDK to use keysOrQuery Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> * Update implementation for keysOrQuery * Remove singleton check * Update SDK to use keysOrQuery 2 Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> * Update keysOrQuery typedoc * Fix import * Update migration timestamp * fixed import * Update api/src/utils/get-service.ts * utilize chunk processing in migration * formatting * only services extended from itemservice should be added * remove redundant checks from comment header * update comment service to v11 permission format * specify missing required fields * Mock comments in users test * Simplify migration and update date * WIP legacy access * Optimise imports * WIP app cleanup * Update loadUserPreviews typing Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Read legacy comments * Parse using comments service * Perform migration directly * Fix legacy app sort query which uses id * Migrate legacy comments in mutations * Reduce api semver * Update app recommended permissions * Recommend updating of comment only * replace hardcoded type with existing one * Allow users to update or delete their own comments Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Skip further access validation for non-existent collections * Check if collection exists before the admin check Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Fix incorrect legacy check Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Fix merging of count when db returns count as string type * Remove unused import --------- Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Consolidate content versioning (#22413) * Add migration * Use the new delta field * Add cast-json flag * Fix typing * Fetch existing deltas if version created during migration * Add changeset * Add version delta field into sdk schema * Update migration timestamp * Update versions.save() to return finalVersionDelta Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> * Sort on DB level * Update migration date * Disallow passing delta via create/update * Update docs & specs * Fix save response * Remove unnecessary access check Already checked by the subsequent itemsService.readOne call * Update changeset * Don't require update perms on versions for save * Optimize validateCreateData * update to new validateAccess * Update docs/reference/system/versions.md * Remove migration of delta * Rename to legacy * Add missed changes for Remove migration of delta in2e2f50fa67* Update docs/reference/system/versions.md --------- Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Update migration dates * api change should be major for versioning * Remove comment paths from activity reference * Added comments reference * Added directus_comments to table of system collections * The linter demands newline * Revert function renaming for patch semver * Use transaction in down migration for comments (#23715) * Remove outdated logic for comments * remove duplicate app access permission * remove unused import/params in gql * remove remaining comment code in activity * remove remaining activity logic in comment * add changeset * reword changeset --------- Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> Co-authored-by: Kevin Lewis <kvn@lws.io> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> * Update config-options.md * add missing docs changeset for retentions * ensure selected id is not ambiguous for joins * Restrict comment create, update and delete to authenticated users (#23996) * Extract comments to a separate table (#22295) * Add directus_comments migration * Add comments controller and service * Remove from activity * Update system-data and types * Refactor app with new endpoints * Expose service * Update app minimal permissions * Add collection translation * Define relations * Allow comment creation only if there's item read access * Patch for MSSQL double constraints issue * Fix users service test * Add sdk support * Update specs * Fix formatting * Fix specs error * Patch whoopsie * Remove obsolete GraphQL mutations * Update required fields * Remove unused vars * Allow edit and delete of legacy activity comments * Remove legacy comments from SDK * Add changeset * Batch upwards migration * Update SDK to use keysOrQuery Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> * Update implementation for keysOrQuery * Remove singleton check * Update SDK to use keysOrQuery 2 Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> * Update keysOrQuery typedoc * Fix import * Update migration timestamp * fixed import * Update api/src/utils/get-service.ts * utilize chunk processing in migration * formatting * only services extended from itemservice should be added * remove redundant checks from comment header * update comment service to v11 permission format * specify missing required fields * Mock comments in users test * Simplify migration and update date * WIP legacy access * Optimise imports * WIP app cleanup * Update loadUserPreviews typing Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Read legacy comments * Parse using comments service * Perform migration directly * Fix legacy app sort query which uses id * Migrate legacy comments in mutations * Reduce api semver * Update app recommended permissions * Recommend updating of comment only * replace hardcoded type with existing one * Allow users to update or delete their own comments Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Skip further access validation for non-existent collections * Check if collection exists before the admin check Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Fix incorrect legacy check Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Fix merging of count when db returns count as string type * Remove unused import --------- Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> * Consolidate content versioning (#22413) * Add migration * Use the new delta field * Add cast-json flag * Fix typing * Fetch existing deltas if version created during migration * Add changeset * Add version delta field into sdk schema * Update migration timestamp * Update versions.save() to return finalVersionDelta Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> * Sort on DB level * Update migration date * Disallow passing delta via create/update * Update docs & specs * Fix save response * Remove unnecessary access check Already checked by the subsequent itemsService.readOne call * Update changeset * Don't require update perms on versions for save * Optimize validateCreateData * update to new validateAccess * Update docs/reference/system/versions.md * Remove migration of delta * Rename to legacy * Add missed changes for Remove migration of delta in2e2f50fa67* Update docs/reference/system/versions.md --------- Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> * Update migration dates * api change should be major for versioning * Remove comment paths from activity reference * Added comments reference * Added directus_comments to table of system collections * The linter demands newline * Revert function renaming for patch semver * Use transaction in down migration for comments (#23715) * Remove outdated logic for comments * remove duplicate app access permission * remove unused import/params in gql * remove remaining comment code in activity * remove remaining activity logic in comment * add changeset * reword changeset * restrict comment CUD to authenticated users * update docs * add changeset * skip mention processing if none are present * update restriction wording in the docs --------- Co-authored-by: ian <licitdev@gmail.com> Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> Co-authored-by: Kevin Lewis <kvn@lws.io> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> * remove foreign key constraint on comment `collection` column * update migration comment wording * Update api/src/database/migrations/20240924A-migrate-legacy-comments.ts Co-authored-by: ian <licitdev@gmail.com> --------- Co-authored-by: ian <licitdev@gmail.com> Co-authored-by: Kevin Lewis <kvn@lws.io> Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: Daniel Biegler <DanielBiegler@users.noreply.github.com> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
8.6 KiB
description, pageClass
| description | pageClass |
|---|---|
| REST and GraphQL API documentation on the comments in Directus. | page-reference |
Comments
Comments are a collaboration tool and can be left on items from the sidebar.
The Comment Object
collection string
Collection identifier in which the item resides.
id uuid
Unique identifier for the object.
item string
The item the comment is created for.
comment string
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
date_created timestamp
Timestamp in ISO8601 when the comment was created.
date_updated timestamp
Timestamp in ISO8601 when the comment was last updated.
user_created many-to-one
The user who created the comment. Many-to-one to users.
user_updated many-to-one
The user who last updated the comment. Many-to-one to users.
{
"collection": "articles",
"id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
"item": "15",
"comment": "This is a comment on an article",
"date_created": "2023-01-15T09:14:52Z",
"date_updated": "2023-01-15T09:00:00Z",
"user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
"user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
}
Get Comments
Returns a list of comments.
Request
GET /comments
SEARCH /comments
If using SEARCH you can provide a query object as the body of your request.
POST /graphql/system
type Query {
flows: [directus_comments]
}
import { createDirectus, rest, readComments } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(readComments(query));
Query Parameters
Supports all global query parameters.
Returns
An array of up to limit comment objects. If no items are available, data will be an empty array.
Get Comment by ID
Returns a single comment by primary key.
Request
GET /comments/:id
POST /graphql/system
type Query {
comment_by_id(id: ID!): directus_comments
}
import { createDirectus, rest, readComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readComment(comment_id, query_object));
Query Parameters
Supports all global query parameters.
Response
Returns a comment object if a valid identifier was provided.
Create a Comment
Create a new comment. This action is only available to authenticated users.
Request
POST /comments
Provide a comment object as the body of your request.
POST /graphql/system
type Mutation {
create_comments_item(data: create_directus_comments_input): directus_comments
}
import { createDirectus, rest, createComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(createComment(comment_object));
Query Parameters
Supports all global query parameters.
Request Body
A partial comment object.
Response
Returns the comment object of the comment that was created.
Create Multiple Comments
Create multiple new comments. This action is only available to authenticated users.
Request
POST /comments
Provide an array of comment objects as the body of your request.
POST /graphql/system
type Mutation {
create_comments_items(data: [create_directus_comments_input]): [directus_comments]
}
import { createDirectus, rest, createComments } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(createComments(comment_object_array));
Query Parameters
Supports all global query parameters.
Request Body
An array of partial comment objects. name is required.
Response
Returns an array of comment objects of the comments that were created.
Update a Comment
Update an existing comment. This action is only available to authenticated users.
Request
PATCH /comments/:id
Provide a partial comment object as the body of your request.
POST /graphql/system
type Mutation {
update_comments_item(id: ID!, data: update_directus_comments_input): directus_comments
}
import { createDirectus, rest, updateComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateComment(comment_id, partial_comment_object));
Query Parameters
Supports all global query parameters.
Request Body
A partial comment object.
Response
Returns the comment object of the comment that was updated.
Update Multiple Comments
Update multiple existing comments. This action is only available to authenticated users.
Request
PATCH /comments
{
"keys": comment_id_array,
"data": partial_comment_objects
}
POST /graphql/system
type Mutation {
update_comments_items(ids: [ID!]!, data: update_directus_comments_input): [directus_comments]
}
import { createDirectus, rest, updateComments } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateComments(comment_id_array, partial_comment_object));
Query Parameters
Supports all global query parameters.
Request Body
keys Required
Array of primary keys of the comments you'd like to update.
data Required
Any of the comment object's properties.
Response
Returns the comment objects of the comments that were updated.
Delete a Comment
Delete an existing comment. This action is only available to authenticated users.
Request
DELETE /comments/:id
POST /graphql/system
type Mutation {
delete_comments_item(id: ID!): delete_one
}
import { createDirectus, rest, deleteComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteComment(comment_id));
Response
Empty body.
Delete Multiple Comments
Delete multiple existing comments. This action is only available to authenticated users.
Request
DELETE /comments
Provide an array of item IDs as your request body.
POST /graphql/system
type Mutation {
delete_comments_items(ids: [ID!]!): delete_many
}
import { createDirectus, rest, deleteComments } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteComments(comment_id_array));
Request Body
An array of comment primary keys.
Returns
Empty body.