mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Fix XEP-0425: Message Moderation with SQL storage
Use the correct server name and room JID when removing moderated messages from SQL.
This commit is contained in:
parent
a6b10ac4c0
commit
6aaefc663b
@ -361,9 +361,9 @@ remove_mam_for_user_with_peer(User, Server, Peer) ->
|
|||||||
ok | {error, binary()}.
|
ok | {error, binary()}.
|
||||||
remove_message_from_archive(User, Server, StanzaId) when is_binary(User) ->
|
remove_message_from_archive(User, Server, StanzaId) when is_binary(User) ->
|
||||||
remove_message_from_archive({User, Server}, Server, StanzaId);
|
remove_message_from_archive({User, Server}, Server, StanzaId);
|
||||||
remove_message_from_archive({User, Host}, Server, StanzaId) ->
|
remove_message_from_archive({_User, _Host} = UserHost, Server, StanzaId) ->
|
||||||
Mod = gen_mod:db_mod(Server, ?MODULE),
|
Mod = gen_mod:db_mod(Server, ?MODULE),
|
||||||
case Mod:remove_from_archive(User, Host, StanzaId) of
|
case Mod:remove_from_archive(UserHost, Server, StanzaId) of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
{error, Bin} when is_binary(Bin) ->
|
{error, Bin} when is_binary(Bin) ->
|
||||||
|
@ -77,14 +77,14 @@ remove_user(LUser, LServer) ->
|
|||||||
remove_room(_LServer, LName, LHost) ->
|
remove_room(_LServer, LName, LHost) ->
|
||||||
remove_user(LName, LHost).
|
remove_user(LName, LHost).
|
||||||
|
|
||||||
remove_from_archive(LUser, LServer, none) ->
|
remove_from_archive(LUser, LHost, Key) when is_binary(LUser) ->
|
||||||
US = {LUser, LServer},
|
remove_from_archive({LUser, LHost}, LHost, Key);
|
||||||
|
remove_from_archive(US, _LServer, none) ->
|
||||||
case mnesia:transaction(fun () -> mnesia:delete({archive_msg, US}) end) of
|
case mnesia:transaction(fun () -> mnesia:delete({archive_msg, US}) end) of
|
||||||
{atomic, _} -> ok;
|
{atomic, _} -> ok;
|
||||||
{aborted, Reason} -> {error, Reason}
|
{aborted, Reason} -> {error, Reason}
|
||||||
end;
|
end;
|
||||||
remove_from_archive(LUser, LServer, #jid{} = WithJid) ->
|
remove_from_archive(US, _LServer, #jid{} = WithJid) ->
|
||||||
US = {LUser, LServer},
|
|
||||||
Peer = jid:remove_resource(jid:split(WithJid)),
|
Peer = jid:remove_resource(jid:split(WithJid)),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
Msgs = mnesia:select(
|
Msgs = mnesia:select(
|
||||||
@ -99,9 +99,8 @@ remove_from_archive(LUser, LServer, #jid{} = WithJid) ->
|
|||||||
{atomic, _} -> ok;
|
{atomic, _} -> ok;
|
||||||
{aborted, Reason} -> {error, Reason}
|
{aborted, Reason} -> {error, Reason}
|
||||||
end;
|
end;
|
||||||
remove_from_archive(LUser, LServer, StanzaId) ->
|
remove_from_archive(US, _LServer, StanzaId) ->
|
||||||
Timestamp = misc:usec_to_now(StanzaId),
|
Timestamp = misc:usec_to_now(StanzaId),
|
||||||
US = {LUser, LServer},
|
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
Msgs = mnesia:select(
|
Msgs = mnesia:select(
|
||||||
archive_msg,
|
archive_msg,
|
||||||
|
@ -163,6 +163,8 @@ remove_room(LServer, LName, LHost) ->
|
|||||||
LUser = jid:encode({LName, LHost, <<>>}),
|
LUser = jid:encode({LName, LHost, <<>>}),
|
||||||
remove_user(LUser, LServer).
|
remove_user(LUser, LServer).
|
||||||
|
|
||||||
|
remove_from_archive({LUser, LHost}, LServer, Key) ->
|
||||||
|
remove_from_archive(jid:encode({LUser, LHost, <<>>}), LServer, Key);
|
||||||
remove_from_archive(LUser, LServer, none) ->
|
remove_from_archive(LUser, LServer, none) ->
|
||||||
case ejabberd_sql:sql_query(LServer,
|
case ejabberd_sql:sql_query(LServer,
|
||||||
?SQL("delete from archive where username=%(LUser)s and %(LServer)H")) of
|
?SQL("delete from archive where username=%(LUser)s and %(LServer)H")) of
|
||||||
|
Loading…
Reference in New Issue
Block a user