asnasd/lib/models/content/join_rules.dart
Henry-Hiles 2041b81141
add toJson to all content models
Fixes a regression from the primary constructor content migration
2026-10-25 18:30:28 -04:00

39 lines
1.2 KiB
Dart

import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/content/content.dart";
import "package:nexus/models/join_rule.dart";
part "join_rules.freezed.dart";
part "join_rules.g.dart";
@Freezed(toJson: false, fromJson: false)
@JsonSerializable()
class const JoinRulesContent({
@JsonKey(unknownEnumValue: JoinRule.unknown) required final JoinRule joinRule,
final ISet<AllowCondition> allow = const .empty(),
}) extends Content with _$JoinRulesContent {
@override
Map<String, Object?> toJson() => _$JoinRulesContentToJson(this);
factory JoinRulesContent.fromJson(Map<String, Object?> json) =>
_$JoinRulesContentFromJson(json);
}
@Freezed(toJson: false, fromJson: false)
@JsonSerializable()
class const AllowCondition({
final String? roomId,
@JsonKey(unknownEnumValue: AllowConditionType.unknown)
required final AllowConditionType type,
}) with _$AllowCondition {
Map<String, Object?> toJson() => _$AllowConditionToJson(this);
factory AllowCondition.fromJson(Map<String, Object?> json) =>
_$AllowConditionFromJson(json);
}
enum AllowConditionType {
@JsonValue("m.room_membership")
membership,
unknown,
}