nostr publish event fix

This commit is contained in:
gitea
2025-11-06 21:43:09 +01:00
parent 120a04c69f
commit 947fb667cf
7 changed files with 207 additions and 459 deletions
+10
View File
@@ -20,6 +20,10 @@ class User {
/// Optional Nostr profile data (if logged in via Nostr).
final NostrProfile? nostrProfile;
/// Optional Nostr private key (nsec) if logged in with nsec.
/// This is stored to enable event publishing. Only set if user logged in with nsec.
final String? nostrPrivateKey;
/// Creates a [User] instance.
///
/// [id] - Unique identifier for the user.
@@ -27,12 +31,14 @@ class User {
/// [token] - Optional authentication token.
/// [createdAt] - Session creation timestamp (defaults to current time).
/// [nostrProfile] - Optional Nostr profile data.
/// [nostrPrivateKey] - Optional Nostr private key (nsec) for event publishing.
User({
required this.id,
required this.username,
this.token,
int? createdAt,
this.nostrProfile,
this.nostrPrivateKey,
}) : createdAt = createdAt ?? DateTime.now().millisecondsSinceEpoch;
/// Creates a [User] from a Map (e.g., from database or JSON).
@@ -45,6 +51,7 @@ class User {
nostrProfile: map['nostr_profile'] != null
? NostrProfile.fromJson(map['nostr_profile'] as Map<String, dynamic>)
: null,
nostrPrivateKey: map['nostr_private_key'] as String?,
);
}
@@ -56,6 +63,7 @@ class User {
'token': token,
'created_at': createdAt,
'nostr_profile': nostrProfile?.toJson(),
'nostr_private_key': nostrPrivateKey,
};
}
@@ -66,6 +74,7 @@ class User {
String? token,
int? createdAt,
NostrProfile? nostrProfile,
String? nostrPrivateKey,
}) {
return User(
id: id ?? this.id,
@@ -73,6 +82,7 @@ class User {
token: token ?? this.token,
createdAt: createdAt ?? this.createdAt,
nostrProfile: nostrProfile ?? this.nostrProfile,
nostrPrivateKey: nostrPrivateKey ?? this.nostrPrivateKey,
);
}