diff --git a/modules/services/nip05.nix b/modules/services/nip05.nix index 567ec3b..df40778 100644 --- a/modules/services/nip05.nix +++ b/modules/services/nip05.nix @@ -30,9 +30,9 @@ let try: con = sqlite3.connect(f"file:{DB_PATH}?mode=ro", uri=True) rows = con.execute(""" - SELECT pub_key, content FROM event + SELECT author, content FROM event WHERE kind = 0 AND (hidden IS NULL OR hidden = 0) - GROUP BY pub_key + GROUP BY author HAVING created_at = MAX(created_at) """).fetchall() con.close() @@ -43,9 +43,11 @@ let names = {} relays = {} - for pub_key, content in rows: + for author_blob, event_json in rows: try: - meta = json.loads(content) + event = json.loads(event_json) + pub_key = event.get("pubkey", author_blob.hex()) + meta = json.loads(event.get("content", "{}")) name = meta.get("name", "").strip().lower() if not name: continue