{ "version": "2.2.0", "name": "Create Forum Post", "description": "Create a new post (reply) in a forum thread", "trigger": { "type": "http", "method": "POST", "path": "/forum/threads/:threadId/posts" }, "nodes": [ { "id": "validate_tenant", "type": "operation", "op": "validate", "input": "{{ $context.tenantId }}", "validator": "required" }, { "id": "validate_input", "type": "operation", "op": "validate", "input": "{{ $json }}", "rules": { "content": "required|string|minLength:3|maxLength:5000" } }, { "id": "check_thread_exists", "type": "operation", "op": "database_read", "entity": "ForumThread", "params": { "filter": { "id": "{{ $json.threadId }}", "tenantId": "{{ $context.tenantId }}" } } }, { "id": "check_thread_locked", "type": "operation", "op": "condition", "condition": "{{ $steps.check_thread_exists.output.isLocked !== true }}" }, { "id": "create_post", "type": "operation", "op": "database_create", "entity": "ForumPost", "data": { "tenantId": "{{ $context.tenantId }}", "threadId": "{{ $json.threadId }}", "authorId": "{{ $context.user.id }}", "content": "{{ $json.content }}", "editedAt": null, "isDeleted": false, "createdAt": "{{ new Date().toISOString() }}" } }, { "id": "increment_thread_count", "type": "operation", "op": "database_update", "entity": "ForumThread", "params": { "filter": { "id": "{{ $json.threadId }}" }, "data": { "postCount": "{{ $steps.check_thread_exists.output.postCount + 1 }}", "updatedAt": "{{ new Date().toISOString() }}" } } }, { "id": "emit_event", "type": "action", "action": "emit_event", "event": "post_created", "channel": "{{ 'forum:thread:' + $json.threadId }}", "data": { "postId": "{{ $steps.create_post.output.id }}", "threadId": "{{ $json.threadId }}", "authorId": "{{ $context.user.id }}" } }, { "id": "return_success", "type": "action", "action": "http_response", "status": 201, "body": "{{ $steps.create_post.output }}" } ] }