Change Post.IsFollowing to a pointer and set to nil for responses to updates to Posts (#17774)

Этот коммит содержится в:
Joram Wilander
2021-06-14 08:25:44 -04:00
коммит произвёл GitHub
родитель 857c5e562f
Коммит 326eb2242a
5 изменённых файлов: 15 добавлений и 6 удалений

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

@@ -34,7 +34,7 @@ type SqlPostStore struct {
type postWithExtra struct {
ThreadReplyCount int64
IsFollowing bool
IsFollowing *bool
ThreadParticipants model.StringArray
model.Post
}
@@ -739,7 +739,9 @@ func (s *SqlPostStore) prepareThreadedResponse(posts []*postWithExtra, extended,
}
processPost := func(p *postWithExtra) error {
p.Post.ReplyCount = p.ThreadReplyCount
p.Post.IsFollowing = p.IsFollowing
if p.IsFollowing != nil {
p.Post.IsFollowing = model.NewBool(*p.IsFollowing)
}
for _, th := range p.ThreadParticipants {
var participant *model.User
for _, u := range users {

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

@@ -451,7 +451,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
r1, err := ss.Post().Get(context.Background(), o1.Id, false, true, false, o1.UserId)
require.NoError(t, err)
require.Equal(t, r1.Posts[o1.Id].CreateAt, o1.CreateAt, "invalid returned post")
require.True(t, r1.Posts[o1.Id].IsFollowing)
require.True(t, *r1.Posts[o1.Id].IsFollowing)
}
func testPostStoreGetSingle(t *testing.T, ss store.Store) {