Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import from Prosody with "roster" has: "approved" attribute. #4188

Closed
istoph opened this issue Apr 1, 2024 · 2 comments
Closed

Import from Prosody with "roster" has: "approved" attribute. #4188

istoph opened this issue Apr 1, 2024 · 2 comments
Assignees
Labels

Comments

@istoph
Copy link

istoph commented Apr 1, 2024

When I try to import a slightly larger instance of Prosody, I get some errors.

Environment

  • ejabberd commit 9ab6093
  • Erlang version: Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 13.1.5
  • OS: Debian GNU/Linux 12 (bookworm)
  • Installed from: source

Errors from cli:

ejabberdctl import_prosody "/var/lib/prosody/"

Unhandled exception occurred executing the command:
** exception error: no function clause matching 
                  prosody2ejabberd:'-convert_roster_item/4-fun-1-'({<<"approved">>,
                                                                    <<"true">>},
                                                                   [{roster,
                                                                     {<<"user">>,
                                                                      <<"5222.de">>,
                                                                      {<<"admin">>,
                                                                       <<"5222.de">>,
                                                                       <<>>}},
                                                                     {<<"user">>,
                                                                      <<"5222.de">>},
                                                                     {<<"admin">>,
                                                                      <<"5222.de">>,
                                                                      <<>>},
                                                                     <<>>,
                                                                     none,
                                                                     none,[],
                                                                     <<>>,
                                                                     []}]) (src/prosody2ejabberd.erl, line 311)
   in function  lists:foldl/3 (lists.erl, line 1350)
   in call from lists:flatmap_1/2 (lists.erl, line 1335)
   in call from lists:flatmap_1/2 (lists.erl, line 1335)
   in call from prosody2ejabberd:convert_data/4 (src/prosody2ejabberd.erl, line 162)
   in call from lists:foreach_1/2 (lists.erl, line 1442)
   in call from ejabberd_ctl:call_command/4 (src/ejabberd_ctl.erl, line 327)
   in call from ejabberd_ctl:try_call_command/4 (src/ejabberd_ctl.erl, line 288)

Example minimal reproducible:

/var/lib/prosody/5222%2ede/roster/user.dat

return {
    [false] = {
        ["version"] = 360;
        ["pending"] = {};
    };
    ["[email protected]"] = {
        ["approved"] = "true";
        ["groups"] = {};
        ["subscription"] = "both";
    };
};

Bug description

The user [email protected] will be import. He has entered [email protected] as a contact and is also countersigned with ["approved"] = "true".

I have added the following roundtrip to line 325:

		     ({<<"approved">>, _}, _) ->
			  [];

But it would make more sense to adopt this attribute as well.

badlop added a commit that referenced this issue Apr 4, 2024
…d it (#4188)

Reference:
https://xmpp.org/rfcs/rfc6121.html#roster-syntax-items-approved

Additionally, when roster contains unknown attribute, discard it and
show a warning
@badlop badlop self-assigned this Apr 4, 2024
@badlop badlop added this to the ejabberd 24.xx milestone Apr 4, 2024
@badlop
Copy link
Member

badlop commented Apr 4, 2024

Nice finding! prosody2ejabberd didn't know how to handle the approved attribute.

In fact, it is an optional attribute and it seems not implemented in ejabberd or the xmpp erlang library. The import code should be able to handle it, even if it does not store the content.

I've committed a fix for this problem, and also included a fix for previous code that forgot R. It seems to work great with your example.

Notice this commit is slightly different than your patch, because you were also fogetting R when handling approved.

@badlop badlop added the Kind:Bug label Apr 4, 2024
@istoph
Copy link
Author

istoph commented Apr 30, 2024

@badlop Thank you! I can confirm that your patch fixes the bug.

@istoph istoph closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants