feat: implement deleteIdentity with S2S relay for soft/full modes
This commit is contained in:
@@ -427,7 +427,7 @@ function DeleteIdentityDialog({
|
|||||||
const [scope, setScope] = useState<DeletionScope>('this');
|
const [scope, setScope] = useState<DeletionScope>('this');
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
deleteIdentity(origin);
|
deleteIdentity([origin]);
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ interface InstanceState {
|
|||||||
registry: Map<string, FederationRegistryEntry>;
|
registry: Map<string, FederationRegistryEntry>;
|
||||||
registryUpdatedAt: number;
|
registryUpdatedAt: number;
|
||||||
syncRegistry: () => Promise<void>;
|
syncRegistry: () => Promise<void>;
|
||||||
deleteIdentity: (origin: string) => void;
|
deleteIdentity: (origins: string[], mode?: 'leave' | 'soft' | 'full') => Promise<Record<string, { success: boolean; error?: string; ownedSpaces?: { id: string; name: string }[] }>>;
|
||||||
forceRemoveEntry: (origin: string) => void;
|
forceRemoveEntry: (origin: string) => void;
|
||||||
|
|
||||||
probeInstance: (url: string) => Promise<InstanceInfoResponse & { origin: string }>;
|
probeInstance: (url: string) => Promise<InstanceInfoResponse & { origin: string }>;
|
||||||
@@ -703,8 +703,31 @@ export const useInstanceStore = create<InstanceState>((set, get) => ({
|
|||||||
await Promise.all([homePromise, ...remotePromises]);
|
await Promise.all([homePromise, ...remotePromises]);
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteIdentity: (_origin: string) => {
|
deleteIdentity: async (origins: string[], mode: 'leave' | 'soft' | 'full' = 'leave') => {
|
||||||
useUIStore.getState().addToast('Identity deletion is not yet implemented', 'info', 3000);
|
// Leave mode: client-only cleanup, no server call
|
||||||
|
if (mode === 'leave') {
|
||||||
|
for (const origin of origins) {
|
||||||
|
get().forceRemoveEntry(origin);
|
||||||
|
}
|
||||||
|
return Object.fromEntries(origins.map(o => [o, { success: true as const }]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Soft/full mode: S2S relay via home instance
|
||||||
|
try {
|
||||||
|
const { results } = await api.users.deleteFederationIdentity({ origins, mode });
|
||||||
|
|
||||||
|
// Clean up client-side state for successful deletions
|
||||||
|
for (const [origin, result] of Object.entries(results)) {
|
||||||
|
if (result.success) {
|
||||||
|
get().forceRemoveEntry(origin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
} catch (err) {
|
||||||
|
const error = err instanceof Error ? err.message : 'Unknown error';
|
||||||
|
return Object.fromEntries(origins.map(o => [o, { success: false as const, error }]));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
forceRemoveEntry: (origin: string) => {
|
forceRemoveEntry: (origin: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user