* Removing some other fake apps

* More FakeApp removed

* Removing entirely FakeApp

* Fixing some tests

* Fixing get Cluster id from get plugin status

* Fixing failing tests

* Fixing tests

* Fixing test initialization for web

* Fixing InitServer for server tests

* Fixing InitServer for server tests

* Reverting go.sum and go.mod

* Removing unneded HTMLTemplates function in App layer

* Moving back some functions to its old place to easy the review

* Moving back some functions to its old place to easy the review

* Using the last struct2interface version

* Generating store layers

* Fixing merge problems

* Addressing PR comments

* Small fix

* Fixing app tests build

* Fixing tests

* fixing tests

* Fix tests

* Fixing tests

* Fixing tests

* Fixing tests

* Moving license to server struct

* Adding some fixes to the test compilation

* Fixing cluster and some jobs initialization

* Fixing some license tests compilation problems

* Fixing recursive cache invalidation

* Regenerating app layers

* Fix test compilation

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2020-06-12 13:43:50 +02:00
коммит произвёл GitHub
родитель f3ac33e6dc
Коммит f5eab1271b
88 изменённых файлов: 973 добавлений и 1177 удалений

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

@@ -11,7 +11,6 @@ import (
"bytes"
"context"
"crypto/ecdsa"
"html/template"
"io"
"mime/multipart"
"net/http"
@@ -160,8 +159,6 @@ type AppIface interface {
GetEnvironmentConfig() map[string]interface{}
// GetGroupsByTeam returns the paged list and the total count of group associated to the given team.
GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, int, *model.AppError)
// GetHubForUserId returns the hub for a given user id.
GetHubForUserId(userId string) *Hub
// GetKnownUsers returns the list of user ids of users with any direct
// relationship with a user. That means any user sharing any channel, including
// direct and group channels.
@@ -204,8 +201,6 @@ type AppIface interface {
HubRegister(webConn *WebConn)
// HubStart starts all the hubs.
HubStart()
// HubStop stops all the hubs.
HubStop()
// HubUnregister unregisters a connection from a hub.
HubUnregister(webConn *WebConn)
// InstallMarketplacePlugin installs a plugin listed in the marketplace server. It will get the plugin bundle
@@ -217,8 +212,6 @@ type AppIface interface {
InstallPluginWithSignature(pluginFile, signature io.ReadSeeker) (*model.Manifest, *model.AppError)
// IsUsernameTaken checks if the username is already used by another user. Return false if the username is invalid.
IsUsernameTaken(name string) bool
// License returns the currently active license or nil if the application is unlicensed.
License() *model.License
// LimitedClientConfigWithComputed gets the configuration in a format suitable for sending to the client.
LimitedClientConfigWithComputed() map[string]string
// LogAuditRec logs an audit record using default CLILevel.
@@ -253,8 +246,6 @@ type AppIface interface {
RenameChannel(channel *model.Channel, newChannelName string, newDisplayName string) (*model.Channel, *model.AppError)
// RenameTeam is used to rename the team Name and the DisplayName fields
RenameTeam(team *model.Team, newTeamName string, newDisplayName string) (*model.Team, *model.AppError)
// RequestTrialLicense request a trial license from the mattermost offical license server
RequestTrialLicense(trialRequest *model.TrialLicenseRequest) *model.AppError
// RevokeSessionsFromAllUsers will go through all the sessions active
// in the server and revoke them
RevokeSessionsFromAllUsers() *model.AppError
@@ -341,7 +332,6 @@ type AppIface interface {
AddChannelMember(userId string, channel *model.Channel, userRequestorId string, postRootId string) (*model.ChannelMember, *model.AppError)
AddConfigListener(listener func(*model.Config, *model.Config)) string
AddDirectChannels(teamId string, user *model.User) *model.AppError
AddLicenseListener(listener func(oldLicense, newLicense *model.License)) string
AddNotificationEmailToBatch(user *model.User, post *model.Post, team *model.Team) *model.AppError
AddSamlIdpCertificate(fileData *multipart.FileHeader) *model.AppError
AddSamlPrivateCertificate(fileData *multipart.FileHeader) *model.AppError
@@ -394,7 +384,6 @@ type AppIface interface {
ClearTeamMembersCache(teamID string)
ClientConfig() map[string]string
ClientConfigHash() string
ClientLicense() map[string]string
Cluster() einterfaces.ClusterInterface
CompareAndDeletePluginKey(pluginId string, key string, oldValue []byte) (bool, *model.AppError)
CompareAndSetPluginKey(pluginId string, key string, oldValue, newValue []byte) (bool, *model.AppError)
@@ -560,6 +549,7 @@ type AppIface interface {
GetGroupsByIDs(groupIDs []string) ([]*model.Group, *model.AppError)
GetGroupsBySource(groupSource model.GroupSource) ([]*model.Group, *model.AppError)
GetGroupsByUserId(userId string) ([]*model.Group, *model.AppError)
GetHubForUserId(userId string) *Hub
GetIncomingWebhook(hookId string) (*model.IncomingWebhook, *model.AppError)
GetIncomingWebhooksForTeamPage(teamId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
GetIncomingWebhooksForTeamPageByUser(teamId string, userId string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
@@ -631,7 +621,6 @@ type AppIface interface {
GetSamlMetadata() (string, *model.AppError)
GetSamlMetadataFromIdp(idpMetadataUrl string) (*model.SamlMetadataResponse, *model.AppError)
GetSanitizeOptions(asAdmin bool) map[string]bool
GetSanitizedClientLicense() map[string]string
GetScheme(id string) (*model.Scheme, *model.AppError)
GetSchemeByName(name string) (*model.Scheme, *model.AppError)
GetSchemeRolesForTeam(teamId string) (string, string, string, *model.AppError)
@@ -696,7 +685,6 @@ type AppIface interface {
GetUsersWithoutTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, *model.AppError)
GetVerifyEmailToken(token string) (*model.Token, *model.AppError)
GetViewUsersRestrictions(userId string) (*model.ViewUsersRestrictions, *model.AppError)
HTMLTemplates() *template.Template
HTTPService() httpservice.HTTPService
Handle404(w http.ResponseWriter, r *http.Request)
HandleCommandResponse(command *model.Command, args *model.CommandArgs, response *model.CommandResponse, builtIn bool) (*model.CommandResponse, *model.AppError)
@@ -710,15 +698,15 @@ type AppIface interface {
HasPermissionToChannelByPost(askingUserId string, postId string, permission *model.Permission) bool
HasPermissionToTeam(askingUserId string, teamId string, permission *model.Permission) bool
HasPermissionToUser(askingUserId string, userId string) bool
HubStop()
ImageProxy() *imageproxy.ImageProxy
ImageProxyAdder() func(string) string
ImageProxyRemover() (f func(string) string)
ImportPermissions(jsonl io.Reader) error
InitPlugins(pluginDir, webappPluginDir string)
InitPostMetadata()
InitServer()
InstallPluginFromData(data model.PluginEventData)
InvalidateAllCaches() *model.AppError
InvalidateAllCachesSkipSend()
InvalidateAllEmailInvites() *model.AppError
InvalidateCacheForUser(userId string)
InvalidateWebConnSessionCacheForUser(userId string)
@@ -744,7 +732,6 @@ type AppIface interface {
ListDirectory(path string) ([]string, *model.AppError)
ListPluginKeys(pluginId string, page, perPage int) ([]string, *model.AppError)
ListTeamCommands(teamId string) ([]*model.Command, *model.AppError)
LoadLicense()
Log() *mlog.Logger
LoginByOAuth(service string, userData io.Reader, teamId string) (*model.User, *model.AppError)
MakePermissionError(permission *model.Permission) *model.AppError
@@ -799,8 +786,6 @@ type AppIface interface {
ReloadConfig() error
RemoveConfigListener(id string)
RemoveFile(path string) *model.AppError
RemoveLicense() *model.AppError
RemoveLicenseListener(id string)
RemovePlugin(id string) *model.AppError
RemovePluginFromData(data model.PluginEventData)
RemoveSamlIdpCertificate() *model.AppError
@@ -831,7 +816,6 @@ type AppIface interface {
SaveAndBroadcastStatus(status *model.Status)
SaveBrandImage(imageData *multipart.FileHeader) *model.AppError
SaveComplianceReport(job *model.Compliance) (*model.Compliance, *model.AppError)
SaveLicense(licenseBytes []byte) (*model.License, *model.AppError)
SaveReactionForPost(reaction *model.Reaction) (*model.Reaction, *model.AppError)
SaveUserTermsOfService(userId, termsOfServiceId string, accepted bool) *model.AppError
SchemesIterator(scope string, batchSize int) func() []*model.Scheme
@@ -856,9 +840,7 @@ type AppIface interface {
SendAckToPushProxy(ack *model.PushNotificationAck) error
SendAutoResponse(channel *model.Channel, receiver *model.User) (bool, *model.AppError)
SendAutoResponseIfNecessary(channel *model.Channel, sender *model.User) (bool, *model.AppError)
SendDailyDiagnostics()
SendDeactivateAccountEmail(email string, locale, siteURL string) *model.AppError
SendDiagnostic(event string, properties map[string]interface{})
SendEmailVerification(user *model.User, newEmail string) *model.AppError
SendEphemeralPost(userId string, post *model.Post) *model.Post
SendInviteEmails(team *model.Team, senderName string, senderUserId string, invites []string, siteURL string)
@@ -880,12 +862,10 @@ type AppIface interface {
SetAcceptLanguage(s string)
SetActiveChannel(userId string, channelId string) *model.AppError
SetAutoResponderStatus(user *model.User, oldNotifyProps model.StringMap)
SetClientLicense(m map[string]string)
SetContext(c context.Context)
SetDefaultProfileImage(user *model.User) *model.AppError
SetDiagnosticId(id string)
SetIpAddress(s string)
SetLicense(license *model.License) bool
SetLog(l *mlog.Logger)
SetPath(s string)
SetPhase2PermissionsMigrationStatus(isComplete bool) error
@@ -911,8 +891,6 @@ type AppIface interface {
SetTeamIconFromFile(team *model.Team, file io.Reader) *model.AppError
SetTeamIconFromMultiPartFile(teamId string, file multipart.File) *model.AppError
SetUserAgent(s string)
SetupInviteEmailRateLimiting() error
ShutDownPlugins()
SlackAddBotUser(teamId string, log *bytes.Buffer) *model.User
SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[string][]SlackPost, users map[string]*model.User, uploads map[string]*zip.File, botUser *model.User, importerLog *bytes.Buffer) map[string]*model.Channel
SlackAddPosts(teamId string, channel *model.Channel, posts []SlackPost, users map[string]*model.User, uploads map[string]*zip.File, botUser *model.User)
@@ -922,7 +900,6 @@ type AppIface interface {
SoftDeleteTeam(teamId string) *model.AppError
Srv() *Server
StartPushNotificationsHubWorkers()
StopPushNotificationsHubWorkers()
SubmitInteractiveDialog(request model.SubmitDialogRequest) (*model.SubmitDialogResponse, *model.AppError)
SwitchEmailToLdap(email, password, code, ldapLoginId, ldapPassword string) (string, *model.AppError)
SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email, password, code, service string) (string, *model.AppError)
@@ -987,7 +964,6 @@ type AppIface interface {
UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError)
UserAgent() string
UserCanSeeOtherUser(userId string, otherUserId string) (bool, *model.AppError)
ValidateAndSetLicenseBytes(b []byte)
VerifyEmailFromToken(userSuppliedTokenString string) *model.AppError
VerifyUserEmail(userId, email string) *model.AppError
ViewChannel(view *model.ChannelView, userId string, currentSessionId string) (map[string]int64, *model.AppError)