From 8dd95df51e7b3ff2ccc9f091a3f8f5f9b3dfe351 Mon Sep 17 00:00:00 2001 From: Tobias Lindahl Date: Mon, 11 May 2020 10:29:42 +0200 Subject: [PATCH 1/2] Fix adding more than one member to a cri room --- .../src/rest/rest_cowboy_cri_handler.erl | 3 +-- spec/nynja_rest.yaml | 5 ++++- test/server_SUITE.erl | 21 +++++++++++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/apps/roster/src/rest/rest_cowboy_cri_handler.erl b/apps/roster/src/rest/rest_cowboy_cri_handler.erl index f635b18f6..3241aafd7 100644 --- a/apps/roster/src/rest/rest_cowboy_cri_handler.erl +++ b/apps/roster/src/rest/rest_cowboy_cri_handler.erl @@ -279,9 +279,8 @@ new_room_member_from_json(Req, #{phone_id := AdminPhoneId} = State) -> , phone_ids := PhoneIDs}} -> case roster:muc_member(AdminPhoneId, RoomId) of #'Member'{status = admin} = AdminMember -> - PhoneIDList = re:split(PhoneIDs, ","), Room = #'Room'{id = RoomId, status = ?ADD_STATUS, admins = [AdminMember]}, - case rest_cri:request_with_failed_status(PhoneIDList, Room) of + case rest_cri:request_with_failed_status(PhoneIDs, Room) of {ok, Json} -> Req2 = cowboy_req:set_resp_body(Json, Req1), {true, Req2, State}; diff --git a/spec/nynja_rest.yaml b/spec/nynja_rest.yaml index c7faf902f..85b079def 100644 --- a/spec/nynja_rest.yaml +++ b/spec/nynja_rest.yaml @@ -584,7 +584,10 @@ paths: - in: query name: phone_ids schema: - type: string + type: array + items: + schema: + type: string description: 'Array with phone ids. Only for join = false' responses: diff --git a/test/server_SUITE.erl b/test/server_SUITE.erl index 65e7fa1c3..500de8b59 100644 --- a/test/server_SUITE.erl +++ b/test/server_SUITE.erl @@ -294,6 +294,10 @@ create_and_join_room_cri(Cfg) -> RosterId1 = nynja:user_roster(User1), User2 = register_fresh_user(), RosterId2 = nynja:user_roster(User2), + User3 = register_fresh_user(), + RosterId3 = nynja:user_roster(User3), + User4 = register_fresh_user(), + RosterId4 = nynja:user_roster(User4), ct:log("Missing header parameter"), {ok, 400, _} = @@ -328,7 +332,20 @@ create_and_join_room_cri(Cfg) -> [basic_auth() | Cfg]), wait_for_cri_room_member(RoomId, RosterId1, RosterId2, Cfg), - {User1, User2, RoomId}. + + ct:log("Add another two members to the room"), + {ok, 200, #{data := _ + }} = + request('PostMembersCRIRoom', + #{phoneid => RosterId1, room_id => RoomId + , phone_ids => [RosterId3, RosterId4], + join => false}, + [basic_auth() | Cfg]), + + wait_for_cri_room_member(RoomId, RosterId1, RosterId3, Cfg), + wait_for_cri_room_member(RoomId, RosterId1, RosterId4, Cfg), + + {User1, [User2, User3, User4], RoomId}. wait_for_cri_room_member(RoomId, RosterId1, RosterId2, Cfg) -> %% The call to add member is asynchronous, so we retry @@ -740,7 +757,7 @@ room_chat_message_errors(Cfg) -> call_bubble_message(Cfg) -> %% Create a call room, join it and add the other user to it - {AdminUser, User, RoomId} = create_and_join_room_cri(Cfg), + {AdminUser, [User|_], RoomId} = create_and_join_room_cri(Cfg), AdminRosterId = nynja:user_roster(AdminUser), RosterId = nynja:user_roster(User), -- GitLab From 65de259ef47b846106faf530939e875a4801d69a Mon Sep 17 00:00:00 2001 From: Thomas Arts Date: Mon, 11 May 2020 10:39:41 +0200 Subject: [PATCH 2/2] Update api_nynja --- test/api_nynja.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/api_nynja.erl b/test/api_nynja.erl index a868ebd19..bf858c121 100644 --- a/test/api_nynja.erl +++ b/test/api_nynja.erl @@ -1,6 +1,6 @@ %% coding: latin-1 %% This code is generated from ../server/spec/nynja_rest.yaml -%% on 2020-05-07 15:17:56 UTC +%% on 2020-05-11 8:39:07 UTC %% Using openapi rebar3 plugin version: #6ad56be %% Do not manually change this code! %% @@ -462,7 +462,10 @@ operations() -> [{"in","query"}, {"name","phone_ids"}, {"description","Array with phone ids. Only for join = false"}, - {"schema",#{<<"type">> => <<"string">>}}]], + {"schema", + #{<<"items">> => + #{<<"schema">> => #{<<"type">> => <<"string">>}}, + <<"type">> => <<"array">>}}]], path => <<"/cri/rooms/members">>, responses => #{200 => -- GitLab