Compare commits

..

No commits in common. "0b1a548ee418cfd6a9206a50ba3f427fc5ea914e" and "2e7d12b3e6ba8a9f5db052aa344dedd4215976bb" have entirely different histories.

8 changed files with 2 additions and 67 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "lemoncurry", "name": "lemoncurry",
"version": "1.12.0", "version": "1.11.0",
"repository": "https://git.00dani.me/00dani/lemoncurry", "repository": "https://git.00dani.me/00dani/lemoncurry",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "lemoncurry" name = "lemoncurry"
version = "1.12.0" version = "1.11.0"
description = "Indieweb-compatible personal website" description = "Indieweb-compatible personal website"
authors = ["Danielle McLean <dani@00dani.me>"] authors = ["Danielle McLean <dani@00dani.me>"]
license = "MIT" license = "MIT"

View file

@ -20,7 +20,6 @@ class ProfileInline(admin.TabularInline):
class UserAdmin(BaseUserAdmin): class UserAdmin(BaseUserAdmin):
fieldsets = BaseUserAdmin.fieldsets + ( fieldsets = BaseUserAdmin.fieldsets + (
("Profile", {"fields": ("avatar", "xmpp", "note")}), ("Profile", {"fields": ("avatar", "xmpp", "note")}),
("Nostr", {"fields": ("nostr_key", "nostr_relays")}),
) )
inlines = ( inlines = (
PgpKeyInline, PgpKeyInline,

View file

@ -1,22 +0,0 @@
# Generated by Django 3.2.20 on 2023-08-10 07:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0017_rename_key_pgpkey"),
]
operations = [
migrations.AddField(
model_name="user",
name="nostr_key",
field=models.CharField(blank=True, max_length=32, null=True, unique=True),
),
migrations.AddField(
model_name="user",
name="nostr_relays",
field=models.JSONField(blank=True, default=list),
),
]

View file

@ -81,19 +81,6 @@ class User(ModelMeta, AbstractUser):
help_text="SHA-256 hash of the user's OpenID URL, used for Libravatar", help_text="SHA-256 hash of the user's OpenID URL, used for Libravatar",
) )
nostr_key = models.CharField(
max_length=32,
unique=True,
blank=True,
null=True,
help_text="A Nostr public key in 32-byte hex format",
)
nostr_relays = models.JSONField(
default=list,
blank=True,
help_text="An array of Nostr relay URLs that this public key posts to",
)
@property @property
def calc_email_md5(self): def calc_email_md5(self):
return md5(self.email.lower().encode("utf-8")).hexdigest() return md5(self.email.lower().encode("utf-8")).hexdigest()

View file

@ -8,6 +8,5 @@ urlpatterns = [
path("host-meta", views.host_meta_xml, name="host-meta"), path("host-meta", views.host_meta_xml, name="host-meta"),
path("host-meta.json", views.host_meta_json, name="host-meta.json"), path("host-meta.json", views.host_meta_json, name="host-meta.json"),
path("manifest.json", views.manifest, name="manifest"), path("manifest.json", views.manifest, name="manifest"),
path("nostr.json", views.nostr_json, name="nostr.json"),
path("webfinger", views.webfinger, name="webfinger"), path("webfinger", views.webfinger, name="webfinger"),
] ]

View file

@ -1,5 +1,4 @@
from .static import keybase from .static import keybase
from .host_meta import host_meta_xml, host_meta_json from .host_meta import host_meta_xml, host_meta_json
from .manifest import manifest from .manifest import manifest
from .nostr import nostr_json
from .webfinger import webfinger from .webfinger import webfinger

View file

@ -1,27 +0,0 @@
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)