服务器 动态与通知
动态与通知
每次改动都会被记录为动态,无论由谁发起:路由、助手,还是回收站自动清空。动态根据改动前后的网盘推导而来,因此不会有任何遗漏。
本页内容
记录的内容
创建、上传、新版本、重命名、移动、移入回收站和恢复、删除、共享和取消共享、创建和撤回链接、设置颜色;以及由谁、在何时。
文件的详情中有它的动态,文件夹的详情中还包括直接在其中进行的操作(GET /entries/:id/activity、client.activity);助手可以通过 get_activity 读取。
在代码中
import { activityOf } from '@rebofiles/core';
activityOf(before, after, 'ana', new Date().toISOString());
// [{ action: 'renamed', name: 'final.docx', was: 'draft.docx', by: 'ana', at, entry, parent }]通知相关人员
网盘会在“与我共享”旁统计新内容。如果你想自己通知对方,请为服务器提供 onShare。
createDriveHandler({
...options,
// Once the share is kept; a failure here is not the request's.
onShare: async ({ entry, with: who, role, by, first }) => {
if (first) await mail(who, `${by.id} shared “${entry.name}” with you as ${role}`);
},
});在网盘中通知
与某人或其所在组共享的内容,以及提到某人的评论:显示在网盘上方的铃铛中,旁边显示新通知数量,点击即可打开对应位置。
const { notifications, unseen } = await client.notifications();
// [{ kind: 'shared', entry, name: 'Budget', by: 'ana', role: 'editor', at }, { kind: 'mentioned', text, … }]
await client.sawNotifications(); // none is new any more为每个人和每个组保存(inbox:<who>),最多两百条;查看后不再有新通知(POST /notifications/seen)。自己做的操作不会通知自己。发送邮件仍由你的应用通过 onShare 和 onComment 完成。
整个网盘
有配置权限的人可在“设置 → 成员”中查看:每个人和整个网盘的文件数、文件夹数和占用空间,以及网盘中任何位置的最新动态。
// For who may 'configure': what each keeps, and what was done anywhere.
const { people, total, quota } = await client.adminUsage(); // GET /admin/usage
const latest = await client.adminActivity(100); // GET /admin/activity每人的空间 每次请求时读取整个网盘来计算:供管理员偶尔查看,而不是每个页面都调用。
须知
改动会被保存,但可能没有对应的动态记录 如果存储写入动态失败:改动属于网盘本身,动态记录只是附带的。