mirror of
https://github.com/processone/ejabberd
synced 2025-10-06 03:50:15 +02:00
Add support for MUC room vCard in get_vcard commands
This commit is contained in:
parent
10481ed895
commit
19019bbe32
2 changed files with 33 additions and 1 deletions
|
@ -1149,12 +1149,35 @@ set_vcard(User, Host, Name, SomeContent) ->
|
||||||
set_vcard(User, Host, Name, Subname, SomeContent) ->
|
set_vcard(User, Host, Name, Subname, SomeContent) ->
|
||||||
set_vcard_content(User, Host, [Name, Subname], SomeContent).
|
set_vcard_content(User, Host, [Name, Subname], SomeContent).
|
||||||
|
|
||||||
|
%%
|
||||||
|
%% Room vcard
|
||||||
|
|
||||||
|
is_muc_service(Domain) ->
|
||||||
|
try mod_muc_admin:get_room_serverhost(Domain) of
|
||||||
|
Domain -> false;
|
||||||
|
Service when is_binary(Service) -> true
|
||||||
|
catch _:{unregistered_route, _} ->
|
||||||
|
throw(error_wrong_hostname)
|
||||||
|
end.
|
||||||
|
|
||||||
|
get_room_vcard(Name, Service) ->
|
||||||
|
case mod_muc_admin:get_room_options(Name, Service) of
|
||||||
|
[] ->
|
||||||
|
throw(error_no_vcard_found);
|
||||||
|
Opts ->
|
||||||
|
case lists:keyfind(<<"vcard">>, 1, Opts) of
|
||||||
|
false ->
|
||||||
|
throw(error_no_vcard_found);
|
||||||
|
{_, VCardRaw} ->
|
||||||
|
[fxml_stream:parse_element(VCardRaw)]
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% Internal vcard
|
%% Internal vcard
|
||||||
|
|
||||||
get_vcard_content(User, Server, Data) ->
|
get_vcard_content(User, Server, Data) ->
|
||||||
case mod_vcard:get_vcard(jid:nodeprep(User), jid:nameprep(Server)) of
|
case get_vcard_element(User, Server) of
|
||||||
[El|_] ->
|
[El|_] ->
|
||||||
case get_vcard(Data, El) of
|
case get_vcard(Data, El) of
|
||||||
[false] -> throw(error_no_value_found_in_vcard);
|
[false] -> throw(error_no_value_found_in_vcard);
|
||||||
|
@ -1166,6 +1189,14 @@ get_vcard_content(User, Server, Data) ->
|
||||||
throw(database_failure)
|
throw(database_failure)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
get_vcard_element(User, Server) ->
|
||||||
|
case is_muc_service(Server) of
|
||||||
|
true ->
|
||||||
|
get_room_vcard(User, Server);
|
||||||
|
false ->
|
||||||
|
mod_vcard:get_vcard(jid:nodeprep(User), jid:nameprep(Server))
|
||||||
|
end.
|
||||||
|
|
||||||
get_vcard([<<"TEL">>, TelType], {_, _, _, OldEls}) ->
|
get_vcard([<<"TEL">>, TelType], {_, _, _, OldEls}) ->
|
||||||
{TakenEl, _NewEls} = take_vcard_tel(TelType, OldEls, [], not_found),
|
{TakenEl, _NewEls} = take_vcard_tel(TelType, OldEls, [], not_found),
|
||||||
[TakenEl];
|
[TakenEl];
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
web_menu_main/2, web_page_main/2, web_menu_host/3,
|
web_menu_main/2, web_page_main/2, web_menu_host/3,
|
||||||
subscribe_room/4, subscribe_room_many/3,
|
subscribe_room/4, subscribe_room_many/3,
|
||||||
unsubscribe_room/2, get_subscribers/2,
|
unsubscribe_room/2, get_subscribers/2,
|
||||||
|
get_room_serverhost/1,
|
||||||
web_page_host/3,
|
web_page_host/3,
|
||||||
mod_opt_type/1, mod_options/1,
|
mod_opt_type/1, mod_options/1,
|
||||||
get_commands_spec/0, find_hosts/1]).
|
get_commands_spec/0, find_hosts/1]).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue