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

* src/odbc/pg.sql: Updated

* src/mod_shared_roster.erl: Updated

* src/ejabberd_sm.erl: Bugfix

* src/mod_roster.erl: Bugfix
* src/mod_roster_odbc.erl: Likewise

SVN Revision: 570
This commit is contained in:
Alexey Shchepin 2006-05-26 00:00:32 +00:00
parent 42cdf80cd4
commit c737ce1b8c
6 changed files with 102 additions and 74 deletions

View File

@ -1,3 +1,14 @@
2006-05-26 Alexey Shchepin <alexey@sevcom.net>
* src/odbc/pg.sql: Updated
* src/mod_shared_roster.erl: Updated
* src/ejabberd_sm.erl: Bugfix
* src/mod_roster.erl: Bugfix
* src/mod_roster_odbc.erl: Likewise
2006-05-23 Mickael Remond <mickael.remond@process-one.net>
* src/mod_roster.erl: The subscribe request are now resend at login as

View File

@ -8,7 +8,6 @@
-module(ejabberd_sm).
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
-behaviour(gen_server).
@ -306,8 +305,9 @@ do_route(From, To, Packet) ->
{Pass, Subsc} =
case xml:get_attr_s("type", Attrs) of
"subscribe" ->
Reason = xml:get_tag_cdata(
xml:get_subtag(Packet, "status")),
Reason = xml:get_path_s(
Packet,
[{elem, "status"}, cdata]),
{ejabberd_hooks:run_fold(
roster_in_subscription,
LServer,

View File

@ -417,7 +417,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason) ->
AskMessage = case NewState of
{_, both} -> Reason;
{_, in} -> Reason;
{_, _} -> []
_ -> ""
end,
case NewState of
none ->
@ -641,35 +641,37 @@ process_item_attrs_ws(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
JID = jlib:make_jid(User, Server, ""),
US = {JID#jid.luser, JID#jid.lserver},
case mnesia:dirty_index_read(roster, US, #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));
_ -> []
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));
_ ->
Ls
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -8,7 +8,6 @@
-module(mod_roster_odbc).
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
-behaviour(gen_mod).
@ -126,10 +125,10 @@ get_user_roster(Acc, {LUser, LServer}) ->
case catch ejabberd_odbc:sql_query(
LServer,
["select username, jid, nick, subscription, ask, "
"server, subscribe, type from rosterusers "
"askmessage, server, subscribe, type from rosterusers "
"where username='", Username, "'"]) of
{selected, ["username", "jid", "nick", "subscription", "ask",
"server", "subscribe", "type"],
"askmessage", "server", "subscribe", "type"],
Items} when is_list(Items) ->
JIDGroups = case catch ejabberd_odbc:sql_query(
LServer,
@ -216,11 +215,12 @@ process_item_set(From, To, {xmlelement, _Name, Attrs, Els}) ->
F = fun() ->
{selected,
["username", "jid", "nick", "subscription",
"ask", "server", "subscribe", "type"],
"ask", "askmessage", "server", "subscribe", "type"],
Res} =
ejabberd_odbc:sql_query_t(
["select username, jid, nick, subscription, "
"ask, server, subscribe, type from rosterusers "
"ask, askmessage, server, subscribe, type "
"from rosterusers "
"where username='", Username, "' "
"and jid='", SJID, "'"]),
Item = case Res of
@ -410,10 +410,10 @@ get_subscription_lists(_, User, Server) ->
case catch ejabberd_odbc:sql_query(
LServer,
["select username, jid, nick, subscription, ask, "
"server, subscribe, type from rosterusers "
"askmessage, server, subscribe, type from rosterusers "
"where username='", Username, "'"]) of
{selected, ["username", "jid", "nick", "subscription", "ask",
"server", "subscribe", "type"],
"askmessage", "server", "subscribe", "type"],
Items} when is_list(Items) ->
fill_subscription_lists(LServer, Items, [], []);
_ ->
@ -458,12 +458,13 @@ process_subscription(Direction, User, Server, JID1, Type, Reason) ->
Item =
case ejabberd_odbc:sql_query_t(
["select username, jid, nick, subscription, ask, "
"server, subscribe, type from rosterusers "
"askmessage, server, subscribe, type "
"from rosterusers "
"where username='", Username, "' "
"and jid='", SJID, "';"]) of
{selected,
["username", "jid", "nick", "subscription", "ask",
"server", "subscribe", "type"],
"askmessage", "server", "subscribe", "type"],
[I]} ->
R = raw_to_record(LServer, I),
Groups =
@ -506,7 +507,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason) ->
AskMessage = case NewState of
{_, both} -> Reason;
{_, in} -> Reason;
{_, _} -> []
_ -> ""
end,
case NewState of
none ->
@ -770,35 +771,47 @@ process_item_attrs_ws(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) ->
JID = jlib:make_jid(User, Server, ""),
LUser = JID#jid.luser,
LServer = JID#jid.lserver,
Username = ejabberd_odbc:escape(LUser),
case catch ejabberd_odbc:sql_query(
LServer,
["select username, jid, nick, subscription, ask, "
"askmessage, server, subscribe, type from rosterusers "
"where username='", Username, "'"]) of
{selected, ["username", "jid", "nick", "subscription", "ask",
"askmessage", "server", "subscribe", "type"],
Items} when is_list(Items) ->
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));
_ -> []
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:flatmap(
fun(I) ->
R = raw_to_record(LServer, I),
case R#roster.ask of
in -> [R];
both -> [R];
_ -> []
end
end,
Items));
_ ->
Ls
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -869,7 +882,7 @@ get_jid_info(_, User, Server, JID) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
raw_to_record(LServer, {User, SJID, Nick, SSubscription, SAsk,
raw_to_record(LServer, {User, SJID, Nick, SSubscription, SAsk, SAskMessage,
_SServer, _SSubscribe, _SType}) ->
case jlib:string_to_jid(SJID) of
error ->
@ -895,7 +908,8 @@ raw_to_record(LServer, {User, SJID, Nick, SSubscription, SAsk,
jid = LJID,
name = Nick,
subscription = Subscription,
ask = Ask}
ask = Ask,
askmessage = SAskMessage}
end.
record_to_string(#roster{us = {User, _Server},

View File

@ -8,7 +8,6 @@
-module(mod_shared_roster).
-author('alexey@sevcom.net').
-vsn('$Revision: 24 $ ').
-behaviour(gen_mod).
@ -16,7 +15,7 @@
get_user_roster/2,
get_subscription_lists/3,
get_jid_info/4,
in_subscription/5,
in_subscription/6,
out_subscription/4,
list_groups/1,
create_group/2,
@ -148,7 +147,7 @@ get_jid_info({Subscription, Groups}, User, Server, JID) ->
{Subscription, Groups}
end.
in_subscription(Acc, User, Server, JID, Type) ->
in_subscription(Acc, User, Server, JID, Type, _Reason) ->
process_subscription(in, User, Server, JID, Type, Acc).
out_subscription(User, Server, JID, Type) ->

View File

@ -18,7 +18,7 @@ CREATE TABLE rosterusers (
nick text,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
askmessage text,
askmessage text NOT NULL,
server character(1) NOT NULL,
subscribe text,
"type" text
@ -99,4 +99,6 @@ CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit);
-- ALTER TABLE spool ALTER COLUMN seq SET NOT NULL;
--- To update from 1.x:
-- ALTER TABLE rosterusers ADD COLUMN askmessage text AFTER ask;
-- ALTER TABLE rosterusers ADD COLUMN askmessage text;
-- UPDATE rosterusers SET askmessage = '';
-- ALTER TABLE rosterusers ALTER COLUMN askmessage SET NOT NULL;