summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-19 08:31:20 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-19 08:31:20 -0400
commit11247061b5623140656e3ec0ee96b6566637a950 (patch)
treeed815e8676b3abb436fc77226b485f6f33245002
parent7004a348b59d5572e8c84eb1c8138bf45cbd0d3e (diff)
downloadchat-11247061b5623140656e3ec0ee96b6566637a950.tar.gz
chat-11247061b5623140656e3ec0ee96b6566637a950.tar.bz2
chat-11247061b5623140656e3ec0ee96b6566637a950.zip
Track channel creator in DB and show in channel intro message.
-rw-r--r--api/channel.go2
-rw-r--r--model/channel.go5
-rw-r--r--store/sql_channel_store.go2
-rw-r--r--web/react/components/post_list.jsx19
4 files changed, 23 insertions, 5 deletions
diff --git a/api/channel.go b/api/channel.go
index 151627623..be6a8b064 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -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
diff --git a/model/channel.go b/model/channel.go
index 94b8fdb43..b46f79f75 100644
--- a/model/channel.go
+++ b/model/channel.go
@@ -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
}
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index b8bf8b5ac..cf34f2847 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -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() {
diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx
index bebd6847f..060b8555b 100644
--- a/web/react/components/post_list.jsx
+++ b/web/react/components/post_list.jsx
@@ -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;
+ }
}
}