Этот коммит содержится в:
Ben Schumacher
2023-10-11 10:13:36 +02:00
коммит произвёл GitHub
родитель 176370e175
Коммит 0d5a8b8841
189 изменённых файлов: 1 добавлений и 361 удалений

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

@@ -143,7 +143,6 @@ func (s *Server) InvalidateAllCaches() *model.AppError {
func (s *Server) InvalidateAllCachesSkipSend() {
s.platform.InvalidateAllCachesSkipSend()
}
func (a *App) RecycleDatabaseConnection(c request.CTX) {

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

@@ -164,7 +164,6 @@ func (a *App) GetAnalytics(name string, teamID string) (model.AnalyticsRows, *mo
rows[5].Value = float64(totalSockets)
rows[6].Value = float64(totalMasterDb)
rows[7].Value = float64(totalReadDb)
} else {
rows[5].Value = float64(a.TotalWebsocketConnections())
rows[6].Value = float64(a.Srv().Store().TotalMasterDbConnections())

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

@@ -45,7 +45,6 @@ func (tl TokenLocation) String() string {
}
func (a *App) IsPasswordValid(password string) *model.AppError {
if err := users.IsPasswordValidWithSettings(password, &a.Config().PasswordSettings); err != nil {
var invErr *users.ErrInvalidPassword
switch {

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

@@ -212,7 +212,6 @@ func (a *App) SessionHasPermissionToGroup(session model.Session, groupID string,
func (a *App) SessionHasPermissionToChannelByPost(session model.Session, postID string, permission *model.Permission) bool {
if channelMember, err := a.Srv().Store().Channel().GetMemberForPost(postID, session.UserId); err == nil {
if a.RolesGrantPermission(channelMember.GetRoles(), permission.Id) {
return true
}

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

@@ -45,7 +45,6 @@ func TestCheckIfRolesGrantPermission(t *testing.T) {
for _, testcase := range cases {
require.Equal(t, th.App.RolesGrantPermission(testcase.roles, testcase.permissionId), testcase.shouldGrant)
}
}
func TestChannelRolesGrantPermission(t *testing.T) {

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

@@ -49,7 +49,6 @@ func TestSetAutoResponderStatus(t *testing.T) {
status, err = th.App.GetStatus(userUpdated2.Id)
require.Nil(t, err)
assert.Equal(t, model.StatusOnline, status.Status)
}
func TestDisableAutoResponder(t *testing.T) {

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

@@ -3205,7 +3205,6 @@ func (a *App) MoveChannel(c request.CTX, team *model.Team, channel *model.Channe
}
func (a *App) postChannelMoveMessage(c request.CTX, user *model.User, channel *model.Channel, previousTeam *model.Team) *model.AppError {
post := &model.Post{
ChannelId: channel.Id,
Message: fmt.Sprintf(i18n.T("api.team.move_channel.success"), previousTeam.Name),

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

@@ -2341,7 +2341,6 @@ func TestMarkChannelAsUnreadFromPostCollapsedThreadsTurnedOff(t *testing.T) {
}
func TestMarkUnreadCRTOffUpdatesThreads(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) {
@@ -2662,5 +2661,4 @@ func TestConvertGroupMessageToChannel(t *testing.T) {
convertedChannel, appErr := th.App.ConvertGroupMessageToChannel(th.Context, "user_id_1", conversionRequest)
require.Nil(t, appErr)
require.Equal(t, model.ChannelTypePrivate, convertedChannel.Type)
}

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

@@ -287,7 +287,6 @@ func (ch *Channels) Start() error {
ch.ShutDownPlugins()
}
}
})
// TODO: This should be moved to the platform service.

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

@@ -12,6 +12,5 @@ func (a *App) IsLeader() bool {
}
func (a *App) GetClusterId() string {
return a.Srv().Platform().GetClusterId()
}

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

@@ -66,7 +66,6 @@ func (s *Server) clusterPluginEventHandler(msg *model.ClusterMessage) {
// The cluster event handlers are spread across this function and NewLocalCacheLayer.
// Be careful to not have duplicated handlers here and there.
func (s *Server) registerClusterHandlers() {
s.platform.RegisterClusterMessageHandler(model.ClusterEventInstallPlugin, s.clusterInstallPluginHandler)
s.platform.RegisterClusterMessageHandler(model.ClusterEventRemovePlugin, s.clusterRemovePluginHandler)
s.platform.RegisterClusterMessageHandler(model.ClusterEventPluginEvent, s.clusterPluginEventHandler)

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

@@ -198,7 +198,6 @@ func TestParseNamedArguments(t *testing.T) {
assert.False(t, found)
assert.Equal(t, "bla", parsed)
assert.Equal(t, "", toBeParsed)
}
func TestSuggestions(t *testing.T) {

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

@@ -163,7 +163,6 @@ func TestSendInviteEmails(t *testing.T) {
false,
)
require.Error(t, err)
})
t.Run("SendGuestInviteEmails should sanitize HTML input", func(t *testing.T) {
@@ -356,7 +355,6 @@ func TestSendCloudWelcomeEmail(t *testing.T) {
require.NoError(t, err, "Could not get message from mailbox")
require.Contains(t, resultsEmail.Subject, "Congratulations!", "Wrong subject message %s", resultsEmail.Subject)
require.Contains(t, resultsEmail.Body.Text, "Your workspace is ready to go!", "Wrong body %s", resultsEmail.Body.Text)
}
mail.DeleteMailBox(emailTo)

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

@@ -540,7 +540,6 @@ func (a *App) BuildPostReactions(ctx request.CTX, postID string) (*[]ReactionImp
}
return &reactionsOfPost, nil
}
func (a *App) buildPostAttachments(postID string) ([]imports.AttachmentImportData, *model.AppError) {

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

@@ -95,7 +95,6 @@ func featureFlagsFromMap(featuresMap map[string]string, baseFeatureFlags model.F
default:
refField.Set(reflect.ValueOf(fieldValue))
}
}
return baseFeatureFlags
}

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

@@ -720,7 +720,6 @@ func (t *UploadFileTask) init(a *App) {
// contained the last "good" FileInfo before the execution of that plugin.
func (a *App) UploadFileX(c *request.Context, channelID, name string, input io.Reader,
opts ...func(*UploadFileTask)) (*model.FileInfo, *model.AppError) {
t := &UploadFileTask{
ChannelId: filepath.Base(channelID),
Name: filepath.Base(name),

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

@@ -89,7 +89,6 @@ func BenchmarkUploadFile(b *testing.B) {
}
th.App.Srv().Store().FileInfo().PermanentDelete(info1.Id)
th.App.RemoveFile(info1.Path)
},
},
{

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

@@ -647,7 +647,6 @@ func TestComputeLastAccessibleFileTime(t *testing.T) {
mockSystemStore.AssertNotCalled(t, "SaveOrUpdate", mock.Anything)
mockSystemStore.AssertCalled(t, "PermanentDeleteByName", mock.Anything)
})
}

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

@@ -570,7 +570,6 @@ func (a *App) importUser(c request.CTX, data *imports.UserImportData, dryRun boo
if err := a.Srv().Store().Preference().Save(model.Preferences{pref}); err != nil {
c.Logger().Warn("Encountered error saving tutorial preference", mlog.Err(err))
}
} else {
var appErr *model.AppError
if hasUserChanged {

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

@@ -215,7 +215,6 @@ func TestImportImportScheme(t *testing.T) {
assert.Equal(t, *data.DisplayName, scheme.DisplayName)
assert.Equal(t, *data.Description, scheme.Description)
assert.Equal(t, "team", scheme.Scope)
}
func TestImportImportSchemeWithoutGuestRoles(t *testing.T) {

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

@@ -15,7 +15,6 @@ import (
)
func ValidateSchemeImportData(data *SchemeImportData) *model.AppError {
if data.Scope == nil {
return model.NewAppError("BulkImport", "app.import.validate_scheme_import_data.null_scope.error", nil, "", http.StatusBadRequest)
}
@@ -85,7 +84,6 @@ func ValidateSchemeImportData(data *SchemeImportData) *model.AppError {
}
func ValidateRoleImportData(data *RoleImportData) *model.AppError {
if data.Name == nil || !model.IsValidRoleName(*data.Name) {
return model.NewAppError("BulkImport", "app.import.validate_role_import_data.name_invalid.error", nil, "", http.StatusBadRequest)
}
@@ -118,7 +116,6 @@ func ValidateRoleImportData(data *RoleImportData) *model.AppError {
}
func ValidateTeamImportData(data *TeamImportData) *model.AppError {
if data.Name == nil {
return model.NewAppError("BulkImport", "app.import.validate_team_import_data.name_missing.error", nil, "", http.StatusBadRequest)
} else if len(*data.Name) > model.TeamNameMaxLength {
@@ -153,7 +150,6 @@ func ValidateTeamImportData(data *TeamImportData) *model.AppError {
}
func ValidateChannelImportData(data *ChannelImportData) *model.AppError {
if data.Team == nil {
return model.NewAppError("BulkImport", "app.import.validate_channel_import_data.team_missing.error", nil, "", http.StatusBadRequest)
}

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

@@ -257,7 +257,6 @@ func TestImportValidateRoleImportData(t *testing.T) {
}
func TestImportValidateTeamImportData(t *testing.T) {
// Test with minimum required valid properties.
data := TeamImportData{
Name: ptrStr("teamname"),
@@ -355,7 +354,6 @@ func TestImportValidateTeamImportData(t *testing.T) {
}
func TestImportValidateChannelImportData(t *testing.T) {
// Test with minimum required valid properties.
chanTypeOpen := model.ChannelTypeOpen
data := ChannelImportData{
@@ -469,7 +467,6 @@ func TestImportValidateChannelImportData(t *testing.T) {
}
func TestImportValidateUserImportData(t *testing.T) {
// Test with minimum required valid properties.
data := UserImportData{
Username: ptrStr("bob"),
@@ -671,11 +668,9 @@ func TestImportValidateUserAuth(t *testing.T) {
require.NotNil(t, err, fmt.Sprintf("authService: %v, authData: %v", test.authService, test.authData))
}
}
}
func TestImportValidateUserTeamsImportData(t *testing.T) {
// Invalid Name.
data := []UserTeamImportData{
{
@@ -721,7 +716,6 @@ func TestImportValidateUserTeamsImportData(t *testing.T) {
}
func TestImportValidateUserChannelsImportData(t *testing.T) {
// Invalid Name.
data := []UserChannelImportData{
{
@@ -1027,7 +1021,6 @@ func TestImportValidatePostImportData(t *testing.T) {
}
func TestImportValidateDirectChannelImportData(t *testing.T) {
// Test with valid number of members for direct message.
data := DirectChannelImportData{
Members: &[]string{

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

@@ -45,7 +45,6 @@ func (a *App) DoPostAction(c *request.Context, postID, actionId, userID, selecte
}
func (a *App) DoPostActionWithCookie(c *request.Context, postID, actionId, userID, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError) {
// PostAction may result in the original post being updated. For the
// updated post, we need to unconditionally preserve the original
// IsPinned and HasReaction attributes, and preserve its entire

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

@@ -405,7 +405,6 @@ func TestPostAction(t *testing.T) {
_, err = th.App.DoPostAction(th.Context, postSubpath.Id, attachmentsSubpath[0].Actions[0].Id, th.BasicUser.Id, "")
require.Nil(t, err)
})
}
}
@@ -744,7 +743,6 @@ func TestPostActionRelativeURL(t *testing.T) {
_, err = th.App.DoPostAction(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "")
require.NotNil(t, err)
})
t.Run("valid (but dirty) relative URL with SiteURL set", func(t *testing.T) {

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

@@ -113,7 +113,6 @@ func extractMethodMetadata(method *ast.Field, src []byte) methodData {
paramsToTrace[strings.TrimSpace(p)] = true
}
}
}
}
if e.Params != nil {

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

@@ -19,7 +19,6 @@ import (
// be re-added; otherwise, they will not be re-added.
func (a *App) SyncLdap(c *request.Context, includeRemovedMembers bool) {
a.Srv().Go(func() {
if license := a.Srv().License(); license != nil && *license.Features.LDAP {
if !*a.Config().LdapSettings.EnableSync {
c.Logger().Error("LdapSettings.EnableSync is set to false. Skipping LDAP sync.")

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

@@ -257,7 +257,6 @@ func (a *App) AttachCloudSessionCookie(c *request.Context, w http.ResponseWriter
if strings.Contains(domain, "localhost") {
workspaceName = "localhost"
} else {
// ensure we have a format for a cloud workspace url i.e. example.cloud.mattermost.com
if len(strings.Split(domain, ".")) != 4 {
return
@@ -278,7 +277,6 @@ func (a *App) AttachCloudSessionCookie(c *request.Context, w http.ResponseWriter
}
http.SetCookie(w, cookie)
}
func (a *App) AttachSessionCookies(c *request.Context, w http.ResponseWriter, r *http.Request) {

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

@@ -40,7 +40,6 @@ func TestCheckForClientSideCert(t *testing.T) {
}
func TestCWSLogin(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
license := model.NewTestLicense()

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

@@ -467,7 +467,6 @@ func (s *Server) doPlaybooksRolesCreationMigration() {
if err := s.Store().System().Save(&system); err != nil {
mlog.Fatal("Failed to mark playbook roles creation migration as completed.", mlog.Err(err))
}
}
// arbitrary choice, though if there is an longstanding installation with less than 10 messages,
@@ -599,7 +598,6 @@ func (s *Server) doCloudS3PathMigrations(c *request.Context) {
mlog.Fatal("failed to start job for migrating s3 file paths", mlog.Err(appErr))
return
}
}
func (a *App) DoAppMigrations() {

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

@@ -1189,7 +1189,6 @@ func getMentionsEnabledFields(post *model.Post) model.StringArray {
ret = append(ret, post.Message)
for _, attachment := range post.Attachments() {
if attachment.Pretext != "" {
ret = append(ret, attachment.Pretext)
}

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

@@ -187,7 +187,6 @@ func (a *App) sendPushNotification(notification *PostNotification, user *model.U
func (a *App) getPushNotificationMessage(contentsConfig, postMessage string, explicitMention, channelWideMention,
hasFiles bool, senderName string, channelType model.ChannelType, replyToThreadType string, userLocale i18n.TranslateFunc) string {
// If the post only has images then push an appropriate message
if postMessage == "" && hasFiles {
if channelType == model.ChannelTypeDirect {
@@ -582,7 +581,6 @@ func DoesStatusAllowPushNotification(userNotifyProps model.StringMap, status *mo
func (a *App) BuildPushNotificationMessage(c request.CTX, contentsConfig string, post *model.Post, user *model.User, channel *model.Channel, channelName string, senderName string,
explicitMention bool, channelWideMention bool, replyToThreadType string) (*model.PushNotification, *model.AppError) {
var msg *model.PushNotification
notificationInterface := a.ch.Notification
@@ -669,7 +667,6 @@ func (a *App) buildIdLoadedPushNotificationMessage(c request.CTX, channel *model
func (a *App) buildFullPushNotificationMessage(c request.CTX, contentsConfig string, post *model.Post, user *model.User, channel *model.Channel, channelName string, senderName string,
explicitMention bool, channelWideMention bool, replyToThreadType string) *model.PushNotification {
msg := &model.PushNotification{
Category: model.CategoryCanReply,
Version: model.PushMessageV2,

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

@@ -1376,7 +1376,6 @@ func TestGetMentionKeywords(t *testing.T) {
require.True(t, ok)
require.Equal(t, user4.Id, ids[0], "should've returned mention key of First")
dup_count := func(list []string) map[string]int {
duplicate_frequency := make(map[string]int)
for _, item := range list {
@@ -1779,7 +1778,6 @@ func TestAddMentionKeywordsForUser(t *testing.T) {
}
func TestGetMentionsEnabledFields(t *testing.T) {
attachmentWithTextAndPreText := model.SlackAttachment{
Text: "@here with mentions",
Pretext: "@Channel some comment for the channel",
@@ -2244,7 +2242,6 @@ func TestCheckForMentionUsers(t *testing.T) {
},
} {
t.Run(name, func(t *testing.T) {
e := &ExplicitMentions{}
e.checkForMention(tc.Word, tc.Keywords, nil)
@@ -2550,7 +2547,6 @@ func TestUserAllowsEmail(t *testing.T) {
assert.False(t, th.App.userAllowsEmail(th.Context, user, channelMemberNotifcationProps, &model.Post{Type: model.PostTypeAutoResponder}))
})
}
func TestInsertGroupMentions(t *testing.T) {

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

@@ -469,7 +469,6 @@ func TestAuthorizeOAuthUser(t *testing.T) {
_, _, _, _, err := th.App.AuthorizeOAuthUser(th.Context, nil, nil, model.ServiceOpenid, "", "", "")
require.NotNil(t, err)
assert.Equal(t, "api.user.get_authorization_code.endpoint.app_error", err.Id)
})
t.Run("enabled and properly configured", func(t *testing.T) {

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

@@ -103,14 +103,11 @@ func (a *App) ResetPermissionsSystem() *model.AppError {
}
func (a *App) ExportPermissions(w io.Writer) error {
next := a.SchemesIterator("", permissionsExportBatchSize)
var schemeBatch []*model.Scheme
for schemeBatch = next(); len(schemeBatch) > 0; schemeBatch = next() {
for _, scheme := range schemeBatch {
roleNames := []string{
scheme.DefaultTeamAdminRole,
scheme.DefaultTeamUserRole,
@@ -156,7 +153,6 @@ func (a *App) ExportPermissions(w io.Writer) error {
return err
}
}
}
defaultRoleNames := []string{}

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

@@ -89,7 +89,6 @@ func TestExportPermissions(t *testing.T) {
t.Errorf("Expected %v but got %v.", expected, actual)
}
}
}
func TestImportPermissions(t *testing.T) {
@@ -106,7 +105,6 @@ func TestImportPermissions(t *testing.T) {
var results []*model.Scheme
var beforeCount int
withMigrationMarkedComplete(th, func() {
var appErr *model.AppError
results, appErr = th.App.GetSchemes(scope, 0, 100)
if appErr != nil {
@@ -125,7 +123,6 @@ func TestImportPermissions(t *testing.T) {
if appErr != nil {
panic(appErr)
}
})
actual := len(results)
@@ -169,7 +166,6 @@ func TestImportPermissions(t *testing.T) {
t.Errorf("Expected %v but got %v.", expected, actual)
}
}
}
func TestImportPermissions_idempotentScheme(t *testing.T) {
@@ -212,7 +208,6 @@ func TestImportPermissions_idempotentScheme(t *testing.T) {
if expected != actual {
t.Errorf("Expected count to be %v but got %v", expected, actual)
}
}
func TestImportPermissions_schemeDeletedOnRoleFailure(t *testing.T) {
@@ -254,7 +249,6 @@ func TestImportPermissions_schemeDeletedOnRoleFailure(t *testing.T) {
if expected != actual {
t.Errorf("Expected count to be %v but got %v", expected, actual)
}
}
func TestMigration(t *testing.T) {

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

@@ -161,7 +161,6 @@ func (ps *PlatformService) InvalidateAllCaches() *model.AppError {
ps.InvalidateAllCachesSkipSend()
if ps.clusterIFace != nil {
msg := &model.ClusterMessage{
Event: model.ClusterEventInvalidateAllCaches,
SendType: model.ClusterSendReliable,

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

@@ -368,7 +368,6 @@ func (ps *PlatformService) IsFirstUserAccount() bool {
}
return true
}
func (ps *PlatformService) MaxPostSize() int {
@@ -402,5 +401,4 @@ func (ps *PlatformService) GetSystemInstallDate() (int64, *model.AppError) {
func (ps *PlatformService) ClientConfig() map[string]string {
return ps.clientConfig.Load().(map[string]string)
}

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

@@ -189,5 +189,4 @@ func TestIsFirstUserAccountThunderingHerd(t *testing.T) {
wg.Wait()
})
}
}

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

@@ -371,7 +371,6 @@ func (ps *PlatformService) Start() error {
ps.Go(func() {
ps.Publish(message)
})
})
return nil
}

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

@@ -85,7 +85,6 @@ func (ps *PlatformService) GetStatusesByIds(userIDs []string) (map[string]any, *
ps.AddStatusCacheSkipClusterSend(s)
statusMap[s.UserId] = s.Status
}
}
// For the case where the user does not have a row in the Status table and cache
@@ -134,7 +133,6 @@ func (ps *PlatformService) GetUserStatusesByIds(userIDs []string) ([]*model.Stat
}
statusMap = append(statusMap, statuses...)
}
// For the case where the user does not have a row in the Status table and cache

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

@@ -127,7 +127,6 @@ func setupMultiPluginAPITest(t *testing.T, pluginCodes []string, pluginManifests
}
func setupPluginAPITest(t *testing.T, pluginCode string, pluginManifest string, pluginID string, app *App, c *request.Context) string {
asMain := pluginID != "test_db_driver"
return setupMultiPluginAPITest(t,
[]string{pluginCode}, []string{pluginManifest}, []string{pluginID},

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

@@ -20,7 +20,6 @@ type BasicConfig struct {
}
func IsEmpty(object any) bool {
// get nil case out of the way
if object == nil {
return true

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

@@ -22,7 +22,6 @@ func (p *MyPlugin) OnConfigurationChange() error {
}
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
channels, err := p.API.GetChannelsForTeamForUser(p.configuration.BasicTeamID, p.configuration.BasicUserID, false)
if err != nil {
return nil, err.Error()

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

@@ -22,7 +22,6 @@ func (p *MyPlugin) OnConfigurationChange() error {
}
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
// check existing user first
data, err := p.API.GetProfileImage(p.configuration.BasicUserID)
if err != nil {

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

@@ -22,7 +22,6 @@ func (p *MyPlugin) OnConfigurationChange() error {
}
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
channels, err := p.API.SearchChannels(p.configuration.BasicTeamID, p.configuration.BasicChannelName)
if err != nil {
return nil, err.Error()

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

@@ -28,7 +28,6 @@ func (p *MyPlugin) OnConfigurationChange() error {
}
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
// Create an 128 x 128 image
img := image.NewRGBA(image.Rect(0, 0, 128, 128))
// Draw a red dot at (2, 3)

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

@@ -39,7 +39,6 @@ func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model
if s != status.Status {
return nil, fmt.Sprintf("Invalid status returned: %v != %v", s, status.Status)
}
}
status, err := p.API.UpdateUserStatus(uid, "notrealstatus")

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

@@ -440,7 +440,6 @@ func TestPluginCommand(t *testing.T) {
require.NotNil(t, err)
require.Equal(t, 500, err.StatusCode)
})
}
// Test Product with the minimum code needed to handle
@@ -621,6 +620,5 @@ func TestProductCommands(t *testing.T) {
require.Nil(t, err2)
require.NotNil(t, resp)
assert.Equal(t, "plugin slash command called", resp.Text)
})
}

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

@@ -393,7 +393,6 @@ func TestPrivateServePluginRequest(t *testing.T) {
th.App.ch.servePluginRequest(recorder, request, handler)
})
}
}
func TestHandlePluginRequest(t *testing.T) {
@@ -505,7 +504,6 @@ func TestPluginSync(t *testing.T) {
cfg.FileSettings.AmazonS3Endpoint = model.NewString(s3Endpoint)
cfg.FileSettings.AmazonS3Region = model.NewString("")
cfg.FileSettings.AmazonS3SSL = model.NewBool(false)
},
},
}

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

@@ -1635,7 +1635,6 @@ func (a *App) SearchPostsForUser(c *request.Context, terms string, userID string
}
func (a *App) GetFileInfosForPostWithMigration(postID string, includeDeleted bool) ([]*model.FileInfo, *model.AppError) {
pchan := make(chan store.StoreResult, 1)
go func() {
post, err := a.Srv().Store().Post().GetSingle(postID, includeDeleted)
@@ -2181,7 +2180,6 @@ func (a *App) CheckPostReminders() {
}
}
}
}
func (a *App) GetPostInfo(c request.CTX, postID string) (*model.PostInfo, *model.AppError) {

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

@@ -646,7 +646,6 @@ func (a *App) getLinkMetadata(c request.CTX, requestURL string, timestamp int64,
permalink = &model.Permalink{PreviewPost: model.NewPreviewPost(referencedPostWithMetadata, referencedTeam, referencedChannel)}
}
} else {
var request *http.Request
// Make request for a web page or an image
request, err = http.NewRequest("GET", requestURL, nil)

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

@@ -350,7 +350,6 @@ func TestPreparePostForClient(t *testing.T) {
assert.True(t, ok)
assert.EqualValues(t, colonEmoji, s)
})
})
t.Run("markdown image dimensions", func(t *testing.T) {
@@ -1971,7 +1970,6 @@ func TestGetLinkMetadata(t *testing.T) {
params := r.URL.Query()
writeImage := func(height, width int) {
img := image.NewGray(image.Rect(0, 0, height, width))
var encoder png.Encoder

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

@@ -1312,7 +1312,6 @@ func TestUpdatePost(t *testing.T) {
})
t.Run("sanitizes post metadata appropriately", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -123,7 +123,6 @@ func noticeMatchesConditions(config *model.Config, preferences store.PreferenceS
if !cnd.Audience.Matches(isSystemAdmin, isTeamAdmin) {
return false, nil
}
}
// check user count condition against previously calculated total user count

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

@@ -40,7 +40,6 @@ func parseContentLength(cl string) int64 {
return -1
}
return n
}
func (rt *PluginResponseWriter) GenerateResponse() *http.Response {

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

@@ -1035,7 +1035,6 @@ func (s *Server) Start() error {
go func() {
var err error
if *s.platform.Config().ServiceSettings.ConnectionSecurity == model.ConnSecurityTLS {
tlsConfig := &tls.Config{
PreferServerCipherSuites: true,
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
@@ -1467,7 +1466,6 @@ func (s *Server) doLicenseExpirationCheck() {
// SendRemoveExpiredLicenseEmail formats an email and uses the email service to send the email to user with link pointing to CWS
// to renew the user license
func (s *Server) SendRemoveExpiredLicenseEmail(email, ctaText, ctaLink, locale, siteURL string) *model.AppError {
if err := s.EmailService.SendRemoveExpiredLicenseEmail(ctaText, ctaLink, email, locale, siteURL); err != nil {
return model.NewAppError("SendRemoveExpiredLicenseEmail", "api.license.remove_expired_license.failed.error", nil, "", http.StatusInternalServerError).Wrap(err)
}

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

@@ -101,7 +101,6 @@ func (a *App) GetSession(token string) (*model.Session, *model.AppError) {
!session.IsOAuth && !session.IsMobileApp() &&
session.Props[model.SessionPropType] != model.SessionTypeUserAccessToken &&
!*a.Config().ServiceSettings.ExtendSessionLengthWithActivity {
timeout := int64(*a.Config().ServiceSettings.SessionIdleTimeoutInMinutes) * 1000 * 60
if (model.GetMillis() - session.LastActivityAt) > timeout {
// Revoking the session is an asynchronous task anyways since we are not checking
@@ -210,7 +209,6 @@ func (a *App) RevokeSessionById(sessionID string) *model.AppError {
return model.NewAppError("RevokeSessionById", "app.session.get.app_error", nil, "", http.StatusBadRequest).Wrap(err)
}
return a.RevokeSession(session)
}
func (a *App) RevokeSession(session *model.Session) *model.AppError {
@@ -346,7 +344,6 @@ func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAc
}
return token, nil
}
func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Session, *model.AppError) {
@@ -411,7 +408,6 @@ func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Sessio
a.ch.srv.platform.AddSessionToCache(session)
return session, nil
}
func (a *App) RevokeUserAccessToken(token *model.UserAccessToken) *model.AppError {
@@ -483,7 +479,6 @@ func (a *App) GetUserAccessTokensForUser(userID string, page, perPage int) ([]*m
}
return tokens, nil
}
func (a *App) GetUserAccessToken(tokenID string, sanitize bool) (*model.UserAccessToken, *model.AppError) {

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

@@ -325,7 +325,6 @@ func (*LoadTestProvider) UsersCommand(a *app.App, c request.CTX, args *model.Com
if err != nil {
return &model.CommandResponse{Text: "Failed to add users: " + err.Error(), ResponseType: model.CommandResponseTypeEphemeral}, err
}
}
team, err := a.Srv().Store().Team().Get(args.TeamId)
@@ -369,7 +368,6 @@ func (*LoadTestProvider) ChannelsCommand(a *app.App, c request.CTX, args *model.
if err != nil {
return &model.CommandResponse{Text: "Failed to add channels: " + err.Error(), ResponseType: model.CommandResponseTypeEphemeral}, err
}
}
team, err := a.Srv().Store().Team().Get(args.TeamId)
@@ -427,7 +425,6 @@ func (*LoadTestProvider) DMsCommand(a *app.App, c request.CTX, args *model.Comma
if err != nil {
return &model.CommandResponse{Text: "Failed to add DMs: " + err.Error(), ResponseType: model.CommandResponseTypeEphemeral}, err
}
}
time := int64(0)
@@ -465,7 +462,6 @@ func (*LoadTestProvider) ThreadedPostCommand(a *app.App, c request.CTX, args *mo
if err != nil {
return &model.CommandResponse{Text: "Failed to create post: " + err.Error(), ResponseType: model.CommandResponseTypeEphemeral}, err
}
}
time := int64(0)
@@ -520,7 +516,6 @@ func (*LoadTestProvider) PostsCommand(a *app.App, c request.CTX, args *model.Com
if err != nil {
return &model.CommandResponse{Text: "Failed to add posts: " + err.Error(), ResponseType: model.CommandResponseTypeEphemeral}, err
}
}
maxImages := 0
@@ -565,7 +560,6 @@ func (*LoadTestProvider) PostsCommand(a *app.App, c request.CTX, args *model.Com
if err != nil {
return &model.CommandResponse{Text: "Failed to add posts", ResponseType: model.CommandResponseTypeEphemeral}, err
}
}
return &model.CommandResponse{Text: "Added posts", ResponseType: model.CommandResponseTypeEphemeral}, nil

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

@@ -35,7 +35,6 @@ func (rp *RemoteProvider) GetTrigger() string {
}
func (rp *RemoteProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command {
remote := model.NewAutocompleteData(rp.GetTrigger(), "[action]", T("api.command_remote.remote_add_remove.help", map[string]any{"Actions": AvailableRemoteActions}))
create := model.NewAutocompleteData("create", "", T("api.command_remote.invite.help"))

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

@@ -72,7 +72,6 @@ func (sp *ShareProvider) GetAutoCompleteListItems(c request.CTX, a *app.App, com
case strings.Contains(parsed, " uninvite "):
return sp.getAutoCompleteUnInviteRemote(a, commandArgs, arg)
}
return nil, errors.New("invalid action")
}

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

@@ -43,7 +43,6 @@ func TestCustomStatus(t *testing.T) {
}
func TestCustomStatusErrors(t *testing.T) {
fakeUserID := "foobar"
mockErr := store.NewErrNotFound("User", fakeUserID)
mockUser := &model.User{Id: fakeUserID}

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

@@ -231,7 +231,6 @@ func (a *App) generateSupportPacketYaml(c *request.Context) (*model.FileData, er
}
func (a *App) createPluginsFile(_ *request.Context) (*model.FileData, error) {
// Getting the plugins installed on the server, prettify it, and then add them to the file data array
pluginsResponse, appErr := a.GetPlugins()
if appErr != nil {
@@ -248,7 +247,6 @@ func (a *App) createPluginsFile(_ *request.Context) (*model.FileData, error) {
Body: pluginsPrettyJSON,
}
return fileData, nil
}
func (a *App) getNotificationsLog(_ *request.Context) (*model.FileData, error) {

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

@@ -83,7 +83,6 @@ func TestGenerateSupportPacketYaml(t *testing.T) {
assert.Equal(t, "mock", packet.FileDriver)
assert.Equal(t, "FAIL: all broken", packet.FileStatus)
})
}
func TestGenerateSupportPacket(t *testing.T) {

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

@@ -220,7 +220,6 @@ func (a *App) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
// RenameTeam is used to rename the team Name and the DisplayName fields
func (a *App) RenameTeam(team *model.Team, newTeamName string, newDisplayName string) (*model.Team, *model.AppError) {
// check if name is occupied
_, errnf := a.GetTeamByName(newTeamName)
@@ -1574,7 +1573,6 @@ func (a *App) InviteGuestsToChannelsGracefully(teamID string, guestsInvite *mode
} else {
inviteListWithErrors[i].Error = model.NewAppError("InviteGuestsToChannelsGracefully", "api.team.invite_members.unable_to_send_email.app_error", nil, "", http.StatusInternalServerError)
}
}
}
case errors.Is(eErr, email.NoRateLimiterError):

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

@@ -466,7 +466,6 @@ func TestAddUserToTeamByTeamId(t *testing.T) {
require.NotNil(t, err, "Should not add restricted user")
require.Equal(t, "JoinUserToTeam", err.Where, "Error should be JoinUserToTeam")
})
}
func TestAdjustTeamsFromProductLimits(t *testing.T) {
@@ -522,7 +521,6 @@ func TestAdjustTeamsFromProductLimits(t *testing.T) {
})
t.Run("Should not do anything if the amount of teams is equal to the limit", func(t *testing.T) {
expectedTeamsList, err := th.App.GetAllTeams()
var expectedActiveTeams []*model.Team
@@ -590,7 +588,6 @@ func TestAdjustTeamsFromProductLimits(t *testing.T) {
})
t.Run("Should only restore teams that were archived by cloud limits", func(t *testing.T) {
activeLimit := 1
teamLimits := &model.TeamsLimits{Active: &activeLimit}
@@ -622,7 +619,6 @@ func TestAdjustTeamsFromProductLimits(t *testing.T) {
require.Equal(t, int64(0), teamsList[1].DeleteAt)
require.Equal(t, int64(0), teamsList[2].DeleteAt)
})
}
func TestPermanentDeleteTeam(t *testing.T) {
@@ -1205,7 +1201,6 @@ func TestGetTeamMembers(t *testing.T) {
})
t.Run("Ensure Sorted By User ID when no TeamMemberGetOptions is passed", func(t *testing.T) {
// Sort them by UserID because the result of GetTeamMembers() is also sorted
sort.Slice(users, func(i, j int) bool {
return users[i].Id < users[j].Id

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

@@ -46,7 +46,6 @@ func (a *App) getMarketplacePlugins() ([]string, error) {
}
func (a *App) getTrueUpProfile() (*model.TrueUpReviewProfile, error) {
license := a.Channels().License()
if license == nil {
return nil, model.NewAppError("requestTrueUpReview", "api.license.true_up_review.license_required", nil, "Could not get the total active users count", http.StatusInternalServerError)
@@ -117,7 +116,6 @@ func (a *App) getTrueUpProfile() (*model.TrueUpReviewProfile, error) {
}
return &reviewProfile, nil
}
func (a *App) GetTrueUpProfile() (map[string]any, error) {

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

@@ -807,7 +807,6 @@ func (a *App) UpdateDefaultProfileImage(c request.CTX, user *model.User) *model.
}
func (a *App) SetDefaultProfileImage(c request.CTX, user *model.User) *model.AppError {
if err := a.UpdateDefaultProfileImage(c, user); err != nil {
c.Logger().Error("Failed to update default profile image for user", mlog.String("user_id", user.Id), mlog.Err(err))
return err
@@ -1598,7 +1597,6 @@ func (a *App) UpdateUserRoles(c request.CTX, userID string, newRoles string, sen
}
func (a *App) UpdateUserRolesWithUser(c request.CTX, user *model.User, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError) {
if err := a.CheckRolesExist(strings.Fields(newRoles)); err != nil {
return nil, err
}

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

@@ -150,5 +150,4 @@ func getBrowserName(ua *uasurfer.UserAgent, userAgentString string) string {
}
return browserNames[uasurfer.BrowserUnknown]
}

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

@@ -576,7 +576,6 @@ func TestUpdateUserEmail(t *testing.T) {
botuser2, appErr := th.App.UpdateUser(th.Context, &botuser, false)
assert.Nil(t, appErr)
assert.Equal(t, botuser2.Email, newBotEmail)
})
t.Run("RequireVerificationAlreadyUsedEmail", func(t *testing.T) {
@@ -1171,7 +1170,6 @@ func TestPasswordRecovery(t *testing.T) {
err = th.App.resetPasswordFromToken(th.Context, token.Token, "abcdefgh", model.GetMillisForTime(time.Now().Add(25*time.Hour)))
assert.NotNil(t, err)
})
}
func TestInvalidatePasswordRecoveryTokens(t *testing.T) {
@@ -1742,7 +1740,6 @@ func TestPatchUser(t *testing.T) {
}
func TestUpdateThreadReadForUser(t *testing.T) {
t.Run("Ensure thread membership is created and followed", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -39,7 +39,6 @@ func ComparePassword(hash string, password string) error {
}
func (us *UserService) isPasswordValid(password string) error {
return IsPasswordValidWithSettings(password, &us.config().PasswordSettings)
}

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

@@ -186,5 +186,4 @@ func TestWebConnShouldSendEvent(t *testing.T) {
event3 := model.NewWebSocketEvent(model.WebsocketEventUpdateTeam, "wrongId", "", "", nil, "")
assert.False(t, basicUserWc.ShouldSendEvent(event3))
}

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

@@ -813,7 +813,6 @@ func (a *App) CreateCommandWebhook(commandID string, args *model.CommandArgs) (*
default:
return nil, model.NewAppError("CreateCommandWebhook", "app.command_webhook.create_command_webhook.internal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
}
return savedHook, nil
}

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

@@ -584,11 +584,9 @@ func TestCreateOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
assert.Equal(t, createdHook.IconURL, outgoingWebhook.IconURL)
assert.Equal(t, createdHook.DisplayName, outgoingWebhook.DisplayName)
assert.Equal(t, createdHook.Description, outgoingWebhook.Description)
}
func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
getPayload := func(hook *model.OutgoingWebhook, th *TestHelper, channel *model.Channel) *model.OutgoingWebhookPayload {
return &model.OutgoingWebhookPayload{
Token: hook.Token,
@@ -647,7 +645,6 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
}
getTestCases := func() map[string]TestCaseOutgoing {
webHookResponse := "sample response text from test server"
testCasesOutgoing := map[string]TestCaseOutgoing{
@@ -682,7 +679,6 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
for name, testCase := range getTestCases() {
t.Run(name, func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.EnableOutgoingWebhooks = true
*cfg.ServiceSettings.EnablePostUsernameOverride = testCase.EnablePostUsernameOverride
@@ -726,10 +722,8 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
case <-time.After(5 * time.Second):
require.Fail(t, "Timeout, webhook response not created as post")
}
})
}
}
type InfiniteReader struct {