change UpdateOutgoing func signature to return OutgoingWebhook and fix formatting (#10710)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
caf0c0d375
Коммит
dc0441e28c
@@ -484,11 +484,7 @@ func (a *App) UpdateOutgoingWebhook(oldHook, updatedHook *model.OutgoingWebhook)
|
|||||||
updatedHook.TeamId = oldHook.TeamId
|
updatedHook.TeamId = oldHook.TeamId
|
||||||
updatedHook.UpdateAt = model.GetMillis()
|
updatedHook.UpdateAt = model.GetMillis()
|
||||||
|
|
||||||
if result = <-a.Srv.Store.Webhook().UpdateOutgoing(updatedHook); result.Err != nil {
|
return a.Srv.Store.Webhook().UpdateOutgoing(updatedHook)
|
||||||
return nil, result.Err
|
|
||||||
} else {
|
|
||||||
return result.Data.(*model.OutgoingWebhook), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetOutgoingWebhook(hookId string) (*model.OutgoingWebhook, *model.AppError) {
|
func (a *App) GetOutgoingWebhook(hookId string) (*model.OutgoingWebhook, *model.AppError) {
|
||||||
@@ -546,11 +542,7 @@ func (a *App) RegenOutgoingWebhookToken(hook *model.OutgoingWebhook) (*model.Out
|
|||||||
|
|
||||||
hook.Token = model.NewId()
|
hook.Token = model.NewId()
|
||||||
|
|
||||||
if result := <-a.Srv.Store.Webhook().UpdateOutgoing(hook); result.Err != nil {
|
return a.Srv.Store.Webhook().UpdateOutgoing(hook)
|
||||||
return nil, result.Err
|
|
||||||
} else {
|
|
||||||
return result.Data.(*model.OutgoingWebhook), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookRequest) *model.AppError {
|
func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookRequest) *model.AppError {
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ func moveChannel(a *app.App, team *model.Team, channel *model.Channel, user *mod
|
|||||||
for _, webhook := range outgoingWebhooks {
|
for _, webhook := range outgoingWebhooks {
|
||||||
if webhook.ChannelId == channel.Id {
|
if webhook.ChannelId == channel.Id {
|
||||||
webhook.TeamId = team.Id
|
webhook.TeamId = team.Id
|
||||||
if result := <-a.Srv.Store.Webhook().UpdateOutgoing(webhook); result.Err != nil {
|
if _, err := a.Srv.Store.Webhook().UpdateOutgoing(webhook); err != nil {
|
||||||
CommandPrintErrorln("Failed to move outgoing webhook '" + webhook.Id + "' to new team.")
|
CommandPrintErrorln("Failed to move outgoing webhook '" + webhook.Id + "' to new team.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,16 +311,14 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) *mod
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) store.StoreChannel {
|
func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
hook.UpdateAt = model.GetMillis()
|
||||||
hook.UpdateAt = model.GetMillis()
|
|
||||||
|
|
||||||
if _, err := s.GetMaster().Update(hook); err != nil {
|
if _, err := s.GetMaster().Update(hook); err != nil {
|
||||||
result.Err = model.NewAppError("SqlWebhookStore.UpdateOutgoing", "store.sql_webhooks.update_outgoing.app_error", nil, "id="+hook.Id+", "+err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SqlWebhookStore.UpdateOutgoing", "store.sql_webhooks.update_outgoing.app_error", nil, "id="+hook.Id+", "+err.Error(), http.StatusInternalServerError)
|
||||||
} else {
|
}
|
||||||
result.Data = hook
|
|
||||||
}
|
return hook, nil
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) AnalyticsIncomingCount(teamId string) (int64, *model.AppError) {
|
func (s SqlWebhookStore) AnalyticsIncomingCount(teamId string) (int64, *model.AppError) {
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ type WebhookStore interface {
|
|||||||
DeleteOutgoing(webhookId string, time int64) *model.AppError
|
DeleteOutgoing(webhookId string, time int64) *model.AppError
|
||||||
PermanentDeleteOutgoingByChannel(channelId string) *model.AppError
|
PermanentDeleteOutgoingByChannel(channelId string) *model.AppError
|
||||||
PermanentDeleteOutgoingByUser(userId string) StoreChannel
|
PermanentDeleteOutgoingByUser(userId string) StoreChannel
|
||||||
UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
|
UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||||
|
|
||||||
AnalyticsIncomingCount(teamId string) (int64, *model.AppError)
|
AnalyticsIncomingCount(teamId string) (int64, *model.AppError)
|
||||||
AnalyticsOutgoingCount(teamId string) StoreChannel
|
AnalyticsOutgoingCount(teamId string) StoreChannel
|
||||||
|
|||||||
@@ -416,17 +416,26 @@ func (_m *WebhookStore) UpdateIncoming(webhook *model.IncomingWebhook) (*model.I
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateOutgoing provides a mock function with given fields: hook
|
// UpdateOutgoing provides a mock function with given fields: hook
|
||||||
func (_m *WebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) store.StoreChannel {
|
func (_m *WebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError) {
|
||||||
ret := _m.Called(hook)
|
ret := _m.Called(hook)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.OutgoingWebhook
|
||||||
if rf, ok := ret.Get(0).(func(*model.OutgoingWebhook) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(*model.OutgoingWebhook) *model.OutgoingWebhook); ok {
|
||||||
r0 = rf(hook)
|
r0 = rf(hook)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.OutgoingWebhook)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(*model.OutgoingWebhook) *model.AppError); ok {
|
||||||
|
r1 = rf(hook)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -500,8 +500,8 @@ func testWebhookStoreUpdateOutgoing(t *testing.T, ss store.Store) {
|
|||||||
o1.Token = model.NewId()
|
o1.Token = model.NewId()
|
||||||
o1.Username = "another-test-user-name"
|
o1.Username = "another-test-user-name"
|
||||||
|
|
||||||
if r2 := <-ss.Webhook().UpdateOutgoing(o1); r2.Err != nil {
|
if _, err := ss.Webhook().UpdateOutgoing(o1); err != nil {
|
||||||
t.Fatal(r2.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user