правки
This commit is contained in:
@@ -436,7 +436,7 @@ class Postgres(DatabaseBase):
|
||||
|
||||
return (
|
||||
await query.prefetch_related('project', 'project__channel', 'channel', 'creative')
|
||||
.order_by('-placement_at', '-created_at')
|
||||
.order_by('-created_at')
|
||||
.all()
|
||||
)
|
||||
|
||||
|
||||
@@ -80,11 +80,6 @@ _INVITE_LINK_HTML = re.compile(
|
||||
)
|
||||
_INVITE_LINK_PLAIN = re.compile(r'https?://t\.me/(?:\+|joinchat/)[a-zA-Z0-9_-]+', re.IGNORECASE)
|
||||
_INVITE_LINK_REPLACED = re.compile(r'<a\s+class=["\']tg-link["\']>(.*?)</a>', re.IGNORECASE | re.DOTALL)
|
||||
_HTML_TAG = re.compile(r'<[^>]+>')
|
||||
|
||||
|
||||
def _strip_html(text: str) -> str:
|
||||
return _HTML_TAG.sub('', text).strip()
|
||||
|
||||
|
||||
def replace_invite_link_with_tag(text: str) -> str:
|
||||
@@ -105,7 +100,7 @@ def replace_invite_link_with_tag(text: str) -> str:
|
||||
|
||||
# Normalize already replaced links (preserve anchor text)
|
||||
def _normalize_replaced(match: re.Match[str]) -> str:
|
||||
inner = _strip_html(match.group(1))
|
||||
inner = match.group(1).strip()
|
||||
if inner == "" or _INVITE_LINK_PLAIN.search(inner):
|
||||
return '<a class="tg-link"></a>'
|
||||
return f'<a class="tg-link">{inner}</a>'
|
||||
@@ -114,7 +109,7 @@ def replace_invite_link_with_tag(text: str) -> str:
|
||||
|
||||
# Replace HTML links with tracking tags (preserve anchor text)
|
||||
def _replace_html(match: re.Match[str]) -> str:
|
||||
inner = _strip_html(match.group(1))
|
||||
inner = match.group(1).strip()
|
||||
if _INVITE_LINK_PLAIN.fullmatch(inner):
|
||||
return '<a class="tg-link"></a>'
|
||||
return f'<a class="tg-link">{inner}</a>'
|
||||
|
||||
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
_INVITE_LINK_TAG = re.compile(r'<a\s+class=["\']tg-link["\']>([^<]*)</a>', re.IGNORECASE)
|
||||
_INVITE_LINK_TAG = re.compile(r'<a\s+class=["\']tg-link["\']>(.*?)</a>', re.IGNORECASE | re.DOTALL)
|
||||
_INVITE_LINK_PLACEHOLDER = '{{invite_link}}'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user