fix fedi item error detection

This commit is contained in:
mein Name 2025-02-06 09:55:33 +00:00 committed by Henri Dickson
parent 4fa701a60d
commit 5d9afbd06e
3 changed files with 6 additions and 3 deletions

View file

@ -74,6 +74,7 @@ class FediverseInstance(AbstractSite):
from takahe.utils import Takahe from takahe.utils import Takahe
val = URLValidator() val = URLValidator()
host = None
try: try:
val(url) val(url)
u = cls.url_to_id(url) u = cls.url_to_id(url)
@ -85,7 +86,8 @@ class FediverseInstance(AbstractSite):
return False return False
return cls.get_json_from_url(u) is not None return cls.get_json_from_url(u) is not None
except Exception as e: except Exception as e:
logger.error(f"Fedi item url validation error: {url} {e}") if host and host in Takahe.get_neodb_peers():
logger.error(f"Fedi item url validation error: {url} {e}")
return False return False
@classmethod @classmethod

View file

@ -1,4 +1,5 @@
from django.urls import path, re_path from django.urls import path, re_path
from django.views.generic import RedirectView
from .models import * from .models import *
from .views import * from .views import *
@ -157,7 +158,7 @@ urlpatterns = [
mark_list, mark_list,
name="mark_list", name="mark_list",
), ),
path("search/", search, name="search_legacy"), path("search/", RedirectView.as_view(url="/search", query_string=True)),
path("search/external", external_search, name="external_search"), path("search/external", external_search, name="external_search"),
path("fetch_refresh/<str:job_id>", fetch_refresh, name="fetch_refresh"), path("fetch_refresh/<str:job_id>", fetch_refresh, name="fetch_refresh"),
path("refetch", refetch, name="refetch"), path("refetch", refetch, name="refetch"),

View file

@ -42,7 +42,7 @@ if you are doing debug or development:
## Settings for administration ## Settings for administration
- `DISCORD_WEBHOOKS` - Discord channel to send notification about user submitted suggestion and changes, e.g. `suggest=https://discord.com/api/webhooks/123/abc,audit=https://discord.com/api/webhooks/123/def`. Both suggest and audit channels must be in forum mode. - `DISCORD_WEBHOOKS` - Discord channel to send notification about user submitted suggestion and changes, e.g. `suggest=https://discord.com/api/webhooks/123/abc,audit=https://discord.com/api/webhooks/123/def`. Both suggest and audit channels must be in forum mode.
- `NEODB_SENTRY_DSN` , `TAKAHE_SENTRY_DSN` - [Sentry](https://neodb.sentry.io/) DSN to log errors. - `NEODB_SENTRY_DSN` , `TAKAHE_SENTRY_DSN` - [Sentry](https://sentry.io/) DSN to log errors.
## Settings for Federation ## Settings for Federation