Skip to content

Friend Request Flow

sequenceDiagram
    participant A as User A (Sender)
    participant S as Ecall Server
    participant B as User B (Receiver)

    Note over A,B: User A initiates add friend...
    alt Using Contact History
        A->>S: POST /friend-request/by-id {targetUserId: B}
    else Using QR/Share Token
        A->>S: POST /friend-request/by-token {token: token}
    end

    rect rgb(239, 246, 255)
    Note over S: Validate request limits & store pending request
    end

    S->>B: Push Notification: .newFriendRequested

    Note right of B: User B opens app, goes to Friend Requests
    B->>S: POST /friend-request/accept

    rect rgb(209, 250, 229)
    Note over S: Create bidirectional contact link (A <-> B)
    end

    S->>A: Push Notification: .acceptFriendRequested

    Note over A,B: ContactsViewModel.fetchContacts() triggered
    Note over A,B: Both users' contact lists & badge counts reload automatically