@coda-console/friends 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -34
- package/lib/avatar.mjs +5 -27
- package/lib/friends.mjs +9 -142
- package/lib/gateway.mjs +16 -165
- package/lib/nickname.mjs +43 -0
- package/lib/outbox.mjs +14 -12
- package/lib/view-members.mjs +38 -0
- package/main.mjs +5 -31
- package/package.json +7 -175
- package/view/app.mjs +148 -460
- package/view/style.css +12 -60
- package/lib/notes.mjs +0 -65
- package/lib/social-streams.mjs +0 -218
- package/lib/view-machine.mjs +0 -42
- package/view/cropper.mjs +0 -106
package/lib/outbox.mjs
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { readJson, writeJson } from './json-file.mjs';
|
|
6
6
|
|
|
7
|
-
/** 网关不替业务发布、撤回的类型:好友关系、名片等 Accord
|
|
8
|
-
export const RESERVED_KINDS = new Set(['binding', 'profile', 'friends', 'coda/profile', 'coda/friends']);
|
|
7
|
+
/** 网关不替业务发布、撤回的类型:好友关系、名片等 Accord 自己的记录;friends/card 是已下线的旧名片,封住旧写路径。 */
|
|
8
|
+
export const RESERVED_KINDS = new Set(['binding', 'profile', 'friends', 'coda/profile', 'coda/friends', 'friends/card']);
|
|
9
9
|
export const MAX_ID_CHARS = 200, MAX_ID_BYTES = 256, MAX_BODY_BYTES = 65536, MAX_AUDIENCE = 500;
|
|
10
10
|
const KIND = /^[a-z][a-z0-9-]{0,63}(?:\/[a-z][a-z0-9-]{0,63})?$/;
|
|
11
11
|
const AUDIENCE = /^(?:public|ed25519:[0-9a-f]{64})$/;
|
|
@@ -62,8 +62,7 @@ export const canonicalHash = value => createHash('sha256').update(JSON.stringify
|
|
|
62
62
|
// 不同作者对同一个 (kind, id) 排下的待撤互不相干,也不挡着对方撤自己的记录。
|
|
63
63
|
// 每次写入发布或撤回的意图都领一个递增的整数 `seq`(落在条目里,不看系统时钟):冲洗按它的先后执行,并据它判断旧撤回是否已被更晚的发布取代。
|
|
64
64
|
// 待发 { seq, kind, id, desired: 'publish', state: queued|paused|no_identity|needs_cert, body, audience, hash, lastError?, + 上次同步的元数据 }
|
|
65
|
-
// 已同步 { seq, kind, id, desired: 'publish', state: 'synced', hash, audience, lastAuthor, lastSyncedHash, lastSyncedAt
|
|
66
|
-
// lastCreatedAt 是 body.createdAt,同一 id 重试时沿用它,不必再查 Accord)
|
|
65
|
+
// 已同步 { seq, kind, id, desired: 'publish', state: 'synced', hash, audience, lastAuthor, lastSyncedHash, lastSyncedAt }(没有 body)
|
|
67
66
|
// 待撤 { seq, kind, id, desired: 'retract', state: queued|no_identity|needs_cert, targetAuthor, lastError?, + 上次同步的元数据 }
|
|
68
67
|
// targetAuthor 是排队时的作者:换了作者就不再替新作者撤,等原作者回来
|
|
69
68
|
// 被拒 { …, state: 'error', lastError }:Accord 明确拒绝,不再自动重试;下一次发布或撤回同一条会替换它
|
|
@@ -97,12 +96,10 @@ export function withState(entry, state, error) {
|
|
|
97
96
|
return { ...rest, state, ...(error ? { lastError: error } : {}) };
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
/** 发布成功:释放 body,只留 `{ seq, kind, id, desired, state: 'synced', hash, audience, lastAuthor, lastSyncedHash, lastSyncedAt }
|
|
101
|
-
export const markSynced = (entry, author, now) =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
lastSyncedAt: now, ...(Number.isSafeInteger(createdAt) && createdAt >= 0 ? { lastCreatedAt: createdAt } : {}) };
|
|
105
|
-
};
|
|
99
|
+
/** 发布成功:释放 body,只留 `{ seq, kind, id, desired, state: 'synced', hash, audience, lastAuthor, lastSyncedHash, lastSyncedAt }`。 */
|
|
100
|
+
export const markSynced = (entry, author, now) =>
|
|
101
|
+
({ seq: entry.seq, kind: entry.kind, id: entry.id, desired: 'publish', state: 'synced', hash: entry.hash, audience: entry.audience, lastAuthor: author, lastSyncedHash: entry.hash,
|
|
102
|
+
lastSyncedAt: now });
|
|
106
103
|
|
|
107
104
|
/** Accord 明确拒绝:不再留 body 和 audience,只留元数据与原因。 */
|
|
108
105
|
export const markRejected = (entry, message) =>
|
|
@@ -118,16 +115,21 @@ export function holdState(entry, certState, pausedKinds) {
|
|
|
118
115
|
|
|
119
116
|
/**
|
|
120
117
|
* 读出整张表 `{ 键: 条目 }`(磁盘上是 `{ seq, entries }`,旧版是直接平铺的条目);键按条目内容重新规范(兼容旧键名),
|
|
121
|
-
*
|
|
118
|
+
* 缺失、损坏、条目不成样子的都丢掉;保留类型(含旧版残留的 friends/card)的条目也丢掉,丢了的个数记在表上不可枚举的 `dropped`,
|
|
119
|
+
* 由冲洗落盘清理。序号计数器取顶层 `seq` 与现存条目最大序号中较大的。
|
|
122
120
|
*/
|
|
123
121
|
export async function readOutbox(dir) {
|
|
124
122
|
const parsed = await readJson(dir, 'outbox.json'), entries = withSeq({}, 0);
|
|
125
123
|
if (!isPlain(parsed)) return entries;
|
|
124
|
+
let dropped = 0;
|
|
126
125
|
const stored = isPlain(parsed.entries) ? parsed.entries : parsed;
|
|
127
126
|
for (const entry of Object.values(stored)) {
|
|
128
127
|
if (isPlain(entry) && typeof entry.kind === 'string' && typeof entry.id === 'string' && ['publish', 'retract'].includes(entry.desired) && typeof entry.state === 'string'
|
|
129
|
-
&& (entry.desired === 'publish' || typeof entry.targetAuthor === 'string'))
|
|
128
|
+
&& (entry.desired === 'publish' || typeof entry.targetAuthor === 'string')) {
|
|
129
|
+
if (RESERVED_KINDS.has(entry.kind)) dropped++; else entries[keyOf(entry)] = entry;
|
|
130
|
+
}
|
|
130
131
|
}
|
|
132
|
+
Object.defineProperty(entries, 'dropped', { value: dropped });
|
|
131
133
|
return withSeq(entries, Math.max(Number.isSafeInteger(parsed.seq) ? parsed.seq : 0, ...Object.values(entries).map(entry => entry.seq ?? 0)));
|
|
132
134
|
}
|
|
133
135
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// 好友页按「视图里的每台电脑」读数据的纯逻辑:成员列表、按身份归组、按电脑分节。不碰 Coda 的 Node API;页面和单测都加载它。
|
|
2
|
+
// 页面不自己选机器:App 的全局视图里有哪几台,页面就读哪几台。
|
|
3
|
+
|
|
4
|
+
import { certStateOf, mergeFriendRows } from './friends.mjs';
|
|
5
|
+
|
|
6
|
+
/** 视图里的成员(去重、保持 coda.machines 的顺序);`unreachable` 是读不到的原因,可达的为 null。 */
|
|
7
|
+
export function listMembers(coda) {
|
|
8
|
+
const list = Array.isArray(coda?.machines) ? coda.machines : [coda?.machine];
|
|
9
|
+
const seen = new Set();
|
|
10
|
+
return list.filter(m => typeof m?.id === 'string' && m.id && !seen.has(m.id) && seen.add(m.id))
|
|
11
|
+
.map(m => ({ id: m.id, name: m.name || m.id, unreachable: m.unreachable ? (m.unreachable === true ? '暂时连不上' : String(m.unreachable)) : null }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 按 `author` 把读到了的成员分组(没有身份的电脑归在 author 为 null 一组;Accord 没读到的成员不参与),组的顺序是成员第一次出现的顺序。
|
|
16
|
+
* `signer` 是代表这个身份证书状态的那一台:组里第一台能签名(证书可用)的,没有就是组里第一台。
|
|
17
|
+
*/
|
|
18
|
+
export function identities(members) {
|
|
19
|
+
const groups = new Map();
|
|
20
|
+
for (const member of members.filter(m => m.loaded)) {
|
|
21
|
+
if (!groups.has(member.author)) groups.set(member.author, []);
|
|
22
|
+
groups.get(member.author).push(member);
|
|
23
|
+
}
|
|
24
|
+
return [...groups].map(([author, group]) => ({ author, members: group, signer: group.find(m => certStateOf(m.entry) === 'active') ?? group[0] }));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 好友按电脑分节:每个成员一节,顺序同视图;节里是这台自己的好友通道(行的内容见 mergeFriendRows),不同电脑上的同一个好友各出现一次。
|
|
29
|
+
* 只有一个成员时 `title` 为 null(不出节标题);读不到的成员(宿主标了 `unreachable`,或 Accord 读失败 `accordProblem`)`unreachable` 写明原因,没有行。
|
|
30
|
+
*/
|
|
31
|
+
export function friendSections(members) {
|
|
32
|
+
return members.map(member => ({
|
|
33
|
+
member,
|
|
34
|
+
title: members.length > 1 ? member.name : null,
|
|
35
|
+
unreachable: member.unreachable || member.accordProblem || null,
|
|
36
|
+
rows: member.unreachable || member.accordProblem ? [] : mergeFriendRows(member.friends),
|
|
37
|
+
}));
|
|
38
|
+
}
|
package/main.mjs
CHANGED
|
@@ -1,38 +1,13 @@
|
|
|
1
|
-
// 好友插件的模块(Coda 的 docs/plugins.md「插件宿主」)。好友页自己的 Accord 读写在页面里发起(页面用自己的 coda.
|
|
2
|
-
// coda.call /
|
|
3
|
-
//
|
|
4
|
-
// 也能用 `coda self notes.list|notes.set|notes.delete` 读写;
|
|
5
|
-
// - 业务无关的社交网关 friends/social@1(lib/gateway.mjs):别的插件经它读好友、发布与撤回记录,全部透传 coda/accord@1;
|
|
6
|
-
// 发布策略用 `coda self policy.get|policy.setKind` 读写。
|
|
1
|
+
// 好友插件的模块(Coda 的 docs/plugins.md「插件宿主」)。好友页自己的 Accord 读写在页面里发起(页面用自己的 coda.watch /
|
|
2
|
+
// coda.call);模块只管业务无关的社交网关 friends/social@1(lib/gateway.mjs):别的插件经它读好友、发布与撤回记录,
|
|
3
|
+
// 全部透传 coda/accord@1;发布策略用 `coda self policy.get|policy.setKind` 读写。
|
|
7
4
|
import { createGateway } from './lib/gateway.mjs';
|
|
8
|
-
import { deleteNote, readNotes, setNote } from './lib/notes.mjs';
|
|
9
5
|
|
|
10
|
-
let
|
|
6
|
+
let gateway = null;
|
|
11
7
|
const handles = [];
|
|
12
8
|
|
|
13
9
|
export async function activate(coda) {
|
|
14
|
-
|
|
15
|
-
const actions = {
|
|
16
|
-
'notes.list': () => readNotes(dir),
|
|
17
|
-
'notes.set': ({ node, note } = {}) => setNote(dir, node, note),
|
|
18
|
-
'notes.delete': ({ node } = {}) => deleteNote(dir, node),
|
|
19
|
-
};
|
|
20
|
-
const run = (name, input) => {
|
|
21
|
-
if (!dir) throw new Error('这台机器没有插件状态目录,备注存不下');
|
|
22
|
-
return actions[name](input);
|
|
23
|
-
};
|
|
24
|
-
for (const name of Object.keys(actions)) handles.push(coda.self.handle(name, input => run(name, input ?? {})));
|
|
25
|
-
coda.views.register('friends', {
|
|
26
|
-
open(view) {
|
|
27
|
-
view.onMessage(async message => {
|
|
28
|
-
const name = message?.type;
|
|
29
|
-
if (!Object.hasOwn(actions, name) || typeof message.rid !== 'string') return;
|
|
30
|
-
try { view.postMessage({ type: 'reply', rid: message.rid, ok: true, value: await run(name, message) }); }
|
|
31
|
-
catch (e) { view.postMessage({ type: 'reply', rid: message.rid, ok: false, error: String(e?.message ?? e) }); }
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
gateway = createGateway(coda, dir);
|
|
10
|
+
gateway = createGateway(coda, coda.plugin.state);
|
|
36
11
|
for (const [name, fn] of Object.entries(gateway.policy)) handles.push(coda.self.handle(name, input => fn(input ?? {})));
|
|
37
12
|
await gateway.start();
|
|
38
13
|
}
|
|
@@ -41,5 +16,4 @@ export function deactivate() {
|
|
|
41
16
|
gateway?.stop();
|
|
42
17
|
gateway = null;
|
|
43
18
|
for (const handle of handles.splice(0)) handle?.dispose?.();
|
|
44
|
-
dir = null;
|
|
45
19
|
}
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@coda-console/friends",
|
|
3
3
|
"id": "friends",
|
|
4
4
|
"displayName": "好友",
|
|
5
|
-
"description": "管理 Accord
|
|
5
|
+
"description": "管理 Accord 身份与熟人好友通道,并提供业务无关的好友网关",
|
|
6
6
|
"icon": { "symbol": "person.2.fill", "color": "blue" },
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.6.0",
|
|
8
8
|
"categories": [
|
|
9
9
|
"Skills 与工具"
|
|
10
10
|
],
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
{
|
|
41
41
|
"name": "friends/social@1",
|
|
42
42
|
"title": "好友社交网关",
|
|
43
|
-
"description": "
|
|
43
|
+
"description": "业务无关的好友网关:读好友与好友分享的记录,向好友发布、撤回记录;签名与记录全部透传 coda/accord@1,没有身份或证书过期时在本机排队,恢复后自动补发。",
|
|
44
44
|
"spec": {
|
|
45
45
|
"type": "object",
|
|
46
46
|
"properties": { "version": { "const": 1 } },
|
|
@@ -73,10 +73,9 @@
|
|
|
73
73
|
"properties": {
|
|
74
74
|
"selfAuthor": { "type": ["string", "null"] },
|
|
75
75
|
"certState": { "enum": ["no_identity", "needs_cert", "active"] },
|
|
76
|
-
"friends": { "type": "array", "items": { "type": "object" } }
|
|
77
|
-
"truncated": { "type": "boolean" }
|
|
76
|
+
"friends": { "type": "array", "items": { "type": "object" } }
|
|
78
77
|
},
|
|
79
|
-
"required": ["selfAuthor", "certState", "friends"
|
|
78
|
+
"required": ["selfAuthor", "certState", "friends"],
|
|
80
79
|
"additionalProperties": false
|
|
81
80
|
}
|
|
82
81
|
},
|
|
@@ -136,145 +135,6 @@
|
|
|
136
135
|
"additionalProperties": false
|
|
137
136
|
}
|
|
138
137
|
},
|
|
139
|
-
"set-card": {
|
|
140
|
-
"idempotent": true,
|
|
141
|
-
"input": {
|
|
142
|
-
"type": "object",
|
|
143
|
-
"properties": {
|
|
144
|
-
"name": { "type": "string", "minLength": 1, "maxLength": 40 },
|
|
145
|
-
"emoji": { "type": "string", "maxLength": 8 },
|
|
146
|
-
"color": { "enum": ["blue", "orange", "green", "purple", "pink", "teal", "gray"] },
|
|
147
|
-
"avatar": {
|
|
148
|
-
"anyOf": [
|
|
149
|
-
{
|
|
150
|
-
"type": "object",
|
|
151
|
-
"description": "内容寻址的图片指针(BlobPointer):path 只收 content/<sha256>,sha256 须与 path 里的一致",
|
|
152
|
-
"properties": {
|
|
153
|
-
"owner": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
|
|
154
|
-
"path": { "type": "string", "pattern": "^content/[0-9a-f]{64}$" },
|
|
155
|
-
"sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
156
|
-
"mime": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
157
|
-
"size": { "type": "integer", "minimum": 0, "maximum": 5242880 },
|
|
158
|
-
"name": { "type": "string", "minLength": 1, "maxLength": 200 }
|
|
159
|
-
},
|
|
160
|
-
"required": ["owner", "path", "sha256"],
|
|
161
|
-
"additionalProperties": false
|
|
162
|
-
},
|
|
163
|
-
{ "type": "null" }
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
"required": ["name"],
|
|
168
|
-
"additionalProperties": false
|
|
169
|
-
},
|
|
170
|
-
"result": {
|
|
171
|
-
"type": "object",
|
|
172
|
-
"properties": {
|
|
173
|
-
"state": { "enum": ["synced", "queued", "paused", "no_identity", "needs_cert", "error"] },
|
|
174
|
-
"skipped": { "type": "boolean" },
|
|
175
|
-
"author": { "type": ["string", "null"] },
|
|
176
|
-
"version": { "type": "integer", "minimum": 0 },
|
|
177
|
-
"error": { "type": "string" }
|
|
178
|
-
},
|
|
179
|
-
"required": ["state"],
|
|
180
|
-
"additionalProperties": false
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
"send-dm": {
|
|
184
|
-
"idempotent": true,
|
|
185
|
-
"input": {
|
|
186
|
-
"type": "object",
|
|
187
|
-
"properties": {
|
|
188
|
-
"to": { "type": "string", "pattern": "^ed25519:[0-9a-f]{64}$" },
|
|
189
|
-
"id": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*[^\\s\\u0000-\\u001f\\u007f-\\u009f][^\\u0000-\\u001f\\u007f-\\u009f]*$", "description": "至多 200 个字符且 UTF-8 至多 256 字节,不含控制字符,去首尾空白后不能为空;省略由网关生成 UUID" },
|
|
190
|
-
"text": { "type": "string", "maxLength": 8000, "description": "至多 8000 个字符(码点,按原样计,含首尾空白),发布时去首尾空白" },
|
|
191
|
-
"attachments": {
|
|
192
|
-
"type": "array",
|
|
193
|
-
"minItems": 1,
|
|
194
|
-
"maxItems": 4,
|
|
195
|
-
"items": {
|
|
196
|
-
"type": "object",
|
|
197
|
-
"description": "内容寻址的图片指针(BlobPointer):path 只收 content/<sha256>,sha256 须与 path 里的一致",
|
|
198
|
-
"properties": {
|
|
199
|
-
"owner": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
|
|
200
|
-
"path": { "type": "string", "pattern": "^content/[0-9a-f]{64}$" },
|
|
201
|
-
"sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
202
|
-
"mime": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
203
|
-
"size": { "type": "integer", "minimum": 0, "maximum": 5242880 },
|
|
204
|
-
"name": { "type": "string", "minLength": 1, "maxLength": 200 }
|
|
205
|
-
},
|
|
206
|
-
"required": ["owner", "path", "sha256"],
|
|
207
|
-
"additionalProperties": false
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
"replyTo": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*[^\\s\\u0000-\\u001f\\u007f-\\u009f][^\\u0000-\\u001f\\u007f-\\u009f]*$", "description": "所回复私信的 id:与 id 同样至多 200 个字符且 UTF-8 至多 256 字节,不含控制字符" }
|
|
211
|
-
},
|
|
212
|
-
"required": ["to"],
|
|
213
|
-
"additionalProperties": false
|
|
214
|
-
},
|
|
215
|
-
"result": {
|
|
216
|
-
"type": "object",
|
|
217
|
-
"properties": {
|
|
218
|
-
"state": { "enum": ["synced", "queued", "paused", "no_identity", "needs_cert", "error"] },
|
|
219
|
-
"id": { "type": "string" },
|
|
220
|
-
"skipped": { "type": "boolean" },
|
|
221
|
-
"author": { "type": ["string", "null"] },
|
|
222
|
-
"version": { "type": "integer", "minimum": 0 },
|
|
223
|
-
"error": { "type": "string" }
|
|
224
|
-
},
|
|
225
|
-
"required": ["state"],
|
|
226
|
-
"additionalProperties": false
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
"post-feed": {
|
|
230
|
-
"idempotent": true,
|
|
231
|
-
"input": {
|
|
232
|
-
"type": "object",
|
|
233
|
-
"properties": {
|
|
234
|
-
"id": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*[^\\s\\u0000-\\u001f\\u007f-\\u009f][^\\u0000-\\u001f\\u007f-\\u009f]*$", "description": "至多 200 个字符且 UTF-8 至多 256 字节,不含控制字符,去首尾空白后不能为空;省略由网关生成 UUID" },
|
|
235
|
-
"text": { "type": "string", "maxLength": 8000, "description": "至多 8000 个字符(码点,按原样计,含首尾空白),发布时去首尾空白" },
|
|
236
|
-
"media": {
|
|
237
|
-
"type": "array",
|
|
238
|
-
"minItems": 1,
|
|
239
|
-
"maxItems": 4,
|
|
240
|
-
"items": {
|
|
241
|
-
"type": "object",
|
|
242
|
-
"description": "内容寻址的图片指针(BlobPointer):path 只收 content/<sha256>,sha256 须与 path 里的一致",
|
|
243
|
-
"properties": {
|
|
244
|
-
"owner": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
|
|
245
|
-
"path": { "type": "string", "pattern": "^content/[0-9a-f]{64}$" },
|
|
246
|
-
"sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
247
|
-
"mime": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
248
|
-
"size": { "type": "integer", "minimum": 0, "maximum": 5242880 },
|
|
249
|
-
"name": { "type": "string", "minLength": 1, "maxLength": 200 }
|
|
250
|
-
},
|
|
251
|
-
"required": ["owner", "path", "sha256"],
|
|
252
|
-
"additionalProperties": false
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
"audience": {
|
|
256
|
-
"type": "array",
|
|
257
|
-
"items": { "type": "string", "pattern": "^(?:public|ed25519:[0-9a-f]{64})$" },
|
|
258
|
-
"minItems": 1,
|
|
259
|
-
"maxItems": 500
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
"additionalProperties": false
|
|
263
|
-
},
|
|
264
|
-
"result": {
|
|
265
|
-
"type": "object",
|
|
266
|
-
"properties": {
|
|
267
|
-
"state": { "enum": ["synced", "queued", "paused", "no_identity", "needs_cert", "error"] },
|
|
268
|
-
"id": { "type": "string" },
|
|
269
|
-
"skipped": { "type": "boolean" },
|
|
270
|
-
"author": { "type": ["string", "null"] },
|
|
271
|
-
"version": { "type": "integer", "minimum": 0 },
|
|
272
|
-
"error": { "type": "string" }
|
|
273
|
-
},
|
|
274
|
-
"required": ["state"],
|
|
275
|
-
"additionalProperties": false
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
138
|
"retract": {
|
|
279
139
|
"idempotent": true,
|
|
280
140
|
"input": {
|
|
@@ -335,37 +195,9 @@
|
|
|
335
195
|
}
|
|
336
196
|
}
|
|
337
197
|
},
|
|
338
|
-
"streams": {
|
|
339
|
-
"dm": {
|
|
340
|
-
"shape": "read",
|
|
341
|
-
"frames": true,
|
|
342
|
-
"description": "私信的实时帧流:首帧 { type: 'snapshot', cursor, items }(按 createdAt 升序),之后每次变化一帧 { type: 'upsert', cursor, item } 或 { type: 'retract', cursor, author, id, peer };peer 只看与这位好友的私信,after 给上次的 cursor 只补增量,续不上回到快照",
|
|
343
|
-
"input": {
|
|
344
|
-
"type": "object",
|
|
345
|
-
"properties": {
|
|
346
|
-
"peer": { "type": "string", "pattern": "^ed25519:[0-9a-f]{64}$" },
|
|
347
|
-
"after": { "type": "string", "minLength": 1, "maxLength": 128 }
|
|
348
|
-
},
|
|
349
|
-
"additionalProperties": false
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
"feed": {
|
|
353
|
-
"shape": "read",
|
|
354
|
-
"frames": true,
|
|
355
|
-
"description": "好友动态的实时帧流:首帧 { type: 'snapshot', cursor, items }(按 createdAt 降序),之后每次变化一帧 { type: 'upsert', cursor, item } 或 { type: 'retract', cursor, author, id };author 只看这一位的,after 给上次的 cursor 只补增量,续不上回到快照",
|
|
356
|
-
"input": {
|
|
357
|
-
"type": "object",
|
|
358
|
-
"properties": {
|
|
359
|
-
"author": { "type": "string", "pattern": "^ed25519:[0-9a-f]{64}$" },
|
|
360
|
-
"after": { "type": "string", "minLength": 1, "maxLength": 128 }
|
|
361
|
-
},
|
|
362
|
-
"additionalProperties": false
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
198
|
"permissions": {
|
|
367
|
-
"read": { "title": "
|
|
368
|
-
"publish": { "title": "
|
|
199
|
+
"read": { "title": "查看好友列表、读取好友分享的记录", "read": true, "operations": ["friends", "records"] },
|
|
200
|
+
"publish": { "title": "通过好友网关发布、撤回记录、查看待发队列", "operations": ["publish", "retract", "outbox"] }
|
|
369
201
|
}
|
|
370
202
|
}
|
|
371
203
|
],
|