community: the encrypted inbox, friend requests and shares travel sealed to a box key when the other side has published one
This commit is contained in:
1 parent
13c44f731a
commit
4378c4c0cc
14 files changed
+1387
-145
No files matched your search
@@ -71,6 +71,10 @@ export const community = $state({
|
||||
sharePreviews: {},
|
||||
/** shared_playlists_mine: what this device has published. */
|
||||
published: [],
|
||||
/** inbox_status: the encrypted inbox's state on this device. */
|
||||
inbox: null,
|
||||
/** What the last check found ({new_items, quarantined, pruned}). */
|
||||
inboxLast: null,
|
||||
/** persona key → ProfileView | {none} | {error} | {pending}: other
|
||||
* people's signed profiles, read once per session when surfaced. */
|
||||
remoteProfiles: {},
|
||||
@@ -323,7 +327,7 @@ export async function initCommunity() {
|
||||
if (p.status === 1 || p.status === 2) noteSeen(p.username);
|
||||
});
|
||||
}
|
||||
await Promise.all([refreshFreenet(), loadContacts(), refreshLinks(), refreshFriends(), refreshShares(), refreshPublished()]);
|
||||
await Promise.all([refreshFreenet(), loadContacts(), refreshLinks(), refreshFriends(), refreshShares(), refreshPublished(), refreshInbox()]);
|
||||
await refreshPersona();
|
||||
}
|
||||
|
||||
@@ -489,7 +493,33 @@ export const shareImport = (card) =>
|
||||
});
|
||||
|
||||
|
||||
// ---- the encrypted inbox --------------------------------------------------------------
|
||||
export async function refreshInbox() {
|
||||
try {
|
||||
community.inbox = await api.inboxStatus();
|
||||
} catch {
|
||||
// stays as it was
|
||||
}
|
||||
}
|
||||
export const publishInbox = () =>
|
||||
run("inbox", async () => {
|
||||
community.inbox = await api.inboxPublish();
|
||||
});
|
||||
/** Read our inbox through the node, act on sealed cargo, prune it. */
|
||||
export const checkInbox = () =>
|
||||
run("inboxcheck", async () => {
|
||||
community.inboxLast = await api.inboxCheck();
|
||||
await Promise.all([refreshInbox(), refreshFriends(), refreshShares()]);
|
||||
return community.inboxLast;
|
||||
});
|
||||
export const friendRequestByKey = (personaKey) => friendAction("friend:" + personaKey, () => api.friendRequestByKey(personaKey));
|
||||
export const friendshipForKey = (key) => {
|
||||
const mine = community.friends.filter((f) => f.persona_key === key);
|
||||
return mine.find((f) => f.state === "friends") ?? mine[0] ?? null;
|
||||
};
|
||||
|
||||
|
||||
// Dev handle beside `__soulstream` (state.svelte.js): probes reach the store
|
||||
// through this, never through a bare import (which would be a second copy).
|
||||
if (import.meta.env.DEV) globalThis.__community = community;
|
||||
if (import.meta.env.DEV) globalThis.__communityActions = { friendRequest, friendAccept, friendDecline, friendRemove, friendForget, checkLink, refreshFriends, sharedPublish, sharedWithdraw, shareSend, sharePreview, shareImport, refreshShares, refreshPublished };
|
||||
if (import.meta.env.DEV) globalThis.__communityActions = { friendRequest, friendRequestByKey, friendAccept, friendDecline, friendRemove, friendForget, checkLink, refreshFriends, sharedPublish, sharedWithdraw, shareSend, sharePreview, shareImport, refreshShares, refreshPublished, publishInbox, checkInbox, refreshInbox };
|
||||
Reference in new issue
Block a user