askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
thread_comments.json · 5.0 KB · 157 lines
| 1 | { |
| 2 | "name": "thread_comments", |
| 3 | "title": "Comments", |
| 4 | "version": 5, |
| 5 | "storage": "append", |
| 6 | "description": "Generic discussion: one comment shape attachable to a record in any collection via parent_collection/parent_id. This is the thread block's data shape landed early -- no widget, config records, or moderation surfaces yet; the schema matches the full design so no re-migration is ever needed. v4: reply_to_id declares relation.requires read. v5: moderators (role:moderator) may update any comment, and that update can only move status: every other client-writable field is editable by the comment's author and admins only (`default: read`), so a moderator reads a comment's text, thread and reply target but cannot rewrite them; status itself stays read-only on a moderator's own comment (the most restrictive match wins).", |
| 7 | "fields": [ |
| 8 | { |
| 9 | "name": "id" |
| 10 | }, |
| 11 | { |
| 12 | "name": "parent_collection", |
| 13 | "type": "text", |
| 14 | "required": true, |
| 15 | "label": "Parent collection", |
| 16 | "permissions": { |
| 17 | "owner": "edit", |
| 18 | "role:admin": "edit", |
| 19 | "role:superuser": "edit", |
| 20 | "default": "read" |
| 21 | } |
| 22 | }, |
| 23 | { |
| 24 | "name": "parent_id", |
| 25 | "type": "text", |
| 26 | "required": true, |
| 27 | "label": "Parent record", |
| 28 | "permissions": { |
| 29 | "owner": "edit", |
| 30 | "role:admin": "edit", |
| 31 | "role:superuser": "edit", |
| 32 | "default": "read" |
| 33 | } |
| 34 | }, |
| 35 | { |
| 36 | "name": "reply_to_id", |
| 37 | "type": "text", |
| 38 | "label": "In reply to", |
| 39 | "relation": { |
| 40 | "collection": "thread_comments", |
| 41 | "display_field": "body", |
| 42 | "requires": "read" |
| 43 | }, |
| 44 | "permissions": { |
| 45 | "owner": "edit", |
| 46 | "role:admin": "edit", |
| 47 | "role:superuser": "edit", |
| 48 | "default": "read" |
| 49 | } |
| 50 | }, |
| 51 | { |
| 52 | "name": "body", |
| 53 | "type": "textarea", |
| 54 | "required": true, |
| 55 | "label": "Comment", |
| 56 | "validation": { |
| 57 | "min_length": 1, |
| 58 | "max_length": 4000 |
| 59 | }, |
| 60 | "permissions": { |
| 61 | "owner": "edit", |
| 62 | "role:admin": "edit", |
| 63 | "role:superuser": "edit", |
| 64 | "default": "read" |
| 65 | } |
| 66 | }, |
| 67 | { |
| 68 | "name": "owner_id", |
| 69 | "type": "text", |
| 70 | "label": "Author", |
| 71 | "help": "Server-owned (stamped from the session on create). Visible to the author and to moderators, hidden from everyone else, who see author_name. It was `public: hidden`, and `public` matches EVERY caller -- the most restrictive match wins -- so the author could not see it either, and the widget's own-comment checks (delete button, seeing your own moderated comment) compared against a field that never arrived.", |
| 72 | "permissions": { |
| 73 | "owner": "read", |
| 74 | "role:moderator": "read", |
| 75 | "default": "hidden" |
| 76 | } |
| 77 | }, |
| 78 | { |
| 79 | "name": "author_name", |
| 80 | "type": "text", |
| 81 | "label": "Name", |
| 82 | "validation": { |
| 83 | "max_length": 80 |
| 84 | }, |
| 85 | "permissions": { |
| 86 | "owner": "edit", |
| 87 | "role:admin": "edit", |
| 88 | "role:superuser": "edit", |
| 89 | "default": "read" |
| 90 | } |
| 91 | }, |
| 92 | { |
| 93 | "name": "status", |
| 94 | "type": "enum", |
| 95 | "enum": [ |
| 96 | "published", |
| 97 | "pending", |
| 98 | "flagged", |
| 99 | "removed" |
| 100 | ], |
| 101 | "default": "published", |
| 102 | "help": "Moderation is enforced by the read rules (permissions/rules.json): other readers only ever receive published rows, so this field tells them nothing and is hidden from them; the author may read it (so their own removed comment says so) and a moderator may edit it. It was `public: hidden` beside `role:moderator: edit`, and since `public` matches everyone and the most restrictive match wins, nobody -- moderators included -- could read or set it through the API. Since v5 a moderator moves it on other people's comments (permissions/rules.json grants role:moderator update, and the other fields are author-and-admin-only, so status is all that update can change) but not on their own (`owner: read` is the more restrictive match). The moves are the map below: approving is pending -> published, rejecting is pending -> removed, and a published comment can be taken back to flagged or removed. The admin token is not named, so it neither reads nor sets status.", |
| 103 | "permissions": { |
| 104 | "owner": "read", |
| 105 | "role:moderator": "edit", |
| 106 | "default": "hidden" |
| 107 | }, |
| 108 | "transitions": { |
| 109 | "published": [ |
| 110 | "flagged", |
| 111 | "removed" |
| 112 | ], |
| 113 | "pending": [ |
| 114 | "published", |
| 115 | "flagged", |
| 116 | "removed" |
| 117 | ], |
| 118 | "flagged": [ |
| 119 | "published", |
| 120 | "removed" |
| 121 | ], |
| 122 | "removed": [] |
| 123 | } |
| 124 | }, |
| 125 | { |
| 126 | "name": "created_at", |
| 127 | "type": "datetime", |
| 128 | "label": "Created", |
| 129 | "read_only": true |
| 130 | }, |
| 131 | { |
| 132 | "name": "edited_at", |
| 133 | "type": "datetime", |
| 134 | "label": "Edited", |
| 135 | "read_only": true |
| 136 | } |
| 137 | ], |
| 138 | "forms": { |
| 139 | "default": { |
| 140 | "fields": [ |
| 141 | "body" |
| 142 | ] |
| 143 | } |
| 144 | }, |
| 145 | "views": { |
| 146 | "list_mode": "cards", |
| 147 | "list_fields": [ |
| 148 | "body", |
| 149 | "created_at" |
| 150 | ] |
| 151 | }, |
| 152 | "search": { |
| 153 | "fields": [ |
| 154 | "body" |
| 155 | ] |
| 156 | } |
| 157 | } |