1 # Utility scripts overview
3 These are scripts that can help you answer questions like "What's this user's eyeball state?" and "What's the userId for mydigitalself?". They can be found in `scripts/utils`.
6 ## :wrench: Before you can run a script :wrench:
7 1. [SSH into a box](https://gitlab.com/gl-infra/gitter-infrastructure#ssh-to-boxes) if you are running the script in beta or prod
8 1. [Setup secrets](https://gitlab.com/gitterHQ/webapp#configure-service-secrets)
9 1. **IMPORTANT:** Adjust the `NODE_ENV=prod` environment variable to the desired environment, `prod`, `beta`, `dev`
12 ## Spam on Gitter (fighting abuse)
14 See https://gitlab.com/gitlab-com/gl-security/runbooks/-/blob/master/abuse/gitter_spam.md
19 ### `auto-lurk-room.js`
22 NODE_ENV=prod ./scripts/utils/auto-lurk-room.js --members 30000 --min 31
28 Removes a user from all room and destroys their auth tokens. Requires a username.
33 NODE_ENV=prod ./scripts/utils/delete-user.js --username trevorah
36 ### `delete-messages-from-user.js`
38 Delete all messages for a given user
41 NODE_ENV=prod ./scripts/utils/delete-messages-from-user.js --username someusername
42 # Delete more messages if they have more
43 NODE_ENV=prod ./scripts/utils/delete-messages-from-user.js --username someusername --limit 30000
44 # Dry run to see what will be deleted
45 NODE_ENV=prod ./scripts/utils/delete-messages-from-user.js --username someusername --limit 30000 --grep "badmessage" --dry
47 NODE_ENV=prod ./scripts/utils/delete-messages-from-user.js --username someusername --limit 30000 --grep "badmessage"
53 Deletes a room and kicks users out. Requires a room URI.
58 NODE_ENV=prod ./scripts/utils/delete-room.js --uri trevorah/noembed
65 NODE_ENV=prod ./delete-token.js -t XXXXXXXXXX
71 Hellbanning a user will still let them send messages but they won't actually
72 show up in the room or even be persisted.
74 Ban user `badusername`, e.g `NODE_ENV=prod ./scripts/utils/migrate-messages.js --username badusername`
75 Unban user `badusername`, e.g `NODE_ENV=prod ./scripts/utils/migrate-messages.js --username badusername -u`
78 ### `migrate-messages.js`
80 Migrates all chat messages from one room to another. Requires two rooms.
82 e.g `NODE_ENV=prod ./scripts/utils/migrate-messages.js --from trevorah/oldroom --to trevorah/newroom`
85 ### `mobile-notify-user.js`
87 Sends a test push notification to all devices registered by a user. Requires a username.
89 e.g `NODE_ENV=prod ./scripts/utils/mobile-notify-user.js trevorah`
94 Prints the current online state for a user. Requires a username.
96 e.g `NODE_ENV=prod ./scripts/utils/online-state.js trevorah`
99 ### `redirect-room.js`
101 Redirect `roomA` to `roomB`. *note:* this will delete `roomA`
103 e.g `NODE_ENV=prod ./scripts/utils/redirect-room.js -f fromroom -t toroom`
106 ### `suggested-rooms.js`
108 Lists out the rooms suggested to a user. Requires a username.
110 e.g `NODE_ENV=prod ./scripts/utils/suggested-rooms.js trevorah`
113 ### `update-room-tags.js`
115 Updates the tags used by the explore page.
117 e.g `NODE_ENV=prod ./scripts/utils/update-room-tags.js`
122 Lists out why a user has an unread badge. Requires a username.
124 e.g `NODE_ENV=prod ./scripts/utils/unread.js trevorah`
129 Looks up users from ids. Requires user ids.
131 e.g `NODE_ENV=prod ./scripts/utils/whois.js 53bec5764bf9c36505409389`
135 ## Adjusting Feature Toggles
137 Use the `NODE_ENV=prod ./scripts/utils/feature-toggle.js` script to adjust feature toggles:
142 # Include suprememoocow and trevorah in the test
143 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --include-user suprememoocow --include-user trevorah
145 # Exclude users from the test
146 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --exclude-user suprememoocow --exclude-user trevorah
148 # Include a percentage of all users
149 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --percentage 70
151 # Undo "include a percentage of all users"
152 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --percentage-off
155 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --enable
157 # Undo "include everyone"
158 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --enable-off
160 # Disable Chrome, version 47 and below
161 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --disable-browser Chrome:47
163 # Disable all versions of IE
164 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --disable-browser IE:all
166 # Re-enable the feature for Chrome
167 NODE_ENV=prod ./scripts/utils/feature-toggle.js fancy-new-feature --disable-browser-off Chrome
170 To turn on and off features manually in your browser:
173 http://localhost:5000/api_web/features/[feature]/[0/1]
179 http://localhost:5000/api_web/features/chat-cache/1
183 ## Updating the Social Graph
185 The social graph updater runs as a batch job in a cron every few hours. You can manually invoke it as follows.
188 NODE_ENV=prod ./scripts/graphs/upload-graph.js
191 The uploader script starts a local webserver, and it will guess the URL for that webserver by looking at the host computers
192 network interfaces. If you want to the script against production from your developer computer, you'll need to specify the OpenVPN
193 tunnel interface, otherwise the script will serve from a URL inaccessible from OpenVPN.
195 You can do this as follows:
197 NODE_ENV=prod LISTEN_IF=utun0 ./scripts/graphs/upload-graph.js