Skip to content

Fix: `delete-messages-from-user.js` should remove message instead of clearing them

Tomas Vik requested to merge 1626-completely-delete-messages into develop

Closes #1626 (closed)

The first commit refactors the script not to use bluebird and to use async/await, the second commit utilizes chatService to delete each message.

Testing:

  1. temporarily add the script to beta because ES doesn't work locally
ssh gitter-beta-01.beta.gitter
$ cd /opt/gitter/gitter-webapp/ && eval $(/opt/gitter/secrets/webapp/env beta) && eval $(/usr/bin/ns-env )
$ export NODE_ENV=beta
$ cd scripts/utils/
$ sudo su
root$ touch dmfu.js
root$ chown deployer dmfu.js
root$ chmod +x dmfu.js
root$ exit
$ vim dmfu.js # paste content of the script file from this MR to the vim editor
  1. have two users join the same room
  2. one of the users is not actively in the room (so we can validate unreads being added and removed)
  3. the other user creates ten messages with the same string (e.g. abc)
  4. now validate that the first user can see 10 unreads in left menu
  5. run the script ./dmfu.js -u username -g abc --dry - testing the dry run
  6. run the script ./dmfu.js -u username -g abc - this should delete all ten messages
  7. validate that the messages are deleted and that the first user doesn't have any unreads (using regex not to delete all the messages)
Edited by 🤖 GitLab Bot 🤖

Merge request reports