Mike Schwörer ab4b40ab75
Some checks failed
Build Docker and Deploy / Build Docker Container (push) Successful in 50s
Build Docker and Deploy / Run Unit-Tests (push) Failing after 11m15s
Build Docker and Deploy / Deploy to Server (push) Has been skipped
implement keytoken list and all-messages list
2025-04-13 19:47:18 +02:00

99 lines
2.7 KiB
Dart

class KeyToken {
final String keytokenID;
final String name;
final String timestampCreated;
final String? timestampLastUsed;
final String ownerUserID;
final bool allChannels;
final List<String> channels;
final String permissions;
final int messagesSent;
const KeyToken({
required this.keytokenID,
required this.name,
required this.timestampCreated,
required this.timestampLastUsed,
required this.ownerUserID,
required this.allChannels,
required this.channels,
required this.permissions,
required this.messagesSent,
});
factory KeyToken.fromJson(Map<String, dynamic> json) {
return KeyToken(
keytokenID: json['keytoken_id'] as String,
name: json['name'] as String,
timestampCreated: json['timestamp_created'] as String,
timestampLastUsed: json['timestamp_lastused'] as String?,
ownerUserID: json['owner_user_id'] as String,
allChannels: json['all_channels'] as bool,
channels: (json['channels'] as List<dynamic>).map((e) => e as String).toList(),
permissions: json['permissions'] as String,
messagesSent: json['messages_sent'] as int,
);
}
static List<KeyToken> fromJsonArray(List<dynamic> jsonArr) {
return jsonArr.map<KeyToken>((e) => KeyToken.fromJson(e as Map<String, dynamic>)).toList();
}
KeyTokenPreview toPreview() {
return KeyTokenPreview(
keytokenID: keytokenID,
name: name,
ownerUserID: ownerUserID,
allChannels: allChannels,
channels: channels,
permissions: permissions,
);
}
}
class KeyTokenWithToken {
final KeyToken keyToken;
final String token;
KeyTokenWithToken({
required this.keyToken,
required this.token,
});
factory KeyTokenWithToken.fromJson(Map<String, dynamic> json) {
return KeyTokenWithToken(
keyToken: KeyToken.fromJson(json),
token: json['token'] as String,
);
}
}
class KeyTokenPreview {
final String keytokenID;
final String name;
final String ownerUserID;
final bool allChannels;
final List<String> channels;
final String permissions;
const KeyTokenPreview({
required this.keytokenID,
required this.name,
required this.ownerUserID,
required this.allChannels,
required this.channels,
required this.permissions,
});
factory KeyTokenPreview.fromJson(Map<String, dynamic> json) {
return KeyTokenPreview(
keytokenID: json['keytoken_id'] as String,
name: json['name'] as String,
ownerUserID: json['owner_user_id'] as String,
allChannels: json['all_channels'] as bool,
channels: (json['channels'] as List<dynamic>).map((e) => e as String).toList(),
permissions: json['permissions'] as String,
);
}
}