Open 2minwia opened 5 years ago
The limit
field is only to be used by clients that wish to break the deletion down into multiple requests. (The web client does this as well, it sets a limit of 2500 so you can track progress on large channels) - sorry this was not yet obvious (frankly, it's a bug).
On my defense, I wrote the documentation for limit
while it was still in development (and the limit
field would work as you described, removing latest messages first until the limit is reached). After some changes by @ggazzo this is no longer the case and limit
cannot ensure integrity.
A flag to bring back this old functionality may be nice, however. (along with other things that used to work, e.g. retention policies in slow channels not waiting for new messages, and also the fact someone deleted the svg icons I added) Be sure to keep this issue open if this is something you are interested in (you can also join open.rocket.chat, join #dev and complain ask there), or if you know some JS, make a PR (and turn off "Let maintainers edit your code" :wink: )
Im trying to create a "remove latest messages" function for a bot, which uses rooms.cleanHistory in conjunction with the limit argument to only remove the latest x messages.
However, limit is seemingly not working properly.
Having it set to a string throws
{"success":false,"error":"Match error: Failed Match.OneOf, Match.Maybe or Match.Optional validation"}
, which is probably intended, but trying to use a number just deletes all messages in the time period set, instead of just the latest x posts. (or the last x posts. i don't really know what its supposed to do, since it doesn't work :^) )Steps to reproduce:
Run something along the lines of
on a terminal with relevant auth-token, user-id, etc.
Expected behavior:
It removes the last three messages sent (or first three messages sent. I'm not really sure. psst: if it does the first three, this is also a feature request for a switch to have it do the last three sent.)
Actual behavior:
It removes all messages within the time period. That's bad. It shouldn't do that.