fedipod-server 0.13.1 → 0.14.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/lib/client/masto/accounts.mjs +6 -1
- package/lib/client/masto/statuses.mjs +16 -2
- package/lib/connections/bskyfeed.mjs +79 -8
- package/lib/core/intake/notes.mjs +7 -1
- package/lib/core/publisher/notes.mjs +17 -0
- package/lib/core/publisher/questions.mjs +2 -0
- package/lib/core/store.mjs +30 -1
- package/lib/gateway/front-core.mjs +3 -1
- package/package.json +1 -1
- package/web/app/dist/sw.js +141 -21
- package/web/app/dist/sw.js.map +3 -3
- package/web/app/site/sw.js +61 -7
package/web/app/site/sw.js
CHANGED
|
@@ -34555,8 +34555,40 @@ var PodStore = class {
|
|
|
34555
34555
|
this.cache.set("ids.json", ids);
|
|
34556
34556
|
return id;
|
|
34557
34557
|
}
|
|
34558
|
+
// The map first, for ids minted under an older scheme. Then, because the
|
|
34559
|
+
// id IS the hash of the url, whatever this store knows is scanned for the
|
|
34560
|
+
// url that hashes to it — actors, posts, contacts, requests, media. The
|
|
34561
|
+
// browser build's worker is stopped whenever it idles, and the in-memory
|
|
34562
|
+
// map went with it: a client clicking an account it had just been shown
|
|
34563
|
+
// reached a fresh worker that held the actor and could not name it.
|
|
34558
34564
|
urlFor(id) {
|
|
34559
|
-
|
|
34565
|
+
const ids = this.getIds();
|
|
34566
|
+
if (ids[id]) return ids[id];
|
|
34567
|
+
if (!/^[a-f0-9]{16}$/u.test(String(id))) return null;
|
|
34568
|
+
const hash = (u) => node_crypto_default.createHash("sha256").update(u).digest("hex").slice(0, 16);
|
|
34569
|
+
const seen = /* @__PURE__ */ new Set();
|
|
34570
|
+
const candidates = function* (store) {
|
|
34571
|
+
for (const u of Object.keys(store.getActors())) yield u;
|
|
34572
|
+
for (const st2 of store.getStatuses()) {
|
|
34573
|
+
yield st2.noteId;
|
|
34574
|
+
yield st2.actor;
|
|
34575
|
+
for (const a of st2.attachments || []) if (a?.url) yield a.url;
|
|
34576
|
+
}
|
|
34577
|
+
const c = store.getContacts();
|
|
34578
|
+
for (const f of [...c.followers, ...c.following]) if (f?.actor) yield f.actor;
|
|
34579
|
+
for (const r of store.getRequests()) if (r?.actor) yield r.actor;
|
|
34580
|
+
for (const u of Object.keys(store.getMedia())) yield u;
|
|
34581
|
+
};
|
|
34582
|
+
for (const u of candidates(this)) {
|
|
34583
|
+
if (typeof u !== "string" || seen.has(u)) continue;
|
|
34584
|
+
seen.add(u);
|
|
34585
|
+
if (hash(u) === id) {
|
|
34586
|
+
ids[id] = u;
|
|
34587
|
+
this.cache.set("ids.json", ids);
|
|
34588
|
+
return u;
|
|
34589
|
+
}
|
|
34590
|
+
}
|
|
34591
|
+
return null;
|
|
34560
34592
|
}
|
|
34561
34593
|
};
|
|
34562
34594
|
|
|
@@ -55914,6 +55946,17 @@ async function mentionsFor(publisher, content, inReplyTo) {
|
|
|
55914
55946
|
}
|
|
55915
55947
|
return mentions;
|
|
55916
55948
|
}
|
|
55949
|
+
function assertDirectAddressed(content, mentions) {
|
|
55950
|
+
const wanted = [...new Set(mentionsIn(content))];
|
|
55951
|
+
const missing = wanted.filter((h) => !mentions.some((m) => m.handle === h));
|
|
55952
|
+
let why = null;
|
|
55953
|
+
if (!wanted.length) why = "a direct message names who it is for \u2014 mention them as @name@host";
|
|
55954
|
+
else if (missing.length) why = `could not find ${missing.map((h) => "@" + h).join(", ")} \u2014 the direct message was not sent`;
|
|
55955
|
+
if (!why) return;
|
|
55956
|
+
const e = new Error(why);
|
|
55957
|
+
e.code = "unaddressed";
|
|
55958
|
+
throw e;
|
|
55959
|
+
}
|
|
55917
55960
|
async function publishNote(publisher, content, { inReplyTo, attachments, visibility = "public", spoilerText = null } = {}) {
|
|
55918
55961
|
const { urls } = publisher;
|
|
55919
55962
|
const priv = visibility === "private" || visibility === "direct";
|
|
@@ -55924,6 +55967,7 @@ async function publishNote(publisher, content, { inReplyTo, attachments, visibil
|
|
|
55924
55967
|
const published = (/* @__PURE__ */ new Date()).toISOString();
|
|
55925
55968
|
const slug = published.slice(0, 10) + "-" + node_crypto_default.randomBytes(4).toString("hex");
|
|
55926
55969
|
const mentions = await publisher._mentionsFor(content, inReplyTo);
|
|
55970
|
+
if (visibility === "direct") assertDirectAddressed(content, mentions);
|
|
55927
55971
|
const note = noteDoc({
|
|
55928
55972
|
urls,
|
|
55929
55973
|
slug,
|
|
@@ -56125,6 +56169,7 @@ async function publishQuestion(publisher, content, {
|
|
|
56125
56169
|
const published = (/* @__PURE__ */ new Date()).toISOString();
|
|
56126
56170
|
const slug = published.slice(0, 10) + "-" + node_crypto_default.randomBytes(4).toString("hex");
|
|
56127
56171
|
const mentions = await publisher._mentionsFor(content, inReplyTo);
|
|
56172
|
+
if (visibility === "direct") assertDirectAddressed(content, mentions);
|
|
56128
56173
|
const poll = {
|
|
56129
56174
|
multiple: !!multiple,
|
|
56130
56175
|
expiresAt: expiresAt || null,
|
|
@@ -57620,7 +57665,9 @@ async function ingestNote(intake, objectId, actor, { via } = {}) {
|
|
|
57620
57665
|
...attachments.length ? { attachments } : {},
|
|
57621
57666
|
...via ? { via } : {}
|
|
57622
57667
|
});
|
|
57623
|
-
|
|
57668
|
+
const namesUs = mentions.some((m) => m.href === intake.urls.actor);
|
|
57669
|
+
const replyToOurs = !!note.inReplyTo && String(note.inReplyTo).startsWith(intake.urls.notes);
|
|
57670
|
+
if (!followed || replyToOurs || direct || namesUs) {
|
|
57624
57671
|
intake.store.addNotification({ type: "mention", actor: author, noteId: note.id });
|
|
57625
57672
|
}
|
|
57626
57673
|
if (note.inReplyTo && String(note.inReplyTo).startsWith(intake.urls.notes)) {
|
|
@@ -65493,7 +65540,8 @@ async function handle4(api, ctx) {
|
|
|
65493
65540
|
}
|
|
65494
65541
|
const hit = Object.entries(api.store.getActors()).find(([u, a]) => {
|
|
65495
65542
|
try {
|
|
65496
|
-
|
|
65543
|
+
const at = new URL(u);
|
|
65544
|
+
return `${a.preferredUsername}@${at.host}` === acct || `${a.preferredUsername}@${at.hostname}` === acct;
|
|
65497
65545
|
} catch {
|
|
65498
65546
|
return false;
|
|
65499
65547
|
}
|
|
@@ -65925,10 +65973,16 @@ async function handle6(api, ctx) {
|
|
|
65925
65973
|
api.store.setScheduled(sched);
|
|
65926
65974
|
return send(200, api.scheduledJson(entry));
|
|
65927
65975
|
}
|
|
65928
|
-
|
|
65929
|
-
|
|
65930
|
-
|
|
65931
|
-
|
|
65976
|
+
let note;
|
|
65977
|
+
try {
|
|
65978
|
+
note = await api.agent.publisher.publishNote(
|
|
65979
|
+
body.status,
|
|
65980
|
+
{ inReplyTo, attachments, visibility, spoilerText }
|
|
65981
|
+
);
|
|
65982
|
+
} catch (e) {
|
|
65983
|
+
if (e.code === "unaddressed") return send(422, { error: e.message });
|
|
65984
|
+
throw e;
|
|
65985
|
+
}
|
|
65932
65986
|
const s = api.store.getStatuses().find((x) => x.noteId === note.id);
|
|
65933
65987
|
return send(200, api.status(s));
|
|
65934
65988
|
}
|