Skip to content

fix: fixed the old social bindings resurfacing when they have already…#1064

Open
Sahil2004 wants to merge 1 commit into
mainfrom
fix/oldSocialBindings
Open

fix: fixed the old social bindings resurfacing when they have already…#1064
Sahil2004 wants to merge 1 commit into
mainfrom
fix/oldSocialBindings

Conversation

@Sahil2004

@Sahil2004 Sahil2004 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

… binded.

Description of change

Critical to know

The logic removes from backend the social bindings that came due to mistakenly re-scanning of qr even after binding was already done between the two parties. If we need to have an update by rescanning the qr, then the logic added in this PR needs to change.

Issue Number

Closes #1001

Type of change

  • Fix (a change which fixes an issue)

How the change has been tested

Manually.

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Summary by CodeRabbit

  • Bug Fixes
    • Prevented already-connected contacts from showing up again as new social-binding requests.
    • Automatically clears outdated, unsigned social-binding items when opening the binding drawer, reducing duplicate prompts.

@Sahil2004 Sahil2004 self-assigned this Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added a collectBoundSigners helper and exported pruneBoundSignerDocs function in socialBinding.ts to detect and delete stale unsigned social_connection documents from already-bound signers. Updated fetchUnsignedSocialDocs filtering accordingly, and wired a fire-and-forget cleanup call into SocialBindingDrawer.svelte's vault initialization before QR polling.

Changes

Stale Social Binding Cleanup

Layer / File(s) Summary
Bound signer detection and filtering
infrastructure/eid-wallet/src/lib/utils/socialBinding.ts
Adds collectBoundSigners to identify originators whose bindings are already counter-signed by the caller, and updates fetchUnsignedSocialDocs to exclude their stale unsigned envelopes.
Pruning function
infrastructure/eid-wallet/src/lib/utils/socialBinding.ts
Adds exported pruneBoundSignerDocs to fetch, filter, and delete stale unsigned social_connection documents addressed to the caller whose originators are already bound, returning the deleted count.
Drawer initialization wiring
infrastructure/eid-wallet/src/routes/(app)/main/components/SocialBindingDrawer.svelte
Imports and invokes pruneBoundSignerDocs asynchronously during initFromVault(), before QR polling starts, to prevent stale requests from resurfacing.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SocialBindingDrawer
  participant socialBindingUtils as socialBinding.ts
  participant GraphQLBackend

  SocialBindingDrawer->>SocialBindingDrawer: initFromVault()
  SocialBindingDrawer->>socialBindingUtils: pruneBoundSignerDocs(gqlUrl, ename)
  socialBindingUtils->>GraphQLBackend: fetch social_connection docs
  GraphQLBackend-->>socialBindingUtils: edges
  socialBindingUtils->>socialBindingUtils: collectBoundSigners(edges)
  socialBindingUtils->>GraphQLBackend: deleteSocialBindingDoc(stale docs)
  socialBindingUtils-->>SocialBindingDrawer: deleted count
  SocialBindingDrawer->>SocialBindingDrawer: startPolling()
Loading

Related issues: #1001 — addresses previously bound contacts resurfacing as social connection requests when opening the QR scanner, by pruning stale unsigned documents from already-bound signers during vault initialization.

Suggested reviewers: Talha

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and refers to the social bindings resurfacing bug addressed by the PR.
Description check ✅ Passed The description includes the required sections and enough detail on type, testing, and checklist.
Linked Issues check ✅ Passed The code prevents stale or already-bound social connection requests from resurfacing, matching #1001.
Out of Scope Changes check ✅ Passed The changes stay focused on social binding cleanup and QR-scanner behavior, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/oldSocialBindings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sahil2004 Sahil2004 marked this pull request as ready for review July 3, 2026 16:50
@Sahil2004 Sahil2004 requested a review from coodos as a code owner July 3, 2026 16:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
infrastructure/eid-wallet/src/lib/utils/socialBinding.ts (1)

606-622: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Optional: the fetch + collectBoundSigners + filter block largely duplicates fetchUnsignedSocialDocs.

Both functions run the same query, compute boundSigners, and apply the same type/subject/alreadySigned/originator ∈ boundSigners predicate — pruneBoundSignerDocs only inverts the last condition to select stale docs rather than exclude them. Extracting a shared isStaleBoundSignerDoc(parsed, normalized, boundSigners) predicate (and optionally a small "fetch edges + boundSigners" helper) would keep the two paths from drifting apart as the binding model evolves.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@infrastructure/eid-wallet/src/lib/utils/socialBinding.ts` around lines 606 -
622, The stale-doc filtering logic in socialBinding.ts duplicates the same query
and predicate flow used by fetchUnsignedSocialDocs, so refactor it to share a
common helper. Extract a reusable isStaleBoundSignerDoc(parsed, normalized,
boundSigners) predicate (and, if helpful, a small helper for fetching edges and
computing boundSigners) that both pruneBoundSignerDocs and
fetchUnsignedSocialDocs can call. Keep the current semantics intact: check
parsed.type, parsed.subject, skip already-signed docs, and use the
originator-in-boundSigners condition consistently so the two paths cannot drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@infrastructure/eid-wallet/src/lib/utils/socialBinding.ts`:
- Around line 606-622: The stale-doc filtering logic in socialBinding.ts
duplicates the same query and predicate flow used by fetchUnsignedSocialDocs, so
refactor it to share a common helper. Extract a reusable
isStaleBoundSignerDoc(parsed, normalized, boundSigners) predicate (and, if
helpful, a small helper for fetching edges and computing boundSigners) that both
pruneBoundSignerDocs and fetchUnsignedSocialDocs can call. Keep the current
semantics intact: check parsed.type, parsed.subject, skip already-signed docs,
and use the originator-in-boundSigners condition consistently so the two paths
cannot drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d095c624-c7ad-4c09-99ca-684810f3b7b2

📥 Commits

Reviewing files that changed from the base of the PR and between c6f8c3e and a5b6501.

⛔ Files ignored due to path filters (1)
  • infrastructure/eid-wallet/src-tauri/gen/android/.idea/deploymentTargetSelector.xml is excluded by !**/gen/**
📒 Files selected for processing (2)
  • infrastructure/eid-wallet/src/lib/utils/socialBinding.ts
  • infrastructure/eid-wallet/src/routes/(app)/main/components/SocialBindingDrawer.svelte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Previously added bindings appear as Social Connection Requests when opening QR code scanner

1 participant