func (ps BoltPostStore) GetPosts(channelID string) StoreChannel {
	storeChannel := make(StoreChannel)

	go func() {
		var result StoreResult
		posts := make(map[string]*model.Post)
		channelPostsJson, err := ps.postsByChannel.Get([]byte(channelID))
		if err != nil {
			result.Err = model.NewAppError("BoltPostStore.", "Post is not valid", "")
		} else {
			channelPosts := model.BoolMapFromJson(strings.NewReader(string(channelPostsJson)))
			postItems, err := ps.postStore.Items()
			if err != nil {
				result.Err = model.NewAppError("BoltPostStore.", "Post is not valid", "")
				storeChannel <- result
				close(storeChannel)
				return
			}

			for _, postItem := range postItems {
				if channelPosts[string(postItem.Key)] {
					postString := string(postItem.Value)
					posts[string(postItem.Key)] = model.PostFromJson(strings.NewReader(postString))
				}
			}
			result.Data = posts
		}

		storeChannel <- result
		close(storeChannel)
		return
	}()

	return storeChannel
}
func (ps BoltPostStore) Save(post *model.Post) StoreChannel {
	storeChannel := make(StoreChannel)

	go func() {
		var result StoreResult
		postErr := post.IsValid()
		if postErr != nil {
			post.PreSave()
			err := ps.postStore.Put([]byte(post.Id), []byte(post.ToJson()))

			postsByChannelsJson, err := ps.postsByChannel.Get([]byte(post.ChannelId))
			postsByChannelsString := string(postsByChannelsJson)
			postsByChannels := model.BoolMapFromJson(strings.NewReader(postsByChannelsString))
			postsByChannels[post.Id] = true

			postsByChannelsString = model.BoolMapToJson(postsByChannels)

			err = ps.postStore.Put([]byte(post.ChannelId), []byte(postsByChannelsString))

			if err != nil {
				result.Err = model.NewAppError("BoltPostStore.", "Post is valid", "")
			} else {
				result.Data = post
			}
		} else {
			result.Err = postErr
		}

		storeChannel <- result
		close(storeChannel)
		return
	}()

	return storeChannel
}