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
@@ -158,6 +158,7 @@ export const slskLinkCheck = (username) => invoke("slsk_link_check", { username
|
||||
export const slskLinkForget = (username) => invoke("slsk_link_forget", { username });
|
||||
export const friendsList = () => invoke("friends_list");
|
||||
export const friendRequest = (username) => invoke("friend_request", { username });
|
||||
export const friendRequestByKey = (personaKey) => invoke("friend_request_by_key", { personaKey });
|
||||
export const friendAccept = (id) => invoke("friend_accept", { id });
|
||||
export const friendDecline = (id) => invoke("friend_decline", { id });
|
||||
export const friendRemove = (id) => invoke("friend_remove", { id });
|
||||
@@ -170,6 +171,9 @@ export const sharedPlaylistImport = (owner, uuid) => invoke("shared_playlist_imp
|
||||
export const shareSend = (username, playlistId) => invoke("share_send", { username, playlistId });
|
||||
export const sharesInbox = () => invoke("shares_inbox");
|
||||
export const shareDismiss = (id) => invoke("share_dismiss", { id });
|
||||
export const inboxStatus = () => invoke("inbox_status");
|
||||
export const inboxPublish = () => invoke("inbox_publish");
|
||||
export const inboxCheck = () => invoke("inbox_check");
|
||||
export const buddyList = () => invoke("buddy_list");
|
||||
export const buddyAdd = (username) => invoke("buddy_add", { username });
|
||||
export const buddyRemove = (username) => invoke("buddy_remove", { username });
|
||||
|
||||
@@ -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