catch parsing errors for invalid replies

This commit is contained in:
Henry Hiles 2026-08-08 11:31:07 -04:00
commit 83e8084213
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -17,6 +17,14 @@ abstract class Event with _$Event {
return content["m.new_content"] ?? content;
}
static String? replyToFromJson(Map<dynamic, dynamic> json) {
try {
return json["m.relates_to"]?["m.in_reply_to"]?["event_id"];
} catch (_) {
return null;
}
}
const factory Event({
@JsonKey(name: "rowid") required int rowId,
@JsonKey(name: "timeline_rowid") required int timelineRowId,
@ -45,9 +53,7 @@ abstract class Event with _$Event {
factory Event.fromJson(Map<String, dynamic> json) =>
_$EventFromJson(json).copyWith(
replyTo: getContentFromJson(
json,
)["m.relates_to"]?["m.in_reply_to"]?["event_id"],
replyTo: replyToFromJson(getContentFromJson(json)),
pmp: json["content"]?["com.beeper.per_message_profile"] == null
? null
: Profile.fromJsonWithCatch(