2024-09-07 07:36:06 +00:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:solian/models/account.dart';
|
2024-05-25 17:21:08 +00:00
|
|
|
import 'package:solian/models/realm.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
|
2024-09-07 07:36:06 +00:00
|
|
|
part 'channel.g.dart';
|
|
|
|
|
|
|
|
@JsonSerializable()
|
2024-05-18 10:17:16 +00:00
|
|
|
class Channel {
|
|
|
|
int id;
|
|
|
|
DateTime createdAt;
|
|
|
|
DateTime updatedAt;
|
|
|
|
DateTime? deletedAt;
|
|
|
|
String alias;
|
|
|
|
String name;
|
|
|
|
String description;
|
|
|
|
int type;
|
2024-05-28 16:14:41 +00:00
|
|
|
List<ChannelMember>? members;
|
2024-05-18 10:17:16 +00:00
|
|
|
Account account;
|
|
|
|
int accountId;
|
2024-05-25 17:21:08 +00:00
|
|
|
Realm? realm;
|
2024-05-18 10:17:16 +00:00
|
|
|
int? realmId;
|
|
|
|
bool isEncrypted;
|
|
|
|
|
2024-09-07 07:36:06 +00:00
|
|
|
@JsonKey(includeFromJson: false, includeToJson: true)
|
2024-05-18 10:17:16 +00:00
|
|
|
bool isAvailable = false;
|
|
|
|
|
|
|
|
Channel({
|
|
|
|
required this.id,
|
|
|
|
required this.createdAt,
|
|
|
|
required this.updatedAt,
|
2024-05-28 16:14:41 +00:00
|
|
|
required this.deletedAt,
|
2024-05-18 10:17:16 +00:00
|
|
|
required this.alias,
|
|
|
|
required this.name,
|
|
|
|
required this.description,
|
|
|
|
required this.type,
|
2024-05-28 16:14:41 +00:00
|
|
|
required this.members,
|
2024-05-18 10:17:16 +00:00
|
|
|
required this.account,
|
|
|
|
required this.accountId,
|
|
|
|
required this.isEncrypted,
|
2024-05-28 16:14:41 +00:00
|
|
|
required this.realm,
|
|
|
|
required this.realmId,
|
2024-05-18 10:17:16 +00:00
|
|
|
});
|
|
|
|
|
2024-09-07 07:36:06 +00:00
|
|
|
factory Channel.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$ChannelFromJson(json);
|
2024-05-18 10:17:16 +00:00
|
|
|
|
2024-09-07 07:36:06 +00:00
|
|
|
Map<String, dynamic> toJson() => _$ChannelToJson(this);
|
2024-09-05 12:25:17 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) {
|
|
|
|
if (other is! Channel) return false;
|
|
|
|
return id == other.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode => id;
|
2024-05-18 10:17:16 +00:00
|
|
|
}
|
|
|
|
|
2024-09-07 07:36:06 +00:00
|
|
|
@JsonSerializable()
|
2024-05-18 10:17:16 +00:00
|
|
|
class ChannelMember {
|
|
|
|
int id;
|
|
|
|
DateTime createdAt;
|
|
|
|
DateTime updatedAt;
|
|
|
|
DateTime? deletedAt;
|
|
|
|
int channelId;
|
|
|
|
int accountId;
|
|
|
|
Account account;
|
|
|
|
int notify;
|
|
|
|
|
|
|
|
ChannelMember({
|
|
|
|
required this.id,
|
|
|
|
required this.createdAt,
|
|
|
|
required this.updatedAt,
|
|
|
|
this.deletedAt,
|
|
|
|
required this.channelId,
|
|
|
|
required this.accountId,
|
|
|
|
required this.account,
|
|
|
|
required this.notify,
|
|
|
|
});
|
|
|
|
|
2024-09-07 07:36:06 +00:00
|
|
|
factory ChannelMember.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$ChannelMemberFromJson(json);
|
2024-05-18 10:17:16 +00:00
|
|
|
|
2024-09-07 07:36:06 +00:00
|
|
|
Map<String, dynamic> toJson() => _$ChannelMemberToJson(this);
|
2024-05-18 10:17:16 +00:00
|
|
|
}
|