Skip to content

Commit 76fe89f

Browse files
committed
api: Add route getReadReceipts
1 parent 7fe57ae commit 76fe89f

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
@@ -435,3 +435,23 @@ class UpdateMessageFlagsForNarrowResult {
435435

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

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)