aboutsummaryrefslogtreecommitdiff
path: root/src/mod_muc_sql.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_muc_sql.erl')
-rw-r--r--src/mod_muc_sql.erl43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/mod_muc_sql.erl b/src/mod_muc_sql.erl
index 7ec598bf3..41ad92bf9 100644
--- a/src/mod_muc_sql.erl
+++ b/src/mod_muc_sql.erl
@@ -68,16 +68,18 @@ store_room(LServer, Host, Name, Opts, ChangesHints) ->
"muc_room",
["!name=%(Name)s",
"!host=%(Host)s",
- "opts=%(SOpts)s"]),
- case ChangesHints of
- Changes when is_list(Changes) ->
- [change_room(Host, Name, Change) || Change <- Changes];
- _ ->
- ejabberd_sql:sql_query_t(?SQL("delete from muc_room_subscribers where "
- "room=%(Name)s and host=%(Host)s")),
- [change_room(Host, Name, {add_subscription, JID, Nick, Nodes})
- || {JID, Nick, Nodes} <- Subs]
- end
+ "server_host=%(LServer)s",
+ "opts=%(SOpts)s"]),
+ case ChangesHints of
+ Changes when is_list(Changes) ->
+ [change_room(Host, Name, Change) || Change <- Changes];
+ _ ->
+ ejabberd_sql:sql_query_t(
+ ?SQL("delete from muc_room_subscribers where "
+ "room=%(Name)s and host=%(Host)s")),
+ [change_room(Host, Name, {add_subscription, JID, Nick, Nodes})
+ || {JID, Nick, Nodes} <- Subs]
+ end
end,
ejabberd_sql:sql_transaction(LServer, F).
@@ -226,6 +228,7 @@ set_nick(LServer, Host, From, Nick) ->
"muc_registered",
["!jid=%(JID)s",
"!host=%(Host)s",
+ "server_host=%(LServer)s",
"nick=%(Nick)s"]),
ok;
true ->
@@ -257,6 +260,7 @@ register_online_room(ServerHost, Room, Host, Pid) ->
"muc_online_room",
["!name=%(Room)s",
"!host=%(Host)s",
+ "server_host=%(ServerHost)s",
"node=%(NodeS)s",
"pid=%(PidS)s"]) of
ok ->
@@ -331,6 +335,7 @@ register_online_user(ServerHost, {U, S, R}, Room, Host) ->
"!resource=%(R)s",
"!name=%(Room)s",
"!host=%(Host)s",
+ "server_host=%(ServerHost)s",
"node=%(NodeS)s"]) of
ok ->
ok;
@@ -379,9 +384,12 @@ export(_Server) ->
SOpts = misc:term_to_expr(Opts),
[?SQL("delete from muc_room where name=%(Name)s"
" and host=%(RoomHost)s;"),
- ?SQL("insert into muc_room(name, host, opts) "
- "values ("
- "%(Name)s, %(RoomHost)s, %(SOpts)s);")];
+ ?SQL_INSERT(
+ "muc_room",
+ ["name=%(Name)s",
+ "host=%(Host)s",
+ "server_host=%(Host)s",
+ "opts=%(SOpts)s"])];
false ->
[]
end
@@ -394,9 +402,12 @@ export(_Server) ->
SJID = jid:encode(jid:make(U, S)),
[?SQL("delete from muc_registered where"
" jid=%(SJID)s and host=%(RoomHost)s;"),
- ?SQL("insert into muc_registered(jid, host, "
- "nick) values ("
- "%(SJID)s, %(RoomHost)s, %(Nick)s);")];
+ ?SQL_INSERT(
+ "muc_registered",
+ ["jid=%(SJID)s",
+ "host=%(Host)s",
+ "server_host=%(Host)s",
+ "nick=%(Nick)s"])];
false ->
[]
end