getMessagesByMessageId method

Future<List<BaseMessage>> getMessagesByMessageId(
  1. int messageId,
  2. MessageListParams params
)

Retrieves previous or next messages based on the message ID in a specific channel.

The messageId to be the reference point for messages to retrieve.

Implementation

Future<List<BaseMessage>> getMessagesByMessageId(
  int messageId,
  MessageListParams params,
) async {
  sbLog.i(StackTrace.current, 'messageId: $messageId');
  checkUnsupportedAction();

  if (messageId <= 0) {
    throw InvalidParameterException();
  }

  if (channelType == ChannelType.group) {
    params.showSubChannelMessagesOnly = false;
  }

  return await chat.apiClient.send<List<BaseMessage>>(
    ChannelMessagesGetRequest(
      chat,
      channelType: channelType,
      channelUrl: channelUrl,
      params: params.toJson(),
      messageId: messageId,
    ),
  );
}