1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00

Can invite a user to join a group

This commit is contained in:
Pierre HUBERT 2020-05-02 15:38:02 +02:00
parent 2ec8693e85
commit 3c7795837c
2 changed files with 12 additions and 1 deletions

View File

@ -268,6 +268,15 @@ class GroupsHelper {
.map((f) => _apiToGroupMembership(f)) .map((f) => _apiToGroupMembership(f))
.toList()); .toList());
/// Invite a user to join a group
///
/// Throws an exception in case of failure
static Future<void> sendInvitation(int groupID, int userID) async =>
APIRequest.withLogin("groups/invite")
.addInt("group_id", groupID)
.addInt("userID", userID)
.execWithThrow();
/// Cancel a group membership invitation /// Cancel a group membership invitation
/// ///
/// Throws an exception in case of failure /// Throws an exception in case of failure

View File

@ -96,11 +96,13 @@ class _GroupMembersScreenState extends State<GroupMembersScreen> {
final userID = await showPickUserDialog(context); final userID = await showPickUserDialog(context);
if (userID == null) return; if (userID == null) return;
print("Invite user: $userID"); await GroupsHelper.sendInvitation(widget.groupID, userID);
} catch (e, s) { } catch (e, s) {
print("Could not invite a user! $e\n$s"); print("Could not invite a user! $e\n$s");
showSimpleSnack(context, tr("Could not invite a user!")); showSimpleSnack(context, tr("Could not invite a user!"));
} }
_key.currentState.refresh();
} }
} }