mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Can update a conversation
This commit is contained in:
@ -8,7 +8,6 @@ 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';
|
||||
@ -28,7 +27,7 @@ class ConversationsHelper {
|
||||
/// Create a new conversation
|
||||
///
|
||||
/// Return the ID of the newly created conversation or -1 in case of failure
|
||||
Future<int> createConversation(ConversationSettings settings) async {
|
||||
Future<int> createConversation(Conversation settings) async {
|
||||
final response =
|
||||
await APIRequest(uri: "conversations/create", needLogin: true, args: {
|
||||
"name": settings.hasName ? settings.name : "false",
|
||||
@ -41,6 +40,27 @@ class ConversationsHelper {
|
||||
return response.getObject()["conversationID"];
|
||||
}
|
||||
|
||||
/// Update an existing conversation
|
||||
///
|
||||
/// Returns a boolean depending of the success of the operation
|
||||
Future<bool> updateConversation(Conversation settings) async {
|
||||
final request =
|
||||
APIRequest(uri: "conversations/updateSettings", needLogin: true, args: {
|
||||
"conversationID": settings.id.toString(),
|
||||
"following": settings.following ? "true" : "false"
|
||||
});
|
||||
|
||||
// Update all conversation settings, if possible
|
||||
if(settings.isOwner) {
|
||||
request.addString("name", settings.hasName ? settings.name : "false");
|
||||
request.addString("members", settings.members.join(","));
|
||||
}
|
||||
|
||||
final response = await request.exec();
|
||||
|
||||
return response.code == 200;
|
||||
}
|
||||
|
||||
/// Download the list of conversations from the server
|
||||
Future<ConversationsList> downloadList() async {
|
||||
final response =
|
||||
|
Reference in New Issue
Block a user