addMessageAction method

Future<AddMessageActionResult> addMessageAction({
  1. required String type,
  2. required String value,
  3. required String channel,
  4. required Timetoken timetoken,
  5. Keyset? keyset,
  6. String? using,
})
inherited

This method adds a message action to a parent message.

type and value cannot be empty.

Parent message is a normal message identified by a combination of subscription key, channel and timetoken.

Important!

Server does not validate if the parent message exists at the time of adding the message action.

It does, however, check if you have not already added this particular action to the parent message.

In other words, for a given parent message, there can be only one message action with type and value.

Implementation

Future<AddMessageActionResult> addMessageAction(
    {required String type,
    required String value,
    required String channel,
    required Timetoken timetoken,
    Keyset? keyset,
    String? using}) async {
  keyset ??= keysets[using];

  Ensure(type).isNotEmpty('message action type');
  Ensure(value).isNotEmpty('message action value');
  Ensure(timetoken).isNotNull('message timetoken');

  var addMessageActionBody =
      await super.parser.encode({'type': type, 'value': value});

  var params = AddMessageActionParams(
      keyset, channel, timetoken, addMessageActionBody);

  return defaultFlow<AddMessageActionParams, AddMessageActionResult>(
      keyset: keyset,
      core: this,
      params: params,
      serialize: (object, [_]) => AddMessageActionResult.fromJson(object));
}