From 7a6899489e9ab6d8d1c5e46228ef771737d479e9 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 10 Sep 2017 10:02:26 +0200 Subject: [PATCH] Don't die if we try to invite a user which has already been invited --- scripts/patrix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/patrix b/scripts/patrix index faab14d..e2ecc7c 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -302,9 +302,15 @@ sub modify_room { uri => $uri, content => to_json($json) }); - # TODO: just warn if already invited - die "Error inviting user $invite in room $opt->{room}\n" - unless ($resp->is_success); + unless ($resp->is_success){ + my $error = from_json($resp->decoded_content); + if ($error->{error} eq $invite . ' is already in the room.' && $error->{errcode} eq 'M_FORBIDDEN'){ + debug($invite . 'has already been invited in this room, ignoring'); + } + else{ + die "Error inviting user $invite in room $opt->{room}\n"; + } + } } } }