MM-48614: saves priority for drafts (#21752)
* MM-48614: saves priority for drafts Adds a new column in the drafts table, "priority". This way we can save post's priority in the draft. Fixes OmitConnectionId, which when you published a ws event for a user was getting bypassed. Fixes Get for drafts returns deleted ones as well, which is needed for upsert. * Adds test case for the OmitConnectionId * Addresses review comments, removes DeleteAt * Vets * Adds missing translation * Re-instates DeleteAt column * Adds separate case to get draft including deleted * Fixes Update Draft * Empty
Этот коммит содержится в:
@@ -23,6 +23,7 @@ type Draft struct {
|
||||
Props StringInterface `json:"props"` // Deprecated: use GetProps()
|
||||
FileIds StringArray `json:"file_ids,omitempty"`
|
||||
Metadata *PostMetadata `json:"metadata,omitempty"`
|
||||
Priority StringInterface `json:"priority,omitempty"`
|
||||
}
|
||||
|
||||
func (o *Draft) IsValid(maxDraftSize int) *AppError {
|
||||
@@ -58,6 +59,10 @@ func (o *Draft) IsValid(maxDraftSize int) *AppError {
|
||||
return NewAppError("Drafts.IsValid", "model.draft.is_valid.props.app_error", nil, "channelid="+o.ChannelId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if utf8.RuneCountInString(StringInterfaceToJSON(o.Priority)) > PostPropsMaxRunes {
|
||||
return NewAppError("Drafts.IsValid", "model.draft.is_valid.priority.app_error", nil, "channelid="+o.ChannelId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -79,6 +84,7 @@ func (o *Draft) PreSave() {
|
||||
}
|
||||
|
||||
o.UpdateAt = o.CreateAt
|
||||
o.DeleteAt = 0
|
||||
o.PreCommit()
|
||||
}
|
||||
|
||||
|
||||
@@ -215,9 +215,10 @@ func TestWebSocketEventDeepCopy(t *testing.T) {
|
||||
TeamId: "ccc",
|
||||
ContainsSanitizedData: true,
|
||||
ContainsSensitiveData: true,
|
||||
OmitConnectionId: "ddd",
|
||||
}
|
||||
|
||||
ev := NewWebSocketEvent("test", "team", "channel", "user", omitUsers, "")
|
||||
ev := NewWebSocketEvent("test", "team", "channel", "user", omitUsers, "ddd")
|
||||
|
||||
ev.Add("post", &Post{})
|
||||
ev.SetBroadcast(broadcast)
|
||||
|
||||
Ссылка в новой задаче
Block a user