Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

slash command to update ignored rooms list #8983

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/SlashCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,28 @@ export const Commands = [
}),
);
}
const roomMatches = args.match(/^([!][^:]+:\S+)$/);
Gnuxie marked this conversation as resolved.
Show resolved Hide resolved
if (roomMatches) {
Copy link
Contributor

@Yoric Yoric Jul 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our main usecase is ignoring the current room, so we should support a syntax such as

/ignore-invites room

(where room is an actual keyword) to ignore invites to the current room.

Feel free to improve that syntax :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you can't write slash commands in a room in which you are holding an invite, you'd need to join the room to the ignore invites and then leave? That doesn't sound safe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, user feedback suggests that this is actually a common behavior:

  1. Get tricked into a room.
  2. Realize that you have been tricked.
  3. Decide never to be invited in this room again.
  4. ...but we don't have tools for that yet.

We definitely want to add the ability to ignore invites before joining the room, but we're planning to work on that as a later stage, as this will require deeper changes in the UI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you leave before you realise "oh maybe I should ignore future invites" then it'll be too late, you'll have to wait for a second invite, accept it, then finally you can ignore it.

Copy link
Contributor

@Yoric Yoric Jul 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely.

Right now, we're trying to reach the following objectives:

  • handle at least one common case with minimal UI, hoping to get to a stage where we can actually put it in the hands of power users for testing;
  • lay the foundations for handling the other cases once we have a proper UI design (which we're working on in the background, but with no ETA as of yet).

const roomId = roomMatches[1];
const ignoredInvites = cli.getIgnoredInvites();
if (ignoredInvites.ignored_rooms === undefined) {
ignoredInvites.ignored_rooms = [];
}
ignoredInvites.ignored_rooms.push({
room_id: roomId,
ts: Date.now(), // TODO: Check this is the timestamp we want?
}); // TODO: figure out whether we're deduplicating or not https://github.com/matrix-org/matrix-js-sdk/pull/2483#discussion_r913013654
Gnuxie marked this conversation as resolved.
Show resolved Hide resolved
return success(
cli.setIgnoredInvites(ignoredInvites).then(() => {
Modal.createDialog(InfoDialog, {
title: _t('Ignored room'),
description: <div>
<p>{ _t('You are now ignoring %(roomId)s', { roomId }) }</p>
</div>,
});
}),
);
}
}
return reject(this.getUsage());
},
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@
"Stops ignoring a user, showing their messages going forward": "Stops ignoring a user, showing their messages going forward",
"Unignored user": "Unignored user",
"You are no longer ignoring %(userId)s": "You are no longer ignoring %(userId)s",
"Ignored room": "Ignored room",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we're not ignoring the room, only the invites from this room!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...actually, you are right, we may be ignoring the room entirely. But to do so, the slash command needs to leave the room immediately, no?

"You are now ignoring %(roomId)s": "You are now ignoring %(roomId)s",
"Define the power level of a user": "Define the power level of a user",
"Command failed: Unable to find room (%(roomId)s": "Command failed: Unable to find room (%(roomId)s",
"Could not find user in room": "Could not find user in room",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
"Ignored user": "Ignored user",
"Stops ignoring a user, showing their messages going forward": "Stops ignoring a user, showing their messages going forward",
"Ignores a user, hiding their messages from you": "Ignores a user, hiding their messages from you",
"Ignored room": "Ignored room",
"You are now ignoring %(roomId)s": "You are now ignoring %(roomId)s",
"Leave room": "Leave room",
"Publish this room to the public in %(domain)s's room directory?": "Publish this room to the public in %(domain)s's room directory?",
"Logout": "Logout",
Expand Down