markAsRead method

Future<bool> markAsRead(
  1. Channel channel,
  2. Authentication authentication
)

Implementation

Future<bool> markAsRead(
    Channel channel, Authentication authentication) async {
  Map<String, String?> body = {"rid": channel.id};

  http.Response response = await _httpService.post(
    '/api/v1/subscriptions.read',
    jsonEncode(body),
    authentication,
  );

  if (response.statusCode == 200) {
    if (response.body.isNotEmpty == true) {
      return Response.fromMap(jsonDecode(response.body)).success == true;
    } else {
      return false;
    }
  }
  throw RocketChatException(response.body);
}