Merge branch 'master' of https://github.com/mattermost/platform
Этот коммит содержится в:
@@ -1,6 +1,6 @@
|
||||
**Mattermost Preview**
|
||||
**Mattermost Alpha**
|
||||
**Team Communication Service**
|
||||
**Version 0.5.0**
|
||||
**Development Build**
|
||||
|
||||
|
||||
About Mattermost
|
||||
@@ -22,7 +22,7 @@ Learn More
|
||||
Installing the Mattermost
|
||||
=========================
|
||||
|
||||
You're installing "Mattermost Preview", a pre-released 0.5.0 version intended for an early look at what we're building. While SpinPunch runs this version internally, it's not recommended for production deployments since we can't guarantee API stability or backwards compatibility until our 1.0.0 version release.
|
||||
You're installing "Mattermost Alpha", a pre-released version intended for an early look at what we're building. While SpinPunch runs this version internally, it's not recommended for production deployments since we can't guarantee API stability or backwards compatibility until our production release.
|
||||
|
||||
That said, any issues at all, please let us know on the Mattermost forum at: http://forum.mattermost.org
|
||||
|
||||
|
||||
@@ -710,6 +710,11 @@ func removeChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
message := model.NewMessage(c.Session.TeamId, "", userId, model.ACTION_USER_REMOVED)
|
||||
message.Add("channel_id",id)
|
||||
message.Add("remover", c.Session.UserId)
|
||||
PublishAndForget(message)
|
||||
|
||||
c.LogAudit("name=" + channel.Name + " user_id=" + userId)
|
||||
|
||||
result := make(map[string]string)
|
||||
|
||||
@@ -16,6 +16,7 @@ const (
|
||||
ACTION_VIEWED = "viewed"
|
||||
ACTION_NEW_USER = "new_user"
|
||||
ACTION_USER_ADDED = "user_added"
|
||||
ACTION_USER_REMOVED = "user_removed"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
const (
|
||||
SESSION_TOKEN = "MMSID"
|
||||
SESSION_TIME_WEB_IN_DAYS = 365
|
||||
SESSION_TIME_WEB_IN_DAYS = 30
|
||||
SESSION_TIME_WEB_IN_SECS = 60 * 60 * 24 * SESSION_TIME_WEB_IN_DAYS
|
||||
SESSION_TIME_MOBILE_IN_DAYS = 365
|
||||
SESSION_TIME_MOBILE_IN_DAYS = 30
|
||||
SESSION_TIME_MOBILE_IN_SECS = 60 * 60 * 24 * SESSION_TIME_MOBILE_IN_DAYS
|
||||
SESSION_CACHE_IN_SECS = 60 * 10
|
||||
SESSION_CACHE_SIZE = 10000
|
||||
|
||||
@@ -120,7 +120,7 @@ func (s SqlChannelStore) Update(channel *model.Channel) StoreChannel {
|
||||
if count, err := s.GetMaster().Update(channel); err != nil {
|
||||
if IsUniqueConstraintError(err.Error(), "Name", "channels_name_teamid_key") {
|
||||
dupChannel := model.Channel{}
|
||||
s.GetReplica().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId=? AND Name=? AND DeleteAt > 0", channel.TeamId, channel.Name)
|
||||
s.GetReplica().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name= :Name AND DeleteAt > 0", map[string]interface{}{"TeamId": channel.TeamId, "Name": channel.Name})
|
||||
if dupChannel.DeleteAt > 0 {
|
||||
result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that name was previously created", "id="+channel.Id+", "+err.Error())
|
||||
} else {
|
||||
|
||||
@@ -38,7 +38,7 @@ func NewSqlPostStore(sqlStore *SqlStore) PostStore {
|
||||
func (s SqlPostStore) UpgradeSchemaIfNeeded() {
|
||||
|
||||
// These execs are for upgrading currently created databases to full utf8mb4 compliance
|
||||
// Will be removed as seen fit for upgrading
|
||||
// Will be removed as seen fit for upgrading
|
||||
s.GetMaster().Exec("ALTER TABLE Posts charset=utf8mb4")
|
||||
s.GetMaster().Exec("ALTER TABLE Posts MODIFY COLUMN Message varchar(4000) CHARACTER SET utf8mb4")
|
||||
}
|
||||
@@ -80,14 +80,14 @@ func (s SqlPostStore) Save(post *model.Post) StoreChannel {
|
||||
time := model.GetMillis()
|
||||
|
||||
if post.Type != model.POST_JOIN_LEAVE {
|
||||
s.GetMaster().Exec("UPDATE Channels SET LastPostAt = ?, TotalMsgCount = TotalMsgCount + 1 WHERE Id = ?", time, post.ChannelId)
|
||||
s.GetMaster().Exec("UPDATE Channels SET LastPostAt = :LastPostAt, TotalMsgCount = TotalMsgCount + 1 WHERE Id = :ChannelId", map[string]interface{}{"LastPostAt": time, "ChannelId": post.ChannelId})
|
||||
} else {
|
||||
// don't update TotalMsgCount for unimportant messages so that the channel isn't marked as unread
|
||||
s.GetMaster().Exec("UPDATE Channels SET LastPostAt = ? WHERE Id = ?", time, post.ChannelId)
|
||||
s.GetMaster().Exec("UPDATE Channels SET LastPostAt = :LastPostAt WHERE Id = :ChannelId", map[string]interface{}{"LastPostAt": time, "ChannelId": post.ChannelId})
|
||||
}
|
||||
|
||||
if len(post.RootId) > 0 {
|
||||
s.GetMaster().Exec("UPDATE Posts SET UpdateAt = ? WHERE Id = ?", time, post.RootId)
|
||||
s.GetMaster().Exec("UPDATE Posts SET UpdateAt = :UpdateAt WHERE Id = :RootId", map[string]interface{}{"UpdateAt": time, "RootId": post.RootId})
|
||||
}
|
||||
|
||||
result.Data = post
|
||||
@@ -126,10 +126,10 @@ func (s SqlPostStore) Update(oldPost *model.Post, newMessage string, newHashtags
|
||||
result.Err = model.NewAppError("SqlPostStore.Update", "We couldn't update the Post", "id="+editPost.Id+", "+err.Error())
|
||||
} else {
|
||||
time := model.GetMillis()
|
||||
s.GetMaster().Exec("UPDATE Channels SET LastPostAt = ? WHERE Id = ?", time, editPost.ChannelId)
|
||||
s.GetMaster().Exec("UPDATE Channels SET LastPostAt = :LastPostAt WHERE Id = :ChannelId", map[string]interface{}{"LastPostAt": time, "ChannelId": editPost.ChannelId})
|
||||
|
||||
if len(editPost.RootId) > 0 {
|
||||
s.GetMaster().Exec("UPDATE Posts SET UpdateAt = ? WHERE Id = ?", time, editPost.RootId)
|
||||
s.GetMaster().Exec("UPDATE Posts SET UpdateAt = :UpdateAt WHERE Id = :RootId", map[string]interface{}{"UpdateAt": time, "RootId": editPost.RootId})
|
||||
}
|
||||
|
||||
// mark the old post as deleted
|
||||
|
||||
@@ -184,7 +184,7 @@ func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel {
|
||||
|
||||
curTime := model.GetMillis()
|
||||
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = ?, UpdateAt = ? WHERE Id = ?", curTime, curTime, userId); err != nil {
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = :Time, UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"Time": curTime, "UserId": userId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlUserStore.UpdateUpdateAt", "We couldn't update the update_at", "user_id="+userId)
|
||||
} else {
|
||||
result.Data = userId
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = React.createClass({
|
||||
post.message = this.state.messageText;
|
||||
|
||||
// if this is a reply, trim off any carets from the beginning of a message
|
||||
if (this.state.rootId && post.message.startsWith("^")) {
|
||||
if (this.state.rootId && post.message[0] === "^") {
|
||||
post.message = post.message.replace(/^\^+\s*/g, "");
|
||||
}
|
||||
|
||||
|
||||
64
web/react/components/removed_from_channel_modal.jsx
Обычный файл
64
web/react/components/removed_from_channel_modal.jsx
Обычный файл
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
var ChannelStore = require('../stores/channel_store.jsx');
|
||||
var UserStore = require('../stores/user_store.jsx');
|
||||
var BrowserStore = require('../stores/browser_store.jsx')
|
||||
var utils = require('../utils/utils.jsx');
|
||||
|
||||
module.exports = React.createClass({
|
||||
handleShow: function() {
|
||||
var newState = {};
|
||||
if(BrowserStore.getItem("channel-removed-state")) {
|
||||
newState = BrowserStore.getItem("channel-removed-state");
|
||||
BrowserStore.removeItem("channel-removed-state");
|
||||
}
|
||||
|
||||
this.setState(newState);
|
||||
},
|
||||
handleClose: function() {
|
||||
var townSquare = ChannelStore.getByName("town-square");
|
||||
utils.switchChannel(townSquare);
|
||||
|
||||
this.setState({channelName: "", remover: ""})
|
||||
},
|
||||
componentDidMount: function() {
|
||||
$(this.getDOMNode()).on('show.bs.modal',this.handleShow);
|
||||
$(this.getDOMNode()).on('hidden.bs.modal',this.handleClose);
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
$(this.getDOMNode()).off('show.bs.modal',this.handleShow);
|
||||
$(this.getDOMNode()).off('hidden.bs.modal',this.handleClose);
|
||||
},
|
||||
getInitialState: function() {
|
||||
return {channelName: "", remover: ""}
|
||||
},
|
||||
render: function() {
|
||||
var currentUser = UserStore.getCurrentUser();
|
||||
var channelName = this.state.channelName ? this.state.channelName : "the channel"
|
||||
var remover = this.state.remover ? this.state.remover : "Someone"
|
||||
|
||||
if (currentUser != null) {
|
||||
return (
|
||||
<div className="modal fade" ref="modal" id="removed_from_channel" tabIndex="-1" role="dialog" aria-hidden="true">
|
||||
<div className="modal-dialog">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 className="modal-title">Removed from {channelName}</h4>
|
||||
</div>
|
||||
<div className="modal-body">
|
||||
<p>{remover} removed you from {channelName}</p>
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
<button type="button" className="btn btn-primary" data-dismiss="modal">Okay</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return <div/>;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -7,6 +7,7 @@ var AsyncClient = require('../utils/async_client.jsx');
|
||||
var SocketStore = require('../stores/socket_store.jsx');
|
||||
var UserStore = require('../stores/user_store.jsx');
|
||||
var TeamStore = require('../stores/team_store.jsx');
|
||||
var BrowserStore = require('../stores/browser_store.jsx')
|
||||
var utils = require('../utils/utils.jsx');
|
||||
var SidebarHeader = require('./sidebar_header.jsx');
|
||||
var SearchBox = require('./search_bar.jsx');
|
||||
@@ -197,6 +198,19 @@ module.exports = React.createClass({
|
||||
if (UserStore.getCurrentId() === msg.user_id) {
|
||||
AsyncClient.getChannels(true);
|
||||
}
|
||||
} else if(msg.action === "user_removed") {
|
||||
if(msg.user_id === UserStore.getCurrentId()) {
|
||||
AsyncClient.getChannels(true);
|
||||
|
||||
if(msg.props.channel_id === ChannelStore.getCurrentId() && $('#removed_from_channel').length > 0) {
|
||||
var sentState = {};
|
||||
sentState.channelName = ChannelStore.getCurrent().display_name;
|
||||
sentState.remover = UserStore.getProfile(msg.props.remover).username;
|
||||
|
||||
BrowserStore.setItem('channel-removed-state',sentState);
|
||||
$('#removed_from_channel').modal('show');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
updateTitle: function() {
|
||||
|
||||
@@ -34,6 +34,7 @@ var MentionList = require('../components/mention_list.jsx');
|
||||
var ChannelInfoModal = require('../components/channel_info_modal.jsx');
|
||||
var AccessHistoryModal = require('../components/access_history_modal.jsx');
|
||||
var ActivityLogModal = require('../components/activity_log_modal.jsx');
|
||||
var RemovedFromChannelModal = require('../components/removed_from_channel_modal.jsx')
|
||||
|
||||
|
||||
var Constants = require('../utils/constants.jsx');
|
||||
@@ -217,4 +218,9 @@ global.window.setup_channel_page = function(team_name, team_type, team_id, chann
|
||||
document.getElementById('activity_log_modal')
|
||||
);
|
||||
|
||||
React.render(
|
||||
<RemovedFromChannelModal />,
|
||||
document.getElementById('removed_from_channel_modal')
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
<div id="channel_info_modal"></div>
|
||||
<div id="access_history_modal"></div>
|
||||
<div id="activity_log_modal"></div>
|
||||
<div id="removed_from_channel_modal"></div>
|
||||
<script>
|
||||
window.setup_channel_page('{{ .Props.TeamDisplayName }}', '{{ .Props.TeamType }}', '{{ .Props.TeamId }}', '{{ .Props.ChannelName }}', '{{ .Props.ChannelId }}');
|
||||
</script>
|
||||
|
||||
Ссылка в новой задаче
Block a user