Migrate CommandWebhook.Save to sync by default (#11595)

Этот коммит содержится в:
Rodrigo Villablanca Vásquez
2019-07-09 10:42:10 -04:00
коммит произвёл jfrerich
родитель ce61681c92
Коммит 25a2e7e981
5 изменённых файлов: 36 добавлений и 30 удалений

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

@@ -36,24 +36,21 @@ func (s SqlCommandWebhookStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_command_webhook_create_at", "CommandWebhooks", "CreateAt")
}
func (s SqlCommandWebhookStore) Save(webhook *model.CommandWebhook) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
if len(webhook.Id) > 0 {
result.Err = model.NewAppError("SqlCommandWebhookStore.Save", "store.sql_command_webhooks.save.existing.app_error", nil, "id="+webhook.Id, http.StatusBadRequest)
return
}
func (s SqlCommandWebhookStore) Save(webhook *model.CommandWebhook) (*model.CommandWebhook, *model.AppError) {
if len(webhook.Id) > 0 {
return nil, model.NewAppError("SqlCommandWebhookStore.Save", "store.sql_command_webhooks.save.existing.app_error", nil, "id="+webhook.Id, http.StatusBadRequest)
}
webhook.PreSave()
if result.Err = webhook.IsValid(); result.Err != nil {
return
}
webhook.PreSave()
if err := webhook.IsValid(); err != nil {
return nil, err
}
if err := s.GetMaster().Insert(webhook); err != nil {
result.Err = model.NewAppError("SqlCommandWebhookStore.Save", "store.sql_command_webhooks.save.app_error", nil, "id="+webhook.Id+", "+err.Error(), http.StatusInternalServerError)
} else {
result.Data = webhook
}
})
if err := s.GetMaster().Insert(webhook); err != nil {
return nil, model.NewAppError("SqlCommandWebhookStore.Save", "store.sql_command_webhooks.save.app_error", nil, "id="+webhook.Id+", "+err.Error(), http.StatusInternalServerError)
}
return webhook, nil
}
func (s SqlCommandWebhookStore) Get(id string) store.StoreChannel {