Support stable identifiers for MSC4175

This commit is contained in:
Henry Hiles 2026-04-02 10:58:34 -04:00
commit e30355a6f1
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -3,15 +3,22 @@ import "package:freezed_annotation/freezed_annotation.dart";
part "profile.freezed.dart"; part "profile.freezed.dart";
part "profile.g.dart"; part "profile.g.dart";
Object? readPronouns(Map<dynamic, dynamic> map, _) =>
map["m.pronouns"] ?? map["io.fsky.nyx.pronouns"];
Object? readTimezone(Map<dynamic, dynamic> map, _) =>
map["m.tz"] ?? map["us.cloke.msc4175.tz"];
@freezed @freezed
abstract class Profile with _$Profile { abstract class Profile with _$Profile {
const factory Profile({ const factory Profile({
String? avatarUrl, String? avatarUrl,
@JsonKey(name: "displayname") String? displayName, @JsonKey(name: "displayname") String? displayName,
@JsonKey(name: "us.cloke.msc4175.tz") String? timezone,
@JsonKey(readValue: readTimezone) String? timezone,
@Default(IList.empty()) @Default(IList.empty())
@JsonKey(name: "io.fsky.nyx.pronouns") @JsonKey(readValue: readPronouns)
IList<Pronoun> pronouns, IList<Pronoun> pronouns,
}) = _Profile; }) = _Profile;