View Source Glific.Flows.ContactSetting (Glific v5.1.6)

Since many of the functions set/update fields in contact and related tables, lets centralize all the code here for now

Link to this section Summary

Functions

Add a preference to a contact. For now, all preferences are stored under the settings map, with a sub-map of preferences. We expect to get more clarity on this soon

Delete a preference from a contact. We actually dont really delete it, we just set the value to false, and hence turn it off

Get all the preferences for this contact

Update profile language if there is an active profile id set

Reset the preferences for a contact.

Set the language for a contact

Set the name for a contact

Wrapper function for setting the contact preference, if preference is empty, it indicates to reset the preference

Link to this section Functions

Link to this function

add_contact_preference(context, preference, value \\ true)

View Source
@spec add_contact_preference(Glific.Flows.FlowContext.t(), String.t(), boolean()) ::
  Glific.Flows.FlowContext.t()

Add a preference to a contact. For now, all preferences are stored under the settings map, with a sub-map of preferences. We expect to get more clarity on this soon

Link to this function

delete_contact_preference(context, preference)

View Source
@spec delete_contact_preference(Glific.Flows.FlowContext.t(), String.t()) ::
  Glific.Flows.FlowContext.t()

Delete a preference from a contact. We actually dont really delete it, we just set the value to false, and hence turn it off

Link to this function

get_contact_preferences(flow_context)

View Source
@spec get_contact_preferences(Glific.Flows.FlowContext.t()) :: [String.t()]

Get all the preferences for this contact

Link to this function

maybe_update_profile_language(contact, language_id)

View Source
@spec maybe_update_profile_language(Glific.Contacts.Contact.t(), non_neg_integer()) ::
  Glific.Contacts.Contact.t()

Update profile language if there is an active profile id set

Link to this function

reset_contact_preference(context)

View Source
@spec reset_contact_preference(Glific.Flows.FlowContext.t()) ::
  Glific.Flows.FlowContext.t()

Reset the preferences for a contact.

Link to this function

set_contact_language(context, language)

View Source
@spec set_contact_language(Glific.Flows.FlowContext.t(), String.t()) ::
  Glific.Flows.FlowContext.t()

Set the language for a contact

Link to this function

set_contact_name(context, name)

View Source

Set the name for a contact

Link to this function

set_contact_preference(context, preference)

View Source
@spec set_contact_preference(Glific.Flows.FlowContext.t(), String.t() | nil) ::
  Glific.Flows.FlowContext.t()

Wrapper function for setting the contact preference, if preference is empty, it indicates to reset the preference