Skip to content

Commit 1055ba9

Browse files
committed
api [nfc]: Rename Message.matchTopic, from matchSubject
Much like the `topic` field in the previous commit.
1 parent 1d021af commit 1055ba9

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

lib/api/model/events.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ class MessageEvent extends Event {
584584
//
585585
// The other difference in the server API between message objects in these
586586
// events and in the get-messages results is that `matchContent` and
587-
// `matchSubject` are absent here. Already [Message.matchContent] and
588-
// [Message.matchSubject] are optional, so no action is needed on that.
587+
// `matchTopic` are absent here. Already [Message.matchContent] and
588+
// [Message.matchTopic] are optional, so no action is needed on that.
589589
final Message message;
590590

591591
MessageEvent({required super.id, required this.message});

lib/api/model/model.dart

+5-4
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ sealed class Message {
657657
@JsonKey(fromJson: _flagsFromJson)
658658
List<MessageFlag> flags; // Unrecognized flags won't roundtrip through {to,from}Json.
659659
final String? matchContent;
660-
final String? matchSubject;
660+
@JsonKey(name: 'match_subject')
661+
final String? matchTopic;
661662

662663
static Reactions? _reactionsFromJson(dynamic json) {
663664
final list = (json as List<dynamic>);
@@ -690,7 +691,7 @@ sealed class Message {
690691
required this.timestamp,
691692
required this.flags,
692693
required this.matchContent,
693-
required this.matchSubject,
694+
required this.matchTopic,
694695
});
695696

696697
factory Message.fromJson(Map<String, dynamic> json) {
@@ -755,7 +756,7 @@ class StreamMessage extends Message {
755756
required super.timestamp,
756757
required super.flags,
757758
required super.matchContent,
758-
required super.matchSubject,
759+
required super.matchTopic,
759760
required this.displayRecipient,
760761
required this.streamId,
761762
});
@@ -857,7 +858,7 @@ class DmMessage extends Message {
857858
required super.timestamp,
858859
required super.flags,
859860
required super.matchContent,
860-
required super.matchSubject,
861+
required super.matchTopic,
861862
required this.displayRecipient,
862863
});
863864

lib/api/model/model.g.dart

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/api/model/model_checks.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extension MessageChecks on Subject<Message> {
5555
Subject<String> get type => has((e) => e.type, 'type');
5656
Subject<List<MessageFlag>> get flags => has((e) => e.flags, 'flags');
5757
Subject<String?> get matchContent => has((e) => e.matchContent, 'matchContent');
58-
Subject<String?> get matchSubject => has((e) => e.matchSubject, 'matchSubject');
58+
Subject<String?> get matchTopic => has((e) => e.matchTopic, 'matchTopic');
5959
}
6060

6161
extension ReactionsChecks on Subject<Reactions> {

test/api/model/model_test.dart

+7
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,13 @@ void main() {
561561
)).topic.equals('hello');
562562
});
563563

564+
test('match_subject -> matchTopic', () {
565+
check(baseStreamJson()).not((it) => it.containsKey('match_topic'));
566+
check(Message.fromJson(baseStreamJson()
567+
..['match_subject'] = 'yo'
568+
)).matchTopic.equals('yo');
569+
});
570+
564571
test('no crash on unrecognized flag', () {
565572
final m1 = Message.fromJson(
566573
(deepToJson(eg.streamMessage()) as Map<String, dynamic>)

0 commit comments

Comments
 (0)