mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-6815 Do not disconnect websocket when joining a team (#6746)
* Do not disconnect websocket when joining a team * Fix eslint error
This commit is contained in:
@@ -374,12 +374,12 @@ func addUserToTeamFromInvite(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
if len(hash) > 0 && len(data) > 0 {
|
||||
member, err = app.AddTeamMemberByHash(c.Session.UserId, hash, data)
|
||||
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 {
|
||||
member, err = app.AddTeamMemberByInviteId(inviteId, c.Session.UserId)
|
||||
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 {
|
||||
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, "")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
if tm != nil {
|
||||
t.Fatal("should have not returned team member")
|
||||
}
|
||||
|
||||
_, resp = Client.AddTeamMemberFromInvite(hashed, "junk", "")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
// expired data of more than 50 hours
|
||||
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))
|
||||
|
||||
tm, resp = Client.AddTeamMemberFromInvite(hashed, data, "")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
// invalid team id
|
||||
dataObject["id"] = GenerateTestId()
|
||||
@@ -950,7 +950,7 @@ func TestAddTeamMember(t *testing.T) {
|
||||
hashed = utils.HashSha256(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
|
||||
|
||||
tm, resp = Client.AddTeamMemberFromInvite(hashed, data, "")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
// by invite_id
|
||||
Client.Login(otherUser.Email, otherUser.Password)
|
||||
@@ -971,14 +971,14 @@ func TestAddTeamMember(t *testing.T) {
|
||||
}
|
||||
|
||||
tm, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
if tm != nil {
|
||||
t.Fatal("should have not returned team member")
|
||||
}
|
||||
|
||||
_, resp = Client.AddTeamMemberFromInvite("", "", "junk")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
}
|
||||
|
||||
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 {TeamTypes} from 'mattermost-redux/action_types';
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
export function checkIfTeamExists(teamName, onSuccess, onError) {
|
||||
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) {
|
||||
Client4.addToTeamFromInvite(hash, data, inviteId).then(
|
||||
(team) => {
|
||||
const member = {
|
||||
team_id: team.id,
|
||||
user_id: getState().entities.users.currentUserId,
|
||||
roles: 'team_user',
|
||||
delete_at: 0,
|
||||
msg_count: 0,
|
||||
mention_count: 0
|
||||
};
|
||||
(member) => {
|
||||
TeamActions.getTeam(member.team_id)(dispatch, getState).then(
|
||||
(team) => {
|
||||
dispatch({
|
||||
type: TeamTypes.RECEIVED_MY_TEAM_MEMBER,
|
||||
data: {
|
||||
...member,
|
||||
delete_at: 0,
|
||||
msg_count: 0,
|
||||
mention_count: 0
|
||||
}
|
||||
});
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: TeamTypes.RECEIVED_TEAMS_LIST,
|
||||
data: [team]
|
||||
},
|
||||
{
|
||||
type: TeamTypes.RECEIVED_MY_TEAM_MEMBER,
|
||||
data: member
|
||||
if (success) {
|
||||
success(team);
|
||||
}
|
||||
}
|
||||
]));
|
||||
|
||||
if (success) {
|
||||
success(team);
|
||||
}
|
||||
);
|
||||
},
|
||||
).catch(
|
||||
(err) => {
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// 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 {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 = {
|
||||
team: PropTypes.object.isRequired,
|
||||
url: PropTypes.string.isRequired,
|
||||
onTeamClick: PropTypes.func.isRequired,
|
||||
loading: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.handleTeamClick = this.handleTeamClick.bind(this);
|
||||
}
|
||||
|
||||
handleTeamClick() {
|
||||
handleTeamClick = () => {
|
||||
addUserToTeamFromInvite('', '', this.props.team.invite_id,
|
||||
() => {
|
||||
browserHistory.push(`/${this.props.team.name}/channels/town-square`);
|
||||
}
|
||||
);
|
||||
this.props.onTeamClick(this.props.team);
|
||||
}
|
||||
|
||||
@@ -71,7 +69,6 @@ export default class SelectTeamItem extends React.Component {
|
||||
{showDescriptionTooltip}
|
||||
<Link
|
||||
id={Utils.createSafeId(this.props.team.display_name)}
|
||||
to={this.props.url}
|
||||
onClick={this.handleTeamClick}
|
||||
>
|
||||
<span className='signup-team-dir__name'>{this.props.team.display_name}</span>
|
||||
|
||||
@@ -84,7 +84,6 @@ export default class SelectTeam extends React.Component {
|
||||
<SelectTeamItem
|
||||
key={'team_' + openTeam.name}
|
||||
team={openTeam}
|
||||
url={`/signup_user_complete/?id=${openTeam.invite_id}`}
|
||||
onTeamClick={this.handleTeamClick}
|
||||
loading={this.state.loadingTeamId === openTeam.id}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user