-
|
I have an ejabberd service using an external PostgreSql DB and I want to be able to remove selected archived messages posted by certain users into group chats using something like
I can use ejabberdctl, but prefer using the REST Admin API I have tried many ways, but get internal errors (and Http 400 – bad request errors) which I think are related to using the ‘@’ in the identifier. Is there a way to get this admin command to work? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Umm, if I perform a call like you do, no error is returned, but no messages are removed. So, it doesn't work correctly. Looking at the command help, you are not providing the arguments correctly. The user argument should be only the username (in this case the roomname) See https://docs.ejabberd.im/developer/ejabberd-api/admin-api/#remove-mam-for-user-with-peer But, when I execute the command with the correct arguments, it crashes: So, there's a bug that breaks this command when removing MAM archives instead of user->user archives. I have to apply this patch for the command to work correctly. Can you try it? diff --git a/src/mod_mam.erl b/src/mod_mam.erl
index 4641836f6..12542bfa5 100644
--- a/src/mod_mam.erl
+++ b/src/mod_mam.erl
@@ -326,7 +326,7 @@ remove_mam_for_user_with_peer(User, Server, Peer) ->
LServer = jid:nameprep(Server),
try jid:decode(Peer) of
Jid ->
- Mod = gen_mod:db_mod(LServer, ?MODULE),
+ Mod = get_module_host(LServer),
case Mod:remove_from_archive(LUser, LServer, Jid) of
ok ->
{ok, <<"MAM archive removed">>};
@@ -339,6 +339,12 @@ remove_mam_for_user_with_peer(User, Server, Peer) ->
{error, <<"Invalid peer JID">>}
end.
+get_module_host(LServer) ->
+ try gen_mod:db_mod(LServer, ?MODULE)
+ catch error:{module_not_loaded, ?MODULE, LServer} ->
+ gen_mod:db_mod(ejabberd_router:host_of_route(LServer), ?MODULE)
+ end.
+
-spec get_room_config([muc_roomconfig:property()], mod_muc_room:state(),
jid(), binary()) -> [muc_roomconfig:property()].
get_room_config(Fields, RoomState, _From, _Lang) -> |
Beta Was this translation helpful? Give feedback.
Umm, if I perform a call like you do, no error is returned, but no messages are removed. So, it doesn't work correctly.
Looking at the command help, you are not providing the arguments correctly. The user argument should be only the username (in this case the roomname) See https://docs.ejabberd.im/developer/ejabberd-api/admin-api/#remove-mam-for-user-with-peer
But, when I execute the command with the correct arguments, it crashes: