]> git.ipfire.org Git - ipfire.org.git/commitdiff
dbl: Encourage people to report a domain if it could not be found
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 24 Jan 2026 15:40:19 +0000 (15:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 24 Jan 2026 15:40:19 +0000 (15:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/dbl.py
src/templates/dbl/search.html
src/web/dbl.py

index 65bc2095d08598347e10064bd46bc275164c856a..5693fad91c282b760b46c119156b48b84f7b12d0 100644 (file)
@@ -104,7 +104,15 @@ class DBL(Object):
                tasks = {}
 
                # Perform the search
-               result = await self._fetch("/search", args={ "q" : q })
+               try:
+                       result = await self._fetch("/search", args={ "q" : q })
+
+               # Catch anything that isn't a valid FQDN
+               except tornado.httpclient.HTTPClientError as e:
+                       if e.code == 400:
+                               raise ValueError("Not a valid FQDN: %s" % q) from e
+
+                       raise e
 
                # Fetch all lists
                async with asyncio.TaskGroup() as tg:
index 67317f21e4108ef41cd2cad5eec4b4528beed266..d0101c9621140b655d5c7e1f7b356fde6f6615f4 100644 (file)
 
                        {# Show a note if there has been no results #}
                        {% else %}
-                               <div class="notification has-text-centered">
-                                       {{ _("There are no matches for '%s'") % q }}
+                               <div class="content has-text-centered">
+                                       <p>
+                                               {{ _("There are no matches for '%s'") % q }}
+                                       </p>
                                </div>
+
+                               {# If the query has been a valid FQDN, we encourage users to report it #}
+                               {% if results == {} %}
+                                       {% module DBLSubmitReport(name=q) %}
+                               {% end %}
                        {% end %}
                </div>
        </section>
index 7c8972546d5a342006d65e3afc52c055bc2fdf4e..543bab6c32cd4fc9ec12540737ca5772032acabe 100644 (file)
@@ -156,7 +156,12 @@ class SearchHandler(base.AnalyticsMixin, BaseHandler):
                        raise tornado.web.HTTPError(400, "Empty search query")
 
                # Search for the query
-               results = await self.backend.dbl.search(q)
+               try:
+                       results = await self.backend.dbl.search(q)
+
+               # ValueError is raised if the query has not been a valid FQDN
+               except ValueError as e:
+                       results = None
 
                # Render the page
                self.render("dbl/search.html", q=q, results=results)