add poll support

Fixes #130
This commit is contained in:
Henry Hiles 2026-11-02 12:03:52 -05:00
commit f6aaf49164
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -0,0 +1,23 @@
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/content/content.dart";
part "poll_response.freezed.dart";
part "poll_response.g.dart";
@Freezed(toJson: false, fromJson: false)
@JsonSerializable(createToJson: false)
class const PollResponseContent({
@JsonKey(readValue: PollResponseContent.answersFromJson)
final IList<String> answers = const .empty(),
}) extends Content with _$PollResponseContent {
static List<dynamic>? answersFromJson(Map<dynamic, dynamic> json, _) =>
json["org.matrix.msc3381.poll.response"]?["answers"];
@override
Map<String, Object?> toJson() => {
"org.matrix.msc3381.poll.response": {"answers": answers.toList()},
};
factory PollResponseContent.fromJson(Map<String, Object?> json) =>
_$PollResponseContentFromJson(json);
}