切换主题
treehole_care_action
/api/treehole/posts
{emoji:'hug_blue'}
post_id
action_type
status
[post_id, createdAt asc]
[post_id, action_type]
[post_id, user_id, action_type='hug']
{ "read": "status == 'active' || _openid == auth.openid || auth.role in ['moderator','counselor']", "write": "_openid == auth.openid || auth.role in ['moderator']" }
守护员可隐藏或恢复互动;作者可删除自身回复。
posts
parent_id
comments
user_id
users
metadata
createdAt
updatedAt
risk_flag
API/云函数契约映射 | 接口/函数 | 读/写 | 使用字段 | 过滤条件 | 排序/分页 | 备注 | | /api/treehole/posts/:id/comments GET | 读 | action_type, content, alias_name, createdAt | post_id = :id, status='active' | createdAt asc | 帖子详情 | | /api/treehole/posts/:id/comments POST | 写 | action_type, content, mood_thermometer, alias_name | _openid = auth.openid | - | 发布互动 | | 抱抱云函数 toggleHug | 写 | action_type='hug', status | post_id, _openid | - | 抱抱/取消 | | 风控函数 moderateComment | 写 | status, risk_flag | _id | - | 隐藏违规互动 |
/api/treehole/posts/:id/comments
post_id = :id
status='active'
createdAt asc
_openid = auth.openid
toggleHug
_openid
moderateComment
_id
示例文档(≥3条)
{ "_id": "cmt_5001", "_openid": "oAbcd222", "user_id": "usr_010", "post_id": "post_900", "action_type": "reply", "content": "可以和室友约个安静时间段,互相提醒。", "alias_name": "同路人", "mood_thermometer": 60, "status": "active", "createdAt": "2024-04-05T15:35:00Z", "updatedAt": "2024-04-05T15:35:00Z" } { "_id": "cmt_5002", "_openid": "oAbcd123", "user_id": "usr_001", "post_id": "post_900", "action_type": "hug", "metadata": {"emoji": "hug_blue"}, "status": "active", "createdAt": "2024-04-05T15:40:00Z", "updatedAt": "2024-04-05T15:40:00Z" } { "_id": "cmt_5003", "_openid": "oAbcd789", "user_id": "usr_guard_01", "post_id": "post_900", "action_type": "moderator_note", "content": "如需即时帮助可查看我的页资源地图。", "status": "active", "risk_flag": "watch", "createdAt": "2024-04-05T16:00:00Z", "updatedAt": "2024-04-05T16:00:00Z" }
// 获取帖子回复 const replies = await db.collection('comments').where({ post_id: postId, action_type: 'reply', status: 'active' }).orderBy('createdAt', 'asc').get(); // 抱抱统计 const hugCount = await db.collection('comments').where({ post_id: postId, action_type: 'hug', status: 'active' }).count(); // 审核员查看被举报互动 const reported = await db.collection('comments').where({ status: 'hidden', risk_flag: db.command.in(['watch','escalated']) }).orderBy('updatedAt', 'desc').limit(100).get();
E_HUG_DUPLICATE
E_COMMENT_BLOCKED
E_FORBIDDEN
f67c2
18e56
集合:树洞互动(comments)
1. 目的与使用场景
treehole_care_action提供数据。由/api/treehole/posts子接口、互动云函数、风控审核使用。2. Schema 定义
{emoji:'hug_blue'}3. 索引与唯一约束
post_id、action_type、status[post_id, createdAt asc]、[post_id, action_type][post_id, user_id, action_type='hug']防止重复抱抱4. 访问控制(TCB 权限)
守护员可隐藏或恢复互动;作者可删除自身回复。
post_id→postsparent_id→commentsuser_id→usersstatus置为 hidden。metadata可存储 hug 颜色、收藏渠道等扩展字段。createdAt、updatedAt、status、risk_flag。API/云函数契约映射 | 接口/函数 | 读/写 | 使用字段 | 过滤条件 | 排序/分页 | 备注 | |
/api/treehole/posts/:id/commentsGET | 读 | action_type, content, alias_name, createdAt |post_id = :id,status='active'|createdAt asc| 帖子详情 | |/api/treehole/posts/:id/commentsPOST | 写 | action_type, content, mood_thermometer, alias_name |_openid = auth.openid| - | 发布互动 | | 抱抱云函数toggleHug| 写 | action_type='hug', status |post_id,_openid| - | 抱抱/取消 | | 风控函数moderateComment| 写 | status, risk_flag |_id| - | 隐藏违规互动 |示例文档(≥3条)
E_HUG_DUPLICATE。E_COMMENT_BLOCKED。E_FORBIDDEN。treehole_care_action、社区看板统计。贡献者
文件历史