PLT-2978: Add channel purpose change system message. (#5094)

Completes original patch by David Lu.
Этот коммит содержится в:
George Goldberg
2017-01-17 20:45:18 +00:00
коммит произвёл Christopher Speller
родитель cdf91d8ee8
Коммит 0685afd1d1
6 изменённых файлов: 80 добавлений и 3 удалений

Просмотреть файл

@@ -262,6 +262,7 @@ func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
}
func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
props := model.MapFromJson(r.Body)
channelId := props["channel_id"]
if len(channelId) != 26 {
@@ -292,6 +293,7 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
oldChannelPurpose := channel.Purpose
channel.Purpose = channelPurpose
app.InvalidateCacheForChannel(channel.Id)
@@ -299,6 +301,9 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
c.Err = ucresult.Err
return
} else {
if err := app.PostUpdateChannelPurposeMessage(c.Session.UserId, channel.Id, c.TeamId, oldChannelPurpose, channelPurpose); err != nil {
l4g.Error(err.Error())
}
c.LogAudit("name=" + channel.Name)
w.Write([]byte(channel.ToJson()))
}

Просмотреть файл

@@ -630,6 +630,17 @@ func TestUpdateChannelPurpose(t *testing.T) {
upChannel1 = result.Data.(*model.Channel)
}
time.Sleep(100 * time.Millisecond)
r1 := Client.Must(Client.GetPosts(channel1.Id, 0, 1, "")).Data.(*model.PostList)
if len(r1.Order) != 1 {
t.Fatal("Purpose update system message was not found")
} else if val, ok := r1.Posts[r1.Order[0]].Props["old_purpose"]; !ok || val != "" {
t.Fatal("Props should contain old_header with old purpose value")
} else if val, ok := r1.Posts[r1.Order[0]].Props["new_purpose"]; !ok || val != "new purpose" {
t.Fatal("Props should contain new_header with new purpose value")
}
if upChannel1.Purpose != data["channel_purpose"] {
t.Fatal("Failed to update purpose")
}