🔍 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
| Field | Type | Description |
|---|---|---|
link | URLField | The original URL (max 2048 characters). |
status | str | Current link status (ACTIVE/BLOCKED/BACKUP etc.). |
owner | Foreign Key User Model | Reference to the user who owns the link. |
created_at | datetime | Timestamp when the link was created. |
updated_at | datetime | Timestamp of the last update. |
blocked_at | datetime | When the link was marked as blocked. |
reason | str | Reason the link was blocked (optional, max 64 characters). |
unblocked_at | datetime | Timestamp when the link was unblocked. |
changed_by | str | Identifier of the actor (system/user) who last changed status. |
🔒 Properties
| Property | Type | Description |
|---|---|---|
domain | str | Extracted domain from the link. |
root_domain | str | Extracted root domain from the link (without subdomains). |
next_link | Link | Next backup link in the chain (if any). |
prev_link | Link | Previous link in the chain (if any). |
🧩 Methods
| Method | Description |
|---|---|
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
| Status | Description |
|---|---|
ACTIVE | The link is currently active and in use. |
BLOCKED | The link is blocked and cannot be used. |
UNBLOCKED | The link is unblocked and can be used again. |
BACKUP | The link is a backup and can be activated after blocking the active link. |
IGNORED | The link is ignored and not considered for use. |
🔏 Block Reasons
| Reason | Description |
|---|---|
UNKNOWN | Default reason when blocking without a specific cause. |
DNS_NOT_RESOLVABLE | The domain cannot be resolved via DNS. |
BLOCKED_BY_USER | The link was blocked by a user action. |
MALWARE | The link was identified as containing malware (Google). |
SOCIAL_ENGINEERING | The link is associated with social engineering threats (Google). |
UNWANTED_SOFTWARE | The link is associated with unwanted software (Google). |
POTENTIALLY_HARMFUL_APPLICATION | The link is associated with potentially harmful applications (Google). |
THREAT_TYPE_UNSPECIFIED | The threat type is not specified (Google). |