add join rules event
This commit is contained in:
parent
e60e247093
commit
17603f0d16
4 changed files with 59 additions and 0 deletions
17
lib/models/content/canonical_alias.dart
Normal file
17
lib/models/content/canonical_alias.dart
Normal 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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
34
lib/models/content/join_rules.dart
Normal file
34
lib/models/content/join_rules.dart
Normal 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,
|
||||
}
|
||||
4
lib/models/join_rule.dart
Normal file
4
lib/models/join_rule.dart
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
enum JoinRule { public, knock, invite, private, restricted, knockRestricted }
|
||||
Loading…
Add table
Add a link
Reference in a new issue