mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
Fix status handling by always using binaries: until now, we were mixing
lists and binaries in a non-working way. PR: EJABP-1 Submitted by: Pablo Polvorin <pablo.polvorin@process-one.net> SVN Revision: 1608
This commit is contained in:
parent
0434c1424a
commit
bc0d8613ab
@ -16,6 +16,10 @@
|
|||||||
* src/mod_privacy.erl: The Mnesia table wasn't updated when converting
|
* src/mod_privacy.erl: The Mnesia table wasn't updated when converting
|
||||||
from an old schema.
|
from an old schema.
|
||||||
|
|
||||||
|
* src/ejabberd_sm.erl, src/mod_roster.erl, src/mod_roster_odbc.erl:
|
||||||
|
Fix status handling by always using binaries: until now, we were
|
||||||
|
mixing lists and binaries in a non-working way.
|
||||||
|
|
||||||
2008-10-02 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
2008-10-02 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
||||||
|
|
||||||
* src/mod_roster_odbc.erl: Fix a bug where a JID represented as a
|
* src/mod_roster_odbc.erl: Fix a bug where a JID represented as a
|
||||||
|
@ -420,21 +420,21 @@ do_route(From, To, Packet) ->
|
|||||||
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}
|
||||||
|
@ -367,7 +367,7 @@ in_subscription(_, User, Server, JID, Type, Reason) ->
|
|||||||
process_subscription(in, User, Server, JID, Type, Reason).
|
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, Reason) ->
|
process_subscription(Direction, User, Server, JID1, Type, Reason) ->
|
||||||
try
|
try
|
||||||
@ -406,7 +406,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason) ->
|
|||||||
AskMessage = case NewState of
|
AskMessage = case NewState of
|
||||||
{_, both} -> Reason;
|
{_, both} -> Reason;
|
||||||
{_, in} -> Reason;
|
{_, in} -> Reason;
|
||||||
_ -> ""
|
_ -> <<>>
|
||||||
end,
|
end,
|
||||||
case NewState of
|
case NewState of
|
||||||
none ->
|
none ->
|
||||||
@ -416,9 +416,13 @@ process_subscription(Direction, User, Server, JID1, Type, Reason) ->
|
|||||||
mnesia:delete({roster, {LUser, LServer, LJID}}),
|
mnesia:delete({roster, {LUser, LServer, LJID}}),
|
||||||
{none, AutoReply};
|
{none, AutoReply};
|
||||||
{Subscription, Pending} ->
|
{Subscription, Pending} ->
|
||||||
|
AskBinary = case AskMessage of
|
||||||
|
undefined -> <<>>;
|
||||||
|
B -> B
|
||||||
|
end,
|
||||||
NewItem = Item#roster{subscription = Subscription,
|
NewItem = Item#roster{subscription = Subscription,
|
||||||
ask = Pending,
|
ask = Pending,
|
||||||
askmessage = list_to_binary(AskMessage)},
|
askmessage = AskBinary},
|
||||||
mnesia:write(NewItem),
|
mnesia:write(NewItem),
|
||||||
{{push, NewItem}, AutoReply}
|
{{push, NewItem}, AutoReply}
|
||||||
end
|
end
|
||||||
@ -648,10 +652,10 @@ get_in_pending_subscriptions(Ls, User, Server) ->
|
|||||||
Ls ++ lists:map(
|
Ls ++ lists:map(
|
||||||
fun(R) ->
|
fun(R) ->
|
||||||
Message = R#roster.askmessage,
|
Message = R#roster.askmessage,
|
||||||
{U, S, R} = R#roster.jid,
|
{U0, S0, R0} = R#roster.jid,
|
||||||
Pres1 = exmpp_presence:subscribe(),
|
Pres1 = exmpp_presence:subscribe(),
|
||||||
Pres2 = exmpp_stanza:set_jids(Pres1,
|
Pres2 = exmpp_stanza:set_jids(Pres1,
|
||||||
exmpp_jid:jid_to_list(U, S, R),
|
exmpp_jid:jid_to_list(U0, S0, R0),
|
||||||
exmpp_jid:jid_to_list(JID)),
|
exmpp_jid:jid_to_list(JID)),
|
||||||
exmpp_presence:set_status(Pres2, Message)
|
exmpp_presence:set_status(Pres2, Message)
|
||||||
end,
|
end,
|
||||||
|
@ -411,15 +411,15 @@ in_subscription(_, User, Server, JID, Type, Reason) ->
|
|||||||
process_subscription(in, User, Server, JID, Type, Reason).
|
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, Reason) ->
|
process_subscription(Direction, User, Server, JID1, Type, Reason) ->
|
||||||
try
|
try
|
||||||
LUser = exmpp_stringprep:nodeprep(User),
|
LUser = exmpp_stringprep:nodeprep(User),
|
||||||
LServer = exmpp_stringprep:nameprep(Server),
|
LServer = exmpp_stringprep:nameprep(Server),
|
||||||
LJID = exmpp_jid:jid_to_bare_jid(JID1),
|
{N0,D0,R0} = LJID = jlib:short_prepd_jid(JID1),
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_odbc:escape(LUser),
|
||||||
SJID = ejabberd_odbc:escape(exmpp_jid:jid_to_list(LJID)),
|
SJID = ejabberd_odbc:escape(exmpp_jid:jid_to_list(N0,D0,R0)),
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
Item =
|
Item =
|
||||||
case odbc_queries:get_roster_by_jid(LServer, Username, SJID) of
|
case odbc_queries:get_roster_by_jid(LServer, Username, SJID) of
|
||||||
@ -467,7 +467,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason) ->
|
|||||||
AskMessage = case NewState of
|
AskMessage = case NewState of
|
||||||
{_, both} -> Reason;
|
{_, both} -> Reason;
|
||||||
{_, in} -> Reason;
|
{_, in} -> Reason;
|
||||||
_ -> ""
|
_ -> <<>>
|
||||||
end,
|
end,
|
||||||
case NewState of
|
case NewState of
|
||||||
none ->
|
none ->
|
||||||
@ -477,9 +477,13 @@ process_subscription(Direction, User, Server, JID1, Type, Reason) ->
|
|||||||
odbc_queries:del_roster(LServer, Username, SJID),
|
odbc_queries:del_roster(LServer, Username, SJID),
|
||||||
{none, AutoReply};
|
{none, AutoReply};
|
||||||
{Subscription, Pending} ->
|
{Subscription, Pending} ->
|
||||||
|
AskBinary = case AskMessage of
|
||||||
|
undefined -> <<>>;
|
||||||
|
B -> B
|
||||||
|
end,
|
||||||
NewItem = Item#roster{subscription = Subscription,
|
NewItem = Item#roster{subscription = Subscription,
|
||||||
ask = Pending,
|
ask = Pending,
|
||||||
askmessage = list_to_binary(AskMessage)},
|
askmessage = AskBinary},
|
||||||
ItemVals = record_to_string(NewItem),
|
ItemVals = record_to_string(NewItem),
|
||||||
odbc_queries:roster_subscribe(LServer, Username, SJID, ItemVals),
|
odbc_queries:roster_subscribe(LServer, Username, SJID, ItemVals),
|
||||||
{{push, NewItem}, AutoReply}
|
{{push, NewItem}, AutoReply}
|
||||||
@ -712,10 +716,10 @@ get_in_pending_subscriptions(Ls, User, Server) ->
|
|||||||
Ls ++ lists:map(
|
Ls ++ lists:map(
|
||||||
fun(R) ->
|
fun(R) ->
|
||||||
Message = R#roster.askmessage,
|
Message = R#roster.askmessage,
|
||||||
{U, S, R} = R#roster.jid,
|
{U0, S0, R0} = R#roster.jid,
|
||||||
Pres1 = exmpp_presence:subscribe(),
|
Pres1 = exmpp_presence:subscribe(),
|
||||||
Pres2 = exmpp_stanza:set_jids(Pres1,
|
Pres2 = exmpp_stanza:set_jids(Pres1,
|
||||||
exmpp_jid:jid_to_list(U, S, R),
|
exmpp_jid:jid_to_list(U0, S0, R0),
|
||||||
exmpp_jid:jid_to_list(JID)),
|
exmpp_jid:jid_to_list(JID)),
|
||||||
exmpp_presence:set_status(Pres2, Message)
|
exmpp_presence:set_status(Pres2, Message)
|
||||||
end,
|
end,
|
||||||
@ -876,7 +880,7 @@ groups_to_string(#roster{us = {User, _Server},
|
|||||||
(Group, Acc) ->
|
(Group, Acc) ->
|
||||||
String = ["'", Username, "',"
|
String = ["'", Username, "',"
|
||||||
"'", SJID, "',"
|
"'", SJID, "',"
|
||||||
"'", ejabberd_odbc:escape(Group), "'"],
|
"'", ejabberd_odbc:escape(binary_to_list(Group)), "'"],
|
||||||
[String|Acc] end, [], Groups).
|
[String|Acc] end, [], Groups).
|
||||||
|
|
||||||
webadmin_page(_, Host,
|
webadmin_page(_, Host,
|
||||||
|
Loading…
Reference in New Issue
Block a user