mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fix channels showing up across teams when multiple teams open in same browser (#3329)
This commit is contained in:
@@ -784,6 +784,11 @@ func getChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
member := cmresult.Data.(model.ChannelMember)
|
member := cmresult.Data.(model.ChannelMember)
|
||||||
data.Member = &member
|
data.Member = &member
|
||||||
|
|
||||||
|
if data.Channel.TeamId != c.TeamId {
|
||||||
|
c.Err = model.NewLocAppError("getChannel", "api.channel.get_channel.wrong_team.app_error", map[string]interface{}{"ChannelId": id, "TeamId": c.TeamId}, "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if HandleEtag(data.Etag(), w, r) {
|
if HandleEtag(data.Etag(), w, r) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -320,6 +320,7 @@ func TestGetChannel(t *testing.T) {
|
|||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
Client := th.BasicClient
|
Client := th.BasicClient
|
||||||
team := th.BasicTeam
|
team := th.BasicTeam
|
||||||
|
team2 := th.CreateTeam(Client)
|
||||||
|
|
||||||
channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
|
channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
|
||||||
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
|
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
|
||||||
@@ -370,6 +371,11 @@ func TestGetChannel(t *testing.T) {
|
|||||||
if _, err := Client.GetChannel("junk", ""); err == nil {
|
if _, err := Client.GetChannel("junk", ""); err == nil {
|
||||||
t.Fatal("should have failed - bad channel id")
|
t.Fatal("should have failed - bad channel id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Client.SetTeamId(team2.Id)
|
||||||
|
if _, err := Client.GetChannel(channel2.Id, ""); err == nil {
|
||||||
|
t.Fatal("should have failed - wrong team")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetMoreChannel(t *testing.T) {
|
func TestGetMoreChannel(t *testing.T) {
|
||||||
|
|||||||
@@ -203,6 +203,10 @@
|
|||||||
"id": "api.channel.delete_channel.permissions.app_error",
|
"id": "api.channel.delete_channel.permissions.app_error",
|
||||||
"translation": "You do not have the appropriate permissions"
|
"translation": "You do not have the appropriate permissions"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.channel.get_channel.wrong_team.app_error",
|
||||||
|
"translation": "There is no channel with channel_id={{.ChannelId}} on team with team_id={{.TeamId}}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.channel.get_channel_counts.app_error",
|
"id": "api.channel.get_channel_counts.app_error",
|
||||||
"translation": "Unable to get channel counts from the database"
|
"translation": "Unable to get channel counts from the database"
|
||||||
|
|||||||
@@ -245,7 +245,9 @@ function handleUserRemovedEvent(msg) {
|
|||||||
|
|
||||||
function handleChannelViewedEvent(msg) {
|
function handleChannelViewedEvent(msg) {
|
||||||
// Useful for when multiple devices have the app open to different channels
|
// Useful for when multiple devices have the app open to different channels
|
||||||
if (ChannelStore.getCurrentId() !== msg.channel_id && UserStore.getCurrentId() === msg.user_id) {
|
if (TeamStore.getCurrentId() === msg.team_id &&
|
||||||
|
ChannelStore.getCurrentId() !== msg.channel_id &&
|
||||||
|
UserStore.getCurrentId() === msg.user_id) {
|
||||||
AsyncClient.getChannel(msg.channel_id);
|
AsyncClient.getChannel(msg.channel_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user