add pinned events content type

This commit is contained in:
Henry Hiles 2026-05-16 11:09:05 -04:00
commit 05b15c44ec
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 18 additions and 5 deletions

View file

@ -8,6 +8,7 @@ import "package:nexus/models/content/join_rules.dart";
import "package:nexus/models/content/membership.dart";
import "package:nexus/models/content/message.dart";
import "package:nexus/models/content/name.dart";
import "package:nexus/models/content/pinned_events.dart";
import "package:nexus/models/content/power_levels.dart";
import "package:nexus/models/content/server_acl.dart";
import "package:nexus/models/content/topic.dart";
@ -38,6 +39,7 @@ enum EventType {
avatar("m.room.avatar", AvatarContent.fromJson),
topic("m.room.topic", TopicContent.fromJson),
name("m.room.name", NameContent.fromJson),
pinnedEvents("m.room.pinned_events", PinnedEventsContent.fromJson),
message("m.room.message", MessageContent.fromJson);
final String type;

View file

@ -18,7 +18,6 @@ abstract class MessageContent extends Content with _$MessageContent {
@FreezedUnionValue("m.image")
const factory MessageContent.image({
required String msgtype,
required String body,
String? format,
String? formattedBody,
@ -30,7 +29,6 @@ abstract class MessageContent extends Content with _$MessageContent {
@FreezedUnionValue("m.file")
const factory MessageContent.file({
required String msgtype,
required String body,
String? format,
String? formattedBody,
@ -42,7 +40,6 @@ abstract class MessageContent extends Content with _$MessageContent {
@FreezedUnionValue("m.audio")
const factory MessageContent.audio({
required String msgtype,
required String body,
String? format,
String? formattedBody,
@ -54,7 +51,6 @@ abstract class MessageContent extends Content with _$MessageContent {
@FreezedUnionValue("m.video")
const factory MessageContent.video({
required String msgtype,
required String body,
String? format,
String? formattedBody,
@ -66,7 +62,6 @@ abstract class MessageContent extends Content with _$MessageContent {
@FreezedUnionValue("m.location")
const factory MessageContent.location({
required String msgtype,
required String body,
required Uri geoUri,
}) = _LocationMessageContent;

View file

@ -0,0 +1,16 @@
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/content/content.dart";
part "pinned_events.freezed.dart";
part "pinned_events.g.dart";
@freezed
abstract class PinnedEventsContent extends Content with _$PinnedEventsContent {
PinnedEventsContent._();
const factory PinnedEventsContent({
@Default(IList.empty()) IList<String> pinned,
}) = _PinnedEventsContent;
factory PinnedEventsContent.fromJson(Map<String, Object?> json) =>
_$PinnedEventsContentFromJson(json);
}