Add NIP-05 verification compatibility

This commit is contained in:
Danielle McLean 2023-08-10 18:05:46 +10:00
parent 2e7d12b3e6
commit 04bd6dd35d
Signed by: 00dani
GPG key ID: 52C059C3B22A753E
6 changed files with 65 additions and 0 deletions

View file

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

View file

@ -0,0 +1,22 @@
# 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,6 +81,19 @@ class User(ModelMeta, AbstractUser):
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
def calc_email_md5(self):
return md5(self.email.lower().encode("utf-8")).hexdigest()