Add NIP-05 verification compatibility
This commit is contained in:
parent
2e7d12b3e6
commit
04bd6dd35d
6 changed files with 65 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
from .static import keybase
|
||||
from .host_meta import host_meta_xml, host_meta_json
|
||||
from .manifest import manifest
|
||||
from .nostr import nostr_json
|
||||
from .webfinger import webfinger
|
||||
|
|
27
wellknowns/views/nostr.py
Normal file
27
wellknowns/views/nostr.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from django.http import JsonResponse
|
||||
from users.models import User
|
||||
|
||||
aliases = {"00dani": ("_", "dani")}
|
||||
unaliases = {alias: name for (name, aliases) in aliases.items() for alias in aliases}
|
||||
|
||||
|
||||
def nostr_json(request) -> JsonResponse:
|
||||
users = User.objects.filter(nostr_key__isnull=False)
|
||||
|
||||
if "name" in request.GET:
|
||||
name = request.GET["name"]
|
||||
if name in unaliases:
|
||||
name = unaliases[name]
|
||||
users = users.filter(username=name)
|
||||
|
||||
names = {u.username: u.nostr_key for u in users}
|
||||
for name in list(names.keys()):
|
||||
for alias in aliases.get(name, []):
|
||||
names[alias] = names[name]
|
||||
|
||||
relays = {u.nostr_key: u.nostr_relays for u in users if u.nostr_relays}
|
||||
|
||||
response = {"names": names}
|
||||
if relays:
|
||||
response["relays"] = relays
|
||||
return JsonResponse(response)
|
Loading…
Add table
Add a link
Reference in a new issue