25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

* src/mod_roster.erl: The subscribe request are now resend at

login as long as they have not been answered. mod_roster do no more
depends on mod_offline.
* src/ejabberd_sm.erl: Likewise.
* src/ejabberd_c2s.erl: Likewise.
* src/mod_roster_odbc.erl: Likewise (The ODBC/relational support
has not yet been tested).
* src/mod_roster.hrl: Likewise.
* src/mod_offline.erl: Likewise.
* src/mod_offline_odbc.erl: Likewise.
* odbc/pg.sql: Likewise.
* odbc/mysql.sql: Likewise.

SVN Revision: 569
This commit is contained in:
Mickaël Rémond 2006-05-23 20:19:37 +00:00
parent 753e768090
commit 42cdf80cd4
10 changed files with 215 additions and 112 deletions

View File

@ -1,3 +1,18 @@
2006-05-23 Mickael Remond <mickael.remond@process-one.net>
* src/mod_roster.erl: The subscribe request are now resend at login as
long as they have not been answered. mod_roster do no more depends on
mod_offline.
* src/ejabberd_sm.erl: Likewise.
* src/ejabberd_c2s.erl: Likewise.
* src/mod_roster_odbc.erl: Likewise (The ODBC/relational support has
not yet been tested).
* src/mod_roster.hrl: Likewise.
* src/mod_offline.erl: Likewise.
* src/mod_offline_odbc.erl: Likewise.
* odbc/pg.sql: Likewise.
* odbc/mysql.sql: Likewise.
2006-05-22 Mickael Remond <mickael.remond@process-one.net> 2006-05-22 Mickael Remond <mickael.remond@process-one.net>
* src/ejabberd_sm.erl: The max_user_sessions has been moved to * src/ejabberd_sm.erl: The max_user_sessions has been moved to

View File

@ -1364,6 +1364,7 @@ presence_update(From, Packet, StateData) ->
StateData#state.server, StateData#state.server,
[StateData#state.jid]), [StateData#state.jid]),
resend_offline_messages(StateData), resend_offline_messages(StateData),
resend_subscription_requests(StateData),
presence_broadcast_first( presence_broadcast_first(
From, StateData#state{pres_last = Packet, From, StateData#state{pres_last = Packet,
pres_invis = false pres_invis = false
@ -1727,6 +1728,19 @@ resend_offline_messages(#state{user = User,
end, Rs) end, Rs)
end. end.
resend_subscription_requests(#state{user = User,
server = Server} = StateData) ->
PendingSubscriptions = ejabberd_hooks:run_fold(
resend_subscription_requests_hook,
Server,
[],
[User, Server]),
lists:foreach(fun(XMLPacket) ->
send_element(StateData,
XMLPacket)
end,
PendingSubscriptions).
get_showtag(undefined) -> get_showtag(undefined) ->
"unavailable"; "unavailable";
get_showtag(Presence) -> get_showtag(Presence) ->

View File

@ -306,32 +306,34 @@ do_route(From, To, Packet) ->
{Pass, Subsc} = {Pass, Subsc} =
case xml:get_attr_s("type", Attrs) of case xml:get_attr_s("type", Attrs) of
"subscribe" -> "subscribe" ->
Reason = xml:get_tag_cdata(
xml:get_subtag(Packet, "status")),
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, subscribe]), [User, Server, From, subscribe, Reason]),
true}; true};
"subscribed" -> "subscribed" ->
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, subscribed]), [User, Server, From, subscribed, ""]),
true}; true};
"unsubscribe" -> "unsubscribe" ->
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, unsubscribe]), [User, Server, From, unsubscribe, ""]),
true}; true};
"unsubscribed" -> "unsubscribed" ->
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, unsubscribed]), [User, Server, From, unsubscribed, ""]),
true}; true};
_ -> _ ->
{true, false} {true, false}
@ -340,39 +342,18 @@ do_route(From, To, Packet) ->
LFrom = jlib:jid_tolower(From), LFrom = jlib:jid_tolower(From),
PResources = get_user_present_resources( PResources = get_user_present_resources(
LUser, LServer), LUser, LServer),
if lists:foreach(
PResources /= [] -> fun({_, R}) ->
lists:foreach( if LFrom /=
fun({_, R}) -> {LUser, LServer, R} ->
if LFrom /= do_route(
{LUser, LServer, R} -> From,
do_route( jlib:jid_replace_resource(To, R),
From, Packet);
jlib:jid_replace_resource(To, R), true ->
Packet); ok
true -> end
ok end, PResources);
end
end, PResources);
true ->
if
Subsc ->
case ejabberd_auth:is_user_exists(
LUser, LServer) of
true ->
ejabberd_hooks:run(
offline_subscription_hook,
LServer,
[From, To, Packet]);
_ ->
Err = jlib:make_error_reply(
Packet, ?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route(To, From, Err)
end;
true ->
ok
end
end;
true -> true ->
ok ok
end; end;

View File

@ -37,8 +37,6 @@ start(Host, _Opts) ->
update_table(), update_table(),
ejabberd_hooks:add(offline_message_hook, Host, ejabberd_hooks:add(offline_message_hook, Host,
?MODULE, store_packet, 50), ?MODULE, store_packet, 50),
ejabberd_hooks:add(offline_subscription_hook, Host,
?MODULE, store_packet, 50),
ejabberd_hooks:add(resend_offline_messages_hook, Host, ejabberd_hooks:add(resend_offline_messages_hook, Host,
?MODULE, pop_offline_messages, 50), ?MODULE, pop_offline_messages, 50),
ejabberd_hooks:add(remove_user, Host, ejabberd_hooks:add(remove_user, Host,
@ -83,8 +81,6 @@ receive_all(Msgs) ->
stop(Host) -> stop(Host) ->
ejabberd_hooks:delete(offline_message_hook, Host, ejabberd_hooks:delete(offline_message_hook, Host,
?MODULE, store_packet, 50), ?MODULE, store_packet, 50),
ejabberd_hooks:delete(offline_subscription_hook, Host,
?MODULE, store_packet, 50),
ejabberd_hooks:delete(resend_offline_messages_hook, Host, ejabberd_hooks:delete(resend_offline_messages_hook, Host,
?MODULE, pop_offline_messages, 50), ?MODULE, pop_offline_messages, 50),
ejabberd_hooks:delete(remove_user, Host, ejabberd_hooks:delete(remove_user, Host,

View File

@ -28,8 +28,6 @@
start(Host, _Opts) -> start(Host, _Opts) ->
ejabberd_hooks:add(offline_message_hook, Host, ejabberd_hooks:add(offline_message_hook, Host,
?MODULE, store_packet, 50), ?MODULE, store_packet, 50),
ejabberd_hooks:add(offline_subscription_hook, Host,
?MODULE, store_packet, 50),
ejabberd_hooks:add(resend_offline_messages_hook, Host, ejabberd_hooks:add(resend_offline_messages_hook, Host,
?MODULE, pop_offline_messages, 50), ?MODULE, pop_offline_messages, 50),
ejabberd_hooks:add(remove_user, Host, ejabberd_hooks:add(remove_user, Host,
@ -97,8 +95,6 @@ receive_all(Msgs) ->
stop(Host) -> stop(Host) ->
ejabberd_hooks:delete(offline_message_hook, Host, ejabberd_hooks:delete(offline_message_hook, Host,
?MODULE, store_packet, 50), ?MODULE, store_packet, 50),
ejabberd_hooks:delete(offline_subscription_hook, Host,
?MODULE, store_packet, 50),
ejabberd_hooks:delete(resend_offline_messages_hook, Host, ejabberd_hooks:delete(resend_offline_messages_hook, Host,
?MODULE, pop_offline_messages, 50), ?MODULE, pop_offline_messages, 50),
ejabberd_hooks:delete(remove_user, Host, ejabberd_hooks:delete(remove_user, Host,

View File

@ -17,7 +17,8 @@
process_local_iq/3, process_local_iq/3,
get_user_roster/2, get_user_roster/2,
get_subscription_lists/3, get_subscription_lists/3,
in_subscription/5, get_in_pending_subscriptions/3,
in_subscription/6,
out_subscription/4, out_subscription/4,
set_items/3, set_items/3,
remove_user/2, remove_user/2,
@ -46,6 +47,8 @@ start(Host, Opts) ->
?MODULE, get_jid_info, 50), ?MODULE, get_jid_info, 50),
ejabberd_hooks:add(remove_user, Host, ejabberd_hooks:add(remove_user, Host,
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
ejabberd_hooks:add(resend_subscription_requests_hook, Host,
?MODULE, get_in_pending_subscriptions, 50),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER, gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER,
?MODULE, process_iq, IQDisc). ?MODULE, process_iq, IQDisc).
@ -62,6 +65,8 @@ stop(Host) ->
?MODULE, get_jid_info, 50), ?MODULE, get_jid_info, 50),
ejabberd_hooks:delete(remove_user, Host, ejabberd_hooks:delete(remove_user, Host,
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
ejabberd_hooks:delete(resend_subscription_requests_hook, Host,
?MODULE, get_in_pending_subscriptions, 50),
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ROSTER). gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ROSTER).
@ -130,8 +135,6 @@ get_user_roster(Acc, US) ->
end. end.
item_to_xml(Item) -> item_to_xml(Item) ->
Attrs1 = [{"jid", jlib:jid_to_string(Item#roster.jid)}], Attrs1 = [{"jid", jlib:jid_to_string(Item#roster.jid)}],
Attrs2 = case Item#roster.name of Attrs2 = case Item#roster.name of
@ -160,12 +163,11 @@ item_to_xml(Item) ->
_ -> _ ->
Attrs3 Attrs3
end, end,
Attrs = Attrs4 ++ Item#roster.xattrs,
SubEls1 = lists:map(fun(G) -> SubEls1 = lists:map(fun(G) ->
{xmlelement, "group", [], [{xmlcdata, G}]} {xmlelement, "group", [], [{xmlcdata, G}]}
end, Item#roster.groups), end, Item#roster.groups),
SubEls = SubEls1 ++ Item#roster.xs, SubEls = SubEls1 ++ Item#roster.xs,
{xmlelement, "item", Attrs, SubEls}. {xmlelement, "item", Attrs4, SubEls}.
process_iq_set(From, To, #iq{sub_el = SubEl} = IQ) -> process_iq_set(From, To, #iq{sub_el = SubEl} = IQ) ->
@ -193,7 +195,6 @@ process_item_set(From, To, {xmlelement, _Name, Attrs, Els}) ->
I#roster{jid = JID, I#roster{jid = JID,
name = "", name = "",
groups = [], groups = [],
xattrs = [],
xs = []} xs = []}
end, end,
Item1 = process_item_attrs(Item, Attrs), Item1 = process_item_attrs(Item, Attrs),
@ -274,9 +275,7 @@ process_item_attrs(Item, [{Attr, Val} | Attrs]) ->
"ask" -> "ask" ->
process_item_attrs(Item, Attrs); process_item_attrs(Item, Attrs);
_ -> _ ->
XAttrs = Item#roster.xattrs, process_item_attrs(Item, Attrs)
process_item_attrs(Item#roster{xattrs = [{Attr, Val} | XAttrs]},
Attrs)
end; end;
process_item_attrs(Item, []) -> process_item_attrs(Item, []) ->
Item. Item.
@ -374,13 +373,13 @@ ask_to_pending(Ask) -> Ask.
in_subscription(_, User, Server, JID, Type) -> in_subscription(_, User, Server, JID, Type, Reason) ->
process_subscription(in, User, Server, JID, Type). process_subscription(in, User, Server, JID, Type, Reason).
out_subscription(User, Server, JID, Type) -> out_subscription(User, Server, JID, Type) ->
process_subscription(out, User, Server, JID, Type). process_subscription(out, User, Server, JID, Type, []).
process_subscription(Direction, User, Server, JID1, Type) -> process_subscription(Direction, User, Server, JID1, Type, Reason) ->
LUser = jlib:nodeprep(User), LUser = jlib:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jlib:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
@ -415,12 +414,18 @@ process_subscription(Direction, User, Server, JID1, Type) ->
Item#roster.ask, Item#roster.ask,
Type) Type)
end, end,
AskMessage = case NewState of
{_, both} -> Reason;
{_, in} -> Reason;
{_, _} -> []
end,
case NewState of case NewState of
none -> none ->
{none, AutoReply}; {none, AutoReply};
{Subscription, Pending} -> {Subscription, Pending} ->
NewItem = Item#roster{subscription = Subscription, NewItem = Item#roster{subscription = Subscription,
ask = Pending}, ask = Pending,
askmessage = list_to_binary(AskMessage)},
mnesia:write(NewItem), mnesia:write(NewItem),
{{push, NewItem}, AutoReply} {{push, NewItem}, AutoReply}
end end
@ -630,13 +635,42 @@ process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) ->
"ask" -> "ask" ->
process_item_attrs_ws(Item, Attrs); process_item_attrs_ws(Item, Attrs);
_ -> _ ->
XAttrs = Item#roster.xattrs, process_item_attrs_ws(Item, Attrs)
process_item_attrs_ws(Item#roster{xattrs = [{Attr, Val} | XAttrs]},
Attrs)
end; end;
process_item_attrs_ws(Item, []) -> process_item_attrs_ws(Item, []) ->
Item. Item.
get_in_pending_subscriptions(Ls, User, Server) ->
JID = jlib:make_jid(User, Server,""),
case mnesia:dirty_index_read(roster, {User,Server}, #roster.us) of
Result when list(Result) ->
Ls ++ lists:map(
fun(R) ->
Message = R#roster.askmessage,
Status = if is_binary(Message) ->
binary_to_list(Message);
true ->
[]
end,
{xmlelement, "presence", [{"from", jlib:jid_to_string(R#roster.jid)},
{"to", jlib:jid_to_string(JID)},
{"type", "subscribe"}],
[{xmlelement, "status", [],
[{xmlcdata, Status}]}]}
end,
lists:filter(
fun(R) ->
case R#roster.ask of
in -> true;
both -> true;
_ -> false
end
end,
Result));
_ -> []
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -673,42 +707,54 @@ update_table() ->
Fields -> Fields ->
ok; ok;
[uj, user, jid, name, subscription, ask, groups, xattrs, xs] -> [uj, user, jid, name, subscription, ask, groups, xattrs, xs] ->
?INFO_MSG("Converting roster table from " convert_table1(Fields);
"{uj, user, jid, name, subscription, ask, groups, xattrs, xs} format", []), [usj, us, jid, name, subscription, ask, groups, xattrs, xs] ->
Host = ?MYNAME, convert_table2(Fields);
{atomic, ok} = mnesia:create_table(
mod_roster_tmp_table,
[{disc_only_copies, [node()]},
{type, bag},
{local_content, true},
{record_name, roster},
{attributes, record_info(fields, roster)}]),
mnesia:del_table_index(roster, user),
mnesia:transform_table(roster, ignore, Fields),
F1 = fun() ->
mnesia:write_lock_table(mod_roster_tmp_table),
mnesia:foldl(
fun(#roster{usj = {U, JID}, us = U} = R, _) ->
mnesia:dirty_write(
mod_roster_tmp_table,
R#roster{usj = {U, Host, JID},
us = {U, Host}})
end, ok, roster)
end,
mnesia:transaction(F1),
mnesia:clear_table(roster),
F2 = fun() ->
mnesia:write_lock_table(roster),
mnesia:foldl(
fun(R, _) ->
mnesia:dirty_write(R)
end, ok, mod_roster_tmp_table)
end,
mnesia:transaction(F2),
mnesia:delete_table(mod_roster_tmp_table);
_ -> _ ->
?INFO_MSG("Recreating roster table", []), ?INFO_MSG("Recreating roster table", []),
mnesia:transform_table(roster, ignore, Fields) mnesia:transform_table(roster, ignore, Fields)
end. end.
%% Convert roster table to support virtual host
convert_table1(Fields) ->
?INFO_MSG("Virtual host support: converting roster table from "
"{uj, user, jid, name, subscription, ask, groups, xattrs, xs} format", []),
Host = ?MYNAME,
{atomic, ok} = mnesia:create_table(
mod_roster_tmp_table,
[{disc_only_copies, [node()]},
{type, bag},
{local_content, true},
{record_name, roster},
{attributes, record_info(fields, roster)}]),
mnesia:del_table_index(roster, user),
mnesia:transform_table(roster, ignore, Fields),
F1 = fun() ->
mnesia:write_lock_table(mod_roster_tmp_table),
mnesia:foldl(
fun(#roster{usj = {U, JID}, us = U} = R, _) ->
mnesia:dirty_write(
mod_roster_tmp_table,
R#roster{usj = {U, Host, JID},
us = {U, Host}})
end, ok, roster)
end,
mnesia:transaction(F1),
mnesia:clear_table(roster),
F2 = fun() ->
mnesia:write_lock_table(roster),
mnesia:foldl(
fun(R, _) ->
mnesia:dirty_write(R)
end, ok, mod_roster_tmp_table)
end,
mnesia:transaction(F2),
mnesia:delete_table(mod_roster_tmp_table).
%% Convert roster table: xattrs fields become
convert_table2(Fields) ->
?INFO_MSG("Converting roster table from "
"{usj, us, jid, name, subscription, ask, groups, xattrs, xs} format", []),
mnesia:transform_table(roster, ignore, Fields).

View File

@ -13,6 +13,6 @@
subscription = none, subscription = none,
ask = none, ask = none,
groups = [], groups = [],
xattrs = [], askmessage = [],
xs = []}). xs = []}).

View File

@ -17,7 +17,8 @@
process_local_iq/3, process_local_iq/3,
get_user_roster/2, get_user_roster/2,
get_subscription_lists/3, get_subscription_lists/3,
in_subscription/5, get_in_pending_subscriptions/3,
in_subscription/6,
out_subscription/4, out_subscription/4,
set_items/3, set_items/3,
remove_user/2, remove_user/2,
@ -41,6 +42,8 @@ start(Host, Opts) ->
?MODULE, get_jid_info, 50), ?MODULE, get_jid_info, 50),
ejabberd_hooks:add(remove_user, Host, ejabberd_hooks:add(remove_user, Host,
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
ejabberd_hooks:add(resend_subscription_requests_hook, Host,
?MODULE, get_in_pending_subscriptions, 50),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER, gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER,
?MODULE, process_iq, IQDisc). ?MODULE, process_iq, IQDisc).
@ -57,6 +60,8 @@ stop(Host) ->
?MODULE, get_jid_info, 50), ?MODULE, get_jid_info, 50),
ejabberd_hooks:delete(remove_user, Host, ejabberd_hooks:delete(remove_user, Host,
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
ejabberd_hooks:delete(resend_subscription_requests_hook, Host,
?MODULE, get_in_pending_subscriptions, 50),
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ROSTER). gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ROSTER).
@ -253,7 +258,8 @@ process_item_set(From, To, {xmlelement, _Name, Attrs, Els}) ->
["insert into rosterusers(" ["insert into rosterusers("
" username, jid, nick, " " username, jid, nick, "
" subscription, ask, " " subscription, ask, "
" server, subscribe, type) " " askmessage, server, "
" subscribe, type) "
" values ", ItemVals, ";"]), " values ", ItemVals, ";"]),
ejabberd_odbc:sql_query_t( ejabberd_odbc:sql_query_t(
["delete from rostergroups " ["delete from rostergroups "
@ -436,13 +442,13 @@ ask_to_pending(Ask) -> Ask.
in_subscription(_, User, Server, JID, Type) -> in_subscription(_, User, Server, JID, Type, Reason) ->
process_subscription(in, User, Server, JID, Type). process_subscription(in, User, Server, JID, Type, Reason).
out_subscription(User, Server, JID, Type) -> out_subscription(User, Server, JID, Type) ->
process_subscription(out, User, Server, JID, Type). process_subscription(out, User, Server, JID, Type, []).
process_subscription(Direction, User, Server, JID1, Type) -> process_subscription(Direction, User, Server, JID1, Type, Reason) ->
LUser = jlib:nodeprep(User), LUser = jlib:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jlib:nameprep(Server),
LJID = jlib:jid_tolower(JID1), LJID = jlib:jid_tolower(JID1),
@ -497,12 +503,18 @@ process_subscription(Direction, User, Server, JID1, Type) ->
Item#roster.ask, Item#roster.ask,
Type) Type)
end, end,
AskMessage = case NewState of
{_, both} -> Reason;
{_, in} -> Reason;
{_, _} -> []
end,
case NewState of case NewState of
none -> none ->
{none, AutoReply}; {none, AutoReply};
{Subscription, Pending} -> {Subscription, Pending} ->
NewItem = Item#roster{subscription = Subscription, NewItem = Item#roster{subscription = Subscription,
ask = Pending}, ask = Pending,
askmessage = AskMessage},
ItemVals = record_to_string(NewItem), ItemVals = record_to_string(NewItem),
ejabberd_odbc:sql_query_t( ejabberd_odbc:sql_query_t(
["delete from rosterusers " ["delete from rosterusers "
@ -512,7 +524,8 @@ process_subscription(Direction, User, Server, JID1, Type) ->
["insert into rosterusers(" ["insert into rosterusers("
" username, jid, nick, " " username, jid, nick, "
" subscription, ask, " " subscription, ask, "
" server, subscribe, type) " " askmessage, server, subscribe, "
" type) "
" values ", ItemVals, ";"]), " values ", ItemVals, ";"]),
{{push, NewItem}, AutoReply} {{push, NewItem}, AutoReply}
end end
@ -700,7 +713,8 @@ process_item_set_t(LUser, LServer, {xmlelement, _Name, Attrs, Els}) ->
["insert into rosterusers(" ["insert into rosterusers("
" username, jid, nick, " " username, jid, nick, "
" subscription, ask, " " subscription, ask, "
" server, subscribe, type) " " askmessage, server, subscribe, "
" type) "
" values ", ItemVals, ";"], " values ", ItemVals, ";"],
["delete from rostergroups " ["delete from rostergroups "
" where username='", Username, "' " " where username='", Username, "' "
@ -755,6 +769,37 @@ process_item_attrs_ws(Item, []) ->
Item. Item.
get_in_pending_subscriptions(Ls, User, Server) ->
JID = jlib:make_jid(User, Server,""),
case mnesia:dirty_index_read(roster, {User,Server}, #roster.us) of
Result when list(Result) ->
Ls ++ lists:map(
fun(R) ->
Message = R#roster.askmessage,
Status = if is_binary(Message) ->
binary_to_list(Message);
true ->
[]
end,
{xmlelement, "presence", [{"from", jlib:jid_to_string(R#roster.jid)},
{"to", jlib:jid_to_string(JID)},
{"type", "subscribe"}],
[{xmlelement, "status", [],
[{xmlcdata, Status}]}]}
end,
lists:filter(
fun(R) ->
case R#roster.ask of
in -> true;
both -> true;
_ -> false
end
end,
Result));
_ -> []
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
get_jid_info(_, User, Server, JID) -> get_jid_info(_, User, Server, JID) ->
@ -857,7 +902,8 @@ record_to_string(#roster{us = {User, _Server},
jid = JID, jid = JID,
name = Name, name = Name,
subscription = Subscription, subscription = Subscription,
ask = Ask}) -> ask = Ask,
askmessage = AskMessage}) ->
Username = ejabberd_odbc:escape(User), Username = ejabberd_odbc:escape(User),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(JID))), SJID = ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(JID))),
Nick = ejabberd_odbc:escape(Name), Nick = ejabberd_odbc:escape(Name),
@ -881,6 +927,7 @@ record_to_string(#roster{us = {User, _Server},
"'", Nick, "'," "'", Nick, "',"
"'", SSubscription, "'," "'", SSubscription, "',"
"'", SAsk, "'," "'", SAsk, "',"
"'", AskMessage, "',"
"'N', '', 'item')"]. "'N', '', 'item')"].
groups_to_string(#roster{us = {User, _Server}, groups_to_string(#roster{us = {User, _Server},

View File

@ -19,6 +19,7 @@ CREATE TABLE rosterusers (
nick text, nick text,
subscription character(1) NOT NULL, subscription character(1) NOT NULL,
ask character(1) NOT NULL, ask character(1) NOT NULL,
askmessage text,
server character(1) NOT NULL, server character(1) NOT NULL,
subscribe text, subscribe text,
type text type text
@ -91,3 +92,5 @@ CREATE INDEX i_vcard_search_lemail ON vcard_search(lemail);
CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname); CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname);
CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit); CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit);
--- To update from 1.x:
-- ALTER TABLE rosterusers ADD COLUMN askmessage text AFTER ask;

View File

@ -18,6 +18,7 @@ CREATE TABLE rosterusers (
nick text, nick text,
subscription character(1) NOT NULL, subscription character(1) NOT NULL,
ask character(1) NOT NULL, ask character(1) NOT NULL,
askmessage text,
server character(1) NOT NULL, server character(1) NOT NULL,
subscribe text, subscribe text,
"type" text "type" text
@ -36,12 +37,6 @@ CREATE TABLE rostergroups (
CREATE INDEX pk_rosterg_user_jid ON rostergroups USING btree (username, jid); CREATE INDEX pk_rosterg_user_jid ON rostergroups USING btree (username, jid);
--- To update from previous table definition:
-- CREATE SEQUENCE spool_seq_seq;
-- ALTER TABLE spool ADD COLUMN seq integer;
-- ALTER TABLE spool ALTER COLUMN seq SET DEFAULT nextval('spool_seq_seq');
-- UPDATE spool SET seq = DEFAULT;
-- ALTER TABLE spool ALTER COLUMN seq SET NOT NULL;
CREATE TABLE spool ( CREATE TABLE spool (
username text NOT NULL, username text NOT NULL,
@ -95,3 +90,13 @@ CREATE INDEX i_vcard_search_llocality ON vcard_search(llocality);
CREATE INDEX i_vcard_search_lemail ON vcard_search(lemail); CREATE INDEX i_vcard_search_lemail ON vcard_search(lemail);
CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname); CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname);
CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit); CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit);
--- To update from 0.9.8:
-- CREATE SEQUENCE spool_seq_seq;
-- ALTER TABLE spool ADD COLUMN seq integer;
-- ALTER TABLE spool ALTER COLUMN seq SET DEFAULT nextval('spool_seq_seq');
-- UPDATE spool SET seq = DEFAULT;
-- ALTER TABLE spool ALTER COLUMN seq SET NOT NULL;
--- To update from 1.x:
-- ALTER TABLE rosterusers ADD COLUMN askmessage text AFTER ask;