mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Merge branch 'master' of https://github.com/mattermost/platform
This commit is contained in:
2
Makefile
2
Makefile
@@ -143,7 +143,7 @@ check-style:
|
||||
test: start-docker
|
||||
@echo Running tests
|
||||
|
||||
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=240s ./api || exit 1
|
||||
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=340s ./api || exit 1
|
||||
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1
|
||||
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./store || exit 1
|
||||
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1
|
||||
|
||||
@@ -513,9 +513,18 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
|
||||
return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "")
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().GetMember(channel.Id, user.Id); result.Err != nil {
|
||||
if result.Err.Id != store.MISSING_MEMBER_ERROR {
|
||||
return nil, result.Err
|
||||
}
|
||||
} else {
|
||||
channelMember := result.Data.(model.ChannelMember)
|
||||
return &channelMember, nil
|
||||
}
|
||||
|
||||
newMember := &model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
if cmresult := <-Srv.Store.Channel().SaveMember(newMember); cmresult.Err != nil {
|
||||
l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, cmresult.Err)
|
||||
if result := <-Srv.Store.Channel().SaveMember(newMember); result.Err != nil {
|
||||
l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, result.Err)
|
||||
return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user.to.channel.failed.app_error", nil, "")
|
||||
}
|
||||
|
||||
|
||||
@@ -691,8 +691,8 @@ func TestAddChannelMember(t *testing.T) {
|
||||
t.Fatal("Should have errored, bad user id")
|
||||
}
|
||||
|
||||
if _, err := Client.AddChannelMember(channel1.Id, user2.Id); err == nil {
|
||||
t.Fatal("Should have errored, user already a member")
|
||||
if _, err := Client.AddChannelMember(channel1.Id, user2.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := Client.AddChannelMember("sgdsgsdg", user2.Id); err == nil {
|
||||
|
||||
@@ -22,7 +22,7 @@ func ImportPost(post *model.Post) {
|
||||
}
|
||||
}
|
||||
|
||||
func ImportUser(teamId string, user *model.User) *model.User {
|
||||
func ImportUser(team *model.Team, user *model.User) *model.User {
|
||||
user.MakeNonNil()
|
||||
|
||||
if result := <-Srv.Store.User().Save(user); result.Err != nil {
|
||||
@@ -31,14 +31,14 @@ func ImportUser(teamId string, user *model.User) *model.User {
|
||||
} else {
|
||||
ruser := result.Data.(*model.User)
|
||||
|
||||
if err := JoinDefaultChannels(teamId, ruser, ""); err != nil {
|
||||
l4g.Error(utils.T("api.import.import_user.joining_default.error"), ruser.Id, teamId, err)
|
||||
}
|
||||
|
||||
if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil {
|
||||
l4g.Error(utils.T("api.import.import_user.set_email.error"), cresult.Err)
|
||||
}
|
||||
|
||||
if err := JoinUserToTeam(team, user); err != nil {
|
||||
l4g.Error(utils.T("api.import.import_user.join_team.error"), err)
|
||||
}
|
||||
|
||||
return ruser
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,16 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
|
||||
log.WriteString("===============\r\n\r\n")
|
||||
|
||||
addedUsers := make(map[string]*model.User)
|
||||
|
||||
// Need the team
|
||||
var team *model.Team
|
||||
if result := <-Srv.Store.Team().Get(teamId); result.Err != nil {
|
||||
log.WriteString(utils.T("api.slackimport.slack_import.team_fail"))
|
||||
return addedUsers
|
||||
} else {
|
||||
team = result.Data.(*model.Team)
|
||||
}
|
||||
|
||||
for _, sUser := range slackusers {
|
||||
firstName := ""
|
||||
lastName := ""
|
||||
@@ -119,7 +129,7 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
|
||||
Password: password,
|
||||
}
|
||||
|
||||
if mUser := ImportUser(teamId, &newUser); mUser != nil {
|
||||
if mUser := ImportUser(team, &newUser); mUser != nil {
|
||||
addedUsers[sUser.Id] = mUser
|
||||
log.WriteString(utils.T("api.slackimport.slack_add_users.email_pwd", map[string]interface{}{"Email": newUser.Email, "Password": password}))
|
||||
} else {
|
||||
@@ -173,6 +183,18 @@ func SlackAddPosts(channel *model.Channel, posts []SlackPost, users map[string]*
|
||||
}
|
||||
}
|
||||
|
||||
func addSlackUsersToChannel(members []string, users map[string]*model.User, channel *model.Channel, log *bytes.Buffer) {
|
||||
for _, member := range members {
|
||||
if user, ok := users[member]; !ok {
|
||||
log.WriteString(utils.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]interface{}{"Username": "?"}))
|
||||
} else {
|
||||
if _, err := AddUserToChannel(user, channel); err != nil {
|
||||
log.WriteString(utils.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]interface{}{"Username": user.Username}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[string][]SlackPost, users map[string]*model.User, log *bytes.Buffer) map[string]*model.Channel {
|
||||
// Write Header
|
||||
log.WriteString(utils.T("api.slackimport.slack_add_channels.added"))
|
||||
@@ -199,6 +221,7 @@ func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[str
|
||||
log.WriteString(utils.T("api.slackimport.slack_add_channels.merge", map[string]interface{}{"DisplayName": newChannel.DisplayName}))
|
||||
}
|
||||
}
|
||||
addSlackUsersToChannel(sChannel.Members, users, mChannel, log)
|
||||
log.WriteString(newChannel.DisplayName + "\r\n")
|
||||
addedChannels[sChannel.Id] = mChannel
|
||||
SlackAddPosts(mChannel, posts[sChannel.Name], users)
|
||||
|
||||
@@ -40,8 +40,8 @@ func InitTeam() {
|
||||
BaseRoutes.NeedTeam.Handle("/add_user_to_team", ApiUserRequired(addUserToTeam)).Methods("POST")
|
||||
|
||||
// These should be moved to the global admain console
|
||||
BaseRoutes.Teams.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST")
|
||||
BaseRoutes.Teams.Handle("/export_team", ApiUserRequired(exportTeam)).Methods("GET")
|
||||
BaseRoutes.NeedTeam.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST")
|
||||
BaseRoutes.NeedTeam.Handle("/export_team", ApiUserRequired(exportTeam)).Methods("GET")
|
||||
BaseRoutes.Teams.Handle("/add_user_to_team_from_invite", ApiUserRequired(addUserToTeamFromInvite)).Methods("POST")
|
||||
}
|
||||
|
||||
|
||||
16
i18n/en.json
16
i18n/en.json
@@ -667,6 +667,10 @@
|
||||
"id": "api.import.import_user.set_email.error",
|
||||
"translation": "Failed to set email verified err=%v"
|
||||
},
|
||||
{
|
||||
"id": "api.import.import_user.join_team.error",
|
||||
"translation": "Failed to join team when importing err=%v"
|
||||
},
|
||||
{
|
||||
"id": "api.license.add_license.array.app_error",
|
||||
"translation": "Empty array under 'license' in request"
|
||||
@@ -995,6 +999,10 @@
|
||||
"id": "api.slackimport.slack_add_channels.merge",
|
||||
"translation": "Merged with existing channel: {{.DisplayName}}\r\n"
|
||||
},
|
||||
{
|
||||
"id": "api.slackimport.slack_add_channels.failed_to_add_user",
|
||||
"translation": "Failed to add user to channel: {{.Username}}\r\n"
|
||||
},
|
||||
{
|
||||
"id": "api.slackimport.slack_add_posts.bot.warn",
|
||||
"translation": "Slack bot posts are not imported yet"
|
||||
@@ -1035,6 +1043,10 @@
|
||||
"id": "api.slackimport.slack_import.log",
|
||||
"translation": "Mattermost Slack Import Log\r\n"
|
||||
},
|
||||
{
|
||||
"id": "api.slackimport.slack_import.team_fail",
|
||||
"translation": "Failed to get team to import into.\r\n"
|
||||
},
|
||||
{
|
||||
"id": "api.slackimport.slack_import.note1",
|
||||
"translation": "- Some posts may not have been imported because they where not supported by this importer.\r\n"
|
||||
@@ -2851,6 +2863,10 @@
|
||||
"id": "store.sql_channel.get_for_export.app_error",
|
||||
"translation": "We couldn't get all the channels"
|
||||
},
|
||||
{
|
||||
"id": "store.sql_channel.get_member.missing.app_error",
|
||||
"translation": "No channel member found for that user id and channel id"
|
||||
},
|
||||
{
|
||||
"id": "store.sql_channel.get_member.app_error",
|
||||
"translation": "We couldn't get the channel member"
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
const (
|
||||
MISSING_CHANNEL_ERROR = "store.sql_channel.get_by_name.missing.app_error"
|
||||
MISSING_MEMBER_ERROR = "store.sql_channel.get_member.missing.app_error"
|
||||
)
|
||||
|
||||
type SqlChannelStore struct {
|
||||
@@ -572,9 +573,13 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel
|
||||
result := StoreResult{}
|
||||
|
||||
var member model.ChannelMember
|
||||
err := s.GetReplica().SelectOne(&member, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId})
|
||||
if err != nil {
|
||||
result.Err = model.NewLocAppError("SqlChannelStore.GetMember", "store.sql_channel.get_member.app_error", nil, "channel_id="+channelId+"user_id="+userId+","+err.Error())
|
||||
|
||||
if err := s.GetReplica().SelectOne(&member, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId}); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
result.Err = model.NewLocAppError("SqlChannelStore.GetMember", MISSING_MEMBER_ERROR, nil, "channel_id="+channelId+"user_id="+userId+","+err.Error())
|
||||
} else {
|
||||
result.Err = model.NewLocAppError("SqlChannelStore.GetMember", "store.sql_channel.get_member.app_error", nil, "channel_id="+channelId+"user_id="+userId+","+err.Error())
|
||||
}
|
||||
} else {
|
||||
result.Data = member
|
||||
}
|
||||
|
||||
@@ -348,10 +348,9 @@ export default class Client {
|
||||
|
||||
importSlack = (fileData, success, error) => {
|
||||
request.
|
||||
post(`${this.getTeamsRoute()}/import_team`).
|
||||
post(`${this.getTeamNeededRoute()}/import_team`).
|
||||
set(this.defaultHeaders).
|
||||
type('application/json').
|
||||
accept('application/json').
|
||||
accept('application/octet-stream').
|
||||
send(fileData).
|
||||
end(this.handleResponse.bind(this, 'importSlack', success, error));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import $ from 'jquery';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import React from 'react';
|
||||
import {Link} from 'react-router';
|
||||
|
||||
export default class NotLoggedIn extends React.Component {
|
||||
componentDidMount() {
|
||||
@@ -30,34 +29,38 @@ export default class NotLoggedIn extends React.Component {
|
||||
</div>
|
||||
<div className='col-xs-12'>
|
||||
<span className='pull-right footer-link copyright'>{'© 2015 Mattermost, Inc.'}</span>
|
||||
<Link
|
||||
<a
|
||||
id='help_link'
|
||||
className='pull-right footer-link'
|
||||
to={global.window.mm_config.HelpLink}
|
||||
target='_blank'
|
||||
href={global.window.mm_config.HelpLink}
|
||||
>
|
||||
<FormattedMessage id='web.footer.help'/>
|
||||
</Link>
|
||||
<Link
|
||||
</a>
|
||||
<a
|
||||
id='terms_link'
|
||||
className='pull-right footer-link'
|
||||
to={global.window.mm_config.TermsOfServiceLink}
|
||||
target='_blank'
|
||||
href={global.window.mm_config.TermsOfServiceLink}
|
||||
>
|
||||
<FormattedMessage id='web.footer.terms'/>
|
||||
</Link>
|
||||
<Link
|
||||
</a>
|
||||
<a
|
||||
id='privacy_link'
|
||||
className='pull-right footer-link'
|
||||
to={global.window.mm_config.PrivacyPolicyLink}
|
||||
target='_blank'
|
||||
href={global.window.mm_config.PrivacyPolicyLink}
|
||||
>
|
||||
<FormattedMessage id='web.footer.privacy'/>
|
||||
</Link>
|
||||
<Link
|
||||
</a>
|
||||
<a
|
||||
id='about_link'
|
||||
className='pull-right footer-link'
|
||||
to={global.window.mm_config.AboutLink}
|
||||
target='_blank'
|
||||
href={global.window.mm_config.AboutLink}
|
||||
>
|
||||
<FormattedMessage id='web.footer.about'/>
|
||||
</Link>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,8 +9,12 @@ function getCountsStateFromStores() {
|
||||
var channels = ChannelStore.getAll();
|
||||
var members = ChannelStore.getAllMembers();
|
||||
|
||||
channels.forEach(function setChannelInfo(channel) {
|
||||
channels.forEach((channel) => {
|
||||
var channelMember = members[channel.id];
|
||||
if (channelMember == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel.type === 'D') {
|
||||
count += channel.total_msg_count - channelMember.msg_count;
|
||||
} else if (channelMember.mention_count > 0) {
|
||||
@@ -20,7 +24,7 @@ function getCountsStateFromStores() {
|
||||
}
|
||||
});
|
||||
|
||||
return {count: count};
|
||||
return {count};
|
||||
}
|
||||
|
||||
import React from 'react';
|
||||
|
||||
@@ -16,6 +16,8 @@ import {createChannelIntroMessage} from 'utils/channel_intro_messages.jsx';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
const MAXIMUM_CACHED_VIEWS = 3;
|
||||
|
||||
export default class PostsViewContainer extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -105,6 +107,12 @@ export default class PostsViewContainer extends React.Component {
|
||||
|
||||
let newIndex = channels.indexOf(channelId);
|
||||
if (newIndex === -1) {
|
||||
if (channels.length >= MAXIMUM_CACHED_VIEWS) {
|
||||
channels.shift();
|
||||
atTop.shift();
|
||||
postLists.shift();
|
||||
}
|
||||
|
||||
newIndex = channels.length;
|
||||
channels.push(channelId);
|
||||
atTop[newIndex] = PostStore.getVisibilityAtTop(channelId);
|
||||
@@ -172,7 +180,7 @@ export default class PostsViewContainer extends React.Component {
|
||||
const isActive = (channels[i] === currentChannelId);
|
||||
postListCtls.push(
|
||||
<PostsView
|
||||
key={'postsviewkey' + i}
|
||||
key={'postsviewkey' + channels[i]}
|
||||
isActive={isActive}
|
||||
postList={postLists[i]}
|
||||
scrollType={this.state.scrollType}
|
||||
|
||||
@@ -33,8 +33,8 @@ class TeamImportTab extends React.Component {
|
||||
this.setState({status: 'fail', link: ''});
|
||||
}
|
||||
|
||||
onImportSuccess(data) {
|
||||
this.setState({status: 'done', link: 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(data)});
|
||||
onImportSuccess(data, res) {
|
||||
this.setState({status: 'done', link: 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(res.text)});
|
||||
}
|
||||
|
||||
doImportSlack(file) {
|
||||
@@ -167,4 +167,4 @@ TeamImportTab.propTypes = {
|
||||
intl: intlShape.isRequired
|
||||
};
|
||||
|
||||
export default injectIntl(TeamImportTab);
|
||||
export default injectIntl(TeamImportTab);
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
|
||||
.popover-title {
|
||||
background: alpha-color($black, .05);
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
padding: 8px 10px;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.popover-content {
|
||||
|
||||
@@ -82,6 +82,12 @@
|
||||
.channel-intro-profile {
|
||||
margin-left: 63px;
|
||||
margin-top: 5px;
|
||||
|
||||
.user-popover {
|
||||
max-width: calc(100% - 100px);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
.channel-intro-img {
|
||||
@@ -106,6 +112,7 @@
|
||||
|
||||
.channel-intro-text {
|
||||
margin-top: 35px;
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +315,7 @@
|
||||
font-size: 1.3em;
|
||||
font-weight: 600;
|
||||
margin: 0 4px 0 0;
|
||||
max-width: 100%;
|
||||
max-width: calc(100% - 50px);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: middle;
|
||||
|
||||
@@ -70,8 +70,12 @@
|
||||
|
||||
.heading {
|
||||
color: $white;
|
||||
display: inline-block;
|
||||
font-weight: 600;
|
||||
margin-right: 3px;
|
||||
overflow: hidden;
|
||||
vertical-align: top;
|
||||
width: calc(100% - 200px);
|
||||
}
|
||||
|
||||
.header-dropdown__icon {
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.user-popover {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.signup-team__container {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
@@ -33,16 +33,16 @@ class UserTypingStoreClass extends EventEmitter {
|
||||
this.removeListener(CHANGE_EVENT, callback);
|
||||
}
|
||||
|
||||
usernameFromId(userId) {
|
||||
let username = Utils.localizeMessage('msg_typing.someone', 'Someone');
|
||||
nameFromId(userId) {
|
||||
let name = Utils.localizeMessage('msg_typing.someone', 'Someone');
|
||||
if (UserStore.hasProfile(userId)) {
|
||||
username = UserStore.getProfile(userId).username;
|
||||
name = Utils.displayUsername(userId);
|
||||
}
|
||||
return username;
|
||||
return name;
|
||||
}
|
||||
|
||||
userTyping(channelId, userId, postParentId) {
|
||||
const username = this.usernameFromId(userId);
|
||||
const name = this.nameFromId(userId);
|
||||
|
||||
// Key representing a location where users can type
|
||||
const loc = channelId + postParentId;
|
||||
@@ -53,15 +53,15 @@ class UserTypingStoreClass extends EventEmitter {
|
||||
}
|
||||
|
||||
// If we already have this user, clear it's timeout to be deleted
|
||||
if (this.typingUsers[loc][username]) {
|
||||
clearTimeout(this.typingUsers[loc][username].timeout);
|
||||
if (this.typingUsers[loc][name]) {
|
||||
clearTimeout(this.typingUsers[loc][name].timeout);
|
||||
}
|
||||
|
||||
// Set the user and a timeout to remove it
|
||||
this.typingUsers[loc][username] = setTimeout(() => {
|
||||
delete this.typingUsers[loc][username];
|
||||
this.typingUsers[loc][name] = setTimeout(() => {
|
||||
Reflect.deleteProperty(this.typingUsers[loc], name);
|
||||
if (this.typingUsers[loc] === {}) {
|
||||
delete this.typingUsers[loc];
|
||||
Reflect.deleteProperty(this.typingUsers, loc);
|
||||
}
|
||||
this.emitChange();
|
||||
}, Constants.UPDATE_TYPING_MS);
|
||||
@@ -76,14 +76,14 @@ class UserTypingStoreClass extends EventEmitter {
|
||||
}
|
||||
|
||||
userPosted(userId, channelId, postParentId) {
|
||||
const username = this.usernameFromId(userId);
|
||||
const name = this.nameFromId(userId);
|
||||
const loc = channelId + postParentId;
|
||||
|
||||
if (this.typingUsers[loc]) {
|
||||
clearTimeout(this.typingUsers[loc][username]);
|
||||
delete this.typingUsers[loc][username];
|
||||
clearTimeout(this.typingUsers[loc][name]);
|
||||
Reflect.deleteProperty(this.typingUsers[loc], name);
|
||||
if (this.typingUsers[loc] === {}) {
|
||||
delete this.typingUsers[loc];
|
||||
Reflect.deleteProperty(this.typingUsers, loc);
|
||||
}
|
||||
this.emitChange();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user