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
@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
@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
@spec get_contact_preferences(Glific.Flows.FlowContext.t()) :: [String.t()]
Get all the preferences for this contact
@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
@spec reset_contact_preference(Glific.Flows.FlowContext.t()) :: Glific.Flows.FlowContext.t()
Reset the preferences for a contact.
@spec set_contact_language(Glific.Flows.FlowContext.t(), String.t()) :: Glific.Flows.FlowContext.t()
Set the language for a contact
@spec set_contact_name(Glific.Flows.FlowContext.t(), String.t()) :: Glific.Flows.FlowContext.t()
Set the name for a contact
@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