Этот коммит содержится в:
Carlos Tadeu Panato Junior
2018-09-10 16:13:21 +02:00
коммит произвёл GitHub
родитель 435ce3df4b a8d116b381
Коммит 1f87596e75
6 изменённых файлов: 19 добавлений и 10 удалений

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

@@ -97,10 +97,11 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
} }
var oldChannel *model.Channel var oldChannel *model.Channel
var err *model.AppError if originalOldChannel, err := c.App.GetChannel(channel.Id); err != nil {
if oldChannel, err = c.App.GetChannel(channel.Id); err != nil {
c.Err = err c.Err = err
return return
} else {
oldChannel = originalOldChannel.DeepCopy()
} }
switch oldChannel.Type { switch oldChannel.Type {
@@ -229,10 +230,12 @@ func patchChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
oldChannel, err := c.App.GetChannel(c.Params.ChannelId) var oldChannel *model.Channel
if err != nil { if originalOldChannel, err := c.App.GetChannel(c.Params.ChannelId); err != nil {
c.Err = err c.Err = err
return return
} else {
oldChannel = originalOldChannel.DeepCopy()
} }
switch oldChannel.Type { switch oldChannel.Type {

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

@@ -4,6 +4,7 @@
package api4 package api4
import ( import (
"crypto/subtle"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@@ -342,7 +343,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if hash != app.GeneratePublicLinkHash(info.Id, *c.App.Config().FileSettings.PublicLinkSalt) { if subtle.ConstantTimeCompare([]byte(hash), []byte(app.GeneratePublicLinkHash(info.Id, *c.App.Config().FileSettings.PublicLinkSalt))) != 1 {
c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "", http.StatusBadRequest) c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "", http.StatusBadRequest)
utils.RenderWebAppError(c.App.Config(), w, r, c.Err, c.App.AsymmetricSigningKey()) utils.RenderWebAppError(c.App.Config(), w, r, c.Err, c.App.AsymmetricSigningKey())
return return

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

@@ -705,8 +705,10 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
return nil, presult.Err return nil, presult.Err
} else { } else {
for _, p := range presult.Data.([]*model.Post) { for _, p := range presult.Data.([]*model.Post) {
postList.AddPost(p) if p.DeleteAt == 0 {
postList.AddOrder(p.Id) postList.AddPost(p)
postList.AddOrder(p.Id)
}
} }
} }
} }

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

@@ -59,6 +59,9 @@ type ChannelPatch struct {
func (o *Channel) DeepCopy() *Channel { func (o *Channel) DeepCopy() *Channel {
copy := *o copy := *o
if copy.SchemeId != nil {
copy.SchemeId = NewString(*o.SchemeId)
}
return &copy return &copy
} }

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

@@ -1156,7 +1156,7 @@ func (s *SqlPostStore) GetPostsByIds(postIds []string) store.StoreChannel {
params[key] = postId params[key] = postId
} }
query := `SELECT * FROM Posts WHERE Id in (` + keys.String() + `) and DeleteAt = 0 ORDER BY CreateAt DESC` query := `SELECT * FROM Posts WHERE Id in (` + keys.String() + `) ORDER BY CreateAt DESC`
var posts []*model.Post var posts []*model.Post
_, err := s.GetReplica().Select(&posts, query, params) _, err := s.GetReplica().Select(&posts, query, params)

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

@@ -1674,8 +1674,8 @@ func testPostStoreGetPostsByIds(t *testing.T, ss store.Store) {
store.Must(ss.Post().Delete(ro1.Id, model.GetMillis(), "")) store.Must(ss.Post().Delete(ro1.Id, model.GetMillis(), ""))
if ro5 := store.Must(ss.Post().GetPostsByIds(postIds)).([]*model.Post); len(ro5) != 2 { if ro5 := store.Must(ss.Post().GetPostsByIds(postIds)).([]*model.Post); len(ro5) != 3 {
t.Fatalf("Expected 2 posts in results. Got %v", len(ro5)) t.Fatalf("Expected 3 posts in results. Got %v", len(ro5))
} }
} }