Skip to content

Commit f5991a8

Browse files
committed
api: Add route getReadReceipts
1 parent e157986 commit f5991a8

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

lib/api/route/messages.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,23 @@ class UpdateMessageFlagsForNarrowResult {
436436

437437
Map<String, dynamic> toJson() => _$UpdateMessageFlagsForNarrowResultToJson(this);
438438
}
439+
440+
/// https://zulip.com/api/get-read-receipts
441+
Future<GetReadReceiptsResult> getReadReceipts(ApiConnection connection, {
442+
required int messageId,
443+
}) {
444+
return connection.get('getReadReceipts', GetReadReceiptsResult.fromJson,
445+
'messages/$messageId/read_receipts', null);
446+
}
447+
448+
@JsonSerializable(fieldRename: FieldRename.snake)
449+
class GetReadReceiptsResult {
450+
const GetReadReceiptsResult({required this.userIds});
451+
452+
final List<int> userIds;
453+
454+
factory GetReadReceiptsResult.fromJson(Map<String, dynamic> json) =>
455+
_$GetReadReceiptsResultFromJson(json);
456+
457+
Map<String, dynamic> toJson() => _$GetReadReceiptsResultToJson(this);
458+
}

lib/api/route/messages.g.dart

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/api/route/messages_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,4 +829,15 @@ void main() {
829829
});
830830
});
831831
});
832+
833+
test('smoke getReadReceipts', () {
834+
return FakeApiConnection.with_((connection) async {
835+
final response = GetReadReceiptsResult(userIds: [7, 6543, 210]);
836+
connection.prepare(json: response.toJson());
837+
await getReadReceipts(connection, messageId: 123321);
838+
check(connection.takeRequests()).single.isA<http.Request>()
839+
..method.equals('GET')
840+
..url.path.equals('/api/v1/messages/123321/read_receipts');
841+
});
842+
});
832843
}

0 commit comments

Comments
 (0)