MM-24135: Migrate AppError from SaveChannel/channel_store.go (#14299)
* MM-24135: Migrate AppError from SaveChannel/channel_store.go This is the first POC of migration of store app errors to plain error. We create a few basic error types in the store package and use them to return the errors from store methods. In the app layer, we inspect the error and re-create the exact app errors. This lets us preserve the same error content, but yet move to plain errors. Since this is a gradual migration, this means that the error inspection code will be duplicated across the app layer whenever a store method is invoked. But all of that should go away once we start propagating the errors higher up the hierarchy. There have been a significant amount of changes in the storetest and searchtest layer, primarily because we have to rename the err variable now that it is of a different type. * Addressed review comments * Made all appError origins to be CreateChannel * Remove typed internal error * Fix translations * fix layer generation Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
41e58d9769
Коммит
729a84a3e6
@@ -424,8 +424,8 @@ func TestGetChannelsForScheme(t *testing.T) {
|
|||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
SchemeId: &scheme1.Id,
|
SchemeId: &scheme1.Id,
|
||||||
}
|
}
|
||||||
channel2, err = th.App.Srv().Store.Channel().Save(channel2, 1000000)
|
channel2, nErr := th.App.Srv().Store.Channel().Save(channel2, 1000000)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, nErr)
|
||||||
|
|
||||||
l4, r4 := th.SystemAdminClient.GetChannelsForScheme(scheme1.Id, 0, 100)
|
l4, r4 := th.SystemAdminClient.GetChannelsForScheme(scheme1.Id, 0, 100)
|
||||||
CheckNoError(t, r4)
|
CheckNoError(t, r4)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -205,10 +206,31 @@ func (a *App) RenameChannel(channel *model.Channel, newChannelName string, newDi
|
|||||||
|
|
||||||
func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Channel, *model.AppError) {
|
func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Channel, *model.AppError) {
|
||||||
channel.DisplayName = strings.TrimSpace(channel.DisplayName)
|
channel.DisplayName = strings.TrimSpace(channel.DisplayName)
|
||||||
|
sc, nErr := a.Srv().Store.Channel().Save(channel, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
||||||
sc, err := a.Srv().Store.Channel().Save(channel, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
if nErr != nil {
|
||||||
if err != nil {
|
var invErr *store.ErrInvalidInput
|
||||||
return nil, err
|
var cErr *store.ErrConflict
|
||||||
|
var ltErr *store.ErrLimitExceeded
|
||||||
|
var appErr *model.AppError
|
||||||
|
switch {
|
||||||
|
case errors.As(nErr, &invErr):
|
||||||
|
switch {
|
||||||
|
case invErr.Entity == "Channel" && invErr.Field == "DeleteAt":
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save.archived_channel.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
case invErr.Entity == "Channel" && invErr.Field == "Type":
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save.direct_channel.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
case invErr.Entity == "Channel" && invErr.Field == "Id":
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save_channel.existing.app_error", nil, "id="+invErr.Value.(string), http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
case errors.As(nErr, &cErr):
|
||||||
|
return channel, model.NewAppError("CreateChannel", store.CHANNEL_EXISTS_ERROR, nil, cErr.Error(), http.StatusBadRequest)
|
||||||
|
case errors.As(nErr, <Err):
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save_channel.limit.app_error", nil, ltErr.Error(), http.StatusBadRequest)
|
||||||
|
case errors.As(nErr, &appErr): // in case we haven't converted to plain error.
|
||||||
|
return nil, appErr
|
||||||
|
default: // last fallback in case it doesn't map to an existing app error.
|
||||||
|
return nil, model.NewAppError("CreateChannel", "app.channel.create_channel.internal_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if addMember {
|
if addMember {
|
||||||
@@ -407,12 +429,31 @@ func (a *App) createGroupChannel(userIds []string, creatorId string) (*model.Cha
|
|||||||
Type: model.CHANNEL_GROUP,
|
Type: model.CHANNEL_GROUP,
|
||||||
}
|
}
|
||||||
|
|
||||||
channel, err := a.Srv().Store.Channel().Save(group, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
channel, nErr := a.Srv().Store.Channel().Save(group, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
||||||
if err != nil {
|
if nErr != nil {
|
||||||
if err.Id == store.CHANNEL_EXISTS_ERROR {
|
var invErr *store.ErrInvalidInput
|
||||||
return channel, err
|
var cErr *store.ErrConflict
|
||||||
|
var ltErr *store.ErrLimitExceeded
|
||||||
|
var appErr *model.AppError
|
||||||
|
switch {
|
||||||
|
case errors.As(nErr, &invErr):
|
||||||
|
switch {
|
||||||
|
case invErr.Entity == "Channel" && invErr.Field == "DeleteAt":
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save.archived_channel.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
case invErr.Entity == "Channel" && invErr.Field == "Type":
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save.direct_channel.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
case invErr.Entity == "Channel" && invErr.Field == "Id":
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save_channel.existing.app_error", nil, "id="+invErr.Value.(string), http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
case errors.As(nErr, &cErr):
|
||||||
|
return channel, model.NewAppError("CreateChannel", store.CHANNEL_EXISTS_ERROR, nil, cErr.Error(), http.StatusBadRequest)
|
||||||
|
case errors.As(nErr, <Err):
|
||||||
|
return nil, model.NewAppError("CreateChannel", "store.sql_channel.save_channel.limit.app_error", nil, ltErr.Error(), http.StatusBadRequest)
|
||||||
|
case errors.As(nErr, &appErr): // in case we haven't converted to plain error.
|
||||||
|
return nil, appErr
|
||||||
|
default: // last fallback in case it doesn't map to an existing app error.
|
||||||
|
return nil, model.NewAppError("CreateChannel", "app.channel.create_channel.internal_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
|
|||||||
28
i18n/en.json
28
i18n/en.json
@@ -2930,6 +2930,10 @@
|
|||||||
"id": "app.bot.get_disable_bot_sysadmin_message",
|
"id": "app.bot.get_disable_bot_sysadmin_message",
|
||||||
"translation": "{{if .disableBotsSetting}}{{if .printAllBots}}{{.UserName}} was deactivated. They managed the following bot accounts which have now been disabled.\n\n{{.BotNames}}{{else}}{{.UserName}} was deactivated. They managed {{.NumBots}} bot accounts which have now been disabled, including the following:\n\n{{.BotNames}}{{end}}You can take ownership of each bot by enabling it at **Integrations > Bot Accounts** and creating new tokens for the bot.\n\nFor more information, see our [documentation](https://docs.mattermost.com/developer/bot-accounts.html#what-happens-when-a-user-who-owns-bot-accounts-is-disabled).{{else}}{{if .printAllBots}}{{.UserName}} was deactivated. They managed the following bot accounts which are still enabled.\n\n{{.BotNames}}\n{{else}}{{.UserName}} was deactivated. They managed {{.NumBots}} bot accounts which are still enabled, including the following:\n\n{{.BotNames}}{{end}}We strongly recommend you to take ownership of each bot by re-enabling it at **Integrations > Bot Accounts** and creating new tokens for the bot.\n\nFor more information, see our [documentation](https://docs.mattermost.com/developer/bot-accounts.html#what-happens-when-a-user-who-owns-bot-accounts-is-disabled).\n\nIf you want bot accounts to disable automatically after owner deactivation, set “Disable bot accounts when owner is deactivated” in **System Console > Integrations > Bot Accounts** to true.{{end}}"
|
"translation": "{{if .disableBotsSetting}}{{if .printAllBots}}{{.UserName}} was deactivated. They managed the following bot accounts which have now been disabled.\n\n{{.BotNames}}{{else}}{{.UserName}} was deactivated. They managed {{.NumBots}} bot accounts which have now been disabled, including the following:\n\n{{.BotNames}}{{end}}You can take ownership of each bot by enabling it at **Integrations > Bot Accounts** and creating new tokens for the bot.\n\nFor more information, see our [documentation](https://docs.mattermost.com/developer/bot-accounts.html#what-happens-when-a-user-who-owns-bot-accounts-is-disabled).{{else}}{{if .printAllBots}}{{.UserName}} was deactivated. They managed the following bot accounts which are still enabled.\n\n{{.BotNames}}\n{{else}}{{.UserName}} was deactivated. They managed {{.NumBots}} bot accounts which are still enabled, including the following:\n\n{{.BotNames}}{{end}}We strongly recommend you to take ownership of each bot by re-enabling it at **Integrations > Bot Accounts** and creating new tokens for the bot.\n\nFor more information, see our [documentation](https://docs.mattermost.com/developer/bot-accounts.html#what-happens-when-a-user-who-owns-bot-accounts-is-disabled).\n\nIf you want bot accounts to disable automatically after owner deactivation, set “Disable bot accounts when owner is deactivated” in **System Console > Integrations > Bot Accounts** to true.{{end}}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "app.channel.create_channel.internal_error",
|
||||||
|
"translation": "Unable to save channel."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "app.channel.create_channel.no_team_id.app_error",
|
"id": "app.channel.create_channel.no_team_id.app_error",
|
||||||
"translation": "Must specify the team ID to create a channel."
|
"translation": "Must specify the team ID to create a channel."
|
||||||
@@ -6042,26 +6046,10 @@
|
|||||||
"id": "store.sql_channel.save.archived_channel.app_error",
|
"id": "store.sql_channel.save.archived_channel.app_error",
|
||||||
"translation": "You can not modify an archived channel."
|
"translation": "You can not modify an archived channel."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "store.sql_channel.save.commit_transaction.app_error",
|
|
||||||
"translation": "Unable to commit transaction."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "store.sql_channel.save.direct_channel.app_error",
|
"id": "store.sql_channel.save.direct_channel.app_error",
|
||||||
"translation": "Use SaveDirectChannel to create a direct channel."
|
"translation": "Use SaveDirectChannel to create a direct channel."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "store.sql_channel.save.open_transaction.app_error",
|
|
||||||
"translation": "Unable to open transaction."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "store.sql_channel.save.upsert_public_channel.app_error",
|
|
||||||
"translation": "Unable to upsert materialized public channel."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "store.sql_channel.save_channel.current_count.app_error",
|
|
||||||
"translation": "Failed to get current channel count."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "store.sql_channel.save_channel.existing.app_error",
|
"id": "store.sql_channel.save_channel.existing.app_error",
|
||||||
"translation": "Must call update for existing channel."
|
"translation": "Must call update for existing channel."
|
||||||
@@ -6074,10 +6062,6 @@
|
|||||||
"id": "store.sql_channel.save_channel.limit.app_error",
|
"id": "store.sql_channel.save_channel.limit.app_error",
|
||||||
"translation": "You've reached the limit of the number of allowed channels."
|
"translation": "You've reached the limit of the number of allowed channels."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "store.sql_channel.save_channel.save.app_error",
|
|
||||||
"translation": "Unable to save the channel."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "store.sql_channel.save_direct_channel.add_members.app_error",
|
"id": "store.sql_channel.save_direct_channel.add_members.app_error",
|
||||||
"translation": "Unable to add direct channel members."
|
"translation": "Unable to add direct channel members."
|
||||||
@@ -6086,6 +6070,10 @@
|
|||||||
"id": "store.sql_channel.save_direct_channel.commit.app_error",
|
"id": "store.sql_channel.save_direct_channel.commit.app_error",
|
||||||
"translation": "Unable to commit transaction."
|
"translation": "Unable to commit transaction."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "store.sql_channel.save_direct_channel.internal_error",
|
||||||
|
"translation": "Unable to save direct channel."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "store.sql_channel.save_direct_channel.not_direct.app_error",
|
"id": "store.sql_channel.save_direct_channel.not_direct.app_error",
|
||||||
"translation": "Not a direct channel attempted to be created with SaveDirectChannel."
|
"translation": "Not a direct channel attempted to be created with SaveDirectChannel."
|
||||||
|
|||||||
73
store/errors.go
Обычный файл
73
store/errors.go
Обычный файл
@@ -0,0 +1,73 @@
|
|||||||
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
package store
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ErrInvalidInput indicates an error that has occured due to an invalid input.
|
||||||
|
type ErrInvalidInput struct {
|
||||||
|
Entity string // The entity which was sent as the input.
|
||||||
|
Field string // The field of the entity which was invalid.
|
||||||
|
Value interface{} // The actual value of the field.
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrInvalidInput(entity, field string, value interface{}) *ErrInvalidInput {
|
||||||
|
return &ErrInvalidInput{
|
||||||
|
Entity: entity,
|
||||||
|
Field: field,
|
||||||
|
Value: value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ErrInvalidInput) Error() string {
|
||||||
|
return fmt.Sprintf("invalid input: entity: %s field: %s value: %s", e.Entity, e.Field, e.Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrLimitExceeded indicates an error that has occured because some value exceeded a limit.
|
||||||
|
type ErrLimitExceeded struct {
|
||||||
|
What string // What was the object that exceeded.
|
||||||
|
Count int // The value of the object.
|
||||||
|
meta string // Any additional metadata.
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrLimitExceeded(what string, count int, meta string) *ErrLimitExceeded {
|
||||||
|
return &ErrLimitExceeded{
|
||||||
|
What: what,
|
||||||
|
Count: count,
|
||||||
|
meta: meta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ErrLimitExceeded) Error() string {
|
||||||
|
return fmt.Sprintf("limit exceeded: what: %s count: %d metadata: %s", e.What, e.Count, e.meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrConflict indicates a conflict that occured.
|
||||||
|
type ErrConflict struct {
|
||||||
|
Resource string // The resource which created the conflict.
|
||||||
|
err error // Internal error.
|
||||||
|
meta string // Any additional metadata.
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrConflict(resource string, err error, meta string) *ErrConflict {
|
||||||
|
return &ErrConflict{
|
||||||
|
Resource: resource,
|
||||||
|
err: err,
|
||||||
|
meta: meta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ErrConflict) Error() string {
|
||||||
|
return e.Resource + "exists " + e.meta + " " + e.err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ErrConflict) Unwrap() error {
|
||||||
|
return e.err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// type ErrNotFound struct {
|
||||||
|
// }
|
||||||
@@ -1665,7 +1665,7 @@ func (s *OpenTracingLayerChannelStore) Restore(channelId string, time int64) *mo
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, *model.AppError) {
|
func (s *OpenTracingLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.Save")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.Save")
|
||||||
s.Root.Store.SetContext(newCtx)
|
s.Root.Store.SetContext(newCtx)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (c *SearchChannelStore) indexChannel(channel *model.Channel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SearchChannelStore) Save(channel *model.Channel, maxChannels int64) (*model.Channel, *model.AppError) {
|
func (c *SearchChannelStore) Save(channel *model.Channel, maxChannels int64) (*model.Channel, error) {
|
||||||
newChannel, err := c.ChannelStore.Save(channel, maxChannels)
|
newChannel, err := c.ChannelStore.Save(channel, maxChannels)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
c.indexChannel(newChannel)
|
c.indexChannel(newChannel)
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ func testAutocompleteChannelByNameSplittedWithUnderscoreChar(t *testing.T, th *S
|
|||||||
func testAutocompleteChannelByDisplayNameSplittedByWhitespaces(t *testing.T, th *SearchTestHelper) {
|
func testAutocompleteChannelByDisplayNameSplittedByWhitespaces(t *testing.T, th *SearchTestHelper) {
|
||||||
alternate, err := th.createChannel(th.Team.Id, "channel-alternate", "Channel Alternate", "", model.CHANNEL_OPEN, false)
|
alternate, err := th.createChannel(th.Team.Id, "channel-alternate", "Channel Alternate", "", model.CHANNEL_OPEN, false)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
defer th.deleteChannel(alternate)
|
defer th.deleteChannel(alternate)
|
||||||
res, apperr := th.Store.Channel().AutocompleteInTeam(th.Team.Id, "Channel A", false)
|
res, apperr := th.Store.Channel().AutocompleteInTeam(th.Team.Id, "Channel A", false)
|
||||||
require.Nil(t, apperr)
|
require.Nil(t, apperr)
|
||||||
|
|||||||
@@ -502,35 +502,33 @@ func (s SqlChannelStore) upsertPublicChannelT(transaction *gorp.Transaction, cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save writes the (non-direct) channel channel to the database.
|
// Save writes the (non-direct) channel channel to the database.
|
||||||
func (s SqlChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, *model.AppError) {
|
func (s SqlChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
|
||||||
|
|
||||||
if channel.DeleteAt != 0 {
|
if channel.DeleteAt != 0 {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save.archived_channel.app_error", nil, "", http.StatusBadRequest)
|
return nil, store.NewErrInvalidInput("Channel", "DeleteAt", channel.DeleteAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if channel.Type == model.CHANNEL_DIRECT {
|
if channel.Type == model.CHANNEL_DIRECT {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save.direct_channel.app_error", nil, "", http.StatusBadRequest)
|
return nil, store.NewErrInvalidInput("Channel", "Type", channel.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction, err := s.GetMaster().Begin()
|
transaction, err := s.GetMaster().Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, errors.Wrapf(err, "begin_transaction: ")
|
||||||
}
|
}
|
||||||
defer finalizeTransaction(transaction)
|
defer finalizeTransaction(transaction)
|
||||||
|
|
||||||
newChannel, appErr := s.saveChannelT(transaction, channel, maxChannelsPerTeam)
|
newChannel, err := s.saveChannelT(transaction, channel, maxChannelsPerTeam)
|
||||||
if appErr != nil {
|
if err != nil {
|
||||||
return newChannel, appErr
|
return newChannel, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additionally propagate the write to the PublicChannels table.
|
// Additionally propagate the write to the PublicChannels table.
|
||||||
if err := s.upsertPublicChannelT(transaction, newChannel); err != nil {
|
if err := s.upsertPublicChannelT(transaction, newChannel); err != nil {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save.upsert_public_channel.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, errors.Wrapf(err, "upsert_public_channel: ")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := transaction.Commit(); err != nil {
|
if err := transaction.Commit(); err != nil {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, errors.Wrapf(err, "commit_transaction: ")
|
||||||
}
|
}
|
||||||
|
|
||||||
return newChannel, nil
|
return newChannel, nil
|
||||||
@@ -577,9 +575,39 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1
|
|||||||
defer finalizeTransaction(transaction)
|
defer finalizeTransaction(transaction)
|
||||||
|
|
||||||
directchannel.TeamId = ""
|
directchannel.TeamId = ""
|
||||||
newChannel, appErr := s.saveChannelT(transaction, directchannel, 0)
|
newChannel, err := s.saveChannelT(transaction, directchannel, 0)
|
||||||
if appErr != nil {
|
if err != nil {
|
||||||
return newChannel, appErr
|
// TODO: This will go away once SaveDirectChannel returns error
|
||||||
|
var invErr *store.ErrInvalidInput
|
||||||
|
var cErr *store.ErrConflict
|
||||||
|
var ltErr *store.ErrLimitExceeded
|
||||||
|
var appErr *model.AppError
|
||||||
|
if errors.As(err, &invErr) {
|
||||||
|
if invErr.Entity == "Channel" && invErr.Field == "DeleteAt" {
|
||||||
|
return newChannel, model.NewAppError("CreateChannel", "store.sql_channel.save.archived_channel.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
if invErr.Entity == "Channel" && invErr.Field == "Type" {
|
||||||
|
return newChannel, model.NewAppError("CreateChannel", "store.sql_channel.save.direct_channel.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
if invErr.Entity == "Channel" && invErr.Field == "Id" {
|
||||||
|
return newChannel, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.existing.app_error", nil, "id="+invErr.Value.(string), http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errors.As(err, &cErr) {
|
||||||
|
if cErr.Resource == "Channel" {
|
||||||
|
return newChannel, model.NewAppError("CreateChannel", store.CHANNEL_EXISTS_ERROR, nil, cErr.Error(), http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errors.As(err, <Err) {
|
||||||
|
if ltErr.What == "channels_per_team" {
|
||||||
|
return newChannel, model.NewAppError("CreateChannel", "store.sql_channel.save_channel.limit.app_error", nil, ltErr.Error(), http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errors.As(err, &appErr) {
|
||||||
|
return nil, appErr
|
||||||
|
} else {
|
||||||
|
return nil, model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Members need new channel ID
|
// Members need new channel ID
|
||||||
@@ -605,21 +633,21 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, *model.AppError) {
|
func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
|
||||||
if len(channel.Id) > 0 {
|
if len(channel.Id) > 0 {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.existing.app_error", nil, "id="+channel.Id, http.StatusBadRequest)
|
return nil, store.NewErrInvalidInput("Channel", "Id", channel.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.PreSave()
|
channel.PreSave()
|
||||||
if err := channel.IsValid(); err != nil {
|
if err := channel.IsValid(); err != nil { // TODO: this needs to return plain error
|
||||||
return nil, err
|
return nil, err // we just pass through the error as-is for now.
|
||||||
}
|
}
|
||||||
|
|
||||||
if channel.Type != model.CHANNEL_DIRECT && channel.Type != model.CHANNEL_GROUP && maxChannelsPerTeam >= 0 {
|
if channel.Type != model.CHANNEL_DIRECT && channel.Type != model.CHANNEL_GROUP && maxChannelsPerTeam >= 0 {
|
||||||
if count, err := transaction.SelectInt("SELECT COUNT(0) FROM Channels WHERE TeamId = :TeamId AND DeleteAt = 0 AND (Type = 'O' OR Type = 'P')", map[string]interface{}{"TeamId": channel.TeamId}); err != nil {
|
if count, err := transaction.SelectInt("SELECT COUNT(0) FROM Channels WHERE TeamId = :TeamId AND DeleteAt = 0 AND (Type = 'O' OR Type = 'P')", map[string]interface{}{"TeamId": channel.TeamId}); err != nil {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.current_count.app_error", nil, "teamId="+channel.TeamId+", "+err.Error(), http.StatusInternalServerError)
|
return nil, errors.Wrapf(err, "save_channel_count: teamId=%s", channel.TeamId)
|
||||||
} else if count >= maxChannelsPerTeam {
|
} else if count >= maxChannelsPerTeam {
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.limit.app_error", nil, "teamId="+channel.TeamId, http.StatusBadRequest)
|
return nil, store.NewErrLimitExceeded("channels_per_team", int(count), "teamId="+channel.TeamId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,9 +655,9 @@ func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *mo
|
|||||||
if IsUniqueConstraintError(err, []string{"Name", "channels_name_teamid_key"}) {
|
if IsUniqueConstraintError(err, []string{"Name", "channels_name_teamid_key"}) {
|
||||||
dupChannel := model.Channel{}
|
dupChannel := model.Channel{}
|
||||||
s.GetMaster().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name = :Name", map[string]interface{}{"TeamId": channel.TeamId, "Name": channel.Name})
|
s.GetMaster().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name = :Name", map[string]interface{}{"TeamId": channel.TeamId, "Name": channel.Name})
|
||||||
return &dupChannel, model.NewAppError("SqlChannelStore.Save", store.CHANNEL_EXISTS_ERROR, nil, "id="+channel.Id+", "+err.Error(), http.StatusBadRequest)
|
return &dupChannel, store.NewErrConflict("Channel", err, "id="+channel.Id)
|
||||||
}
|
}
|
||||||
return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save_channel.save.app_error", nil, "id="+channel.Id+", "+err.Error(), http.StatusInternalServerError)
|
return nil, errors.Wrapf(err, "save_channel: id=%s", channel.Id)
|
||||||
}
|
}
|
||||||
return channel, nil
|
return channel, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ type TeamStore interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ChannelStore interface {
|
type ChannelStore interface {
|
||||||
Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, *model.AppError)
|
Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error)
|
||||||
CreateDirectChannel(userId *model.User, otherUserId *model.User) (*model.Channel, *model.AppError)
|
CreateDirectChannel(userId *model.User, otherUserId *model.User) (*model.Channel, *model.AppError)
|
||||||
SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, *model.AppError)
|
SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, *model.AppError)
|
||||||
Update(channel *model.Channel) (*model.Channel, *model.AppError)
|
Update(channel *model.Channel) (*model.Channel, *model.AppError)
|
||||||
|
|||||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -127,8 +127,8 @@ func testComplianceExport(t *testing.T, ss store.Store) {
|
|||||||
c1.DisplayName = "Channel2"
|
c1.DisplayName = "Channel2"
|
||||||
c1.Name = "zz" + model.NewId() + "b"
|
c1.Name = "zz" + model.NewId() + "b"
|
||||||
c1.Type = model.CHANNEL_OPEN
|
c1.Type = model.CHANNEL_OPEN
|
||||||
c1, err = ss.Channel().Save(c1, -1)
|
c1, nErr := ss.Channel().Save(c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
o1 := &model.Post{}
|
o1 := &model.Post{}
|
||||||
o1.ChannelId = c1.Id
|
o1.ChannelId = c1.Id
|
||||||
@@ -236,8 +236,8 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) {
|
|||||||
c1.DisplayName = "Channel2"
|
c1.DisplayName = "Channel2"
|
||||||
c1.Name = "zz" + model.NewId() + "b"
|
c1.Name = "zz" + model.NewId() + "b"
|
||||||
c1.Type = model.CHANNEL_OPEN
|
c1.Type = model.CHANNEL_OPEN
|
||||||
c1, err = ss.Channel().Save(c1, -1)
|
c1, nErr := ss.Channel().Save(c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
cDM, err := ss.Channel().CreateDirectChannel(u1, u2)
|
cDM, err := ss.Channel().CreateDirectChannel(u1, u2)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -342,8 +342,8 @@ func testMessageExportPublicChannel(t *testing.T, ss store.Store) {
|
|||||||
DisplayName: "Public Channel",
|
DisplayName: "Public Channel",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, -1)
|
channel, nErr := ss.Channel().Save(channel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// user1 posts twice in the public channel
|
// user1 posts twice in the public channel
|
||||||
post1 := &model.Post{
|
post1 := &model.Post{
|
||||||
@@ -446,8 +446,8 @@ func testMessageExportPrivateChannel(t *testing.T, ss store.Store) {
|
|||||||
DisplayName: "Private Channel",
|
DisplayName: "Private Channel",
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, -1)
|
channel, nErr := ss.Channel().Save(channel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// user1 posts twice in the private channel
|
// user1 posts twice in the private channel
|
||||||
post1 := &model.Post{
|
post1 := &model.Post{
|
||||||
@@ -644,8 +644,8 @@ func testMessageExportGroupMessageChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_GROUP,
|
Type: model.CHANNEL_GROUP,
|
||||||
}
|
}
|
||||||
groupMessageChannel, err = ss.Channel().Save(groupMessageChannel, -1)
|
groupMessageChannel, nErr := ss.Channel().Save(groupMessageChannel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// user1 posts in the GM
|
// user1 posts in the GM
|
||||||
post := &model.Post{
|
post := &model.Post{
|
||||||
@@ -718,8 +718,8 @@ func testEditExportMessage(t *testing.T, ss store.Store) {
|
|||||||
DisplayName: "Public Channel",
|
DisplayName: "Public Channel",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, -1)
|
channel, nErr := ss.Channel().Save(channel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// user1 posts in the public channel
|
// user1 posts in the public channel
|
||||||
post1 := &model.Post{
|
post1 := &model.Post{
|
||||||
@@ -811,8 +811,8 @@ func testEditAfterExportMessage(t *testing.T, ss store.Store) {
|
|||||||
DisplayName: "Public Channel",
|
DisplayName: "Public Channel",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, -1)
|
channel, nErr := ss.Channel().Save(channel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// user1 posts in the public channel
|
// user1 posts in the public channel
|
||||||
post1 := &model.Post{
|
post1 := &model.Post{
|
||||||
@@ -923,8 +923,8 @@ func testDeleteExportMessage(t *testing.T, ss store.Store) {
|
|||||||
DisplayName: "Public Channel",
|
DisplayName: "Public Channel",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, -1)
|
channel, nErr := ss.Channel().Save(channel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// user1 posts in the public channel
|
// user1 posts in the public channel
|
||||||
post1 := &model.Post{
|
post1 := &model.Post{
|
||||||
@@ -1008,8 +1008,8 @@ func testDeleteAfterExportMessage(t *testing.T, ss store.Store) {
|
|||||||
DisplayName: "Public Channel",
|
DisplayName: "Public Channel",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, -1)
|
channel, nErr := ss.Channel().Save(channel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// user1 posts in the public channel
|
// user1 posts in the public channel
|
||||||
post1 := &model.Post{
|
post1 := &model.Post{
|
||||||
|
|||||||
@@ -847,8 +847,8 @@ func testGroupGetMemberUsersNotInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN, // Query does not look at type so this shouldn't matter.
|
Type: model.CHANNEL_OPEN, // Query does not look at type so this shouldn't matter.
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, 9999)
|
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// returns no members when channel does not exist
|
// returns no members when channel does not exist
|
||||||
groupMembers, err := ss.Group().GetMemberUsersNotInChannel(group.Id, "non-existant-channel-id")
|
groupMembers, err := ss.Group().GetMemberUsersNotInChannel(group.Id, "non-existant-channel-id")
|
||||||
@@ -1606,8 +1606,8 @@ func testChannelMembersToAdd(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN, // Query does not look at type so this shouldn't matter.
|
Type: model.CHANNEL_OPEN, // Query does not look at type so this shouldn't matter.
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, 9999)
|
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// Create GroupChannel
|
// Create GroupChannel
|
||||||
syncable, err := ss.Group().CreateGroupSyncable(model.NewGroupChannel(group.Id, channel.Id, true))
|
syncable, err := ss.Group().CreateGroupSyncable(model.NewGroupChannel(group.Id, channel.Id, true))
|
||||||
@@ -1796,16 +1796,16 @@ func testChannelMembersToAddSingleChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "z-z-" + model.NewId() + "a",
|
Name: "z-z-" + model.NewId() + "a",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel1, err = ss.Channel().Save(channel1, 999)
|
channel1, nErr := ss.Channel().Save(channel1, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
channel2 := &model.Channel{
|
channel2 := &model.Channel{
|
||||||
DisplayName: "Name",
|
DisplayName: "Name",
|
||||||
Name: "z-z-" + model.NewId() + "a",
|
Name: "z-z-" + model.NewId() + "a",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel2, err = ss.Channel().Save(channel2, 999)
|
channel2, nErr = ss.Channel().Save(channel2, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Group().CreateGroupSyncable(model.NewGroupChannel(group1.Id, channel1.Id, true))
|
_, err = ss.Group().CreateGroupSyncable(model.NewGroupChannel(group1.Id, channel1.Id, true))
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -2081,8 +2081,8 @@ func testChannelMembersToRemoveSingleChannel(t *testing.T, ss store.Store) {
|
|||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
GroupConstrained: model.NewBool(true),
|
GroupConstrained: model.NewBool(true),
|
||||||
}
|
}
|
||||||
channel1, err = ss.Channel().Save(channel1, 999)
|
channel1, nErr := ss.Channel().Save(channel1, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
channel2 := &model.Channel{
|
channel2 := &model.Channel{
|
||||||
DisplayName: "Name",
|
DisplayName: "Name",
|
||||||
@@ -2090,8 +2090,8 @@ func testChannelMembersToRemoveSingleChannel(t *testing.T, ss store.Store) {
|
|||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
GroupConstrained: model.NewBool(true),
|
GroupConstrained: model.NewBool(true),
|
||||||
}
|
}
|
||||||
channel2, err = ss.Channel().Save(channel2, 999)
|
channel2, nErr = ss.Channel().Save(channel2, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
for _, user := range []*model.User{user1, user2} {
|
for _, user := range []*model.User{user1, user2} {
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
@@ -2183,8 +2183,8 @@ func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData
|
|||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
GroupConstrained: model.NewBool(true),
|
GroupConstrained: model.NewBool(true),
|
||||||
}
|
}
|
||||||
channelConstrained, err = ss.Channel().Save(channelConstrained, 9999)
|
channelConstrained, nErr := ss.Channel().Save(channelConstrained, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
channelUnconstrained := &model.Channel{
|
channelUnconstrained := &model.Channel{
|
||||||
TeamId: model.NewId(),
|
TeamId: model.NewId(),
|
||||||
@@ -2192,8 +2192,8 @@ func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
channelUnconstrained, err = ss.Channel().Save(channelUnconstrained, 9999)
|
channelUnconstrained, nErr = ss.Channel().Save(channelUnconstrained, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// create teams
|
// create teams
|
||||||
teamConstrained := &model.Team{
|
teamConstrained := &model.Team{
|
||||||
@@ -2344,8 +2344,8 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel2, err = ss.Channel().Save(channel2, 9999)
|
channel2, nErr := ss.Channel().Save(channel2, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// Create Group3
|
// Create Group3
|
||||||
group3, err := ss.Group().Create(&model.Group{
|
group3, err := ss.Group().Create(&model.Group{
|
||||||
@@ -3033,8 +3033,8 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
channel1, err = ss.Channel().Save(channel1, 9999)
|
channel1, nErr := ss.Channel().Save(channel1, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// Create Groups 1 and 2
|
// Create Groups 1 and 2
|
||||||
group1, err := ss.Group().Create(&model.Group{
|
group1, err := ss.Group().Create(&model.Group{
|
||||||
@@ -3097,8 +3097,8 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
channel2, err = ss.Channel().Save(channel2, 9999)
|
channel2, nErr = ss.Channel().Save(channel2, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
// Create Group3
|
// Create Group3
|
||||||
group3, err := ss.Group().Create(&model.Group{
|
group3, err := ss.Group().Create(&model.Group{
|
||||||
@@ -3761,8 +3761,8 @@ func groupTestAdminRoleGroupsForSyncableMemberChannel(t *testing.T, ss store.Sto
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, 9999)
|
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
_, err = ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||||
AutoAdd: true,
|
AutoAdd: true,
|
||||||
@@ -4058,8 +4058,8 @@ func groupTestPermittedSyncableAdminsChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, 9999)
|
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
_, err = ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||||
AutoAdd: true,
|
AutoAdd: true,
|
||||||
|
|||||||
@@ -1424,7 +1424,7 @@ func (_m *ChannelStore) Restore(channelId string, time int64) *model.AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save provides a mock function with given fields: channel, maxChannelsPerTeam
|
// Save provides a mock function with given fields: channel, maxChannelsPerTeam
|
||||||
func (_m *ChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, *model.AppError) {
|
func (_m *ChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
|
||||||
ret := _m.Called(channel, maxChannelsPerTeam)
|
ret := _m.Called(channel, maxChannelsPerTeam)
|
||||||
|
|
||||||
var r0 *model.Channel
|
var r0 *model.Channel
|
||||||
@@ -1436,13 +1436,11 @@ func (_m *ChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var r1 *model.AppError
|
var r1 error
|
||||||
if rf, ok := ret.Get(1).(func(*model.Channel, int64) *model.AppError); ok {
|
if rf, ok := ret.Get(1).(func(*model.Channel, int64) error); ok {
|
||||||
r1 = rf(channel, maxChannelsPerTeam)
|
r1 = rf(channel, maxChannelsPerTeam)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(1) != nil {
|
r1 = ret.Error(1)
|
||||||
r1 = ret.Get(1).(*model.AppError)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0, r1
|
return r0, r1
|
||||||
|
|||||||
@@ -1445,8 +1445,8 @@ func testUserCountsWithPostsByDay(t *testing.T, ss store.Store) {
|
|||||||
c1.DisplayName = "Channel2"
|
c1.DisplayName = "Channel2"
|
||||||
c1.Name = "zz" + model.NewId() + "b"
|
c1.Name = "zz" + model.NewId() + "b"
|
||||||
c1.Type = model.CHANNEL_OPEN
|
c1.Type = model.CHANNEL_OPEN
|
||||||
c1, err = ss.Channel().Save(c1, -1)
|
c1, nErr := ss.Channel().Save(c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
o1 := &model.Post{}
|
o1 := &model.Post{}
|
||||||
o1.ChannelId = c1.Id
|
o1.ChannelId = c1.Id
|
||||||
@@ -1504,8 +1504,8 @@ func testPostCountsByDay(t *testing.T, ss store.Store) {
|
|||||||
c1.DisplayName = "Channel2"
|
c1.DisplayName = "Channel2"
|
||||||
c1.Name = "zz" + model.NewId() + "b"
|
c1.Name = "zz" + model.NewId() + "b"
|
||||||
c1.Type = model.CHANNEL_OPEN
|
c1.Type = model.CHANNEL_OPEN
|
||||||
c1, err = ss.Channel().Save(c1, -1)
|
c1, nErr := ss.Channel().Save(c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
o1 := &model.Post{}
|
o1 := &model.Post{}
|
||||||
o1.ChannelId = c1.Id
|
o1.ChannelId = c1.Id
|
||||||
@@ -2415,8 +2415,8 @@ func testPostStoreGetParentsForExportAfter(t *testing.T, ss store.Store) {
|
|||||||
c1.DisplayName = "Channel1"
|
c1.DisplayName = "Channel1"
|
||||||
c1.Name = "zz" + model.NewId() + "b"
|
c1.Name = "zz" + model.NewId() + "b"
|
||||||
c1.Type = model.CHANNEL_OPEN
|
c1.Type = model.CHANNEL_OPEN
|
||||||
_, err = ss.Channel().Save(&c1, -1)
|
_, nErr := ss.Channel().Save(&c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
u1 := model.User{}
|
u1 := model.User{}
|
||||||
u1.Username = model.NewId()
|
u1.Username = model.NewId()
|
||||||
@@ -2464,8 +2464,8 @@ func testPostStoreGetRepliesForExport(t *testing.T, ss store.Store) {
|
|||||||
c1.DisplayName = "Channel1"
|
c1.DisplayName = "Channel1"
|
||||||
c1.Name = "zz" + model.NewId() + "b"
|
c1.Name = "zz" + model.NewId() + "b"
|
||||||
c1.Type = model.CHANNEL_OPEN
|
c1.Type = model.CHANNEL_OPEN
|
||||||
_, err = ss.Channel().Save(&c1, -1)
|
_, nErr := ss.Channel().Save(&c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
u1 := model.User{}
|
u1 := model.User{}
|
||||||
u1.Email = MakeEmail()
|
u1.Email = MakeEmail()
|
||||||
|
|||||||
@@ -432,8 +432,8 @@ func testRoleStoreLowerScopedChannelSchemeRoles(t *testing.T, ss store.Store) {
|
|||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
SchemeId: &channelScheme1.Id,
|
SchemeId: &channelScheme1.Id,
|
||||||
}
|
}
|
||||||
channel1, err = ss.Channel().Save(channel1, -1)
|
channel1, nErr := ss.Channel().Save(channel1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
defer ss.Channel().Delete(channel1.Id, 0)
|
defer ss.Channel().Delete(channel1.Id, 0)
|
||||||
|
|
||||||
channel2 := &model.Channel{
|
channel2 := &model.Channel{
|
||||||
@@ -443,8 +443,8 @@ func testRoleStoreLowerScopedChannelSchemeRoles(t *testing.T, ss store.Store) {
|
|||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
SchemeId: &channelScheme2.Id,
|
SchemeId: &channelScheme2.Id,
|
||||||
}
|
}
|
||||||
channel2, err = ss.Channel().Save(channel2, -1)
|
channel2, nErr = ss.Channel().Save(channel2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
defer ss.Channel().Delete(channel2.Id, 0)
|
defer ss.Channel().Delete(channel2.Id, 0)
|
||||||
|
|
||||||
t.Run("ChannelRolesUnderTeamRole", func(t *testing.T) {
|
t.Run("ChannelRolesUnderTeamRole", func(t *testing.T) {
|
||||||
@@ -555,8 +555,8 @@ func testRoleStoreChannelHigherScopedPermissionsBlankTeamSchemeChannelGuest(t *t
|
|||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
SchemeId: &channelScheme.Id,
|
SchemeId: &channelScheme.Id,
|
||||||
}
|
}
|
||||||
channel, err = ss.Channel().Save(channel, -1)
|
channel, nErr := ss.Channel().Save(channel, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
defer ss.Channel().Delete(channel.Id, 0)
|
defer ss.Channel().Delete(channel.Id, 0)
|
||||||
|
|
||||||
channelSchemeUserRole, err := ss.Role().GetByName(channelScheme.DefaultChannelUserRole)
|
channelSchemeUserRole, err := ss.Role().GetByName(channelScheme.DefaultChannelUserRole)
|
||||||
|
|||||||
@@ -444,8 +444,8 @@ func testSchemeStoreDelete(t *testing.T, ss store.Store) {
|
|||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
SchemeId: &d5.Id,
|
SchemeId: &d5.Id,
|
||||||
}
|
}
|
||||||
c5, err = ss.Channel().Save(c5, -1)
|
c5, nErr := ss.Channel().Save(c5, -1)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Scheme().Delete(d5.Id)
|
_, err = ss.Scheme().Delete(d5.Id)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|||||||
@@ -2808,12 +2808,12 @@ func testGetChannelUnreadsForAllTeams(t *testing.T, ss store.Store) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||||
_, err = ss.Channel().Save(c1, -1)
|
_, nErr := ss.Channel().Save(c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
c2 := &model.Channel{TeamId: m2.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
c2 := &model.Channel{TeamId: m2.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||||
_, err = ss.Channel().Save(c2, -1)
|
_, nErr = ss.Channel().Save(c2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
cm1 := &model.ChannelMember{ChannelId: c1.Id, UserId: m1.UserId, NotifyProps: model.GetDefaultChannelNotifyProps(), MsgCount: 90}
|
cm1 := &model.ChannelMember{ChannelId: c1.Id, UserId: m1.UserId, NotifyProps: model.GetDefaultChannelNotifyProps(), MsgCount: 90}
|
||||||
_, err = ss.Channel().SaveMember(cm1)
|
_, err = ss.Channel().SaveMember(cm1)
|
||||||
@@ -2862,12 +2862,12 @@ func testGetChannelUnreadsForTeam(t *testing.T, ss store.Store) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||||
_, err = ss.Channel().Save(c1, -1)
|
_, nErr := ss.Channel().Save(c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
c2 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
c2 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||||
_, err = ss.Channel().Save(c2, -1)
|
_, nErr = ss.Channel().Save(c2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
cm1 := &model.ChannelMember{ChannelId: c1.Id, UserId: m1.UserId, NotifyProps: model.GetDefaultChannelNotifyProps(), MsgCount: 90}
|
cm1 := &model.ChannelMember{ChannelId: c1.Id, UserId: m1.UserId, NotifyProps: model.GetDefaultChannelNotifyProps(), MsgCount: 90}
|
||||||
_, err = ss.Channel().SaveMember(cm1)
|
_, err = ss.Channel().SaveMember(cm1)
|
||||||
|
|||||||
@@ -700,8 +700,8 @@ func testUserStoreGetProfilesInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c1, err := ss.Channel().Save(ch1, -1)
|
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := &model.Channel{
|
ch2 := &model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
@@ -709,8 +709,8 @@ func testUserStoreGetProfilesInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
c2, err := ss.Channel().Save(ch2, -1)
|
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
ChannelId: c1.Id,
|
ChannelId: c1.Id,
|
||||||
@@ -805,8 +805,8 @@ func testUserStoreGetProfilesInChannelByStatus(t *testing.T, ss store.Store, s S
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c1, err := ss.Channel().Save(ch1, -1)
|
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := &model.Channel{
|
ch2 := &model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
@@ -814,8 +814,8 @@ func testUserStoreGetProfilesInChannelByStatus(t *testing.T, ss store.Store, s S
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
c2, err := ss.Channel().Save(ch2, -1)
|
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
ChannelId: c1.Id,
|
ChannelId: c1.Id,
|
||||||
@@ -981,8 +981,8 @@ func testUserStoreGetAllProfilesInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c1, err := ss.Channel().Save(ch1, -1)
|
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := &model.Channel{
|
ch2 := &model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
@@ -990,8 +990,8 @@ func testUserStoreGetAllProfilesInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
c2, err := ss.Channel().Save(ch2, -1)
|
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
ChannelId: c1.Id,
|
ChannelId: c1.Id,
|
||||||
@@ -1109,8 +1109,8 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c1, err := ss.Channel().Save(ch1, -1)
|
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := &model.Channel{
|
ch2 := &model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
@@ -1118,8 +1118,8 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
c2, err := ss.Channel().Save(ch2, -1)
|
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
t.Run("get team 1, channel 1, offset 0, limit 100", func(t *testing.T) {
|
t.Run("get team 1, channel 1, offset 0, limit 100", func(t *testing.T) {
|
||||||
var profiles []*model.User
|
var profiles []*model.User
|
||||||
@@ -1343,12 +1343,12 @@ func testUserStoreGetProfileByGroupChannelIdsForUser(t *testing.T, ss store.Stor
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u4.Id)) }()
|
defer func() { require.Nil(t, ss.User().PermanentDelete(u4.Id)) }()
|
||||||
|
|
||||||
gc1, err := ss.Channel().Save(&model.Channel{
|
gc1, nErr := ss.Channel().Save(&model.Channel{
|
||||||
DisplayName: "Profiles in private",
|
DisplayName: "Profiles in private",
|
||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_GROUP,
|
Type: model.CHANNEL_GROUP,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
for _, uId := range []string{u1.Id, u2.Id, u3.Id} {
|
for _, uId := range []string{u1.Id, u2.Id, u3.Id} {
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
@@ -1359,12 +1359,12 @@ func testUserStoreGetProfileByGroupChannelIdsForUser(t *testing.T, ss store.Stor
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
gc2, err := ss.Channel().Save(&model.Channel{
|
gc2, nErr := ss.Channel().Save(&model.Channel{
|
||||||
DisplayName: "Profiles in private",
|
DisplayName: "Profiles in private",
|
||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_GROUP,
|
Type: model.CHANNEL_GROUP,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
for _, uId := range []string{u1.Id, u3.Id, u4.Id} {
|
for _, uId := range []string{u1.Id, u3.Id, u4.Id} {
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
@@ -1952,8 +1952,8 @@ func testUserUnreadCount(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
_, err = ss.Channel().Save(&c1, -1)
|
_, nErr := ss.Channel().Save(&c1, -1)
|
||||||
require.Nil(t, err, "couldn't save item")
|
require.Nil(t, nErr, "couldn't save item")
|
||||||
|
|
||||||
m1 := model.ChannelMember{}
|
m1 := model.ChannelMember{}
|
||||||
m1.ChannelId = c1.Id
|
m1.ChannelId = c1.Id
|
||||||
@@ -2289,8 +2289,8 @@ func testUserStoreSearchNotInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "zz" + model.NewId() + "b",
|
Name: "zz" + model.NewId() + "b",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c1, err := ss.Channel().Save(&ch1, -1)
|
c1, nErr := ss.Channel().Save(&ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := model.Channel{
|
ch2 := model.Channel{
|
||||||
TeamId: tid,
|
TeamId: tid,
|
||||||
@@ -2298,8 +2298,8 @@ func testUserStoreSearchNotInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "zz" + model.NewId() + "b",
|
Name: "zz" + model.NewId() + "b",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c2, err := ss.Channel().Save(&ch2, -1)
|
c2, nErr := ss.Channel().Save(&ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
ChannelId: c2.Id,
|
ChannelId: c2.Id,
|
||||||
@@ -2515,8 +2515,8 @@ func testUserStoreSearchInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "zz" + model.NewId() + "b",
|
Name: "zz" + model.NewId() + "b",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c1, err := ss.Channel().Save(&ch1, -1)
|
c1, nErr := ss.Channel().Save(&ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := model.Channel{
|
ch2 := model.Channel{
|
||||||
TeamId: tid,
|
TeamId: tid,
|
||||||
@@ -2524,8 +2524,8 @@ func testUserStoreSearchInChannel(t *testing.T, ss store.Store) {
|
|||||||
Name: "zz" + model.NewId() + "b",
|
Name: "zz" + model.NewId() + "b",
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c2, err := ss.Channel().Save(&ch2, -1)
|
c2, nErr := ss.Channel().Save(&ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
ChannelId: c1.Id,
|
ChannelId: c1.Id,
|
||||||
@@ -3524,23 +3524,23 @@ func testUserStoreGetUsersBatchForIndexing(t *testing.T, ss store.Store) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
cPub1, err := ss.Channel().Save(ch1, -1)
|
cPub1, nErr := ss.Channel().Save(ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := &model.Channel{
|
ch2 := &model.Channel{
|
||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
cPub2, err := ss.Channel().Save(ch2, -1)
|
cPub2, nErr := ss.Channel().Save(ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch3 := &model.Channel{
|
ch3 := &model.Channel{
|
||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
|
|
||||||
cPriv, err := ss.Channel().Save(ch3, -1)
|
cPriv, nErr := ss.Channel().Save(ch3, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
u1, err := ss.User().Save(&model.User{
|
u1, err := ss.User().Save(&model.User{
|
||||||
Email: MakeEmail(),
|
Email: MakeEmail(),
|
||||||
@@ -3770,12 +3770,12 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, ss store.Store) {
|
|||||||
func testUserStoreGetChannelGroupUsers(t *testing.T, ss store.Store) {
|
func testUserStoreGetChannelGroupUsers(t *testing.T, ss store.Store) {
|
||||||
// create channel
|
// create channel
|
||||||
id := model.NewId()
|
id := model.NewId()
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
DisplayName: "dn_" + id,
|
DisplayName: "dn_" + id,
|
||||||
Name: "n-" + id,
|
Name: "n-" + id,
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}, 999)
|
}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
require.NotNil(t, channel)
|
require.NotNil(t, channel)
|
||||||
|
|
||||||
// create users
|
// create users
|
||||||
@@ -3798,7 +3798,7 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, ss store.Store) {
|
|||||||
userGroupA, userGroupB, userNoGroup := testUsers[0], testUsers[1], testUsers[2]
|
userGroupA, userGroupB, userNoGroup := testUsers[0], testUsers[1], testUsers[2]
|
||||||
|
|
||||||
// add non-group-member to the channel (to prove that the query isn't just returning all members)
|
// add non-group-member to the channel (to prove that the query isn't just returning all members)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err := ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
UserId: userNoGroup.Id,
|
UserId: userNoGroup.Id,
|
||||||
NotifyProps: model.GetDefaultChannelNotifyProps(),
|
NotifyProps: model.GetDefaultChannelNotifyProps(),
|
||||||
@@ -3908,13 +3908,13 @@ func testUserStorePromoteGuestToUser(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -3954,13 +3954,13 @@ func testUserStorePromoteGuestToUser(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -4050,13 +4050,13 @@ func testUserStorePromoteGuestToUser(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -4095,13 +4095,13 @@ func testUserStorePromoteGuestToUser(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -4140,13 +4140,13 @@ func testUserStorePromoteGuestToUser(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId1, UserId: user1.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId1, UserId: user1.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId1,
|
TeamId: teamId1,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user1.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user1.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -4223,13 +4223,13 @@ func testUserStoreDemoteUserToGuest(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -4269,13 +4269,13 @@ func testUserStoreDemoteUserToGuest(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: true, SchemeUser: false}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: true, SchemeUser: false, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -4365,13 +4365,13 @@ func testUserStoreDemoteUserToGuest(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -4410,13 +4410,13 @@ func testUserStoreDemoteUserToGuest(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: user.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -4455,13 +4455,13 @@ func testUserStoreDemoteUserToGuest(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId1, UserId: user1.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
_, err = ss.Team().SaveMember(&model.TeamMember{TeamId: teamId1, UserId: user1.Id, SchemeGuest: false, SchemeUser: true}, 999)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
channel, err := ss.Channel().Save(&model.Channel{
|
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||||
TeamId: teamId1,
|
TeamId: teamId1,
|
||||||
DisplayName: "Channel name",
|
DisplayName: "Channel name",
|
||||||
Name: "channel-" + model.NewId(),
|
Name: "channel-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}, -1)
|
}, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user1.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{ChannelId: channel.Id, UserId: user1.Id, SchemeGuest: false, SchemeUser: true, NotifyProps: model.GetDefaultChannelNotifyProps()})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -4680,8 +4680,8 @@ func testGetKnownUsers(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_OPEN,
|
Type: model.CHANNEL_OPEN,
|
||||||
}
|
}
|
||||||
c1, err := ss.Channel().Save(ch1, -1)
|
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch2 := &model.Channel{
|
ch2 := &model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
@@ -4689,8 +4689,8 @@ func testGetKnownUsers(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
c2, err := ss.Channel().Save(ch2, -1)
|
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
ch3 := &model.Channel{
|
ch3 := &model.Channel{
|
||||||
TeamId: teamId,
|
TeamId: teamId,
|
||||||
@@ -4698,8 +4698,8 @@ func testGetKnownUsers(t *testing.T, ss store.Store) {
|
|||||||
Name: "profiles-" + model.NewId(),
|
Name: "profiles-" + model.NewId(),
|
||||||
Type: model.CHANNEL_PRIVATE,
|
Type: model.CHANNEL_PRIVATE,
|
||||||
}
|
}
|
||||||
c3, err := ss.Channel().Save(ch3, -1)
|
c3, nErr := ss.Channel().Save(ch3, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
|
|
||||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||||
ChannelId: c1.Id,
|
ChannelId: c1.Id,
|
||||||
|
|||||||
@@ -1553,7 +1553,7 @@ func (s *TimerLayerChannelStore) Restore(channelId string, time int64) *model.Ap
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, *model.AppError) {
|
func (s *TimerLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
|
||||||
start := timemodule.Now()
|
start := timemodule.Now()
|
||||||
|
|
||||||
resultVar0, resultVar1 := s.ChannelStore.Save(channel, maxChannelsPerTeam)
|
resultVar0, resultVar1 := s.ChannelStore.Save(channel, maxChannelsPerTeam)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user