sendFileMessage method

Future<void> sendFileMessage({
  1. required String id,
  2. required String message,
  3. required String channelName,
  4. required String messageType,
})

Implementation

Future<void> sendFileMessage(
    {required String id,
    required String message,
    required String channelName,
    required String messageType}) async {
  final request = SendMessageRequest(
    messageType: messageType,
    message: message,
    conversationId: id,
  );

  final response = channelName.toLowerCase() == 'twitter'
      ? await _conversationRepository.sendTwitterMessage(request)
      : channelName.toLowerCase() == 'facebook'
          ? await _conversationRepository.sendFacebookMessage(request)
          : channelName.toLowerCase() == 'instagram'
              ? await _conversationRepository.sendInstagramMessage(request)
              : const ConversationModel();

  textMessageController.clear();

  if (response.status == 'success') {
    _conversationsService.conversation.value = response;
    await getSingleConversation(
      id,
    );

    getAllConversations();
  } else {
    _loadingService.showError(
      'unable to send message...',
    );
    getAllConversations();
  }
}