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
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
|
||||
}
|
||||
|
||||
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()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.Save")
|
||||
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)
|
||||
if err == nil {
|
||||
c.indexChannel(newChannel)
|
||||
|
||||
@@ -113,6 +113,7 @@ func testAutocompleteChannelByNameSplittedWithUnderscoreChar(t *testing.T, th *S
|
||||
func testAutocompleteChannelByDisplayNameSplittedByWhitespaces(t *testing.T, th *SearchTestHelper) {
|
||||
alternate, err := th.createChannel(th.Team.Id, "channel-alternate", "Channel Alternate", "", model.CHANNEL_OPEN, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
defer th.deleteChannel(alternate)
|
||||
res, apperr := th.Store.Channel().AutocompleteInTeam(th.Team.Id, "Channel A", false)
|
||||
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.
|
||||
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 {
|
||||
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 {
|
||||
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()
|
||||
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)
|
||||
|
||||
newChannel, appErr := s.saveChannelT(transaction, channel, maxChannelsPerTeam)
|
||||
if appErr != nil {
|
||||
return newChannel, appErr
|
||||
newChannel, err := s.saveChannelT(transaction, channel, maxChannelsPerTeam)
|
||||
if err != nil {
|
||||
return newChannel, err
|
||||
}
|
||||
|
||||
// Additionally propagate the write to the PublicChannels table.
|
||||
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 {
|
||||
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
|
||||
@@ -577,9 +575,39 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1
|
||||
defer finalizeTransaction(transaction)
|
||||
|
||||
directchannel.TeamId = ""
|
||||
newChannel, appErr := s.saveChannelT(transaction, directchannel, 0)
|
||||
if appErr != nil {
|
||||
return newChannel, appErr
|
||||
newChannel, err := s.saveChannelT(transaction, directchannel, 0)
|
||||
if err != nil {
|
||||
// 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
|
||||
@@ -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 {
|
||||
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()
|
||||
if err := channel.IsValid(); err != nil {
|
||||
return nil, err
|
||||
if err := channel.IsValid(); err != nil { // TODO: this needs to return plain error
|
||||
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 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 {
|
||||
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"}) {
|
||||
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})
|
||||
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
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ type TeamStore 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)
|
||||
SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*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.Name = "zz" + model.NewId() + "b"
|
||||
c1.Type = model.CHANNEL_OPEN
|
||||
c1, err = ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
o1 := &model.Post{}
|
||||
o1.ChannelId = c1.Id
|
||||
@@ -236,8 +236,8 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) {
|
||||
c1.DisplayName = "Channel2"
|
||||
c1.Name = "zz" + model.NewId() + "b"
|
||||
c1.Type = model.CHANNEL_OPEN
|
||||
c1, err = ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
cDM, err := ss.Channel().CreateDirectChannel(u1, u2)
|
||||
require.Nil(t, err)
|
||||
@@ -342,8 +342,8 @@ func testMessageExportPublicChannel(t *testing.T, ss store.Store) {
|
||||
DisplayName: "Public Channel",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// user1 posts twice in the public channel
|
||||
post1 := &model.Post{
|
||||
@@ -446,8 +446,8 @@ func testMessageExportPrivateChannel(t *testing.T, ss store.Store) {
|
||||
DisplayName: "Private Channel",
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// user1 posts twice in the private channel
|
||||
post1 := &model.Post{
|
||||
@@ -644,8 +644,8 @@ func testMessageExportGroupMessageChannel(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_GROUP,
|
||||
}
|
||||
groupMessageChannel, err = ss.Channel().Save(groupMessageChannel, -1)
|
||||
require.Nil(t, err)
|
||||
groupMessageChannel, nErr := ss.Channel().Save(groupMessageChannel, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// user1 posts in the GM
|
||||
post := &model.Post{
|
||||
@@ -718,8 +718,8 @@ func testEditExportMessage(t *testing.T, ss store.Store) {
|
||||
DisplayName: "Public Channel",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// user1 posts in the public channel
|
||||
post1 := &model.Post{
|
||||
@@ -811,8 +811,8 @@ func testEditAfterExportMessage(t *testing.T, ss store.Store) {
|
||||
DisplayName: "Public Channel",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// user1 posts in the public channel
|
||||
post1 := &model.Post{
|
||||
@@ -923,8 +923,8 @@ func testDeleteExportMessage(t *testing.T, ss store.Store) {
|
||||
DisplayName: "Public Channel",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// user1 posts in the public channel
|
||||
post1 := &model.Post{
|
||||
@@ -1008,8 +1008,8 @@ func testDeleteAfterExportMessage(t *testing.T, ss store.Store) {
|
||||
DisplayName: "Public Channel",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// user1 posts in the public channel
|
||||
post1 := &model.Post{
|
||||
|
||||
@@ -847,8 +847,8 @@ func testGroupGetMemberUsersNotInChannel(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN, // Query does not look at type so this shouldn't matter.
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// returns no members when channel does not exist
|
||||
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(),
|
||||
Type: model.CHANNEL_OPEN, // Query does not look at type so this shouldn't matter.
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create GroupChannel
|
||||
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",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel1, err = ss.Channel().Save(channel1, 999)
|
||||
require.Nil(t, err)
|
||||
channel1, nErr := ss.Channel().Save(channel1, 999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
channel2 := &model.Channel{
|
||||
DisplayName: "Name",
|
||||
Name: "z-z-" + model.NewId() + "a",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel2, err = ss.Channel().Save(channel2, 999)
|
||||
require.Nil(t, err)
|
||||
channel2, nErr = ss.Channel().Save(channel2, 999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().CreateGroupSyncable(model.NewGroupChannel(group1.Id, channel1.Id, true))
|
||||
require.Nil(t, err)
|
||||
@@ -2081,8 +2081,8 @@ func testChannelMembersToRemoveSingleChannel(t *testing.T, ss store.Store) {
|
||||
Type: model.CHANNEL_OPEN,
|
||||
GroupConstrained: model.NewBool(true),
|
||||
}
|
||||
channel1, err = ss.Channel().Save(channel1, 999)
|
||||
require.Nil(t, err)
|
||||
channel1, nErr := ss.Channel().Save(channel1, 999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
channel2 := &model.Channel{
|
||||
DisplayName: "Name",
|
||||
@@ -2090,8 +2090,8 @@ func testChannelMembersToRemoveSingleChannel(t *testing.T, ss store.Store) {
|
||||
Type: model.CHANNEL_OPEN,
|
||||
GroupConstrained: model.NewBool(true),
|
||||
}
|
||||
channel2, err = ss.Channel().Save(channel2, 999)
|
||||
require.Nil(t, err)
|
||||
channel2, nErr = ss.Channel().Save(channel2, 999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
for _, user := range []*model.User{user1, user2} {
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
@@ -2183,8 +2183,8 @@ func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
GroupConstrained: model.NewBool(true),
|
||||
}
|
||||
channelConstrained, err = ss.Channel().Save(channelConstrained, 9999)
|
||||
require.Nil(t, err)
|
||||
channelConstrained, nErr := ss.Channel().Save(channelConstrained, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
channelUnconstrained := &model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
@@ -2192,8 +2192,8 @@ func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
channelUnconstrained, err = ss.Channel().Save(channelUnconstrained, 9999)
|
||||
require.Nil(t, err)
|
||||
channelUnconstrained, nErr = ss.Channel().Save(channelUnconstrained, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// create teams
|
||||
teamConstrained := &model.Team{
|
||||
@@ -2344,8 +2344,8 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel2, err = ss.Channel().Save(channel2, 9999)
|
||||
require.Nil(t, err)
|
||||
channel2, nErr := ss.Channel().Save(channel2, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create Group3
|
||||
group3, err := ss.Group().Create(&model.Group{
|
||||
@@ -3033,8 +3033,8 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
channel1, err = ss.Channel().Save(channel1, 9999)
|
||||
require.Nil(t, err)
|
||||
channel1, nErr := ss.Channel().Save(channel1, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create Groups 1 and 2
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
@@ -3097,8 +3097,8 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
channel2, err = ss.Channel().Save(channel2, 9999)
|
||||
require.Nil(t, err)
|
||||
channel2, nErr = ss.Channel().Save(channel2, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// Create Group3
|
||||
group3, err := ss.Group().Create(&model.Group{
|
||||
@@ -3761,8 +3761,8 @@ func groupTestAdminRoleGroupsForSyncableMemberChannel(t *testing.T, ss store.Sto
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
@@ -4058,8 +4058,8 @@ func groupTestPermittedSyncableAdminsChannel(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, 9999)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
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
|
||||
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)
|
||||
|
||||
var r0 *model.Channel
|
||||
@@ -1436,13 +1436,11 @@ func (_m *ChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(*model.Channel, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*model.Channel, int64) error); ok {
|
||||
r1 = rf(channel, maxChannelsPerTeam)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
|
||||
@@ -1445,8 +1445,8 @@ func testUserCountsWithPostsByDay(t *testing.T, ss store.Store) {
|
||||
c1.DisplayName = "Channel2"
|
||||
c1.Name = "zz" + model.NewId() + "b"
|
||||
c1.Type = model.CHANNEL_OPEN
|
||||
c1, err = ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
o1 := &model.Post{}
|
||||
o1.ChannelId = c1.Id
|
||||
@@ -1504,8 +1504,8 @@ func testPostCountsByDay(t *testing.T, ss store.Store) {
|
||||
c1.DisplayName = "Channel2"
|
||||
c1.Name = "zz" + model.NewId() + "b"
|
||||
c1.Type = model.CHANNEL_OPEN
|
||||
c1, err = ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
o1 := &model.Post{}
|
||||
o1.ChannelId = c1.Id
|
||||
@@ -2415,8 +2415,8 @@ func testPostStoreGetParentsForExportAfter(t *testing.T, ss store.Store) {
|
||||
c1.DisplayName = "Channel1"
|
||||
c1.Name = "zz" + model.NewId() + "b"
|
||||
c1.Type = model.CHANNEL_OPEN
|
||||
_, err = ss.Channel().Save(&c1, -1)
|
||||
require.Nil(t, err)
|
||||
_, nErr := ss.Channel().Save(&c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
u1 := model.User{}
|
||||
u1.Username = model.NewId()
|
||||
@@ -2464,8 +2464,8 @@ func testPostStoreGetRepliesForExport(t *testing.T, ss store.Store) {
|
||||
c1.DisplayName = "Channel1"
|
||||
c1.Name = "zz" + model.NewId() + "b"
|
||||
c1.Type = model.CHANNEL_OPEN
|
||||
_, err = ss.Channel().Save(&c1, -1)
|
||||
require.Nil(t, err)
|
||||
_, nErr := ss.Channel().Save(&c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
u1 := model.User{}
|
||||
u1.Email = MakeEmail()
|
||||
|
||||
@@ -432,8 +432,8 @@ func testRoleStoreLowerScopedChannelSchemeRoles(t *testing.T, ss store.Store) {
|
||||
Type: model.CHANNEL_OPEN,
|
||||
SchemeId: &channelScheme1.Id,
|
||||
}
|
||||
channel1, err = ss.Channel().Save(channel1, -1)
|
||||
require.Nil(t, err)
|
||||
channel1, nErr := ss.Channel().Save(channel1, -1)
|
||||
require.Nil(t, nErr)
|
||||
defer ss.Channel().Delete(channel1.Id, 0)
|
||||
|
||||
channel2 := &model.Channel{
|
||||
@@ -443,8 +443,8 @@ func testRoleStoreLowerScopedChannelSchemeRoles(t *testing.T, ss store.Store) {
|
||||
Type: model.CHANNEL_OPEN,
|
||||
SchemeId: &channelScheme2.Id,
|
||||
}
|
||||
channel2, err = ss.Channel().Save(channel2, -1)
|
||||
require.Nil(t, err)
|
||||
channel2, nErr = ss.Channel().Save(channel2, -1)
|
||||
require.Nil(t, nErr)
|
||||
defer ss.Channel().Delete(channel2.Id, 0)
|
||||
|
||||
t.Run("ChannelRolesUnderTeamRole", func(t *testing.T) {
|
||||
@@ -555,8 +555,8 @@ func testRoleStoreChannelHigherScopedPermissionsBlankTeamSchemeChannelGuest(t *t
|
||||
Type: model.CHANNEL_OPEN,
|
||||
SchemeId: &channelScheme.Id,
|
||||
}
|
||||
channel, err = ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, err)
|
||||
channel, nErr := ss.Channel().Save(channel, -1)
|
||||
require.Nil(t, nErr)
|
||||
defer ss.Channel().Delete(channel.Id, 0)
|
||||
|
||||
channelSchemeUserRole, err := ss.Role().GetByName(channelScheme.DefaultChannelUserRole)
|
||||
|
||||
@@ -444,8 +444,8 @@ func testSchemeStoreDelete(t *testing.T, ss store.Store) {
|
||||
Type: model.CHANNEL_OPEN,
|
||||
SchemeId: &d5.Id,
|
||||
}
|
||||
c5, err = ss.Channel().Save(c5, -1)
|
||||
assert.Nil(t, err)
|
||||
c5, nErr := ss.Channel().Save(c5, -1)
|
||||
assert.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Scheme().Delete(d5.Id)
|
||||
assert.Nil(t, err)
|
||||
|
||||
@@ -2808,12 +2808,12 @@ func testGetChannelUnreadsForAllTeams(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||
_, err = ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, err)
|
||||
_, nErr := ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
c2 := &model.Channel{TeamId: m2.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||
_, err = ss.Channel().Save(c2, -1)
|
||||
require.Nil(t, err)
|
||||
_, nErr = ss.Channel().Save(c2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
cm1 := &model.ChannelMember{ChannelId: c1.Id, UserId: m1.UserId, NotifyProps: model.GetDefaultChannelNotifyProps(), MsgCount: 90}
|
||||
_, err = ss.Channel().SaveMember(cm1)
|
||||
@@ -2862,12 +2862,12 @@ func testGetChannelUnreadsForTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||
_, err = ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, err)
|
||||
_, nErr := ss.Channel().Save(c1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
c2 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
|
||||
_, err = ss.Channel().Save(c2, -1)
|
||||
require.Nil(t, err)
|
||||
_, nErr = ss.Channel().Save(c2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
cm1 := &model.ChannelMember{ChannelId: c1.Id, UserId: m1.UserId, NotifyProps: model.GetDefaultChannelNotifyProps(), MsgCount: 90}
|
||||
_, err = ss.Channel().SaveMember(cm1)
|
||||
|
||||
@@ -700,8 +700,8 @@ func testUserStoreGetProfilesInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c1, err := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := &model.Channel{
|
||||
TeamId: teamId,
|
||||
@@ -709,8 +709,8 @@ func testUserStoreGetProfilesInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
c2, err := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, err)
|
||||
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
ChannelId: c1.Id,
|
||||
@@ -805,8 +805,8 @@ func testUserStoreGetProfilesInChannelByStatus(t *testing.T, ss store.Store, s S
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c1, err := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := &model.Channel{
|
||||
TeamId: teamId,
|
||||
@@ -814,8 +814,8 @@ func testUserStoreGetProfilesInChannelByStatus(t *testing.T, ss store.Store, s S
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
c2, err := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, err)
|
||||
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
ChannelId: c1.Id,
|
||||
@@ -981,8 +981,8 @@ func testUserStoreGetAllProfilesInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c1, err := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := &model.Channel{
|
||||
TeamId: teamId,
|
||||
@@ -990,8 +990,8 @@ func testUserStoreGetAllProfilesInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
c2, err := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, err)
|
||||
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
ChannelId: c1.Id,
|
||||
@@ -1109,8 +1109,8 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c1, err := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := &model.Channel{
|
||||
TeamId: teamId,
|
||||
@@ -1118,8 +1118,8 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
c2, err := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, err)
|
||||
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
t.Run("get team 1, channel 1, offset 0, limit 100", func(t *testing.T) {
|
||||
var profiles []*model.User
|
||||
@@ -1343,12 +1343,12 @@ func testUserStoreGetProfileByGroupChannelIdsForUser(t *testing.T, ss store.Stor
|
||||
require.Nil(t, err)
|
||||
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",
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_GROUP,
|
||||
}, -1)
|
||||
require.Nil(t, err)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
for _, uId := range []string{u1.Id, u2.Id, u3.Id} {
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
@@ -1359,12 +1359,12 @@ func testUserStoreGetProfileByGroupChannelIdsForUser(t *testing.T, ss store.Stor
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
gc2, err := ss.Channel().Save(&model.Channel{
|
||||
gc2, nErr := ss.Channel().Save(&model.Channel{
|
||||
DisplayName: "Profiles in private",
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_GROUP,
|
||||
}, -1)
|
||||
require.Nil(t, err)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
for _, uId := range []string{u1.Id, u3.Id, u4.Id} {
|
||||
_, 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)
|
||||
require.Nil(t, err)
|
||||
|
||||
_, err = ss.Channel().Save(&c1, -1)
|
||||
require.Nil(t, err, "couldn't save item")
|
||||
_, nErr := ss.Channel().Save(&c1, -1)
|
||||
require.Nil(t, nErr, "couldn't save item")
|
||||
|
||||
m1 := model.ChannelMember{}
|
||||
m1.ChannelId = c1.Id
|
||||
@@ -2289,8 +2289,8 @@ func testUserStoreSearchNotInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c1, err := ss.Channel().Save(&ch1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(&ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := model.Channel{
|
||||
TeamId: tid,
|
||||
@@ -2298,8 +2298,8 @@ func testUserStoreSearchNotInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c2, err := ss.Channel().Save(&ch2, -1)
|
||||
require.Nil(t, err)
|
||||
c2, nErr := ss.Channel().Save(&ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
ChannelId: c2.Id,
|
||||
@@ -2515,8 +2515,8 @@ func testUserStoreSearchInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c1, err := ss.Channel().Save(&ch1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(&ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := model.Channel{
|
||||
TeamId: tid,
|
||||
@@ -2524,8 +2524,8 @@ func testUserStoreSearchInChannel(t *testing.T, ss store.Store) {
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c2, err := ss.Channel().Save(&ch2, -1)
|
||||
require.Nil(t, err)
|
||||
c2, nErr := ss.Channel().Save(&ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
ChannelId: c1.Id,
|
||||
@@ -3524,23 +3524,23 @@ func testUserStoreGetUsersBatchForIndexing(t *testing.T, ss store.Store) {
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
cPub1, err := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, err)
|
||||
cPub1, nErr := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := &model.Channel{
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
cPub2, err := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, err)
|
||||
cPub2, nErr := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch3 := &model.Channel{
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
|
||||
cPriv, err := ss.Channel().Save(ch3, -1)
|
||||
require.Nil(t, err)
|
||||
cPriv, nErr := ss.Channel().Save(ch3, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
u1, err := ss.User().Save(&model.User{
|
||||
Email: MakeEmail(),
|
||||
@@ -3770,12 +3770,12 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, ss store.Store) {
|
||||
func testUserStoreGetChannelGroupUsers(t *testing.T, ss store.Store) {
|
||||
// create channel
|
||||
id := model.NewId()
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "n-" + id,
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}, 999)
|
||||
require.Nil(t, err)
|
||||
require.Nil(t, nErr)
|
||||
require.NotNil(t, channel)
|
||||
|
||||
// create users
|
||||
@@ -3798,7 +3798,7 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, ss store.Store) {
|
||||
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)
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
_, err := ss.Channel().SaveMember(&model.ChannelMember{
|
||||
ChannelId: channel.Id,
|
||||
UserId: userNoGroup.Id,
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId1,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
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)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
channel, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId1,
|
||||
DisplayName: "Channel name",
|
||||
Name: "channel-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}, -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()})
|
||||
require.Nil(t, err)
|
||||
@@ -4680,8 +4680,8 @@ func testGetKnownUsers(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
c1, err := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, err)
|
||||
c1, nErr := ss.Channel().Save(ch1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch2 := &model.Channel{
|
||||
TeamId: teamId,
|
||||
@@ -4689,8 +4689,8 @@ func testGetKnownUsers(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
c2, err := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, err)
|
||||
c2, nErr := ss.Channel().Save(ch2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
ch3 := &model.Channel{
|
||||
TeamId: teamId,
|
||||
@@ -4698,8 +4698,8 @@ func testGetKnownUsers(t *testing.T, ss store.Store) {
|
||||
Name: "profiles-" + model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
c3, err := ss.Channel().Save(ch3, -1)
|
||||
require.Nil(t, err)
|
||||
c3, nErr := ss.Channel().Save(ch3, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
_, err = ss.Channel().SaveMember(&model.ChannelMember{
|
||||
ChannelId: c1.Id,
|
||||
|
||||
@@ -1553,7 +1553,7 @@ func (s *TimerLayerChannelStore) Restore(channelId string, time int64) *model.Ap
|
||||
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()
|
||||
|
||||
resultVar0, resultVar1 := s.ChannelStore.Save(channel, maxChannelsPerTeam)
|
||||
|
||||
Ссылка в новой задаче
Block a user