🔍 Overview

block_links_from_mail_tracker_domains_task blocks active Links whose root_domain matches domains reported by the external Mail Tracker.

This task is usually triggered by the Mail Tracker API endpoint after saving BlockedByMailTrackerDomain records.


📝 Task Definition

@celery.task
def block_links_from_mail_tracker_domains_task(root_domains: list[str]):
    root_domain_map = Link.get_root_domains_map()
 
    VoluumController.load_data(landers=True, offers=True, campaigns=False)
 
    for root_domain in root_domains:
        for obj in root_domain_map.get(root_domain, []):
            block_link_task.delay(
                link_id=obj.id,
                reason=BlockReasons.SOCIAL_ENGINEERING,
                action_by="system",
            )

⚙️ Task Behavior & Flow

  1. Loads active links grouped by root_domain.
  2. Loads Voluum mappings (landers + offers).
  3. Enqueues block_link_task for every active link that matches the provided root domains.
  4. The actual switching and Telegram notifications happen inside Link.set_block(..., with_switch=True).