Introducing a new way to review your PRs.

Read the announcement

crmne / zapfast

ZapFast: a fast, native WhatsApp client in Rust and egui

View on GitHub

19 documents · Updated Nov 18, 2026

docs / groups-contacts-and-blocking

Groups, contacts, and blocking

Groups, contacts, favorites, and blocks connect the chat UI to WhatsApp account state. The UI presents safe actions and current names, while background workers validate requests, send them to WhatsApp, and update local chat state only after accepted results.

This page is a child of Messaging and conversation experience. Read it with Chat interaction and message composition, Interactive messages and polls, and Chat archive and export for the surrounding chat flows.

Group lifecycle

Group work starts in the New chat flow and continues in the group info panel. A group draft first selects at least one other person, then accepts a required name and an optional photo. The worker creates the group, confirms its members when possible, records the new chat, and opens it after the UI receives the result. (References: src/…/new_group.rs• L68-176, src/…/new_group.rs• L290-475, src/…/new_group.rs• L41-195)

The same member picker supports adding people to an existing group. It excludes current members and the account owner. WhatsApp may reject selected people because of privacy limits, a recent departure, or group capacity; the UI reports these results by person instead of treating a partial add as a full failure. (References: src/new_group.rs• L54-100, src/…/group_admin.rs• L80-125, src/group_admin.rs• L236-303)

This diagram shows how a group request moves from a UI draft to accepted local chat state.

flowchart LR
    A[Select people] --> B[Set group name]
    B --> C[Create or add request]
    C --> D[Worker checks rights and connection]
    D --> E[WhatsApp accepts or refuses]
    E --> F[Update chat and show result]

Group administration

The group info panel is the control point for members, invite links, and group permissions. Admin status determines whether a person can manage the group, while group settings determine whether members may add people or share an invite link. The panel does not treat a control as complete until WhatsApp accepts the change. (References: src/…/info.rs• L921-1089, src/…/info.rs• L2003-2079, src/group_admin.rs• L13-84)

Admins can promote or dismiss other members and remove them. The account owner and the group creator are protected from these member actions. Permissions cover group settings, sending messages, adding members, and approval of new members. (References: src/group_admin.rs• L86-145, src/…/info.rs• L1952-1987, src/…/group_admin.rs• L187-250)

Invite links are treated as access secrets. An admin can request or reset a link when the group permits it, but the link is not stored or written to logs. A failed request causes the worker to report the current reason and may trigger a fresh group metadata read when local rights are stale. (References: src/group_admin.rs• L147-234, src/…/group_admin.rs• L37-77, src/…/group_admin.rs• L253-335)

Contact names

Contact names give chat rows, member lists, and message views a human label instead of an address. A saved address-book name takes priority over a profile push name. A saved first name is kept separately so narrow UI areas can use the intended short form without cutting a full name at an arbitrary space. (References: src/model.rs• L1983-2014, src/util.rs• L251-267)

The contact editor lets a person change the first name and surname from the contact panel. Existing saved name parts guide the fields, and a name without a known first-name split stays whole so an unchanged save does not alter it. (References: src/…/info.rs• L450-505, src/…/info.rs• L824-837)

Older contact records may not have the separate first name. After a connection, the worker can request one contact replay from the phone and records completion locally. If the replay fails, it waits for a later connection rather than marking the repair complete. (References: src/…/contact_names.rs• L13-64, src/…/worker.rs• L947-956, src/…/worker.rs• L4118)

Favorite chats

Chat favorites are an ordered list shared with the phone. The chat list uses the list for its Favorites view, while local changes take effect at once and wait for the phone's list before they are sent back. Channels are excluded. (References: src/…/chats.rs• L924-960, src/…/favorites.rs• L65-107, src/…/favorite_chats.rs• L74-130)

The worker first learns the phone's full list. It then sends the whole ordered list one request at a time. A phone update replaces the known list, and local changes made during that exchange are merged and sent again. This prevents a first local edit from overwriting favorites that the phone has not reported yet. (References: src/…/favorites.rs• L109-189, src/…/favorite_chats.rs• L134-241)

Favorites follow a contact when WhatsApp changes the address from a privacy ID to a phone number. Older phone lists are ignored, so a delayed update cannot move the app back to stale order. (References: src/…/favorites.rs• L120-174, src/…/favorites.rs• L192-209, src/…/favorite_chats.rs• L80-110)

Blocking controls

Blocking applies only to another person addressed by a phone number or privacy ID. The UI exposes the same block or unblock state in contact menus, contact panels, and the privacy settings list. Every change uses a confirmation step and requires a connected, current block list. (References: src/blocking.rs• L40-83, src/…/blocking.rs• L11-59, src/…/settings.rs• L591-606)

The worker keeps the block list in memory for the account and reads it from WhatsApp. It resolves privacy IDs to canonical chat IDs before publishing the state. A block or unblock request is serialized with the list read, and stale replies cannot replace a newer confirmed state. (References: src/…/blocking.rs• L5-66, src/…/blocking.rs• L68-122)

Blocking changes conversation behavior as well as the control list. Direct messages and calls to a blocked person are refused, and unsent content is returned to the composer when possible. Group destinations remain writable, so a block does not disable group conversation. (References: src/…/blocking.rs• L74-100, src/…/blocking.rs• L124-226, src/…/blocking.rs• L363-390)

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep group member IDs canonical across creation, member changes, block entries, and contact-name lookup when privacy IDs map to phone numbers.
  • Keep group controls gated by both local metadata and WhatsApp's accepted result; a refused change must not update the archived group state.
  • Preserve the full-list favorite merge and ordering contract when changing either local favorite actions or phone app-state handling.
  • Keep blocked-contact UI state and the worker's confirmed state aligned across list reads, pending writes, reconnects, and stale replies.
  • Preserve the one-time contact first-name recovery marker so a failed replay can retry and a completed replay does not run again.

Important failure modes

TriggerConsequenceGuard
Group creation times outThe group may exist even though the UI did not receive a confirmed resultShow the timeout as uncertain and let the chat metadata appear through normal sync
WhatsApp refuses selected group membersThe group or add request succeeds only for the accepted peopleCompare confirmed members and report refused people by reason
A non-admin changes group controlsWhatsApp refuses the request and local rights may be staleGate the worker request and refresh group metadata after a refusal
Favorites are sent before the phone list is knownThe app can overwrite favorites that exist only on the phoneComplete the initial full-list read before sending local changes
A block-list reply is delayed or failsA stale or incomplete reply can hide the last confirmed block stateUse generations and retain confirmed entries until a matching result succeeds
A blocked send or call reaches the workerThe operation is rejected after the UI has started itReturn the unsent payload or call error and keep group destinations available

Key files

FileWhy to read it
src/new_group.rsDefines the group draft, validation, and creation outcomes shared by the UI and worker.
src/…/new_group.rsShows the member selection, naming, photo, and add-member flow.
src/group_admin.rsDefines group permissions, member actions, invite-link state, and user-facing refusal reasons.
src/…/new_group.rsExplains group creation confirmation and how a new chat is filed.
src/…/group_admin.rsShows how accepted group changes update local state and how rights are refreshed.
src/model.rsDefines contact name sources and the display-name rules.
src/…/contact_names.rsCovers recovery of first names for older contact records.
src/…/favorites.rsDefines ordered favorite state and the merge contract with phone updates.
src/…/favorite_chats.rsCoordinates favorite reads, writes, retries, and concurrent updates.
src/blocking.rsDefines block-list state and which chat identities are eligible.
src/…/blocking.rsConnects block and unblock controls to confirmation and privacy UI.
src/…/blocking.rsApplies block-list changes and enforces blocked-operation behavior.