예제 #1
0
def update_user_meta(token, data):
    """Update a user's metadata, not newsletters"""
    sfdc.update({"token": token}, data)
    try:
        ctms.update_by_alt_id("token", token, data)
    except CTMSNotFoundByAltIDError:
        if not settings.SFDC_ENABLED:
            raise
예제 #2
0
def update_user_meta(token, data):
    """Update a user's metadata, not newsletters"""
    sfdc.update({"token": token}, data)
    try:
        ctms.update_by_alt_id("token", token, data)
    except CTMSNotFoundByAltIDError:
        # TODO: raise this exception when CTMS is primary data source
        pass
예제 #3
0
def amo_check_user_for_deletion(user_id):
    """If a user has no addons their AMO info should be removed"""
    addons = sfdc.sf.query(
        sfapi.format_soql(
            "SELECT Id FROM DevAddOn__c WHERE AMO_Contact_ID__c = {contact_id} LIMIT 1",
            contact_id=user_id,
        ), )
    if not addons["records"]:
        sfdc.update({"id": user_id}, {"amo_id": None, "amo_user": False})
        ctms.update_by_alt_id("sfdc_id", user_id, {"amo_deleted": True})
예제 #4
0
def update_custom_unsub(token, reason):
    """Record a user's custom unsubscribe reason."""
    get_lock(token)
    try:
        sfdc.update({"token": token}, {"reason": reason})
    except sfapi.SalesforceMalformedRequest:
        # likely the record can't be found. nothing to do.
        return

    try:
        ctms.update_by_alt_id("token", token, {"reason": reason})
    except CTMSNotFoundByAltIDError:
        # No record found for that token, nothing to do.
        pass
예제 #5
0
def fxa_direct_update_contact(fxa_id, data):
    """Set some small data for a contact with an FxA ID

    Ignore if contact with FxA ID can't be found
    """
    try:
        sfdc.contact.update(f"FxA_Id__c/{fxa_id}", data)
    except sfapi.SalesforceMalformedRequest as e:
        if e.content[0]["errorCode"] == "REQUIRED_FIELD_MISSING":
            # couldn't find the fxa_id and tried to create a record but doesn't
            # have the required data to do so. We can drop this one.
            return
        else:
            # otherwise it's something else and we should potentially retry
            raise

    basket_data = from_sfdc(data)
    try:
        ctms.update_by_alt_id("fxa_id", fxa_id, basket_data)
    except CTMSNotFoundByAltIDError:
        # No associated record found, skip this update.
        pass