Skip to content

Commit ab579c3

Browse files
authored
Merge pull request #4302 from esl/error-text-mam-id
Add error text when message with given ID is not found
2 parents 83cabbf + 67b5e26 commit ab579c3

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

big_tests/tests/mam_SUITE.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
assert_only_one_of_many_is_equal/2,
6969
add_nostore_hint/1,
7070
assert_not_stored/2,
71+
verify_id_error_text_msg/2,
7172
has_x_user_element/1,
7273
stanza_date_range_archive_request/1,
7374
make_iso_time/1,
@@ -3088,6 +3089,7 @@ server_returns_item_not_found_for_nonexistent_id(Config, RSM, StanzaID, Conditio
30883089
Res = escalus:wait_for_stanza(Alice),
30893090
escalus:assert(is_iq_error, [IQ], Res),
30903091
escalus:assert(is_error, Condition, Res),
3092+
verify_id_error_text_msg(Condition, Res),
30913093
ok
30923094
end,
30933095
parallel_story(Config, [{alice, 1}], F).

big_tests/tests/mam_helper.erl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ retract_tombstone_ns() -> <<"urn:xmpp:message-retract:0#tombstone">>.
178178
groupchat_field_ns() -> <<"urn:xmpp:mam:2#groupchat-field">>.
179179
groupchat_available_ns() -> <<"urn:xmpp:mam:2#groupchat-available">>.
180180
data_validate_ns() -> <<"http://jabber.org/protocol/xdata-validate">>.
181+
stanzas_ns() -> <<"urn:ietf:params:xml:ns:xmpp-stanzas">>.
181182

182183
skip_undefined(Xs) ->
183184
[X || X <- Xs, X =/= undefined].
@@ -413,6 +414,16 @@ verify_archived_muc_light_aff_msg(Msg, AffUsersChanges, IsCreate) ->
413414
Items = exml_query:subelements(X, <<"user">>),
414415
muc_light_helper:verify_aff_users(Items, BinAffUsersChanges).
415416

417+
verify_id_error_text_msg(Condition, Stanza) ->
418+
Text = exml_query:path(Stanza, [{element, <<"error">>},
419+
{element_with_ns, <<"text">>, stanzas_ns()}, cdata]),
420+
case Condition of
421+
[<<"modify">>, <<"not-acceptable">>] ->
422+
?assert_equal(<<"Invalid stanza ID provided">>, Text);
423+
[<<"cancel">>, <<"item-not-found">>] ->
424+
?assert_equal(<<"Message with specified ID is not found">>, Text)
425+
end.
426+
416427
%% ----------------------------------------------------------------------
417428
%% PREFERENCE QUERIES
418429

src/mam/mod_mam_muc.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,11 @@ return_error_iq(IQ, {Reason, {stacktrace, _Stacktrace}}) ->
596596
return_error_iq(IQ, timeout) ->
597597
{error, timeout, IQ#iq{type = error, sub_el = [mongoose_xmpp_errors:service_unavailable(<<"en">>, <<"Timeout in mod_mam_muc">>)]}};
598598
return_error_iq(IQ, invalid_stanza_id) ->
599-
Text = mongoose_xmpp_errors:not_acceptable(<<"en">>, <<"Invalid stanza id provided">>),
599+
Text = mongoose_xmpp_errors:not_acceptable(<<"en">>, <<"Invalid stanza ID provided">>),
600600
{error, invalid_stanza_id, IQ#iq{type = error, sub_el = [Text]}};
601601
return_error_iq(IQ, item_not_found) ->
602-
{error, item_not_found, IQ#iq{type = error, sub_el = [mongoose_xmpp_errors:item_not_found()]}};
602+
Text = mongoose_xmpp_errors:item_not_found(<<"en">>, <<"Message with specified ID is not found">>),
603+
{error, item_not_found, IQ#iq{type = error, sub_el = [Text]}};
603604
return_error_iq(IQ, not_implemented) ->
604605
{error, not_implemented, IQ#iq{type = error, sub_el = [mongoose_xmpp_errors:feature_not_implemented(<<"en">>, <<"From mod_mam_muc">>)]}};
605606
return_error_iq(IQ, missing_with_jid) ->

src/mam/mod_mam_pm.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,11 @@ return_error_iq(IQ, timeout) ->
668668
E = mongoose_xmpp_errors:service_unavailable(<<"en">>, <<"Timeout">>),
669669
{error, timeout, IQ#iq{type = error, sub_el = [E]}};
670670
return_error_iq(IQ, invalid_stanza_id) ->
671-
Text = mongoose_xmpp_errors:not_acceptable(<<"en">>, <<"Invalid stanza id provided">>),
671+
Text = mongoose_xmpp_errors:not_acceptable(<<"en">>, <<"Invalid stanza ID provided">>),
672672
{error, invalid_stanza_id, IQ#iq{type = error, sub_el = [Text]}};
673673
return_error_iq(IQ, item_not_found) ->
674-
{error, item_not_found, IQ#iq{type = error, sub_el = [mongoose_xmpp_errors:item_not_found()]}};
674+
Text = mongoose_xmpp_errors:item_not_found(<<"en">>, <<"Message with specified ID is not found">>),
675+
{error, item_not_found, IQ#iq{type = error, sub_el = [Text]}};
675676
return_error_iq(IQ, not_implemented) ->
676677
{error, not_implemented, IQ#iq{type = error, sub_el = [mongoose_xmpp_errors:feature_not_implemented()]}};
677678
return_error_iq(IQ, Reason) ->

0 commit comments

Comments
 (0)