nostr tools added
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import '../../nostr/models/nostr_profile.dart';
|
||||
|
||||
/// Data model representing a user session.
|
||||
///
|
||||
/// This model stores user identification and authentication information
|
||||
@@ -15,17 +17,22 @@ class User {
|
||||
/// Timestamp when the session was created (milliseconds since epoch).
|
||||
final int createdAt;
|
||||
|
||||
/// Optional Nostr profile data (if logged in via Nostr).
|
||||
final NostrProfile? nostrProfile;
|
||||
|
||||
/// Creates a [User] instance.
|
||||
///
|
||||
/// [id] - Unique identifier for the user.
|
||||
/// [username] - Display name or username.
|
||||
/// [token] - Optional authentication token.
|
||||
/// [createdAt] - Session creation timestamp (defaults to current time).
|
||||
/// [nostrProfile] - Optional Nostr profile data.
|
||||
User({
|
||||
required this.id,
|
||||
required this.username,
|
||||
this.token,
|
||||
int? createdAt,
|
||||
this.nostrProfile,
|
||||
}) : createdAt = createdAt ?? DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
/// Creates a [User] from a Map (e.g., from database or JSON).
|
||||
@@ -35,6 +42,9 @@ class User {
|
||||
username: map['username'] as String,
|
||||
token: map['token'] as String?,
|
||||
createdAt: map['created_at'] as int?,
|
||||
nostrProfile: map['nostr_profile'] != null
|
||||
? NostrProfile.fromJson(map['nostr_profile'] as Map<String, dynamic>)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,6 +55,7 @@ class User {
|
||||
'username': username,
|
||||
'token': token,
|
||||
'created_at': createdAt,
|
||||
'nostr_profile': nostrProfile?.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,12 +65,14 @@ class User {
|
||||
String? username,
|
||||
String? token,
|
||||
int? createdAt,
|
||||
NostrProfile? nostrProfile,
|
||||
}) {
|
||||
return User(
|
||||
id: id ?? this.id,
|
||||
username: username ?? this.username,
|
||||
token: token ?? this.token,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
nostrProfile: nostrProfile ?? this.nostrProfile,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user