GH-10617 SyncStore: GetIncomingByChannel to sync (#10633)

* GH-10617 GetIncomingByChannel to sync

* GH-10617 using async calls explicitly

* GH-10617 order of assignment change

* Update store.go

* Update store.go

* Update store.go

* GH-10617 fmt fix
Этот коммит содержится в:
Syerikjan Kh
2019-04-22 23:28:08 +08:00
коммит произвёл Jesse Hallam
родитель 99a8370742
Коммит 1e92646646
5 изменённых файлов: 49 добавлений и 19 удалений

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

@@ -4,9 +4,8 @@
package sqlstore
import (
"net/http"
"database/sql"
"net/http"
"github.com/mattermost/mattermost-server/einterfaces"
"github.com/mattermost/mattermost-server/model"
@@ -201,16 +200,14 @@ func (s SqlWebhookStore) GetIncomingByTeam(teamId string, offset, limit int) sto
})
}
func (s SqlWebhookStore) GetIncomingByChannel(channelId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
var webhooks []*model.IncomingWebhook
func (s SqlWebhookStore) GetIncomingByChannel(channelId string) ([]*model.IncomingWebhook, *model.AppError) {
var webhooks []*model.IncomingWebhook
if _, err := s.GetReplica().Select(&webhooks, "SELECT * FROM IncomingWebhooks WHERE ChannelId = :ChannelId AND DeleteAt = 0", map[string]interface{}{"ChannelId": channelId}); err != nil {
result.Err = model.NewAppError("SqlWebhookStore.GetIncomingByChannel", "store.sql_webhooks.get_incoming_by_channel.app_error", nil, "channelId="+channelId+", err="+err.Error(), http.StatusInternalServerError)
}
if _, err := s.GetReplica().Select(&webhooks, "SELECT * FROM IncomingWebhooks WHERE ChannelId = :ChannelId AND DeleteAt = 0", map[string]interface{}{"ChannelId": channelId}); err != nil {
return nil, model.NewAppError("SqlWebhookStore.GetIncomingByChannel", "store.sql_webhooks.get_incoming_by_channel.app_error", nil, "channelId="+channelId+", err="+err.Error(), http.StatusInternalServerError)
}
result.Data = webhooks
})
return webhooks, nil
}
func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) store.StoreChannel {