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
|
||||
}
|
||||
|
||||
channel.CreatorId = c.Session.UserId
|
||||
|
||||
if sc, err := CreateChannel(c, channel, true); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
|
||||
@@ -28,6 +28,7 @@ type Channel struct {
|
||||
LastPostAt int64 `json:"last_post_at"`
|
||||
TotalMsgCount int64 `json:"total_msg_count"`
|
||||
ExtraUpdateAt int64 `json:"extra_update_at"`
|
||||
CreatorId string `json:"creator_id"`
|
||||
}
|
||||
|
||||
func (o *Channel) ToJson() string {
|
||||
@@ -92,6 +93,10 @@ func (o *Channel) IsValid() *AppError {
|
||||
return NewAppError("Channel.IsValid", "Invalid description", "id="+o.Id)
|
||||
}
|
||||
|
||||
if len(o.CreatorId) > 26 {
|
||||
return NewAppError("Channel.IsValid", "Invalid creator id", "")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
|
||||
table.ColMap("Name").SetMaxSize(64)
|
||||
table.SetUniqueTogether("Name", "TeamId")
|
||||
table.ColMap("Description").SetMaxSize(1024)
|
||||
table.ColMap("CreatorId").SetMaxSize(26)
|
||||
|
||||
tablem := db.AddTableWithName(model.ChannelMember{}, "ChannelMembers").SetKeys(false, "ChannelId", "UserId")
|
||||
tablem.ColMap("ChannelId").SetMaxSize(26)
|
||||
@@ -37,6 +38,7 @@ func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
|
||||
|
||||
func (s SqlChannelStore) UpgradeSchemaIfNeeded() {
|
||||
s.CreateColumnIfNotExists("Channels", "ExtraUpdateAt", "TotalMsgCount", "bigint(20)", "0")
|
||||
s.CreateColumnIfNotExists("Channels", "CreatorId", "ExtraUpdateAt", "varchar(26)", "")
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) CreateIndexesIfNotExists() {
|
||||
|
||||
@@ -377,13 +377,22 @@ module.exports = React.createClass({
|
||||
}
|
||||
} else if (channel.type === 'P' || channel.type === 'O') {
|
||||
var uiName = channel.display_name;
|
||||
var members = ChannelStore.getCurrentExtraInfo().members;
|
||||
var creatorName = '';
|
||||
|
||||
for (var i = 0; i < members.length; i++) {
|
||||
if (members[i].roles.indexOf('admin') > -1) {
|
||||
creatorName = members[i].username;
|
||||
break;
|
||||
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++) {
|
||||
if (members[i].roles.indexOf('admin') > -1) {
|
||||
creatorName = members[i].username;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user