fedipod-bb 0.5.0 → 0.5.2
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/package.json +1 -1
- package/site/robots.txt +2 -0
- package/src/gateway.mjs +14 -8
- package/src/render.mjs +3 -0
package/package.json
CHANGED
package/site/robots.txt
ADDED
package/src/gateway.mjs
CHANGED
|
@@ -194,10 +194,14 @@ export async function keepOnce(ctx, handle, rec, { log = console.log, session =
|
|
|
194
194
|
let asks = 0;
|
|
195
195
|
try {
|
|
196
196
|
forum = agentFor(ctx, f, { remote, podFetch, copies, log: say, mode: 'run' });
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
// The lease before the connect: connecting writes a category's settings
|
|
198
|
+
// again where the forum's changed, and a copy takes a write only from
|
|
199
|
+
// the lease's holder.
|
|
200
|
+
const lease = forum.givenLease;
|
|
201
|
+
if (!await lease.acquire()) return { skipped: 'another host has the forum', retry: 'soon' };
|
|
200
202
|
try {
|
|
203
|
+
if (!await forum.connect({ act: false })) return { skipped: 'no forum on the pod' };
|
|
204
|
+
prepare?.(forum); // a test's origins, in place of the network
|
|
201
205
|
// A forum on a pod it has not published to — moved there, its rows
|
|
202
206
|
// naming the new pod — is published there whole, and what that pod
|
|
203
207
|
// lacks is read again from where its authors keep it. Recorded once
|
|
@@ -222,7 +226,7 @@ export async function keepOnce(ctx, handle, rec, { log = console.log, session =
|
|
|
222
226
|
await Promise.allSettled(storesOf(forum).map((s) => s.flush()));
|
|
223
227
|
asks = storesOf(forum).reduce((n, s) => n + s.read('modqueue.json', []).length, 0);
|
|
224
228
|
before = new Map(storesOf(forum).map((s) => [s, s.getQueue?.() || []]));
|
|
225
|
-
} finally { await
|
|
229
|
+
} finally { await lease.release().catch(() => {}); }
|
|
226
230
|
} finally { await unlock(); }
|
|
227
231
|
|
|
228
232
|
// The carry, with the forum free.
|
|
@@ -278,15 +282,17 @@ export async function placeAtDoor(ctx, handle, rec, { name, raw, receipt = null,
|
|
|
278
282
|
if (!unlock) return { ...out, why: 'the forum is busy' };
|
|
279
283
|
try {
|
|
280
284
|
const forum = agentFor(ctx, f, { remote, podFetch, copies, log: say, mode: 'door' });
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (!await
|
|
285
|
+
// The lease before the connect, as in the run.
|
|
286
|
+
const lease = forum.givenLease;
|
|
287
|
+
if (!await lease.acquire()) return { ...out, why: 'another host has the forum' };
|
|
284
288
|
try {
|
|
289
|
+
if (!await forum.connect({ act: false })) return { ...out, why: 'no forum on the pod' };
|
|
290
|
+
prepare?.(forum); // a test's origins, in place of the network
|
|
285
291
|
if (!await forum.placeOne(name, raw, receipt)) return { ...out, why: 'not done here; left for the run' };
|
|
286
292
|
const item = f.home + 'ap/inbox/' + name;
|
|
287
293
|
await podInbox.dropHandledItem(remote, item).catch(() => false);
|
|
288
294
|
await podInbox.dropReceiptBeside(remote, item);
|
|
289
295
|
return { ...out, placed: true };
|
|
290
|
-
} finally { await
|
|
296
|
+
} finally { await lease.release().catch(() => {}); }
|
|
291
297
|
} finally { await unlock(); }
|
|
292
298
|
}
|
package/src/render.mjs
CHANGED
|
@@ -52,6 +52,9 @@ function fill(shell, { title, description, forumName, forumHref, modsLine, acts,
|
|
|
52
52
|
async function draw(url, shell, f) {
|
|
53
53
|
const place = placeOf({ origin: url.origin, pathname: url.pathname, search: '' });
|
|
54
54
|
if (!place.own || !place.root || !place.base) return null;
|
|
55
|
+
// Drawn: the front page, a category, a topic. Any other address under the
|
|
56
|
+
// forum is the page's own to build.
|
|
57
|
+
if (!/^(?:c\/[^/]+|t\/[^/]+\/[^/]+)?\/?$/u.test(url.pathname.slice(place.root.length))) return null;
|
|
55
58
|
const view = viewOfPath(url.pathname, place.root);
|
|
56
59
|
const read = reader({ fetch: f, at: AT });
|
|
57
60
|
const forum = await read.forum(place.base);
|