removeParticipants method

Future<VIConversationEvent> removeParticipants(
  1. List<VIConversationParticipant> participants
)

Remove participants from the conversation.

It's possible only on two conditions:

Duplicated users are ignored. Will cause VIException if at least one user:

  • does not exist
  • is already removed

Note that you can remove participants that are marked as deleted (VIUser.isDeleted is true).

The removed users can later get this conversation's UUID via the VIUser.leaveConversationList property.

Other parties of the conversation (online participants and logged in clients) can be informed about removing participants via the VIMessenger.onEditConversation callback.

participants - List of VIConversationParticipant to be removed from the conversation. Shouldn't contain null(s), be null or empty list.

Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError

Implementation

Future<VIConversationEvent> removeParticipants(
  List<VIConversationParticipant> participants,
) async {
  try {
    Map<String, dynamic>? data =
        await _methodChannel.invokeMapMethod('Messaging.removeParticipants', {
      'conversation': uuid,
      'participants': participants.map((e) => e._toMap).toList(),
    });
    if (data == null) {
      _VILog._e(
          'VIConversation: removeParticipants: data was null, skipping');
      throw VIException(
        VIMessagingError.ERROR_INTERNAL,
        'VIConversation:removeParticipants: data was null',
      );
    }
    return VIConversationEvent._fromMap(data);
  } on PlatformException catch (e) {
    throw VIException(e.code, e.message);
  }
}