add join rules event

This commit is contained in:
Henry Hiles 2026-05-15 21:18:05 -04:00
commit 17603f0d16
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
4 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,17 @@
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/content/content.dart";
part "canonical_alias.freezed.dart";
part "canonical_alias.g.dart";
@freezed
abstract class CanonicalAliasContent extends Content
with _$CanonicalAliasContent {
CanonicalAliasContent._();
const factory CanonicalAliasContent({
String? alias,
@Default([]) altAliases,
}) = _CanonicalAliasContent;
factory CanonicalAliasContent.fromJson(Map<String, Object?> json) =>
_$CanonicalAliasContentFromJson(json);
}

View file

@ -1,6 +1,8 @@
import "package:collection/collection.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/content/canonical_alias.dart";
import "package:nexus/models/content/create.dart";
import "package:nexus/models/content/join_rules.dart";
import "package:nexus/models/content/membership.dart";
import "package:nexus/models/content/message.dart";
@ -22,6 +24,8 @@ enum EventType {
encrypted("m.room.encrypted", Content.fromJson),
membership("m.room.member", MembershipContent.fromJson),
create("m.room.create", CreateContent.fromJson),
canonicalAlias("m.room.canonical_alias", CanonicalAliasContent.fromJson),
joinRules("m.room.join_rules", JoinRulesContent.fromJson),
message("m.room.message", MessageContent.fromJson);
final String type;

View file

@ -0,0 +1,34 @@
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
abstract class JoinRulesContent extends Content with _$JoinRulesContent {
JoinRulesContent._();
const factory JoinRulesContent({
required JoinRule joinRule,
@Default(IList.empty()) IList<AllowCondition> allow,
}) = _JoinRulesContent;
factory JoinRulesContent.fromJson(Map<String, Object?> json) =>
_$JoinRulesContentFromJson(json);
}
@freezed
abstract class AllowCondition with _$AllowCondition {
const factory AllowCondition({
String? roomId,
required AllowConditionType type,
}) = _AllowCondition;
factory AllowCondition.fromJson(Map<String, Object?> json) =>
_$AllowConditionFromJson(json);
}
enum AllowConditionType {
@JsonValue("m.room_membership")
membership,
}

View file

@ -0,0 +1,4 @@
import "package:freezed_annotation/freezed_annotation.dart";
@JsonEnum(fieldRename: FieldRename.snake)
enum JoinRule { public, knock, invite, private, restricted, knockRestricted }