|
7 | 7 | -include_lib("exml/include/exml.hrl").
|
8 | 8 | -include_lib("jid/include/jid.hrl").
|
9 | 9 | -include_lib("inbox.hrl").
|
| 10 | +-include("muc_light.hrl"). |
10 | 11 |
|
11 | 12 | %% tests
|
12 | 13 | -import(muc_light_helper, [room_bin_jid/1]).
|
@@ -97,7 +98,9 @@ groups() ->
|
97 | 98 | leave_and_remove_conversation,
|
98 | 99 | groupchat_markers_one_reset_room_created,
|
99 | 100 | groupchat_markers_all_reset_room_created,
|
100 |
| - inbox_does_not_trigger_does_user_exist |
| 101 | + inbox_does_not_trigger_does_user_exist, |
| 102 | + remove_muclight_messages_after_the_room_is_deleted_xmpp, |
| 103 | + remove_muclight_messages_after_the_room_is_deleted_graphql |
101 | 104 | ]},
|
102 | 105 | {muclight_config, [sequence],
|
103 | 106 | [
|
@@ -678,6 +681,54 @@ simple_groupchat_stored_in_all_inbox(Config) ->
|
678 | 681 | check_inbox(Kate, [#conv{unread = 1, from = AliceRoomJid, to = KateJid, content = Msg}])
|
679 | 682 | end).
|
680 | 683 |
|
| 684 | +remove_muclight_messages_after_the_room_is_deleted_xmpp(Config) -> |
| 685 | + remove_muclight_messages_after_the_room_is_deleted(Config, xmpp). |
| 686 | + |
| 687 | +remove_muclight_messages_after_the_room_is_deleted_graphql(Config) -> |
| 688 | + remove_muclight_messages_after_the_room_is_deleted(Config, graphql). |
| 689 | + |
| 690 | +remove_muclight_messages_after_the_room_is_deleted(Config, ReqType) -> |
| 691 | + escalus:fresh_story(Config, [{alice, 1}, {bob, 1}, {kate, 1}], fun(Alice, Bob, Kate) -> |
| 692 | + Msg = <<"Hi Room!">>, |
| 693 | + Id = <<"MyID">>, |
| 694 | + Users = [Alice, Bob, Kate], |
| 695 | + Room = inbox_helper:create_room(Alice, [Bob, Kate]), |
| 696 | + AliceJid = inbox_helper:to_bare_lower(Alice), |
| 697 | + KateJid = inbox_helper:to_bare_lower(Kate), |
| 698 | + BobJid = inbox_helper:to_bare_lower(Bob), |
| 699 | + RoomJid = room_bin_jid(Room), |
| 700 | + AliceRoomJid = <<RoomJid/binary, "/", AliceJid/binary>>, |
| 701 | + Stanza = escalus_stanza:set_id( |
| 702 | + escalus_stanza:groupchat_to(RoomJid, Msg), Id), |
| 703 | + %% Alice sends message to a room |
| 704 | + escalus:send(Alice, Stanza), |
| 705 | + inbox_helper:wait_for_groupchat_msg(Users), |
| 706 | + %% Alice has 0 unread messages |
| 707 | + check_inbox(Alice, [#conv{unread = 0, from = AliceRoomJid, to = AliceJid, content = Msg}]), |
| 708 | + %% Bob and Kate have one conv with 1 unread message |
| 709 | + check_inbox(Bob, [#conv{unread = 1, from = AliceRoomJid, to = BobJid, content = Msg}]), |
| 710 | + check_inbox(Kate, [#conv{unread = 1, from = AliceRoomJid, to = KateJid, content = Msg}]), |
| 711 | + |
| 712 | + %% Remove the room |
| 713 | + destroy_room(Config, Alice, Bob, Kate, RoomJid, ReqType), |
| 714 | + |
| 715 | + %% Inbox entries are removed |
| 716 | + check_inbox(Alice, []), |
| 717 | + check_inbox(Bob, []), |
| 718 | + check_inbox(Kate, []) |
| 719 | + end). |
| 720 | + |
| 721 | +destroy_room(_, Alice, Bob, Kate, RoomJid, xmpp) -> |
| 722 | + Stanza = escalus_stanza:to( |
| 723 | + escalus_stanza:iq_set(?NS_MUC_LIGHT_DESTROY, []), RoomJid), |
| 724 | + escalus:send(Alice, Stanza), |
| 725 | + AffUsersChanges = [{Alice, none}, {Bob, none}, {Kate, none}], |
| 726 | + muc_light_helper:verify_aff_bcast([], AffUsersChanges, [?NS_MUC_LIGHT_DESTROY]); |
| 727 | +destroy_room(Config, _, _, _, RoomJid, graphql) -> |
| 728 | + Vars = #{<<"room">> => RoomJid}, |
| 729 | + graphql_helper:execute_command(<<"muc_light">>, <<"deleteRoom">>, Vars, |
| 730 | + graphql_helper:init_admin_handler(Config)). |
| 731 | + |
681 | 732 | advanced_groupchat_stored_in_all_inbox(Config) ->
|
682 | 733 | escalus:fresh_story(Config, [{alice, 1}, {bob, 1}, {kate, 1}], fun(Alice, Bob, Kate) ->
|
683 | 734 | Msg1 = <<"Hi Room!">>,
|
|
0 commit comments