mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Can create conversations
This commit is contained in:
@ -17,6 +17,7 @@ import 'package:comunic/models/new_conversation_message.dart';
|
||||
import 'package:comunic/models/new_conversation_settings.dart';
|
||||
import 'package:comunic/models/unread_conversation.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
import 'package:comunic/utils/color_utils.dart';
|
||||
import 'package:comunic/utils/dart_color.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
@ -32,17 +33,18 @@ class ConversationsHelper {
|
||||
|
||||
/// Create a new conversation
|
||||
///
|
||||
/// Return the ID of the newly created conversation or -1 in case of failure
|
||||
Future<int> createConversation(NewConversation settings) async {
|
||||
final response =
|
||||
await APIRequest(uri: "conversations/create", needLogin: true, args: {
|
||||
/// Return the ID of the newly created conversation
|
||||
///
|
||||
/// Throws in case of failure
|
||||
static Future<int> createConversation(NewConversation settings) async {
|
||||
final response = await APIRequest.withLogin("conversations/create", args: {
|
||||
"name": settings.name ?? "",
|
||||
"follow": settings.follow ? "true" : "false",
|
||||
"users": settings.members.join(","),
|
||||
"color": settings.color ?? ","
|
||||
}).addBool("canEveryoneAddMembers", settings.canEveryoneAddMembers).exec();
|
||||
|
||||
if (response.code != 200) return -1;
|
||||
"color": colorToHex(settings.color) ?? ","
|
||||
})
|
||||
.addBool("canEveryoneAddMembers", settings.canEveryoneAddMembers)
|
||||
.execWithThrow();
|
||||
|
||||
return response.getObject()["conversationID"];
|
||||
}
|
||||
|
Reference in New Issue
Block a user