threadMessages method

Future<SequenceNode> threadMessages({
  1. required DateTime since,
  2. String method = 'ORDEREDSUBJECT',
  3. String charset = 'UTF-8',
  4. bool threadUids = false,
  5. Duration? responseTimeout,
})

Requests the IDs of message threads starting on since using the given method (defaults to ORDEREDSUBJECT) and charset (defaults to UTF-8).

Optionally set threadUids to true when you want to receive UIDs rather than sequence IDs. You can use this method when the server announces the THREAD capability, in which it also announces the supported methods, e.g. THREAD=ORDEREDSUBJECT THREAD=REFERENCES. Specify a responseTimeout when a response is expected within the given time. Compare ServerInfo.supportsThreading and ServerInfo.supportedThreadingMethods.

Implementation

Future<SequenceNode> threadMessages({
  required DateTime since,
  String method = 'ORDEREDSUBJECT',
  String charset = 'UTF-8',
  bool threadUids = false,
  Duration? responseTimeout,
}) {
  final buffer = StringBuffer();
  if (threadUids) {
    buffer.write('UID ');
  }
  buffer
    ..write('THREAD ')
    ..write(method)
    ..write(' ')
    ..write(charset)
    ..write(' SINCE ')
    ..write(DateCodec.encodeSearchDate(since));

  return sendCommand(
    Command(
      buffer.toString(),
      writeTimeout: defaultWriteTimeout,
      responseTimeout: responseTimeout,
    ),
    ThreadParser(isUidSequence: threadUids),
  );
}