summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-26 16:18:28 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-27 12:46:30 -0400
commit09b38404fa9aadd1b359863024f7def0f34de823 (patch)
treec4027f76a9607c823b25e568c944d21b57f34071 /api
parent95c464b167a6b1324bb829271b89e88900e278a2 (diff)
downloadchat-09b38404fa9aadd1b359863024f7def0f34de823.tar.gz
chat-09b38404fa9aadd1b359863024f7def0f34de823.tar.bz2
chat-09b38404fa9aadd1b359863024f7def0f34de823.zip
Renamed Channel.Description to Channel.Header on the server
Diffstat (limited to 'api')
-rw-r--r--api/channel.go20
-rw-r--r--api/channel_benchmark_test.go6
-rw-r--r--api/channel_test.go46
-rw-r--r--api/slackimport.go2
4 files changed, 37 insertions, 37 deletions
diff --git a/api/channel.go b/api/channel.go
index a8c8505e9..10b6e1d0e 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -22,7 +22,7 @@ func InitChannel(r *mux.Router) {
sr.Handle("/create", ApiUserRequired(createChannel)).Methods("POST")
sr.Handle("/create_direct", ApiUserRequired(createDirectChannel)).Methods("POST")
sr.Handle("/update", ApiUserRequired(updateChannel)).Methods("POST")
- sr.Handle("/update_desc", ApiUserRequired(updateChannelDesc)).Methods("POST")
+ sr.Handle("/update_header", ApiUserRequired(updateChannelHeader)).Methods("POST")
sr.Handle("/update_notify_props", ApiUserRequired(updateNotifyProps)).Methods("POST")
sr.Handle("/{id:[A-Za-z0-9]+}/", ApiUserRequiredActivity(getChannel, false)).Methods("GET")
sr.Handle("/{id:[A-Za-z0-9]+}/extra_info", ApiUserRequired(getChannelExtraInfo)).Methods("GET")
@@ -124,7 +124,7 @@ func CreateDirectChannel(c *Context, otherUserId string) (*model.Channel, *model
channel.Name = model.GetDMNameFromIds(otherUserId, c.Session.UserId)
channel.TeamId = c.Session.TeamId
- channel.Description = ""
+ channel.Header = ""
channel.Type = model.CHANNEL_DIRECT
if uresult := <-uc; uresult.Err != nil {
@@ -209,7 +209,7 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- oldChannel.Description = channel.Description
+ oldChannel.Header = channel.Header
if len(channel.DisplayName) > 0 {
oldChannel.DisplayName = channel.DisplayName
@@ -233,18 +233,18 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
-func updateChannelDesc(c *Context, w http.ResponseWriter, r *http.Request) {
+func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
props := model.MapFromJson(r.Body)
channelId := props["channel_id"]
if len(channelId) != 26 {
- c.SetInvalidParam("updateChannelDesc", "channel_id")
+ c.SetInvalidParam("updateChannelHeader", "channel_id")
return
}
- channelDesc := props["channel_description"]
- if len(channelDesc) > 1024 {
- c.SetInvalidParam("updateChannelDesc", "channel_description")
+ channelHeader := props["channel_header"]
+ if len(channelHeader) > 1024 {
+ c.SetInvalidParam("updateChannelHeader", "channel_header")
return
}
@@ -261,11 +261,11 @@ func updateChannelDesc(c *Context, w http.ResponseWriter, r *http.Request) {
channel := cresult.Data.(*model.Channel)
// Don't need to do anything channel member, just wanted to confirm it exists
- if !c.HasPermissionsToTeam(channel.TeamId, "updateChannelDesc") {
+ if !c.HasPermissionsToTeam(channel.TeamId, "updateChannelHeader") {
return
}
- channel.Description = channelDesc
+ channel.Header = channelHeader
if ucresult := <-Srv.Store.Channel().Update(channel); ucresult.Err != nil {
c.Err = ucresult.Err
diff --git a/api/channel_benchmark_test.go b/api/channel_benchmark_test.go
index 58e3fa18d..fb8dd61bc 100644
--- a/api/channel_benchmark_test.go
+++ b/api/channel_benchmark_test.go
@@ -61,8 +61,8 @@ func BenchmarkCreateDirectChannel(b *testing.B) {
func BenchmarkUpdateChannel(b *testing.B) {
var (
- NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
- CHANNEL_DESCRIPTION_LEN = 50
+ NUM_CHANNELS_RANGE = utils.Range{NUM_CHANNELS, NUM_CHANNELS}
+ CHANNEL_HEADER_LEN = 50
)
team, _, _ := SetupBenchmark()
@@ -73,7 +73,7 @@ func BenchmarkUpdateChannel(b *testing.B) {
}
for i := range channels {
- channels[i].Description = utils.RandString(CHANNEL_DESCRIPTION_LEN, utils.ALPHANUMERIC)
+ channels[i].Header = utils.RandString(CHANNEL_HEADER_LEN, utils.ALPHANUMERIC)
}
// Benchmark Start
diff --git a/api/channel_test.go b/api/channel_test.go
index 899016065..2cfd1601f 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -173,12 +173,12 @@ func TestUpdateChannel(t *testing.T) {
Client.AddChannelMember(channel1.Id, userTeamAdmin.Id)
- desc := "a" + model.NewId() + "a"
- upChannel1 := &model.Channel{Id: channel1.Id, Description: desc}
+ header := "a" + model.NewId() + "a"
+ upChannel1 := &model.Channel{Id: channel1.Id, Header: header}
upChannel1 = Client.Must(Client.UpdateChannel(upChannel1)).Data.(*model.Channel)
- if upChannel1.Description != desc {
- t.Fatal("Channel admin failed to update desc")
+ if upChannel1.Header != header {
+ t.Fatal("Channel admin failed to update header")
}
if upChannel1.DisplayName != channel1.DisplayName {
@@ -187,12 +187,12 @@ func TestUpdateChannel(t *testing.T) {
Client.LoginByEmail(team.Name, userTeamAdmin.Email, "pwd")
- desc = "b" + model.NewId() + "b"
- upChannel1 = &model.Channel{Id: channel1.Id, Description: desc}
+ header = "b" + model.NewId() + "b"
+ upChannel1 = &model.Channel{Id: channel1.Id, Header: header}
upChannel1 = Client.Must(Client.UpdateChannel(upChannel1)).Data.(*model.Channel)
- if upChannel1.Description != desc {
- t.Fatal("Team admin failed to update desc")
+ if upChannel1.Header != header {
+ t.Fatal("Team admin failed to update header")
}
if upChannel1.DisplayName != channel1.DisplayName {
@@ -203,7 +203,7 @@ func TestUpdateChannel(t *testing.T) {
data := rget.Data.(*model.ChannelList)
for _, c := range data.Channels {
if c.Name == model.DEFAULT_CHANNEL {
- c.Description = "new desc"
+ c.Header = "new header"
if _, err := Client.UpdateChannel(c); err == nil {
t.Fatal("should have errored on updating default channel")
}
@@ -218,7 +218,7 @@ func TestUpdateChannel(t *testing.T) {
}
}
-func TestUpdateChannelDesc(t *testing.T) {
+func TestUpdateChannelHeader(t *testing.T) {
Setup()
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
@@ -235,36 +235,36 @@ func TestUpdateChannelDesc(t *testing.T) {
data := make(map[string]string)
data["channel_id"] = channel1.Id
- data["channel_description"] = "new desc"
+ data["channel_header"] = "new header"
var upChannel1 *model.Channel
- if result, err := Client.UpdateChannelDesc(data); err != nil {
+ if result, err := Client.UpdateChannelHeader(data); err != nil {
t.Fatal(err)
} else {
upChannel1 = result.Data.(*model.Channel)
}
- if upChannel1.Description != data["channel_description"] {
- t.Fatal("Failed to update desc")
+ if upChannel1.Header != data["channel_header"] {
+ t.Fatal("Failed to update header")
}
data["channel_id"] = "junk"
- if _, err := Client.UpdateChannelDesc(data); err == nil {
+ if _, err := Client.UpdateChannelHeader(data); err == nil {
t.Fatal("should have errored on junk channel id")
}
data["channel_id"] = "12345678901234567890123456"
- if _, err := Client.UpdateChannelDesc(data); err == nil {
+ if _, err := Client.UpdateChannelHeader(data); err == nil {
t.Fatal("should have errored on non-existent channel id")
}
data["channel_id"] = channel1.Id
- data["channel_description"] = ""
+ data["channel_header"] = ""
for i := 0; i < 1050; i++ {
- data["channel_description"] += "a"
+ data["channel_header"] += "a"
}
- if _, err := Client.UpdateChannelDesc(data); err == nil {
- t.Fatal("should have errored on bad channel desc")
+ if _, err := Client.UpdateChannelHeader(data); err == nil {
+ t.Fatal("should have errored on bad channel header")
}
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"}
@@ -274,9 +274,9 @@ func TestUpdateChannelDesc(t *testing.T) {
Client.LoginByEmail(team.Name, user2.Email, "pwd")
data["channel_id"] = channel1.Id
- data["channel_description"] = "new desc"
- if _, err := Client.UpdateChannelDesc(data); err == nil {
- t.Fatal("should have errored non-channel member trying to update desc")
+ data["channel_header"] = "new header"
+ if _, err := Client.UpdateChannelHeader(data); err == nil {
+ t.Fatal("should have errored non-channel member trying to update header")
}
}
diff --git a/api/slackimport.go b/api/slackimport.go
index 06032c068..af3d56bad 100644
--- a/api/slackimport.go
+++ b/api/slackimport.go
@@ -182,7 +182,7 @@ func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[str
Type: model.CHANNEL_OPEN,
DisplayName: sChannel.Name,
Name: SlackConvertChannelName(sChannel.Name),
- Description: sChannel.Topic["value"],
+ //Purpose: sChannel.Topic["value"], // TODO uncomment this once Channel.Purpose is a field
}
mChannel := ImportChannel(&newChannel)
if mChannel == nil {