Fixed MM-14627, was incorrectly removing props from updated post (#10545)

* Fixed MM-14627, was incorrectly removing props from updated post

- Fixed the wrong initialization of `remove`
- Consolidated the list of properties to retain in `model.PostActionRetainPropKeys`
- Added a test

* Not sure why this broke the test, reverted the change
Этот коммит содержится в:
Lev
2019-04-02 15:13:27 -07:00
коммит произвёл GitHub
родитель 0e6f335f74
Коммит 7272864bea
3 изменённых файлов: 82 добавлений и 5 удалений

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

@@ -26,6 +26,8 @@ const (
INTERACTIVE_DIALOG_TRIGGER_TIMEOUT_MILLISECONDS = 3000
)
var PostActionRetainPropKeys = []string{"override_username", "override_icon_url"}
type DoPostActionRequest struct {
SelectedOption string `json:"selected_option,omitempty"`
Cookie string `json:"cookie,omitempty"`
@@ -327,10 +329,9 @@ func AddPostActionCookies(o *Post, secret []byte) *Post {
p := o.Clone()
// retainedProps carry over their value from the old post, including no value
retainPropKeys := []string{"override_username", "override_icon_url"}
retainProps := map[string]interface{}{}
removeProps := []string{}
for _, key := range retainPropKeys {
for _, key := range PostActionRetainPropKeys {
value, ok := p.Props[key]
if ok {
retainProps[key] = value