🔍 Overview

The Link model represents a managed URL with an associated status, owner, and lifecycle metadata. It supports chaining, blocking/unblocking operations. The relationship between links (next/prev) is associated through an additional model called MirrorRule.


📑 Fields

FieldTypeDescription
linkURLFieldThe original URL (max 2048 characters).
statusstrCurrent link status (ACTIVE/BLOCKED/BACKUP etc.).
ownerForeign Key User ModelReference to the user who owns the link.
created_atdatetimeTimestamp when the link was created.
updated_atdatetimeTimestamp of the last update.
blocked_atdatetimeWhen the link was marked as blocked.
reasonstrReason the link was blocked (optional, max 64 characters).
unblocked_atdatetimeTimestamp when the link was unblocked.
changed_bystrIdentifier of the actor (system/user) who last changed status.

🔒 Properties

PropertyTypeDescription
domainstrExtracted domain from the link.
root_domainstrExtracted root domain from the link (without subdomains).
next_linkLinkNext backup link in the chain (if any).
prev_linkLinkPrevious link in the chain (if any).

🧩 Methods

MethodDescription
find_owners_by_domains(domains)Finds all owners associated with the given domains (classmethod).
find_owners_by_root_domains(domains)Finds all owners associated with the given root domains (classmethod).
get_domains_map(status="active", reason_exclude=None)Get a map of links grouped by domain (classmethod).
get_root_domains_map(status="active", reason_exclude=None)Get a map of links grouped by root domain (classmethod).
get_blocked_by_google_domains_map()Get a map of root domains blocked by Google, with owners (classmethod).
add_next_link(link)Creates a new backup link and associates it via MirrorRule.
set_active(action_by="system")Marks a backup link as active.
set_block(reason, with_switch=False, action_by="system")Blocks the active link, optionally triggers a switch to backup.
set_unblock(with_return_to_work=False, action_by="system")Unblocks the link & run return_unblocked_to_work if blocked by Google.
set_ignored(with_next=False, action_by="system")Marks link (and optionally chain) as ignored.
return_unblocked_to_work(action_by="system")Returns link to work (create new link object).
remove_all_next_links()Deletes the next link and its chained backups.
get_all_next_links()Traverses and collects all backup links in the chain.
get_main_active_link(search_direction)Recursively finds the closest active link.
get_last_backup_link()Returns the last backup in the chain.
delete(with_next_links=False)Deletes the link, optionally removing next links.

🏷 Statuses

StatusDescription
ACTIVEThe link is currently active and in use.
BLOCKEDThe link is blocked and cannot be used.
UNBLOCKEDThe link is unblocked and can be used again.
BACKUPThe link is a backup and can be activated after blocking the active link.
IGNOREDThe link is ignored and not considered for use.

🔏 Block Reasons

ReasonDescription
UNKNOWNDefault reason when blocking without a specific cause.
DNS_NOT_RESOLVABLEThe domain cannot be resolved via DNS.
BLOCKED_BY_USERThe link was blocked by a user action.
MALWAREThe link was identified as containing malware (Google).
SOCIAL_ENGINEERINGThe link is associated with social engineering threats (Google).
UNWANTED_SOFTWAREThe link is associated with unwanted software (Google).
POTENTIALLY_HARMFUL_APPLICATIONThe link is associated with potentially harmful applications (Google).
THREAT_TYPE_UNSPECIFIEDThe threat type is not specified (Google).