mirror of
https://github.com/processone/ejabberd
synced 2025-10-05 10:39:29 +02:00
Add SQL_INSERT macro and update SQL queries to use server_host field
This commit is contained in:
parent
354a710e70
commit
78dfb832b8
25 changed files with 1638 additions and 297 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue