PLT-6815 Do not disconnect websocket when joining a team (#6746)
* Do not disconnect websocket when joining a team * Fix eslint error
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
072da672a8
Коммит
82b36b3721
@@ -374,12 +374,12 @@ func addUserToTeamFromInvite(c *Context, w http.ResponseWriter, r *http.Request)
|
|||||||
if len(hash) > 0 && len(data) > 0 {
|
if len(hash) > 0 && len(data) > 0 {
|
||||||
member, err = app.AddTeamMemberByHash(c.Session.UserId, hash, data)
|
member, err = app.AddTeamMemberByHash(c.Session.UserId, hash, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.invalid_data.app_error", nil, "", http.StatusNotFound)
|
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.invalid_data.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
} else if len(inviteId) > 0 {
|
} else if len(inviteId) > 0 {
|
||||||
member, err = app.AddTeamMemberByInviteId(inviteId, c.Session.UserId)
|
member, err = app.AddTeamMemberByInviteId(inviteId, c.Session.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.invalid_invite_id.app_error", nil, "", http.StatusNotFound)
|
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.invalid_invite_id.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.missing_parameter.app_error", nil, "", http.StatusBadRequest)
|
err = model.NewAppError("addTeamMember", "api.team.add_user_to_team.missing_parameter.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
|||||||
@@ -927,14 +927,14 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tm, resp = Client.AddTeamMemberFromInvite("junk", data, "")
|
tm, resp = Client.AddTeamMemberFromInvite("junk", data, "")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
if tm != nil {
|
if tm != nil {
|
||||||
t.Fatal("should have not returned team member")
|
t.Fatal("should have not returned team member")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, resp = Client.AddTeamMemberFromInvite(hashed, "junk", "")
|
_, resp = Client.AddTeamMemberFromInvite(hashed, "junk", "")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
// expired data of more than 50 hours
|
// expired data of more than 50 hours
|
||||||
dataObject["time"] = fmt.Sprintf("%v", model.GetMillis()-1000*60*60*50)
|
dataObject["time"] = fmt.Sprintf("%v", model.GetMillis()-1000*60*60*50)
|
||||||
@@ -942,7 +942,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
hashed = utils.HashSha256(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
|
hashed = utils.HashSha256(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
|
||||||
|
|
||||||
tm, resp = Client.AddTeamMemberFromInvite(hashed, data, "")
|
tm, resp = Client.AddTeamMemberFromInvite(hashed, data, "")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
// invalid team id
|
// invalid team id
|
||||||
dataObject["id"] = GenerateTestId()
|
dataObject["id"] = GenerateTestId()
|
||||||
@@ -950,7 +950,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
hashed = utils.HashSha256(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
|
hashed = utils.HashSha256(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
|
||||||
|
|
||||||
tm, resp = Client.AddTeamMemberFromInvite(hashed, data, "")
|
tm, resp = Client.AddTeamMemberFromInvite(hashed, data, "")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
// by invite_id
|
// by invite_id
|
||||||
Client.Login(otherUser.Email, otherUser.Password)
|
Client.Login(otherUser.Email, otherUser.Password)
|
||||||
@@ -971,14 +971,14 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tm, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
tm, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
if tm != nil {
|
if tm != nil {
|
||||||
t.Fatal("should have not returned team member")
|
t.Fatal("should have not returned team member")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
_, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddTeamMembers(t *testing.T) {
|
func TestAddTeamMembers(t *testing.T) {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {viewChannel} from 'mattermost-redux/actions/channels';
|
|||||||
import * as TeamActions from 'mattermost-redux/actions/teams';
|
import * as TeamActions from 'mattermost-redux/actions/teams';
|
||||||
|
|
||||||
import {TeamTypes} from 'mattermost-redux/action_types';
|
import {TeamTypes} from 'mattermost-redux/action_types';
|
||||||
import {batchActions} from 'redux-batched-actions';
|
|
||||||
|
|
||||||
export function checkIfTeamExists(teamName, onSuccess, onError) {
|
export function checkIfTeamExists(teamName, onSuccess, onError) {
|
||||||
TeamActions.checkIfTeamExists(teamName)(dispatch, getState).then(
|
TeamActions.checkIfTeamExists(teamName)(dispatch, getState).then(
|
||||||
@@ -92,30 +91,24 @@ export function updateTeamMemberRoles(teamId, userId, newRoles, success, error)
|
|||||||
|
|
||||||
export function addUserToTeamFromInvite(data, hash, inviteId, success, error) {
|
export function addUserToTeamFromInvite(data, hash, inviteId, success, error) {
|
||||||
Client4.addToTeamFromInvite(hash, data, inviteId).then(
|
Client4.addToTeamFromInvite(hash, data, inviteId).then(
|
||||||
(team) => {
|
(member) => {
|
||||||
const member = {
|
TeamActions.getTeam(member.team_id)(dispatch, getState).then(
|
||||||
team_id: team.id,
|
(team) => {
|
||||||
user_id: getState().entities.users.currentUserId,
|
dispatch({
|
||||||
roles: 'team_user',
|
type: TeamTypes.RECEIVED_MY_TEAM_MEMBER,
|
||||||
delete_at: 0,
|
data: {
|
||||||
msg_count: 0,
|
...member,
|
||||||
mention_count: 0
|
delete_at: 0,
|
||||||
};
|
msg_count: 0,
|
||||||
|
mention_count: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
dispatch(batchActions([
|
if (success) {
|
||||||
{
|
success(team);
|
||||||
type: TeamTypes.RECEIVED_TEAMS_LIST,
|
}
|
||||||
data: [team]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: TeamTypes.RECEIVED_MY_TEAM_MEMBER,
|
|
||||||
data: member
|
|
||||||
}
|
}
|
||||||
]));
|
);
|
||||||
|
|
||||||
if (success) {
|
|
||||||
success(team);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
).catch(
|
).catch(
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|||||||
@@ -1,30 +1,28 @@
|
|||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
|
||||||
|
|
||||||
import {Link} from 'react-router/es6';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import {Link, browserHistory} from 'react-router/es6';
|
||||||
import {Tooltip, OverlayTrigger} from 'react-bootstrap';
|
import {Tooltip, OverlayTrigger} from 'react-bootstrap';
|
||||||
import {Constants} from 'utils/constants.jsx';
|
import {Constants} from 'utils/constants.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
|
||||||
|
|
||||||
export default class SelectTeamItem extends React.Component {
|
export default class SelectTeamItem extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
team: PropTypes.object.isRequired,
|
team: PropTypes.object.isRequired,
|
||||||
url: PropTypes.string.isRequired,
|
|
||||||
onTeamClick: PropTypes.func.isRequired,
|
onTeamClick: PropTypes.func.isRequired,
|
||||||
loading: PropTypes.bool.isRequired
|
loading: PropTypes.bool.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
handleTeamClick = () => {
|
||||||
super(props);
|
addUserToTeamFromInvite('', '', this.props.team.invite_id,
|
||||||
|
() => {
|
||||||
this.handleTeamClick = this.handleTeamClick.bind(this);
|
browserHistory.push(`/${this.props.team.name}/channels/town-square`);
|
||||||
}
|
}
|
||||||
|
);
|
||||||
handleTeamClick() {
|
|
||||||
this.props.onTeamClick(this.props.team);
|
this.props.onTeamClick(this.props.team);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +69,6 @@ export default class SelectTeamItem extends React.Component {
|
|||||||
{showDescriptionTooltip}
|
{showDescriptionTooltip}
|
||||||
<Link
|
<Link
|
||||||
id={Utils.createSafeId(this.props.team.display_name)}
|
id={Utils.createSafeId(this.props.team.display_name)}
|
||||||
to={this.props.url}
|
|
||||||
onClick={this.handleTeamClick}
|
onClick={this.handleTeamClick}
|
||||||
>
|
>
|
||||||
<span className='signup-team-dir__name'>{this.props.team.display_name}</span>
|
<span className='signup-team-dir__name'>{this.props.team.display_name}</span>
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ export default class SelectTeam extends React.Component {
|
|||||||
<SelectTeamItem
|
<SelectTeamItem
|
||||||
key={'team_' + openTeam.name}
|
key={'team_' + openTeam.name}
|
||||||
team={openTeam}
|
team={openTeam}
|
||||||
url={`/signup_user_complete/?id=${openTeam.invite_id}`}
|
|
||||||
onTeamClick={this.handleTeamClick}
|
onTeamClick={this.handleTeamClick}
|
||||||
loading={this.state.loadingTeamId === openTeam.id}
|
loading={this.state.loadingTeamId === openTeam.id}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user