1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Create new conversations

This commit is contained in:
2019-04-27 16:23:08 +02:00
parent 765ca82300
commit 852064e82d
7 changed files with 272 additions and 15 deletions

View File

@ -8,6 +8,7 @@ import 'package:comunic/models/api_request.dart';
import 'package:comunic/models/api_response.dart';
import 'package:comunic/models/conversation.dart';
import 'package:comunic/models/conversation_message.dart';
import 'package:comunic/models/conversation_settings.dart';
import 'package:comunic/models/new_conversation_message.dart';
import 'package:comunic/utils/account_utils.dart';
import 'package:meta/meta.dart';
@ -24,6 +25,27 @@ class ConversationsHelper {
final ConversationMessagesDatabaseHelper _conversationMessagesDatabaseHelper =
ConversationMessagesDatabaseHelper();
/// Create a new conversation
///
/// Return the ID of the newly created conversation or -1 in case of failure
Future<int> createConversation(ConversationSettings settings) async {
final response = await APIRequest(
uri: "conversations/create",
needLogin: true,
args: {
"name" : settings.hasName ? settings.name : "false",
"follow" : settings.following ? "true" : "false",
"users": settings.members.join(",")
}
).exec();
if(response.code != 200) return -1;
return response.getObject()["conversationID"];
}
/// Download the list of conversations from the server
Future<ConversationsList> downloadList() async {
final response =