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.
profile_comments.json · 5.7 KB · 93 lines
| 1 | { |
| 2 | "name": "profile_comments", |
| 3 | "title": "Profile Comments", |
| 4 | "version": 4, |
| 5 | "description": "Moderated guestbook comments on a public profile. A faithful port of the source system's ProfileComment model: author_name/author_email/author_url plus a pending/approved/rejected moderation status and the submitter's ip_address. v1 posture (see permissions/rules.json and dbbasic-package.json): guestbook posting is signed-in only, not anonymous -- the source's anonymous-submission path needs the anti-abuse stack in plan/vocabulary/02-public-write-hardening-spec.md (rate limits, honeypot, timing token), which this package does not build. The author_name/author_email/author_url fields are carried from the source's anonymous-guestbook shape even though v1 has no anonymous path, so no migration is needed when that path lands. v2: profile_id declares relation.requires read (profiles are public). v3: status is readable by the comment's author and editable by role:moderator (it was hidden from everyone, admin token included), the same grant thread_comments.status has. v4: comment moderation works over the API: role:moderator reads every comment and may update one, and that update can only move status -- profile_id, author_name, author_url, content and owner_id are editable by the comment's author and admins only (`default: read`) -- and never on the moderator's own comment.", |
| 6 | "fields": [ |
| 7 | { |
| 8 | "name": "id" |
| 9 | }, |
| 10 | { |
| 11 | "name": "profile_id", |
| 12 | "type": "relation", |
| 13 | "required": true, |
| 14 | "relation": {"collection": "profiles", "display_field": "display_name", "requires": "read"}, |
| 15 | "label": "Profile", |
| 16 | "permissions": {"owner": "edit", "role:admin": "edit", "role:superuser": "edit", "default": "read"} |
| 17 | }, |
| 18 | { |
| 19 | "name": "author_name", |
| 20 | "type": "text", |
| 21 | "label": "Name", |
| 22 | "validation": {"max_length": 120}, |
| 23 | "permissions": {"owner": "edit", "role:admin": "edit", "role:superuser": "edit", "default": "read"} |
| 24 | }, |
| 25 | { |
| 26 | "name": "author_email", |
| 27 | "subject": "email", |
| 28 | "type": "text", |
| 29 | "label": "Email", |
| 30 | "validation": {"max_length": 254}, |
| 31 | "permissions": {"public": "hidden"}, |
| 32 | "help": "Carried from the source's anonymous-guestbook shape. Hidden from public reads even though v1 has no public-write path to it -- defense in depth, matching the public-write-hardening spec's posture for contact fields." |
| 33 | }, |
| 34 | { |
| 35 | "name": "author_url", |
| 36 | "type": "text", |
| 37 | "label": "URL", |
| 38 | "validation": {"max_length": 300}, |
| 39 | "permissions": {"owner": "edit", "role:admin": "edit", "role:superuser": "edit", "default": "read"} |
| 40 | }, |
| 41 | { |
| 42 | "name": "content", |
| 43 | "type": "textarea", |
| 44 | "required": true, |
| 45 | "label": "Comment", |
| 46 | "validation": {"min_length": 1, "max_length": 2000}, |
| 47 | "permissions": {"owner": "edit", "role:admin": "edit", "role:superuser": "edit", "default": "read"} |
| 48 | }, |
| 49 | { |
| 50 | "name": "status", |
| 51 | "type": "enum", |
| 52 | "label": "Status", |
| 53 | "default": "pending", |
| 54 | "enum": ["pending", "approved", "rejected"], |
| 55 | "permissions": { |
| 56 | "owner": "read", |
| 57 | "role:moderator": "edit", |
| 58 | "default": "hidden" |
| 59 | }, |
| 60 | "transitions": { |
| 61 | "pending": ["approved", "rejected"], |
| 62 | "approved": ["rejected"] |
| 63 | }, |
| 64 | "help": "Matches the source: every new comment lands pending and only an approved comment is publicly visible (see permissions/rules.json's row_filter), so other readers only ever receive approved rows and this field tells them nothing; it is hidden from them. The author may read it (so their own pending or rejected comment says so); a moderator may edit it. It was `public: hidden`, and since `public` matches everyone and the most restrictive match wins, nobody -- the author, moderators and the admin token included -- could read or set it through the API, so the transitions below could never run. Same grant as thread_comments.status. Since v4 a moderator moves it on other people's comments: permissions/rules.json grants role:moderator read of every comment and update, and every other client-writable field is the author's and admins' alone, so status is all that update can change. Approving is pending -> approved, rejecting is pending -> rejected, and an approved comment can be taken back to rejected; rejected is final. The moves are no longer guarded: they were guarded on the comment BEING the mover's own (owner_id == $user_id), which let only the commenter move it, and since v3 not even them, so they could never run for anybody. Who may move status is decided by this field's permissions alone, as on thread_comments: a moderator, and not on their own comment (`owner: read` is the more restrictive match). A guard cannot say 'not your own' (a transition guard takes literal and $-variable equalities only). The commenter cannot move it (read, not edit); the admin token is not named, so it neither reads nor sets it. Moderation by the PROFILE owner is still not built." |
| 65 | }, |
| 66 | { |
| 67 | "name": "ip_address", |
| 68 | "type": "text", |
| 69 | "label": "IP Address", |
| 70 | "permissions": {"public": "hidden"}, |
| 71 | "help": "Carried from the source's abuse-tracking field. Nothing in this package stamps it -- no request-context plumbing exists on the create path here -- so it stays empty until a later slice fills it in." |
| 72 | }, |
| 73 | { |
| 74 | "name": "created_at", |
| 75 | "type": "datetime", |
| 76 | "label": "Created", |
| 77 | "read_only": true |
| 78 | }, |
| 79 | { |
| 80 | "name": "owner_id", |
| 81 | "type": "text", |
| 82 | "label": "Owner", |
| 83 | "permissions": {"owner": "edit", "role:admin": "edit", "role:superuser": "edit", "default": "read"} |
| 84 | } |
| 85 | ], |
| 86 | "forms": { |
| 87 | "default": {"fields": ["content"]} |
| 88 | }, |
| 89 | "views": { |
| 90 | "list_mode": "cards", |
| 91 | "list_fields": ["content", "status", "created_at"] |
| 92 | } |
| 93 | } |