Merge pull request #406 from mattermost/mm-1281
MM-1281 Track channel creator in DB and show in channel intro message
Этот коммит содержится в:
@@ -58,6 +58,8 @@ func createChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel.CreatorId = c.Session.UserId
|
||||||
|
|
||||||
if sc, err := CreateChannel(c, channel, true); err != nil {
|
if sc, err := CreateChannel(c, channel, true); err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ type Channel struct {
|
|||||||
LastPostAt int64 `json:"last_post_at"`
|
LastPostAt int64 `json:"last_post_at"`
|
||||||
TotalMsgCount int64 `json:"total_msg_count"`
|
TotalMsgCount int64 `json:"total_msg_count"`
|
||||||
ExtraUpdateAt int64 `json:"extra_update_at"`
|
ExtraUpdateAt int64 `json:"extra_update_at"`
|
||||||
|
CreatorId string `json:"creator_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Channel) ToJson() string {
|
func (o *Channel) ToJson() string {
|
||||||
@@ -92,6 +93,10 @@ func (o *Channel) IsValid() *AppError {
|
|||||||
return NewAppError("Channel.IsValid", "Invalid description", "id="+o.Id)
|
return NewAppError("Channel.IsValid", "Invalid description", "id="+o.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(o.CreatorId) > 26 {
|
||||||
|
return NewAppError("Channel.IsValid", "Invalid creator id", "")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
|
|||||||
table.ColMap("Name").SetMaxSize(64)
|
table.ColMap("Name").SetMaxSize(64)
|
||||||
table.SetUniqueTogether("Name", "TeamId")
|
table.SetUniqueTogether("Name", "TeamId")
|
||||||
table.ColMap("Description").SetMaxSize(1024)
|
table.ColMap("Description").SetMaxSize(1024)
|
||||||
|
table.ColMap("CreatorId").SetMaxSize(26)
|
||||||
|
|
||||||
tablem := db.AddTableWithName(model.ChannelMember{}, "ChannelMembers").SetKeys(false, "ChannelId", "UserId")
|
tablem := db.AddTableWithName(model.ChannelMember{}, "ChannelMembers").SetKeys(false, "ChannelId", "UserId")
|
||||||
tablem.ColMap("ChannelId").SetMaxSize(26)
|
tablem.ColMap("ChannelId").SetMaxSize(26)
|
||||||
@@ -37,6 +38,7 @@ func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
|
|||||||
|
|
||||||
func (s SqlChannelStore) UpgradeSchemaIfNeeded() {
|
func (s SqlChannelStore) UpgradeSchemaIfNeeded() {
|
||||||
s.CreateColumnIfNotExists("Channels", "ExtraUpdateAt", "TotalMsgCount", "bigint(20)", "0")
|
s.CreateColumnIfNotExists("Channels", "ExtraUpdateAt", "TotalMsgCount", "bigint(20)", "0")
|
||||||
|
s.CreateColumnIfNotExists("Channels", "CreatorId", "ExtraUpdateAt", "varchar(26)", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) CreateIndexesIfNotExists() {
|
func (s SqlChannelStore) CreateIndexesIfNotExists() {
|
||||||
|
|||||||
@@ -392,15 +392,24 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
} else if (channel.type === 'P' || channel.type === 'O') {
|
} else if (channel.type === 'P' || channel.type === 'O') {
|
||||||
var uiName = channel.display_name;
|
var uiName = channel.display_name;
|
||||||
var members = ChannelStore.getCurrentExtraInfo().members;
|
|
||||||
var creatorName = '';
|
var creatorName = '';
|
||||||
|
|
||||||
|
if (channel.creator_id.length > 0) {
|
||||||
|
var creator = UserStore.getProfile(channel.creator_id);
|
||||||
|
if (creator) {
|
||||||
|
creatorName = creator.username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creatorName === '') {
|
||||||
|
var members = ChannelStore.getCurrentExtraInfo().members;
|
||||||
for (var i = 0; i < members.length; i++) {
|
for (var i = 0; i < members.length; i++) {
|
||||||
if (members[i].roles.indexOf('admin') > -1) {
|
if (members[i].roles.indexOf('admin') > -1) {
|
||||||
creatorName = members[i].username;
|
creatorName = members[i].username;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ChannelStore.isDefault(channel)) {
|
if (ChannelStore.isDefault(channel)) {
|
||||||
moreMessages = (
|
moreMessages = (
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user