mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
change UpdateOutgoing func signature to return OutgoingWebhook and fix formatting (#10710)
This commit is contained in:
committed by
Jesús Espino
parent
caf0c0d375
commit
dc0441e28c
@@ -484,11 +484,7 @@ func (a *App) UpdateOutgoingWebhook(oldHook, updatedHook *model.OutgoingWebhook)
|
||||
updatedHook.TeamId = oldHook.TeamId
|
||||
updatedHook.UpdateAt = model.GetMillis()
|
||||
|
||||
if result = <-a.Srv.Store.Webhook().UpdateOutgoing(updatedHook); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
return result.Data.(*model.OutgoingWebhook), nil
|
||||
}
|
||||
return a.Srv.Store.Webhook().UpdateOutgoing(updatedHook)
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
if result := <-a.Srv.Store.Webhook().UpdateOutgoing(hook); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
return result.Data.(*model.OutgoingWebhook), nil
|
||||
}
|
||||
return a.Srv.Store.Webhook().UpdateOutgoing(hook)
|
||||
}
|
||||
|
||||
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 {
|
||||
if webhook.ChannelId == channel.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.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,16 +311,14 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) *mod
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
hook.UpdateAt = model.GetMillis()
|
||||
func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError) {
|
||||
hook.UpdateAt = model.GetMillis()
|
||||
|
||||
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)
|
||||
} else {
|
||||
result.Data = hook
|
||||
}
|
||||
})
|
||||
if _, err := s.GetMaster().Update(hook); err != nil {
|
||||
return nil, model.NewAppError("SqlWebhookStore.UpdateOutgoing", "store.sql_webhooks.update_outgoing.app_error", nil, "id="+hook.Id+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return hook, nil
|
||||
}
|
||||
|
||||
func (s SqlWebhookStore) AnalyticsIncomingCount(teamId string) (int64, *model.AppError) {
|
||||
|
||||
@@ -395,7 +395,7 @@ type WebhookStore interface {
|
||||
DeleteOutgoing(webhookId string, time int64) *model.AppError
|
||||
PermanentDeleteOutgoingByChannel(channelId string) *model.AppError
|
||||
PermanentDeleteOutgoingByUser(userId string) StoreChannel
|
||||
UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
|
||||
UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||
|
||||
AnalyticsIncomingCount(teamId string) (int64, *model.AppError)
|
||||
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
|
||||
func (_m *WebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) store.StoreChannel {
|
||||
func (_m *WebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError) {
|
||||
ret := _m.Called(hook)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(*model.OutgoingWebhook) store.StoreChannel); ok {
|
||||
var r0 *model.OutgoingWebhook
|
||||
if rf, ok := ret.Get(0).(func(*model.OutgoingWebhook) *model.OutgoingWebhook); ok {
|
||||
r0 = rf(hook)
|
||||
} else {
|
||||
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.Username = "another-test-user-name"
|
||||
|
||||
if r2 := <-ss.Webhook().UpdateOutgoing(o1); r2.Err != nil {
|
||||
t.Fatal(r2.Err)
|
||||
if _, err := ss.Webhook().UpdateOutgoing(o1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user