getPostsAroundLastUnread method

Future<MmPostList?> getPostsAroundLastUnread(
  1. String userId,
  2. String channelId, {
  3. int? limitBefore,
  4. int? limitAfter,
  5. bool? skipFetchThreads,
  6. bool? collapsedThreads,
  7. bool? collapsedThreadsExtended,
})

Get posts around oldest unread

Get the oldest unread post in the channel for the given user as well as the posts around it. The returned list is sorted in descending order (most recent post first). ##### Permissions Must be logged in as the user or have edit_other_users permission, and must have read_channel permission for the channel. Minimum server version: 5.14

Parameters:

  • String userId (required): ID of the user

  • String channelId (required): The channel ID to get the posts for

  • int limitBefore: Number of posts before the oldest unread posts. Maximum is 200 posts if limit is set greater than that.

  • int limitAfter: Number of posts after and including the oldest unread post. Maximum is 200 posts if limit is set greater than that.

  • bool skipFetchThreads: Whether to skip fetching threads or not

  • bool collapsedThreads: Whether the client uses CRT or not

  • bool collapsedThreadsExtended: Whether to return the associated users as part of the response or not

Implementation

Future<MmPostList?> getPostsAroundLastUnread(
  String userId,
  String channelId, {
  int? limitBefore,
  int? limitAfter,
  bool? skipFetchThreads,
  bool? collapsedThreads,
  bool? collapsedThreadsExtended,
}) async {
  final response = await getPostsAroundLastUnreadWithHttpInfo(
    userId,
    channelId,
    limitBefore: limitBefore,
    limitAfter: limitAfter,
    skipFetchThreads: skipFetchThreads,
    collapsedThreads: collapsedThreads,
    collapsedThreadsExtended: collapsedThreadsExtended,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'MmPostList',
    ) as MmPostList;
  }
  return null;
}