postReceipt method
Future<void>
postReceipt(
- String roomId,
- ReceiptType receiptType,
- String eventId, {
- String? threadId,
This API updates the marker for the given receipt type to the event ID specified.
roomId
The room in which to send the event.
receiptType
The type of receipt to send. This can also be m.fully_read
as an
alternative to /read_markers
.
Note that m.fully_read
does not appear under m.receipt
: this endpoint
effectively calls /read_markers
internally when presented with a receipt
type of m.fully_read
.
eventId
The event ID to acknowledge up to.
threadId
The root thread event's ID (or main
) for which
thread this receipt is intended to be under. If
not specified, the read receipt is unthreaded
(default).
Implementation
Future<void> postReceipt(
String roomId,
ReceiptType receiptType,
String eventId, {
String? threadId,
}) async {
final requestUri = Uri(
path:
'_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/receipt/${Uri.encodeComponent(receiptType.name)}/${Uri.encodeComponent(eventId)}',
);
final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(
jsonEncode({
if (threadId != null) 'thread_id': threadId,
}),
);
final response = await httpClient.send(request);
final responseBody = await response.stream.toBytes();
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
final responseString = utf8.decode(responseBody);
final json = jsonDecode(responseString);
return ignore(json);
}