PhoenixKitCRM.Interactions (PhoenixKitCRM v0.2.4)

Copy Markdown View Source

Context for CRM interactions — the History/Interactions tab.

Handles the logged interaction itself, its resolvable "involved parties" (flat list, no per-party role), the as-of-then party_snapshot captured on save, and the reverse "all interactions involving this contact" query (subject OR party).

Summary

Functions

Creates an interaction and (re)builds its party list. party_inputs is a list of maps with :raw_name (required) and an optional resolved reference (:contact_uuid OR :staff_person_uuid). The snapshot is captured here.

UUIDs of the interactions a contact is the subject of (for the Files rollup).

Interactions logged on any of the given contacts (as subject), newest first, with the subject contact + parties preloaded. Powers the company's aggregated read-only interactions feed.

Lists every interaction that involves the given contact — whether they are the subject (interactions.contact_uuid) or an involved party (interaction_parties.contact_uuid). Newest first; parties preloaded.

Functions

change_interaction(interaction, attrs \\ %{})

@spec change_interaction(PhoenixKitCRM.Schemas.Interaction.t(), map()) ::
  Ecto.Changeset.t()

create_interaction(attrs, party_inputs \\ [], file_uuids \\ [])

@spec create_interaction(map(), [map()], [binary()]) ::
  {:ok, PhoenixKitCRM.Schemas.Interaction.t()} | {:error, Ecto.Changeset.t()}

Creates an interaction and (re)builds its party list. party_inputs is a list of maps with :raw_name (required) and an optional resolved reference (:contact_uuid OR :staff_person_uuid). The snapshot is captured here.

delete_interaction(interaction, opts \\ [])

@spec delete_interaction(
  PhoenixKitCRM.Schemas.Interaction.t(),
  keyword()
) :: {:ok, PhoenixKitCRM.Schemas.Interaction.t()} | {:error, Ecto.Changeset.t()}

get_interaction(uuid)

@spec get_interaction(UUIDv7.t() | String.t() | nil) ::
  PhoenixKitCRM.Schemas.Interaction.t() | nil

interaction_uuids_for_contact(contact_uuid)

@spec interaction_uuids_for_contact(binary()) :: [binary()]

UUIDs of the interactions a contact is the subject of (for the Files rollup).

list_for_contacts(contact_uuids)

@spec list_for_contacts([binary()]) :: [PhoenixKitCRM.Schemas.Interaction.t()]

Interactions logged on any of the given contacts (as subject), newest first, with the subject contact + parties preloaded. Powers the company's aggregated read-only interactions feed.

list_involving(contact_uuid)

@spec list_involving(UUIDv7.t() | String.t() | nil) :: [
  PhoenixKitCRM.Schemas.Interaction.t()
]

Lists every interaction that involves the given contact — whether they are the subject (interactions.contact_uuid) or an involved party (interaction_parties.contact_uuid). Newest first; parties preloaded.

update_interaction(interaction, attrs, party_inputs \\ nil, opts \\ [])

@spec update_interaction(
  PhoenixKitCRM.Schemas.Interaction.t(),
  map(),
  [map()] | nil,
  keyword()
) ::
  {:ok, PhoenixKitCRM.Schemas.Interaction.t()} | {:error, Ecto.Changeset.t()}