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

ABC-214: fix permalinks to direct messages #720

Merged
merged 1 commit into from
Feb 6, 2018

Conversation

lieut-data
Copy link
Member

@lieut-data lieut-data commented Feb 5, 2018

Summary

This simplifies the changes introduced in ABC-160 to simply check that
the channel exists instead of also checking that the channel team id
matches the current team. The additional check was redundant, since the
set of channels available are already constrained to the current team;
it was also wrong, since direct messages and group messages aren't
actually assigned team ids, leading to the regression in question.

Note that this check (before and even now) only works if you have access
to the two teams in question. If you try to open a malformed permalink
referencing a team for which you don't have access or that doesn't
exist, none of the router code in <NeedsTeam> executes (team is null),
and a different path is executed that doesn't try to evaluate the
permalink. Fixing that appears to be non-trivial and out of scope for
this change.

Ticket Link

https://mattermost.atlassian.net/browse/ABC-214

Checklist

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed

This simplifies the changes introduced in ABC-160 to simply check that
the channel exists instead of also checking that the channel team id
matches the current team. The additional check was redundant, since the
set of channels available are already constrained to the current team;
it was also wrong, since direct messages and group messages aren't
actually assigned team ids, leading to the regression in question.

Note that this check (before and even now) only works if you have access
to the two teams in question. If you try to open a malformed permalink
referencing a team for which you don't have access or that doesn't
exist, none of the router code in <NeedsTeam> executes (team is null),
and a different path is executed that doesn't try to evaluate the
permalink. Fixing that appears to be non-trivial and out of scope for
this change.
@lieut-data
Copy link
Member Author

@crspeller, if you have any advice re: the limitations of permalink checking above, let me know. This is my first exposure to react-router, and this seems like one of the challenges of allowing "side effects from views". I fell in love with the https://github.com/redux-saga/redux-saga library to externalize/"purify" side effects for precisely these kinds of challenges.

@jasonblais jasonblais added the 2: Dev Review Requires review by a core commiter label Feb 6, 2018
@@ -120,7 +120,7 @@ export async function emitPostFocusEvent(postId) {
if (data) {
const channelId = data.posts[data.order[0]].channel_id;
const channel = ChannelStore.getChannelById(channelId);
if (!channel || channel.team_id !== TeamStore.getCurrentId()) {
if (!channel) {
Copy link
Member

Choose a reason for hiding this comment

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

The check is unfortunately not redundant. This was put here to fix the case where you have a permalink with the wrong team ID at the beginning. So /wrong-team/pl/ID. Without this check, it will break (I forget how). But with it, it will redirect to an error page.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're referring to https://mattermost.atlassian.net/browse/ABC-160, right? This was the issue I had in mind while testing, and I've verified that this continues to fix ABC-160. I couldn't find a case where the channel existed but had a different team -- in all cases, the channel wasn't part of the channel store if you permalink to the wrong team.

@crspeller crspeller merged commit 31c3c86 into master Feb 6, 2018
@crspeller crspeller deleted the ABC-214-dm-permalinks-not-found branch February 6, 2018 17:53
@lindalumitchell lindalumitchell added the Tests/Done Release tests have been written label Feb 6, 2018
@amyblais amyblais added the Docs/Not Needed Does not require documentation label Feb 7, 2018
@amyblais amyblais added the Changelog/Not Needed Does not require a changelog entry label Feb 17, 2018
hmhealey pushed a commit that referenced this pull request Aug 28, 2020
* Keep autocomplete generated display names for DMs

* Fixing tests
hmhealey pushed a commit that referenced this pull request Mar 17, 2021
* Keep autocomplete generated display names for DMs

* Fixing tests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2: Dev Review Requires review by a core commiter Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation Tests/Done Release tests have been written
Projects
None yet
7 participants