ExWapp.Contact (ExWapp v0.1.2)

Copy Markdown View Source

Contact struct and local CRUD operations.

Contact data is populated from:

  • App state sync patches (field "contact" in critical_unblock_low)
  • Incoming message notify attribute (push name)
  • History sync data

Summary

Functions

Delete a contact by JID.

Get a contact by JID.

List all contacts from the store.

Merge contact data from an app state sync ContactAction.

Put (create or update) a contact.

Update push name for a contact (from incoming message notify attr).

Builds a WhatsApp-compatible vCard 3.0 payload for send_contact/5.

Types

t()

@type t() :: %ExWapp.Contact{
  first_name: String.t() | nil,
  full_name: String.t() | nil,
  jid: String.t(),
  lid: String.t() | nil,
  phone_number: String.t() | nil,
  push_name: String.t() | nil,
  username: String.t() | nil
}

Functions

delete(store, jid)

@spec delete(
  struct(),
  String.t()
) :: :ok

Delete a contact by JID.

get(store, jid)

@spec get(
  struct(),
  String.t()
) :: t() | nil

Get a contact by JID.

list(store)

@spec list(struct()) :: [t()]

List all contacts from the store.

merge_from_sync(store, jid, contact_action)

@spec merge_from_sync(struct(), String.t(), map()) :: :ok

Merge contact data from an app state sync ContactAction.

put(store, jid, contact)

@spec put(struct(), String.t(), t()) :: :ok

Put (create or update) a contact.

update_push_name(store, jid, name)

@spec update_push_name(struct(), String.t(), String.t()) :: :ok

Update push name for a contact (from incoming message notify attr).

vcard(display_name, phone_number)

@spec vcard(String.t(), String.t()) :: String.t()

Builds a WhatsApp-compatible vCard 3.0 payload for send_contact/5.

The waid parameter is normalized to digits while the displayed telephone number keeps its leading + when one was supplied.