Cleanup usage of global logger (#26835)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
92a6c6517d
Коммит
30d450c4d8
@@ -327,7 +327,7 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
status, appErr := c.App.GetOrCreateTrueUpReviewStatus()
|
status, appErr := c.App.GetOrCreateTrueUpReviewStatus(c.AppContext)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
c.Err = appErr
|
c.Err = appErr
|
||||||
return
|
return
|
||||||
@@ -394,7 +394,7 @@ func trueUpReviewStatus(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
status, appErr := c.App.GetOrCreateTrueUpReviewStatus()
|
status, appErr := c.App.GetOrCreateTrueUpReviewStatus(c.AppContext)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
c.Err = appErr
|
c.Err = appErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ func deleteOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.App.DeleteOAuthApp(oauthApp.Id)
|
err = c.App.DeleteOAuthApp(c.AppContext, oauthApp.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ func getMarketplacePlugins(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins, appErr := c.App.GetMarketplacePlugins(filter)
|
plugins, appErr := c.App.GetMarketplacePlugins(c.AppContext, filter)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
c.Err = appErr
|
c.Err = appErr
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1005,7 +1005,7 @@ func setPostReminder(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
appErr := c.App.SetPostReminder(c.Params.PostId, c.Params.UserId, reminder.TargetTime)
|
appErr := c.App.SetPostReminder(c.AppContext, c.Params.PostId, c.Params.UserId, reminder.TargetTime)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
c.Err = appErr
|
c.Err = appErr
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1412,7 +1412,7 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
var invitesWithError []*model.EmailInviteWithError
|
var invitesWithError []*model.EmailInviteWithError
|
||||||
var appErr *model.AppError
|
var appErr *model.AppError
|
||||||
if emailList != nil {
|
if emailList != nil {
|
||||||
invitesWithError, appErr = c.App.InviteNewUsersToTeamGracefully(memberInvite, c.Params.TeamId, c.AppContext.Session().UserId, "")
|
invitesWithError, appErr = c.App.InviteNewUsersToTeamGracefully(c.AppContext, memberInvite, c.Params.TeamId, c.AppContext.Session().UserId, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if invitesWithError != nil {
|
if invitesWithError != nil {
|
||||||
@@ -1458,7 +1458,7 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
w.Write(js)
|
w.Write(js)
|
||||||
} else {
|
} else {
|
||||||
appErr := c.App.InviteNewUsersToTeam(emailList, c.Params.TeamId, c.AppContext.Session().UserId)
|
appErr := c.App.InviteNewUsersToTeam(c.AppContext, emailList, c.Params.TeamId, c.AppContext.Session().UserId)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
c.Err = appErr
|
c.Err = appErr
|
||||||
return
|
return
|
||||||
@@ -1528,7 +1528,7 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request)
|
|||||||
var appErr *model.AppError
|
var appErr *model.AppError
|
||||||
|
|
||||||
if guestsInvite.Emails != nil {
|
if guestsInvite.Emails != nil {
|
||||||
invitesWithError, appErr = c.App.InviteGuestsToChannelsGracefully(c.Params.TeamId, &guestsInvite, c.AppContext.Session().UserId)
|
invitesWithError, appErr = c.App.InviteGuestsToChannelsGracefully(c.AppContext, c.Params.TeamId, &guestsInvite, c.AppContext.Session().UserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
@@ -1549,7 +1549,7 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
w.Write(js)
|
w.Write(js)
|
||||||
} else {
|
} else {
|
||||||
appErr := c.App.InviteGuestsToChannels(c.Params.TeamId, &guestsInvite, c.AppContext.Session().UserId)
|
appErr := c.App.InviteGuestsToChannels(c.AppContext, c.Params.TeamId, &guestsInvite, c.AppContext.Session().UserId)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
c.Err = appErr
|
c.Err = appErr
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -3534,30 +3534,30 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
|||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictCreationToDomains = "@global.com,@common.com" })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictCreationToDomains = "@global.com,@common.com" })
|
||||||
|
|
||||||
t.Run("team domain restrictions should not affect inviting guests", func(t *testing.T) {
|
t.Run("team domain restrictions should not affect inviting guests", func(t *testing.T) {
|
||||||
err := th.App.InviteGuestsToChannels(th.BasicTeam.Id, &model.GuestsInvite{Emails: emailList, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
err := th.App.InviteGuestsToChannels(th.Context, th.BasicTeam.Id, &model.GuestsInvite{Emails: emailList, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
||||||
require.Nil(t, err, "guest user invites should not be affected by team restrictions")
|
require.Nil(t, err, "guest user invites should not be affected by team restrictions")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("guest restrictions should affect guest users", func(t *testing.T) {
|
t.Run("guest restrictions should affect guest users", func(t *testing.T) {
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.RestrictCreationToDomains = "@guest.com" })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.RestrictCreationToDomains = "@guest.com" })
|
||||||
|
|
||||||
err := th.App.InviteGuestsToChannels(th.BasicTeam.Id, &model.GuestsInvite{Emails: []string{"guest1@invalid.com"}, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
err := th.App.InviteGuestsToChannels(th.Context, th.BasicTeam.Id, &model.GuestsInvite{Emails: []string{"guest1@invalid.com"}, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
||||||
require.NotNil(t, err, "guest user invites should be affected by the guest domain restrictions")
|
require.NotNil(t, err, "guest user invites should be affected by the guest domain restrictions")
|
||||||
|
|
||||||
res, err := th.App.InviteGuestsToChannelsGracefully(th.BasicTeam.Id, &model.GuestsInvite{Emails: []string{"guest1@invalid.com", "guest1@guest.com"}, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
res, err := th.App.InviteGuestsToChannelsGracefully(th.Context, th.BasicTeam.Id, &model.GuestsInvite{Emails: []string{"guest1@invalid.com", "guest1@guest.com"}, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Len(t, res, 2)
|
require.Len(t, res, 2)
|
||||||
require.NotNil(t, res[0].Error)
|
require.NotNil(t, res[0].Error)
|
||||||
require.Nil(t, res[1].Error)
|
require.Nil(t, res[1].Error)
|
||||||
|
|
||||||
err = th.App.InviteGuestsToChannels(th.BasicTeam.Id, &model.GuestsInvite{Emails: []string{"guest1@guest.com"}, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
err = th.App.InviteGuestsToChannels(th.Context, th.BasicTeam.Id, &model.GuestsInvite{Emails: []string{"guest1@guest.com"}, Channels: []string{th.BasicChannel.Id}, Message: "test message"}, th.BasicUser.Id)
|
||||||
require.Nil(t, err, "whitelisted guest user email should be allowed by the guest domain restrictions")
|
require.Nil(t, err, "whitelisted guest user email should be allowed by the guest domain restrictions")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("guest restrictions should not affect inviting new team members", func(t *testing.T) {
|
t.Run("guest restrictions should not affect inviting new team members", func(t *testing.T) {
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.RestrictCreationToDomains = "@guest.com" })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.RestrictCreationToDomains = "@guest.com" })
|
||||||
|
|
||||||
err := th.App.InviteNewUsersToTeam([]string{"user@global.com"}, th.BasicTeam.Id, th.BasicUser.Id)
|
err := th.App.InviteNewUsersToTeam(th.Context, []string{"user@global.com"}, th.BasicTeam.Id, th.BasicUser.Id)
|
||||||
require.Nil(t, err, "non guest user invites should not be affected by the guest domain restrictions")
|
require.Nil(t, err, "non guest user invites should not be affected by the guest domain restrictions")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -3576,12 +3576,12 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
|||||||
Channels: []string{th.BasicChannel.Id},
|
Channels: []string{th.BasicChannel.Id},
|
||||||
Message: "test message",
|
Message: "test message",
|
||||||
}
|
}
|
||||||
err = th.App.InviteGuestsToChannels(th.BasicTeam.Id, invite, th.BasicUser.Id)
|
err = th.App.InviteGuestsToChannels(th.Context, th.BasicTeam.Id, invite, th.BasicUser.Id)
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
||||||
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
||||||
|
|
||||||
_, appErr := th.App.InviteGuestsToChannelsGracefully(th.BasicTeam.Id, invite, th.BasicUser.Id)
|
_, appErr := th.App.InviteGuestsToChannelsGracefully(th.Context, th.BasicTeam.Id, invite, th.BasicUser.Id)
|
||||||
require.NotNil(t, appErr)
|
require.NotNil(t, appErr)
|
||||||
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
||||||
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
||||||
|
|||||||
@@ -1798,7 +1798,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
audit.AddEventParameter(auditRec, "email", email)
|
audit.AddEventParameter(auditRec, "email", email)
|
||||||
|
|
||||||
sent, err := c.App.SendPasswordReset(email, c.App.GetSiteURL())
|
sent, err := c.App.SendPasswordReset(c.AppContext, email, c.App.GetSiteURL())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if *c.App.Config().ServiceSettings.ExperimentalEnableHardenedMode {
|
if *c.App.Config().ServiceSettings.ExperimentalEnableHardenedMode {
|
||||||
ReturnStatusOK(w)
|
ReturnStatusOK(w)
|
||||||
@@ -2452,7 +2452,7 @@ func createUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
accessToken.UserId = c.Params.UserId
|
accessToken.UserId = c.Params.UserId
|
||||||
accessToken.Token = ""
|
accessToken.Token = ""
|
||||||
|
|
||||||
token, err := c.App.CreateUserAccessToken(&accessToken)
|
token, err := c.App.CreateUserAccessToken(c.AppContext, &accessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ type AppIface interface {
|
|||||||
GetLdapGroup(rctx request.CTX, ldapGroupID string) (*model.Group, *model.AppError)
|
GetLdapGroup(rctx request.CTX, ldapGroupID string) (*model.Group, *model.AppError)
|
||||||
// GetMarketplacePlugins returns a list of plugins from the marketplace-server,
|
// GetMarketplacePlugins returns a list of plugins from the marketplace-server,
|
||||||
// and plugins that are installed locally.
|
// and plugins that are installed locally.
|
||||||
GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError)
|
GetMarketplacePlugins(rctx request.CTX, filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError)
|
||||||
// GetPluginStatus returns the status for a plugin installed on this server.
|
// GetPluginStatus returns the status for a plugin installed on this server.
|
||||||
GetPluginStatus(id string) (*model.PluginStatus, *model.AppError)
|
GetPluginStatus(id string) (*model.PluginStatus, *model.AppError)
|
||||||
// GetPluginStatuses returns the status for plugins installed on this server.
|
// GetPluginStatuses returns the status for plugins installed on this server.
|
||||||
@@ -472,7 +472,7 @@ type AppIface interface {
|
|||||||
BulkExport(ctx request.CTX, writer io.Writer, outPath string, job *model.Job, opts model.BulkExportOpts) *model.AppError
|
BulkExport(ctx request.CTX, writer io.Writer, outPath string, job *model.Job, opts model.BulkExportOpts) *model.AppError
|
||||||
BulkImport(c request.CTX, jsonlReader io.Reader, attachmentsReader *zip.Reader, dryRun bool, workers int) (*model.AppError, int)
|
BulkImport(c request.CTX, jsonlReader io.Reader, attachmentsReader *zip.Reader, dryRun bool, workers int) (*model.AppError, int)
|
||||||
BulkImportWithPath(c request.CTX, jsonlReader io.Reader, attachmentsReader *zip.Reader, dryRun, extractContent bool, workers int, importPath string) (*model.AppError, int)
|
BulkImportWithPath(c request.CTX, jsonlReader io.Reader, attachmentsReader *zip.Reader, dryRun, extractContent bool, workers int, importPath string) (*model.AppError, int)
|
||||||
CanNotifyAdmin(trial bool) bool
|
CanNotifyAdmin(rctx request.CTX, trial bool) bool
|
||||||
CancelJob(c request.CTX, jobId string) *model.AppError
|
CancelJob(c request.CTX, jobId string) *model.AppError
|
||||||
ChannelMembersToRemove(teamID *string) ([]*model.ChannelMember, *model.AppError)
|
ChannelMembersToRemove(teamID *string) ([]*model.ChannelMember, *model.AppError)
|
||||||
Channels() *Channels
|
Channels() *Channels
|
||||||
@@ -500,7 +500,7 @@ type AppIface interface {
|
|||||||
ClientConfigHash() string
|
ClientConfigHash() string
|
||||||
Cloud() einterfaces.CloudInterface
|
Cloud() einterfaces.CloudInterface
|
||||||
Cluster() einterfaces.ClusterInterface
|
Cluster() einterfaces.ClusterInterface
|
||||||
CompareAndDeletePluginKey(pluginID string, key string, oldValue []byte) (bool, *model.AppError)
|
CompareAndDeletePluginKey(rctx request.CTX, pluginID string, key string, oldValue []byte) (bool, *model.AppError)
|
||||||
CompareAndSetPluginKey(pluginID string, key string, oldValue, newValue []byte) (bool, *model.AppError)
|
CompareAndSetPluginKey(pluginID string, key string, oldValue, newValue []byte) (bool, *model.AppError)
|
||||||
CompileReportChunks(format string, prefix string, numberOfChunks int, headers []string) *model.AppError
|
CompileReportChunks(format string, prefix string, numberOfChunks int, headers []string) *model.AppError
|
||||||
CompleteOAuth(c request.CTX, service string, body io.ReadCloser, teamID string, props map[string]string, tokenUser *model.User) (*model.User, *model.AppError)
|
CompleteOAuth(c request.CTX, service string, body io.ReadCloser, teamID string, props map[string]string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||||
@@ -529,7 +529,7 @@ type AppIface interface {
|
|||||||
CreateOAuthStateToken(extra string) (*model.Token, *model.AppError)
|
CreateOAuthStateToken(extra string) (*model.Token, *model.AppError)
|
||||||
CreateOAuthUser(c request.CTX, service string, userData io.Reader, teamID string, tokenUser *model.User) (*model.User, *model.AppError)
|
CreateOAuthUser(c request.CTX, service string, userData io.Reader, teamID string, tokenUser *model.User) (*model.User, *model.AppError)
|
||||||
CreateOutgoingWebhook(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
CreateOutgoingWebhook(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||||
CreatePasswordRecoveryToken(userID, email string) (*model.Token, *model.AppError)
|
CreatePasswordRecoveryToken(rctx request.CTX, userID, email string) (*model.Token, *model.AppError)
|
||||||
CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError)
|
CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError)
|
||||||
CreatePostAsUser(c request.CTX, post *model.Post, currentSessionId string, setOnline bool) (*model.Post, *model.AppError)
|
CreatePostAsUser(c request.CTX, post *model.Post, currentSessionId string, setOnline bool) (*model.Post, *model.AppError)
|
||||||
CreatePostMissingChannel(c request.CTX, post *model.Post, triggerWebhooks bool, setOnline bool) (*model.Post, *model.AppError)
|
CreatePostMissingChannel(c request.CTX, post *model.Post, triggerWebhooks bool, setOnline bool) (*model.Post, *model.AppError)
|
||||||
@@ -543,7 +543,7 @@ type AppIface interface {
|
|||||||
CreateTeamWithUser(c request.CTX, team *model.Team, userID string) (*model.Team, *model.AppError)
|
CreateTeamWithUser(c request.CTX, team *model.Team, userID string) (*model.Team, *model.AppError)
|
||||||
CreateTermsOfService(text, userID string) (*model.TermsOfService, *model.AppError)
|
CreateTermsOfService(text, userID string) (*model.TermsOfService, *model.AppError)
|
||||||
CreateUploadSession(c request.CTX, us *model.UploadSession) (*model.UploadSession, *model.AppError)
|
CreateUploadSession(c request.CTX, us *model.UploadSession) (*model.UploadSession, *model.AppError)
|
||||||
CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError)
|
CreateUserAccessToken(rctx request.CTX, token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError)
|
||||||
CreateUserAsAdmin(c request.CTX, user *model.User, redirect string) (*model.User, *model.AppError)
|
CreateUserAsAdmin(c request.CTX, user *model.User, redirect string) (*model.User, *model.AppError)
|
||||||
CreateUserFromSignup(c request.CTX, user *model.User, redirect string) (*model.User, *model.AppError)
|
CreateUserFromSignup(c request.CTX, user *model.User, redirect string) (*model.User, *model.AppError)
|
||||||
CreateUserWithInviteId(c request.CTX, user *model.User, inviteId, redirect string) (*model.User, *model.AppError)
|
CreateUserWithInviteId(c request.CTX, user *model.User, inviteId, redirect string) (*model.User, *model.AppError)
|
||||||
@@ -564,14 +564,14 @@ type AppIface interface {
|
|||||||
DeleteCommand(commandID string) *model.AppError
|
DeleteCommand(commandID string) *model.AppError
|
||||||
DeleteDraft(rctx request.CTX, draft *model.Draft, connectionID string) *model.AppError
|
DeleteDraft(rctx request.CTX, draft *model.Draft, connectionID string) *model.AppError
|
||||||
DeleteEmoji(c request.CTX, emoji *model.Emoji) *model.AppError
|
DeleteEmoji(c request.CTX, emoji *model.Emoji) *model.AppError
|
||||||
DeleteEphemeralPost(userID, postID string)
|
DeleteEphemeralPost(rctx request.CTX, userID, postID string)
|
||||||
DeleteExport(name string) *model.AppError
|
DeleteExport(name string) *model.AppError
|
||||||
DeleteGroup(groupID string) (*model.Group, *model.AppError)
|
DeleteGroup(groupID string) (*model.Group, *model.AppError)
|
||||||
DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError)
|
DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError)
|
||||||
DeleteGroupMembers(groupID string, userIDs []string) ([]*model.GroupMember, *model.AppError)
|
DeleteGroupMembers(groupID string, userIDs []string) ([]*model.GroupMember, *model.AppError)
|
||||||
DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError)
|
DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError)
|
||||||
DeleteIncomingWebhook(hookID string) *model.AppError
|
DeleteIncomingWebhook(hookID string) *model.AppError
|
||||||
DeleteOAuthApp(appID string) *model.AppError
|
DeleteOAuthApp(rctx request.CTX, appID string) *model.AppError
|
||||||
DeleteOutgoingWebhook(hookID string) *model.AppError
|
DeleteOutgoingWebhook(hookID string) *model.AppError
|
||||||
DeletePluginKey(pluginID string, key string) *model.AppError
|
DeletePluginKey(pluginID string, key string) *model.AppError
|
||||||
DeletePost(c request.CTX, postID, deleteByID string) (*model.Post, *model.AppError)
|
DeletePost(c request.CTX, postID, deleteByID string) (*model.Post, *model.AppError)
|
||||||
@@ -613,7 +613,7 @@ type AppIface interface {
|
|||||||
FillInChannelsProps(c request.CTX, channelList model.ChannelList) *model.AppError
|
FillInChannelsProps(c request.CTX, channelList model.ChannelList) *model.AppError
|
||||||
FilterUsersByVisible(c request.CTX, viewer *model.User, otherUsers []*model.User) ([]*model.User, *model.AppError)
|
FilterUsersByVisible(c request.CTX, viewer *model.User, otherUsers []*model.User) ([]*model.User, *model.AppError)
|
||||||
FindTeamByName(name string) bool
|
FindTeamByName(name string) bool
|
||||||
FinishSendAdminNotifyPost(trial bool, now int64, pluginBasedData map[string][]*model.NotifyAdminData)
|
FinishSendAdminNotifyPost(rctx request.CTX, trial bool, now int64, pluginBasedData map[string][]*model.NotifyAdminData)
|
||||||
GenerateAndSaveDesktopToken(createAt int64, user *model.User) (*string, *model.AppError)
|
GenerateAndSaveDesktopToken(createAt int64, user *model.User) (*string, *model.AppError)
|
||||||
GenerateMfaSecret(userID string) (*model.MfaSecret, *model.AppError)
|
GenerateMfaSecret(userID string) (*model.MfaSecret, *model.AppError)
|
||||||
GeneratePresignURLForExport(name string) (*model.PresignURLResponse, *model.AppError)
|
GeneratePresignURLForExport(name string) (*model.PresignURLResponse, *model.AppError)
|
||||||
@@ -747,7 +747,7 @@ type AppIface interface {
|
|||||||
GetOnboarding() (*model.System, *model.AppError)
|
GetOnboarding() (*model.System, *model.AppError)
|
||||||
GetOpenGraphMetadata(requestURL string) ([]byte, error)
|
GetOpenGraphMetadata(requestURL string) ([]byte, error)
|
||||||
GetOrCreateDirectChannel(c request.CTX, userID, otherUserID string, channelOptions ...model.ChannelOption) (*model.Channel, *model.AppError)
|
GetOrCreateDirectChannel(c request.CTX, userID, otherUserID string, channelOptions ...model.ChannelOption) (*model.Channel, *model.AppError)
|
||||||
GetOrCreateTrueUpReviewStatus() (*model.TrueUpReviewStatus, *model.AppError)
|
GetOrCreateTrueUpReviewStatus(rctx request.CTX) (*model.TrueUpReviewStatus, *model.AppError)
|
||||||
GetOutgoingWebhook(hookID string) (*model.OutgoingWebhook, *model.AppError)
|
GetOutgoingWebhook(hookID string) (*model.OutgoingWebhook, *model.AppError)
|
||||||
GetOutgoingWebhooksForChannelPageByUser(channelID string, userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
GetOutgoingWebhooksForChannelPageByUser(channelID string, userID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||||
GetOutgoingWebhooksForTeamPage(teamID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
GetOutgoingWebhooksForTeamPage(teamID string, page, perPage int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||||
@@ -830,7 +830,7 @@ type AppIface interface {
|
|||||||
GetTeamByInviteId(inviteId string) (*model.Team, *model.AppError)
|
GetTeamByInviteId(inviteId string) (*model.Team, *model.AppError)
|
||||||
GetTeamByName(name string) (*model.Team, *model.AppError)
|
GetTeamByName(name string) (*model.Team, *model.AppError)
|
||||||
GetTeamIcon(team *model.Team) ([]byte, *model.AppError)
|
GetTeamIcon(team *model.Team) ([]byte, *model.AppError)
|
||||||
GetTeamIdFromQuery(query url.Values) (string, *model.AppError)
|
GetTeamIdFromQuery(rctx request.CTX, query url.Values) (string, *model.AppError)
|
||||||
GetTeamMember(c request.CTX, teamID, userID string) (*model.TeamMember, *model.AppError)
|
GetTeamMember(c request.CTX, teamID, userID string) (*model.TeamMember, *model.AppError)
|
||||||
GetTeamMembers(teamID string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, *model.AppError)
|
GetTeamMembers(teamID string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, *model.AppError)
|
||||||
GetTeamMembersByIds(teamID string, userIDs []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError)
|
GetTeamMembersByIds(teamID string, userIDs []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError)
|
||||||
@@ -921,10 +921,10 @@ type AppIface interface {
|
|||||||
InvalidateAllResendInviteEmailJobs(c request.CTX) *model.AppError
|
InvalidateAllResendInviteEmailJobs(c request.CTX) *model.AppError
|
||||||
InvalidateCacheForUser(userID string)
|
InvalidateCacheForUser(userID string)
|
||||||
InvalidatePasswordRecoveryTokensForUser(userID string) *model.AppError
|
InvalidatePasswordRecoveryTokensForUser(userID string) *model.AppError
|
||||||
InviteGuestsToChannels(teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError
|
InviteGuestsToChannels(rctx request.CTX, teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError
|
||||||
InviteGuestsToChannelsGracefully(teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError)
|
InviteGuestsToChannelsGracefully(rctx request.CTX, teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||||
InviteNewUsersToTeam(emailList []string, teamID, senderId string) *model.AppError
|
InviteNewUsersToTeam(rctx request.CTX, emailList []string, teamID, senderId string) *model.AppError
|
||||||
InviteNewUsersToTeamGracefully(memberInvite *model.MemberInvite, teamID, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError)
|
InviteNewUsersToTeamGracefully(rctx request.CTX, memberInvite *model.MemberInvite, teamID, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||||
InviteRemoteToChannel(channelID, remoteID, userID string, shareIfNotShared bool) error
|
InviteRemoteToChannel(channelID, remoteID, userID string, shareIfNotShared bool) error
|
||||||
IsCRTEnabledForUser(c request.CTX, userID string) bool
|
IsCRTEnabledForUser(c request.CTX, userID string) bool
|
||||||
IsConfigReadOnly() bool
|
IsConfigReadOnly() bool
|
||||||
@@ -1007,7 +1007,7 @@ type AppIface interface {
|
|||||||
RegenerateOAuthAppSecret(app *model.OAuthApp) (*model.OAuthApp, *model.AppError)
|
RegenerateOAuthAppSecret(app *model.OAuthApp) (*model.OAuthApp, *model.AppError)
|
||||||
RegenerateTeamInviteId(teamID string) (*model.Team, *model.AppError)
|
RegenerateTeamInviteId(teamID string) (*model.Team, *model.AppError)
|
||||||
RegisterPluginCommand(pluginID string, command *model.Command) error
|
RegisterPluginCommand(pluginID string, command *model.Command) error
|
||||||
RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (remoteID string, err error)
|
RegisterPluginForSharedChannels(rctx request.CTX, opts model.RegisterPluginOpts) (remoteID string, err error)
|
||||||
ReloadConfig() error
|
ReloadConfig() error
|
||||||
RemoveAllDeactivatedMembersFromChannel(c request.CTX, channel *model.Channel) *model.AppError
|
RemoveAllDeactivatedMembersFromChannel(c request.CTX, channel *model.Channel) *model.AppError
|
||||||
RemoveChannelsFromRetentionPolicy(policyID string, channelIDs []string) *model.AppError
|
RemoveChannelsFromRetentionPolicy(policyID string, channelIDs []string) *model.AppError
|
||||||
@@ -1088,7 +1088,7 @@ type AppIface interface {
|
|||||||
SendIPFiltersChangedEmail(c request.CTX, userID string) error
|
SendIPFiltersChangedEmail(c request.CTX, userID string) error
|
||||||
SendNotifications(c request.CTX, post *model.Post, team *model.Team, channel *model.Channel, sender *model.User, parentPostList *model.PostList, setOnline bool) ([]string, error)
|
SendNotifications(c request.CTX, post *model.Post, team *model.Team, channel *model.Channel, sender *model.User, parentPostList *model.PostList, setOnline bool) ([]string, error)
|
||||||
SendNotifyAdminPosts(c request.CTX, workspaceName string, currentSKU string, trial bool) *model.AppError
|
SendNotifyAdminPosts(c request.CTX, workspaceName string, currentSKU string, trial bool) *model.AppError
|
||||||
SendPasswordReset(email string, siteURL string) (bool, *model.AppError)
|
SendPasswordReset(rctx request.CTX, email string, siteURL string) (bool, *model.AppError)
|
||||||
SendPersistentNotifications() error
|
SendPersistentNotifications() error
|
||||||
SendReportToUser(rctx request.CTX, job *model.Job, format string) *model.AppError
|
SendReportToUser(rctx request.CTX, job *model.Job, format string) *model.AppError
|
||||||
SendTestPushNotification(deviceID string) string
|
SendTestPushNotification(deviceID string) string
|
||||||
@@ -1114,7 +1114,7 @@ type AppIface interface {
|
|||||||
SetPluginKey(pluginID string, key string, value []byte) *model.AppError
|
SetPluginKey(pluginID string, key string, value []byte) *model.AppError
|
||||||
SetPluginKeyWithExpiry(pluginID string, key string, value []byte, expireInSeconds int64) *model.AppError
|
SetPluginKeyWithExpiry(pluginID string, key string, value []byte, expireInSeconds int64) *model.AppError
|
||||||
SetPluginKeyWithOptions(pluginID string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
SetPluginKeyWithOptions(pluginID string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
||||||
SetPostReminder(postID, userID string, targetTime int64) *model.AppError
|
SetPostReminder(rctx request.CTX, postID, userID string, targetTime int64) *model.AppError
|
||||||
SetProfileImage(c request.CTX, userID string, imageData *multipart.FileHeader) *model.AppError
|
SetProfileImage(c request.CTX, userID string, imageData *multipart.FileHeader) *model.AppError
|
||||||
SetProfileImageFromFile(c request.CTX, userID string, file io.Reader) *model.AppError
|
SetProfileImageFromFile(c request.CTX, userID string, file io.Reader) *model.AppError
|
||||||
SetProfileImageFromMultiPartFile(c request.CTX, userID string, file multipart.File) *model.AppError
|
SetProfileImageFromMultiPartFile(c request.CTX, userID string, file multipart.File) *model.AppError
|
||||||
@@ -1217,7 +1217,7 @@ type AppIface interface {
|
|||||||
UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError)
|
UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError)
|
||||||
UserAlreadyNotifiedOnRequiredFeature(user string, feature model.MattermostFeature) bool
|
UserAlreadyNotifiedOnRequiredFeature(user string, feature model.MattermostFeature) bool
|
||||||
UserCanSeeOtherUser(c request.CTX, userID string, otherUserId string) (bool, *model.AppError)
|
UserCanSeeOtherUser(c request.CTX, userID string, otherUserId string) (bool, *model.AppError)
|
||||||
UserIsFirstAdmin(user *model.User) bool
|
UserIsFirstAdmin(rctx request.CTX, user *model.User) bool
|
||||||
ValidateDesktopToken(token string, expiryTime int64) (*model.User, *model.AppError)
|
ValidateDesktopToken(token string, expiryTime int64) (*model.User, *model.AppError)
|
||||||
VerifyEmailFromToken(c request.CTX, userSuppliedTokenString string) *model.AppError
|
VerifyEmailFromToken(c request.CTX, userSuppliedTokenString string) *model.AppError
|
||||||
VerifyUserEmail(userID, email string) *model.AppError
|
VerifyUserEmail(userID, email string) *model.AppError
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ func (a *App) getDynamicListArgument(c request.CTX, commandArgs *model.CommandAr
|
|||||||
if strings.HasPrefix(dynamicArg.FetchURL, "builtin:") {
|
if strings.HasPrefix(dynamicArg.FetchURL, "builtin:") {
|
||||||
listItems, err := a.getBuiltinDynamicListArgument(c, commandArgs, arg, parsed, toBeParsed)
|
listItems, err := a.getBuiltinDynamicListArgument(c, commandArgs, arg, parsed, toBeParsed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Error("Can't fetch dynamic list arguments for", mlog.String("url", dynamicArg.FetchURL), mlog.Err(err))
|
c.Logger().Error("Can't fetch dynamic list arguments for", mlog.String("url", dynamicArg.FetchURL), mlog.Err(err))
|
||||||
return false, parsed, toBeParsed, []model.AutocompleteSuggestion{}
|
return false, parsed, toBeParsed, []model.AutocompleteSuggestion{}
|
||||||
}
|
}
|
||||||
return parseListItems(listItems, parsed, toBeParsed)
|
return parseListItems(listItems, parsed, toBeParsed)
|
||||||
@@ -274,7 +274,7 @@ func (a *App) getDynamicListArgument(c request.CTX, commandArgs *model.CommandAr
|
|||||||
resp, err := a.doPluginRequest(c, "GET", dynamicArg.FetchURL, params, nil)
|
resp, err := a.doPluginRequest(c, "GET", dynamicArg.FetchURL, params, nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Error("Can't fetch dynamic list arguments for", mlog.String("url", dynamicArg.FetchURL), mlog.Err(err))
|
c.Logger().Error("Can't fetch dynamic list arguments for", mlog.String("url", dynamicArg.FetchURL), mlog.Err(err))
|
||||||
return false, parsed, toBeParsed, []model.AutocompleteSuggestion{}
|
return false, parsed, toBeParsed, []model.AutocompleteSuggestion{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ func TestSendInviteEmailRateLimits(t *testing.T) {
|
|||||||
for i := 0; i < 22; i++ {
|
for i := 0; i < 22; i++ {
|
||||||
memberInvite.Emails[i] = "test-" + strconv.Itoa(i) + "@common.com"
|
memberInvite.Emails[i] = "test-" + strconv.Itoa(i) + "@common.com"
|
||||||
}
|
}
|
||||||
err = th.App.InviteNewUsersToTeam(memberInvite.Emails, th.BasicTeam.Id, th.BasicUser.Id)
|
err = th.App.InviteNewUsersToTeam(th.Context, memberInvite.Emails, th.BasicTeam.Id, th.BasicUser.Id)
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
||||||
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
||||||
|
|
||||||
_, err = th.App.InviteNewUsersToTeamGracefully(memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
_, err = th.App.InviteNewUsersToTeamGracefully(th.Context, memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
|
||||||
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
assert.Equal(t, http.StatusRequestEntityTooLarge, err.StatusCode)
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ func (a *App) SendNotifications(c request.CTX, post *model.Post, team *model.Tea
|
|||||||
if a.userAllowsEmail(c, profileMap[id], channelMemberNotifyPropsMap[id], post) {
|
if a.userAllowsEmail(c, profileMap[id], channelMemberNotifyPropsMap[id], post) {
|
||||||
senderProfileImage, _, err := a.GetProfileImage(sender)
|
senderProfileImage, _, err := a.GetProfileImage(sender)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Unable to get the sender user profile image.", mlog.String("user_id", sender.Id), mlog.Err(err))
|
c.Logger().Warn("Unable to get the sender user profile image.", mlog.String("user_id", sender.Id), mlog.Err(err))
|
||||||
}
|
}
|
||||||
if err := a.sendNotificationEmail(c, notification, profileMap[id], team, senderProfileImage); err != nil {
|
if err := a.sendNotificationEmail(c, notification, profileMap[id], team, senderProfileImage); err != nil {
|
||||||
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeEmail, model.NotificationReasonEmailSendError)
|
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeEmail, model.NotificationReasonEmailSendError)
|
||||||
|
|||||||
@@ -77,16 +77,16 @@ func (a *App) sendPushNotificationSync(c request.CTX, post *model.Post, user *mo
|
|||||||
return appErr
|
return appErr
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.sendPushNotificationToAllSessions(msg, user.Id, "")
|
return a.sendPushNotificationToAllSessions(c, msg, user.Id, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) sendPushNotificationToAllSessions(msg *model.PushNotification, userID string, skipSessionId string) *model.AppError {
|
func (a *App) sendPushNotificationToAllSessions(rctx request.CTX, msg *model.PushNotification, userID string, skipSessionId string) *model.AppError {
|
||||||
rejectionReason := ""
|
rejectionReason := ""
|
||||||
a.ch.RunMultiHook(func(hooks plugin.Hooks) bool {
|
a.ch.RunMultiHook(func(hooks plugin.Hooks) bool {
|
||||||
var replacementNotification *model.PushNotification
|
var replacementNotification *model.PushNotification
|
||||||
replacementNotification, rejectionReason = hooks.NotificationWillBePushed(msg, userID)
|
replacementNotification, rejectionReason = hooks.NotificationWillBePushed(msg, userID)
|
||||||
if rejectionReason != "" {
|
if rejectionReason != "" {
|
||||||
mlog.Info("Notification cancelled by plugin.", mlog.String("rejection reason", rejectionReason))
|
rctx.Logger().Info("Notification cancelled by plugin.", mlog.String("rejection reason", rejectionReason))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if replacementNotification != nil {
|
if replacementNotification != nil {
|
||||||
@@ -311,7 +311,7 @@ func (a *App) clearPushNotificationSync(c request.CTX, currentSessionId, userID,
|
|||||||
IsCRTEnabled: isCRTEnabled,
|
IsCRTEnabled: isCRTEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.sendPushNotificationToAllSessions(msg, userID, currentSessionId)
|
return a.sendPushNotificationToAllSessions(c, msg, userID, currentSessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) clearPushNotification(currentSessionId, userID, channelID, rootID string) {
|
func (a *App) clearPushNotification(currentSessionId, userID, channelID, rootID string) {
|
||||||
@@ -341,7 +341,7 @@ func (a *App) updateMobileAppBadgeSync(c request.CTX, userID string) *model.AppE
|
|||||||
ContentAvailable: 1,
|
ContentAvailable: 1,
|
||||||
Badge: badgeCount,
|
Badge: badgeCount,
|
||||||
}
|
}
|
||||||
return a.sendPushNotificationToAllSessions(msg, userID, "")
|
return a.sendPushNotificationToAllSessions(c, msg, userID, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) UpdateMobileAppBadge(userID string) {
|
func (a *App) UpdateMobileAppBadge(userID string) {
|
||||||
|
|||||||
@@ -1077,11 +1077,11 @@ func TestSendPushNotifications(t *testing.T) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
t.Run("should return error if data is not valid or nil", func(t *testing.T) {
|
t.Run("should return error if data is not valid or nil", func(t *testing.T) {
|
||||||
err := th.App.sendPushNotificationToAllSessions(nil, th.BasicUser.Id, "")
|
err := th.App.sendPushNotificationToAllSessions(th.Context, nil, th.BasicUser.Id, "")
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
assert.Equal(t, "api.push_notifications.message.parse.app_error", err.Id)
|
assert.Equal(t, "api.push_notifications.message.parse.app_error", err.Id)
|
||||||
// Errors derived of using an empty object are handled internally through the notifications log
|
// Errors derived of using an empty object are handled internally through the notifications log
|
||||||
err = th.App.sendPushNotificationToAllSessions(&model.PushNotification{}, th.BasicUser.Id, "")
|
err = th.App.sendPushNotificationToAllSessions(th.Context, &model.PushNotification{}, th.BasicUser.Id, "")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ func filterNotificationData(data []*model.NotifyAdminData, test func(*model.Noti
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SendNotifyAdminPosts(c request.CTX, workspaceName string, currentSKU string, trial bool) *model.AppError {
|
func (a *App) SendNotifyAdminPosts(c request.CTX, workspaceName string, currentSKU string, trial bool) *model.AppError {
|
||||||
if !a.CanNotifyAdmin(trial) {
|
if !a.CanNotifyAdmin(c, trial) {
|
||||||
return model.NewAppError("SendNotifyAdminPosts", "app.notify_admin.send_notification_post.app_error", nil, "Cannot notify yet", http.StatusForbidden)
|
return model.NewAppError("SendNotifyAdminPosts", "app.notify_admin.send_notification_post.app_error", nil, "Cannot notify yet", http.StatusForbidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ func (a *App) SendNotifyAdminPosts(c request.CTX, workspaceName string, currentS
|
|||||||
data = filterNotificationData(data, func(nad *model.NotifyAdminData) bool { return nad.RequiredPlan != currentSKU })
|
data = filterNotificationData(data, func(nad *model.NotifyAdminData) bool { return nad.RequiredPlan != currentSKU })
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
a.Log().Warn("No notification data available")
|
c.Logger().Warn("No notification data available")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ func (a *App) SendNotifyAdminPosts(c request.CTX, workspaceName string, currentS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.FinishSendAdminNotifyPost(trial, now, pluginBasedData)
|
a.FinishSendAdminNotifyPost(c, trial, now, pluginBasedData)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ func (a *App) pluginInstallAdminNotifyPost(c request.CTX, userBasedData map[stri
|
|||||||
|
|
||||||
channel, appErr := a.GetOrCreateDirectChannel(c, systemBot.UserId, admin.Id)
|
channel, appErr := a.GetOrCreateDirectChannel(c, systemBot.UserId, admin.Id)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
a.Log().Warn("Error getting direct channel", mlog.Err(appErr))
|
c.Logger().Warn("Error getting direct channel", mlog.Err(appErr))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ func (a *App) pluginInstallAdminNotifyPost(c request.CTX, userBasedData map[stri
|
|||||||
|
|
||||||
_, appErr = a.CreatePost(c, post, channel, false, true)
|
_, appErr = a.CreatePost(c, post, channel, false, true)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
a.Log().Warn("Error creating post", mlog.Err(appErr))
|
c.Logger().Warn("Error creating post", mlog.Err(appErr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ func (a *App) upgradePlanAdminNotifyPost(c request.CTX, workspaceName string, us
|
|||||||
|
|
||||||
channel, appErr := a.GetOrCreateDirectChannel(c, systemBot.UserId, admin.Id)
|
channel, appErr := a.GetOrCreateDirectChannel(c, systemBot.UserId, admin.Id)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
a.Log().Warn("Error getting direct channel", mlog.Err(appErr))
|
c.Logger().Warn("Error getting direct channel", mlog.Err(appErr))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ func (a *App) upgradePlanAdminNotifyPost(c request.CTX, workspaceName string, us
|
|||||||
_, appErr = a.CreatePost(c, post, channel, false, true)
|
_, appErr = a.CreatePost(c, post, channel, false, true)
|
||||||
|
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
a.Log().Warn("Error creating post", mlog.Err(appErr))
|
c.Logger().Warn("Error creating post", mlog.Err(appErr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ func (a *App) UserAlreadyNotifiedOnRequiredFeature(user string, feature model.Ma
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CanNotifyAdmin(trial bool) bool {
|
func (a *App) CanNotifyAdmin(rctx request.CTX, trial bool) bool {
|
||||||
systemVarName := lastUpgradeNotificationTimeStamp
|
systemVarName := lastUpgradeNotificationTimeStamp
|
||||||
if trial {
|
if trial {
|
||||||
systemVarName = lastTrialNotificationTimeStamp
|
systemVarName = lastTrialNotificationTimeStamp
|
||||||
@@ -224,13 +224,13 @@ func (a *App) CanNotifyAdmin(trial bool) bool {
|
|||||||
if errors.As(sysValErr, &nfErr) { // if no timestamps have been recorded before, system is free to notify
|
if errors.As(sysValErr, &nfErr) { // if no timestamps have been recorded before, system is free to notify
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
a.Log().Error("Cannot notify", mlog.Err(sysValErr))
|
rctx.Logger().Error("Cannot notify", mlog.Err(sysValErr))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
lastNotificationTimestamp, err := strconv.ParseFloat(sysVal.Value, 64)
|
lastNotificationTimestamp, err := strconv.ParseFloat(sysVal.Value, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Error("Cannot notify", mlog.Err(err))
|
rctx.Logger().Error("Cannot notify", mlog.Err(err))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ func (a *App) CanNotifyAdmin(trial bool) bool {
|
|||||||
return timeDiff >= int64(daysToMillis)
|
return timeDiff >= int64(daysToMillis)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) FinishSendAdminNotifyPost(trial bool, now int64, pluginBasedData map[string][]*model.NotifyAdminData) {
|
func (a *App) FinishSendAdminNotifyPost(rctx request.CTX, trial bool, now int64, pluginBasedData map[string][]*model.NotifyAdminData) {
|
||||||
systemVarName := lastUpgradeNotificationTimeStamp
|
systemVarName := lastUpgradeNotificationTimeStamp
|
||||||
if trial {
|
if trial {
|
||||||
systemVarName = lastTrialNotificationTimeStamp
|
systemVarName = lastTrialNotificationTimeStamp
|
||||||
@@ -253,7 +253,7 @@ func (a *App) FinishSendAdminNotifyPost(trial bool, now int64, pluginBasedData m
|
|||||||
val := strconv.FormatInt(model.GetMillis(), 10)
|
val := strconv.FormatInt(model.GetMillis(), 10)
|
||||||
sysVar := &model.System{Name: systemVarName, Value: val}
|
sysVar := &model.System{Name: systemVarName, Value: val}
|
||||||
if err := a.Srv().Store().System().SaveOrUpdate(sysVar); err != nil {
|
if err := a.Srv().Store().System().SaveOrUpdate(sysVar); err != nil {
|
||||||
a.Log().Error("Unable to finish send admin notify post job", mlog.Err(err))
|
rctx.Logger().Error("Unable to finish send admin notify post job", mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the requested features notifications are now sent in a post and can safely be removed except
|
// All the requested features notifications are now sent in a post and can safely be removed except
|
||||||
@@ -266,13 +266,13 @@ func (a *App) FinishSendAdminNotifyPost(trial bool, now int64, pluginBasedData m
|
|||||||
requiredPlan := notification.RequiredPlan
|
requiredPlan := notification.RequiredPlan
|
||||||
userId := notification.UserId
|
userId := notification.UserId
|
||||||
if err := a.Srv().Store().NotifyAdmin().Update(userId, requiredPlan, requiredFeature, now); err != nil {
|
if err := a.Srv().Store().NotifyAdmin().Update(userId, requiredPlan, requiredFeature, now); err != nil {
|
||||||
a.Log().Error("Unable to update SentAt for work template feature", mlog.Err(err))
|
rctx.Logger().Error("Unable to update SentAt for work template feature", mlog.Err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.Srv().Store().NotifyAdmin().DeleteBefore(trial, now); err != nil {
|
if err := a.Srv().Store().NotifyAdmin().DeleteBefore(trial, now); err != nil {
|
||||||
a.Log().Error("Unable to finish send admin notify post job", mlog.Err(err))
|
rctx.Logger().Error("Unable to finish send admin notify post job", mlog.Err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func (a *App) UpdateOAuthApp(oldApp, updatedApp *model.OAuthApp) (*model.OAuthAp
|
|||||||
return oauthApp, nil
|
return oauthApp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) DeleteOAuthApp(appID string) *model.AppError {
|
func (a *App) DeleteOAuthApp(rctx request.CTX, appID string) *model.AppError {
|
||||||
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||||
return model.NewAppError("DeleteOAuthApp", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
|
return model.NewAppError("DeleteOAuthApp", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ func (a *App) DeleteOAuthApp(appID string) *model.AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := a.Srv().InvalidateAllCaches(); err != nil {
|
if err := a.Srv().InvalidateAllCaches(); err != nil {
|
||||||
mlog.Warn("error in invalidating cache", mlog.Err(err))
|
rctx.Logger().Warn("error in invalidating cache", mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func TestOAuthDeleteApp(t *testing.T) {
|
|||||||
_, nErr := th.App.Srv().Store().OAuth().SaveAccessData(accessData)
|
_, nErr := th.App.Srv().Store().OAuth().SaveAccessData(accessData)
|
||||||
require.NoError(t, nErr)
|
require.NoError(t, nErr)
|
||||||
|
|
||||||
err = th.App.DeleteOAuthApp(a1.Id)
|
err = th.App.DeleteOAuthApp(th.Context, a1.Id)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
_, err = th.App.GetSession(session.Token)
|
_, err = th.App.GetSession(session.Token)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (a *App) CompleteOnboarding(c request.CTX, request *model.CompleteOnboardin
|
|||||||
Value: request.Organization,
|
Value: request.Organization,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Error("failed to save organization name", mlog.Err(err))
|
c.Logger().Error("failed to save organization name", mlog.Err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1074,7 +1074,7 @@ func (a *OpenTracingAppLayer) BulkImportWithPath(c request.CTX, jsonlReader io.R
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) CanNotifyAdmin(trial bool) bool {
|
func (a *OpenTracingAppLayer) CanNotifyAdmin(rctx request.CTX, trial bool) bool {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CanNotifyAdmin")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CanNotifyAdmin")
|
||||||
|
|
||||||
@@ -1086,7 +1086,7 @@ func (a *OpenTracingAppLayer) CanNotifyAdmin(trial bool) bool {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0 := a.app.CanNotifyAdmin(trial)
|
resultVar0 := a.app.CanNotifyAdmin(rctx, trial)
|
||||||
|
|
||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
@@ -1664,7 +1664,7 @@ func (a *OpenTracingAppLayer) CommandsForTeam(teamID string) []*model.Command {
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) CompareAndDeletePluginKey(pluginID string, key string, oldValue []byte) (bool, *model.AppError) {
|
func (a *OpenTracingAppLayer) CompareAndDeletePluginKey(rctx request.CTX, pluginID string, key string, oldValue []byte) (bool, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CompareAndDeletePluginKey")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CompareAndDeletePluginKey")
|
||||||
|
|
||||||
@@ -1676,7 +1676,7 @@ func (a *OpenTracingAppLayer) CompareAndDeletePluginKey(pluginID string, key str
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.CompareAndDeletePluginKey(pluginID, key, oldValue)
|
resultVar0, resultVar1 := a.app.CompareAndDeletePluginKey(rctx, pluginID, key, oldValue)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -2456,7 +2456,7 @@ func (a *OpenTracingAppLayer) CreateOutgoingWebhook(hook *model.OutgoingWebhook)
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) CreatePasswordRecoveryToken(userID string, email string) (*model.Token, *model.AppError) {
|
func (a *OpenTracingAppLayer) CreatePasswordRecoveryToken(rctx request.CTX, userID string, email string) (*model.Token, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreatePasswordRecoveryToken")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreatePasswordRecoveryToken")
|
||||||
|
|
||||||
@@ -2468,7 +2468,7 @@ func (a *OpenTracingAppLayer) CreatePasswordRecoveryToken(userID string, email s
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.CreatePasswordRecoveryToken(userID, email)
|
resultVar0, resultVar1 := a.app.CreatePasswordRecoveryToken(rctx, userID, email)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -2786,7 +2786,7 @@ func (a *OpenTracingAppLayer) CreateUser(c request.CTX, user *model.User) (*mode
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
func (a *OpenTracingAppLayer) CreateUserAccessToken(rctx request.CTX, token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreateUserAccessToken")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreateUserAccessToken")
|
||||||
|
|
||||||
@@ -2798,7 +2798,7 @@ func (a *OpenTracingAppLayer) CreateUserAccessToken(token *model.UserAccessToken
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.CreateUserAccessToken(token)
|
resultVar0, resultVar1 := a.app.CreateUserAccessToken(rctx, token)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -3287,7 +3287,7 @@ func (a *OpenTracingAppLayer) DeleteEmoji(c request.CTX, emoji *model.Emoji) *mo
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) DeleteEphemeralPost(userID string, postID string) {
|
func (a *OpenTracingAppLayer) DeleteEphemeralPost(rctx request.CTX, userID string, postID string) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteEphemeralPost")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteEphemeralPost")
|
||||||
|
|
||||||
@@ -3299,7 +3299,7 @@ func (a *OpenTracingAppLayer) DeleteEphemeralPost(userID string, postID string)
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
a.app.DeleteEphemeralPost(userID, postID)
|
a.app.DeleteEphemeralPost(rctx, userID, postID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) DeleteExport(name string) *model.AppError {
|
func (a *OpenTracingAppLayer) DeleteExport(name string) *model.AppError {
|
||||||
@@ -3456,7 +3456,7 @@ func (a *OpenTracingAppLayer) DeleteIncomingWebhook(hookID string) *model.AppErr
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) DeleteOAuthApp(appID string) *model.AppError {
|
func (a *OpenTracingAppLayer) DeleteOAuthApp(rctx request.CTX, appID string) *model.AppError {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteOAuthApp")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteOAuthApp")
|
||||||
|
|
||||||
@@ -3468,7 +3468,7 @@ func (a *OpenTracingAppLayer) DeleteOAuthApp(appID string) *model.AppError {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0 := a.app.DeleteOAuthApp(appID)
|
resultVar0 := a.app.DeleteOAuthApp(rctx, appID)
|
||||||
|
|
||||||
if resultVar0 != nil {
|
if resultVar0 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar0))
|
span.LogFields(spanlog.Error(resultVar0))
|
||||||
@@ -4718,7 +4718,7 @@ func (a *OpenTracingAppLayer) FindTeamByName(name string) bool {
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) FinishSendAdminNotifyPost(trial bool, now int64, pluginBasedData map[string][]*model.NotifyAdminData) {
|
func (a *OpenTracingAppLayer) FinishSendAdminNotifyPost(rctx request.CTX, trial bool, now int64, pluginBasedData map[string][]*model.NotifyAdminData) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FinishSendAdminNotifyPost")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.FinishSendAdminNotifyPost")
|
||||||
|
|
||||||
@@ -4730,7 +4730,7 @@ func (a *OpenTracingAppLayer) FinishSendAdminNotifyPost(trial bool, now int64, p
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
a.app.FinishSendAdminNotifyPost(trial, now, pluginBasedData)
|
a.app.FinishSendAdminNotifyPost(rctx, trial, now, pluginBasedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) GenerateAndSaveDesktopToken(createAt int64, user *model.User) (*string, *model.AppError) {
|
func (a *OpenTracingAppLayer) GenerateAndSaveDesktopToken(createAt int64, user *model.User) (*string, *model.AppError) {
|
||||||
@@ -7558,7 +7558,7 @@ func (a *OpenTracingAppLayer) GetLogsSkipSend(rctx request.CTX, page int, perPag
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError) {
|
func (a *OpenTracingAppLayer) GetMarketplacePlugins(rctx request.CTX, filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetMarketplacePlugins")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetMarketplacePlugins")
|
||||||
|
|
||||||
@@ -7570,7 +7570,7 @@ func (a *OpenTracingAppLayer) GetMarketplacePlugins(filter *model.MarketplacePlu
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.GetMarketplacePlugins(filter)
|
resultVar0, resultVar1 := a.app.GetMarketplacePlugins(rctx, filter)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -8005,7 +8005,7 @@ func (a *OpenTracingAppLayer) GetOrCreateDirectChannel(c request.CTX, userID str
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) GetOrCreateTrueUpReviewStatus() (*model.TrueUpReviewStatus, *model.AppError) {
|
func (a *OpenTracingAppLayer) GetOrCreateTrueUpReviewStatus(rctx request.CTX) (*model.TrueUpReviewStatus, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetOrCreateTrueUpReviewStatus")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetOrCreateTrueUpReviewStatus")
|
||||||
|
|
||||||
@@ -8017,7 +8017,7 @@ func (a *OpenTracingAppLayer) GetOrCreateTrueUpReviewStatus() (*model.TrueUpRevi
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.GetOrCreateTrueUpReviewStatus()
|
resultVar0, resultVar1 := a.app.GetOrCreateTrueUpReviewStatus(rctx)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -10089,7 +10089,7 @@ func (a *OpenTracingAppLayer) GetTeamIcon(team *model.Team) ([]byte, *model.AppE
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) GetTeamIdFromQuery(query url.Values) (string, *model.AppError) {
|
func (a *OpenTracingAppLayer) GetTeamIdFromQuery(rctx request.CTX, query url.Values) (string, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTeamIdFromQuery")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTeamIdFromQuery")
|
||||||
|
|
||||||
@@ -10101,7 +10101,7 @@ func (a *OpenTracingAppLayer) GetTeamIdFromQuery(query url.Values) (string, *mod
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.GetTeamIdFromQuery(query)
|
resultVar0, resultVar1 := a.app.GetTeamIdFromQuery(rctx, query)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -12094,7 +12094,7 @@ func (a *OpenTracingAppLayer) InvalidatePasswordRecoveryTokensForUser(userID str
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) InviteGuestsToChannels(teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError {
|
func (a *OpenTracingAppLayer) InviteGuestsToChannels(rctx request.CTX, teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteGuestsToChannels")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteGuestsToChannels")
|
||||||
|
|
||||||
@@ -12106,7 +12106,7 @@ func (a *OpenTracingAppLayer) InviteGuestsToChannels(teamID string, guestsInvite
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0 := a.app.InviteGuestsToChannels(teamID, guestsInvite, senderId)
|
resultVar0 := a.app.InviteGuestsToChannels(rctx, teamID, guestsInvite, senderId)
|
||||||
|
|
||||||
if resultVar0 != nil {
|
if resultVar0 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar0))
|
span.LogFields(spanlog.Error(resultVar0))
|
||||||
@@ -12116,7 +12116,7 @@ func (a *OpenTracingAppLayer) InviteGuestsToChannels(teamID string, guestsInvite
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) InviteGuestsToChannelsGracefully(teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
func (a *OpenTracingAppLayer) InviteGuestsToChannelsGracefully(rctx request.CTX, teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteGuestsToChannelsGracefully")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteGuestsToChannelsGracefully")
|
||||||
|
|
||||||
@@ -12128,7 +12128,7 @@ func (a *OpenTracingAppLayer) InviteGuestsToChannelsGracefully(teamID string, gu
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.InviteGuestsToChannelsGracefully(teamID, guestsInvite, senderId)
|
resultVar0, resultVar1 := a.app.InviteGuestsToChannelsGracefully(rctx, teamID, guestsInvite, senderId)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -12138,7 +12138,7 @@ func (a *OpenTracingAppLayer) InviteGuestsToChannelsGracefully(teamID string, gu
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) InviteNewUsersToTeam(emailList []string, teamID string, senderId string) *model.AppError {
|
func (a *OpenTracingAppLayer) InviteNewUsersToTeam(rctx request.CTX, emailList []string, teamID string, senderId string) *model.AppError {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteNewUsersToTeam")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteNewUsersToTeam")
|
||||||
|
|
||||||
@@ -12150,7 +12150,7 @@ func (a *OpenTracingAppLayer) InviteNewUsersToTeam(emailList []string, teamID st
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0 := a.app.InviteNewUsersToTeam(emailList, teamID, senderId)
|
resultVar0 := a.app.InviteNewUsersToTeam(rctx, emailList, teamID, senderId)
|
||||||
|
|
||||||
if resultVar0 != nil {
|
if resultVar0 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar0))
|
span.LogFields(spanlog.Error(resultVar0))
|
||||||
@@ -12160,7 +12160,7 @@ func (a *OpenTracingAppLayer) InviteNewUsersToTeam(emailList []string, teamID st
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) InviteNewUsersToTeamGracefully(memberInvite *model.MemberInvite, teamID string, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError) {
|
func (a *OpenTracingAppLayer) InviteNewUsersToTeamGracefully(rctx request.CTX, memberInvite *model.MemberInvite, teamID string, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteNewUsersToTeamGracefully")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.InviteNewUsersToTeamGracefully")
|
||||||
|
|
||||||
@@ -12172,7 +12172,7 @@ func (a *OpenTracingAppLayer) InviteNewUsersToTeamGracefully(memberInvite *model
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.InviteNewUsersToTeamGracefully(memberInvite, teamID, senderId, reminderInterval)
|
resultVar0, resultVar1 := a.app.InviteNewUsersToTeamGracefully(rctx, memberInvite, teamID, senderId, reminderInterval)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -14161,7 +14161,7 @@ func (a *OpenTracingAppLayer) RegisterPluginCommand(pluginID string, command *mo
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (remoteID string, err error) {
|
func (a *OpenTracingAppLayer) RegisterPluginForSharedChannels(rctx request.CTX, opts model.RegisterPluginOpts) (remoteID string, err error) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RegisterPluginForSharedChannels")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RegisterPluginForSharedChannels")
|
||||||
|
|
||||||
@@ -14173,7 +14173,7 @@ func (a *OpenTracingAppLayer) RegisterPluginForSharedChannels(opts model.Registe
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.RegisterPluginForSharedChannels(opts)
|
resultVar0, resultVar1 := a.app.RegisterPluginForSharedChannels(rctx, opts)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -16046,7 +16046,7 @@ func (a *OpenTracingAppLayer) SendNotifyAdminPosts(c request.CTX, workspaceName
|
|||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) SendPasswordReset(email string, siteURL string) (bool, *model.AppError) {
|
func (a *OpenTracingAppLayer) SendPasswordReset(rctx request.CTX, email string, siteURL string) (bool, *model.AppError) {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SendPasswordReset")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SendPasswordReset")
|
||||||
|
|
||||||
@@ -16058,7 +16058,7 @@ func (a *OpenTracingAppLayer) SendPasswordReset(email string, siteURL string) (b
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.SendPasswordReset(email, siteURL)
|
resultVar0, resultVar1 := a.app.SendPasswordReset(rctx, email, siteURL)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
@@ -16632,7 +16632,7 @@ func (a *OpenTracingAppLayer) SetPluginKeyWithOptions(pluginID string, key strin
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) SetPostReminder(postID string, userID string, targetTime int64) *model.AppError {
|
func (a *OpenTracingAppLayer) SetPostReminder(rctx request.CTX, postID string, userID string, targetTime int64) *model.AppError {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SetPostReminder")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SetPostReminder")
|
||||||
|
|
||||||
@@ -16644,7 +16644,7 @@ func (a *OpenTracingAppLayer) SetPostReminder(postID string, userID string, targ
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0 := a.app.SetPostReminder(postID, userID, targetTime)
|
resultVar0 := a.app.SetPostReminder(rctx, postID, userID, targetTime)
|
||||||
|
|
||||||
if resultVar0 != nil {
|
if resultVar0 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar0))
|
span.LogFields(spanlog.Error(resultVar0))
|
||||||
@@ -19165,7 +19165,7 @@ func (a *OpenTracingAppLayer) UserCanSeeOtherUser(c request.CTX, userID string,
|
|||||||
return resultVar0, resultVar1
|
return resultVar0, resultVar1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OpenTracingAppLayer) UserIsFirstAdmin(user *model.User) bool {
|
func (a *OpenTracingAppLayer) UserIsFirstAdmin(rctx request.CTX, user *model.User) bool {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.UserIsFirstAdmin")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.UserIsFirstAdmin")
|
||||||
|
|
||||||
@@ -19177,7 +19177,7 @@ func (a *OpenTracingAppLayer) UserIsFirstAdmin(user *model.User) bool {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0 := a.app.UserIsFirstAdmin(user)
|
resultVar0 := a.app.UserIsFirstAdmin(rctx, user)
|
||||||
|
|
||||||
return resultVar0
|
return resultVar0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ func (ps *PlatformService) UpdateSessionsIsGuest(c request.CTX, user *model.User
|
|||||||
session.AddProp(model.SessionPropIsGuest, strconv.FormatBool(isGuest))
|
session.AddProp(model.SessionPropIsGuest, strconv.FormatBool(isGuest))
|
||||||
err := ps.Store.Session().UpdateProps(session)
|
err := ps.Store.Session().UpdateProps(session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Warn("Unable to update isGuest session", mlog.Err(err))
|
c.Logger().Warn("Unable to update isGuest session", mlog.Err(err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ps.AddSessionToCache(session)
|
ps.AddSessionToCache(session)
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ func (a *App) GetPlugins() (*model.PluginsResponse, *model.AppError) {
|
|||||||
|
|
||||||
// GetMarketplacePlugins returns a list of plugins from the marketplace-server,
|
// GetMarketplacePlugins returns a list of plugins from the marketplace-server,
|
||||||
// and plugins that are installed locally.
|
// and plugins that are installed locally.
|
||||||
func (a *App) GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError) {
|
func (a *App) GetMarketplacePlugins(rctx request.CTX, filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError) {
|
||||||
plugins := map[string]*model.MarketplacePlugin{}
|
plugins := map[string]*model.MarketplacePlugin{}
|
||||||
|
|
||||||
if *a.Config().PluginSettings.EnableRemoteMarketplace && !filter.LocalOnly {
|
if *a.Config().PluginSettings.EnableRemoteMarketplace && !filter.LocalOnly {
|
||||||
@@ -539,7 +539,7 @@ func (a *App) GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*m
|
|||||||
return nil, appErr
|
return nil, appErr
|
||||||
}
|
}
|
||||||
|
|
||||||
appErr = a.mergeLocalPlugins(plugins)
|
appErr = a.mergeLocalPlugins(rctx, plugins)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return nil, appErr
|
return nil, appErr
|
||||||
}
|
}
|
||||||
@@ -692,7 +692,7 @@ func (a *App) mergePrepackagedPlugins(remoteMarketplacePlugins map[string]*model
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mergeLocalPlugins merges locally installed plugins to remote marketplace plugins list.
|
// mergeLocalPlugins merges locally installed plugins to remote marketplace plugins list.
|
||||||
func (a *App) mergeLocalPlugins(remoteMarketplacePlugins map[string]*model.MarketplacePlugin) *model.AppError {
|
func (a *App) mergeLocalPlugins(rctx request.CTX, remoteMarketplacePlugins map[string]*model.MarketplacePlugin) *model.AppError {
|
||||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||||
if pluginsEnvironment == nil {
|
if pluginsEnvironment == nil {
|
||||||
return model.NewAppError("GetMarketplacePlugins", "app.plugin.config.app_error", nil, "", http.StatusInternalServerError)
|
return model.NewAppError("GetMarketplacePlugins", "app.plugin.config.app_error", nil, "", http.StatusInternalServerError)
|
||||||
@@ -718,7 +718,7 @@ func (a *App) mergeLocalPlugins(remoteMarketplacePlugins map[string]*model.Marke
|
|||||||
if plugin.Manifest.IconPath != "" {
|
if plugin.Manifest.IconPath != "" {
|
||||||
iconData, err = getIcon(filepath.Join(plugin.Path, plugin.Manifest.IconPath))
|
iconData, err = getIcon(filepath.Join(plugin.Path, plugin.Manifest.IconPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Error loading local plugin icon", mlog.String("plugin_id", plugin.Manifest.Id), mlog.String("icon_path", plugin.Manifest.IconPath), mlog.Err(err))
|
rctx.Logger().Warn("Error loading local plugin icon", mlog.String("plugin_id", plugin.Manifest.Id), mlog.String("icon_path", plugin.Manifest.IconPath), mlog.Err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ func (api *PluginAPI) RevokeSession(sessionID string) *model.AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
func (api *PluginAPI) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
||||||
return api.app.CreateUserAccessToken(token)
|
return api.app.CreateUserAccessToken(api.ctx, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) RevokeUserAccessToken(tokenID string) *model.AppError {
|
func (api *PluginAPI) RevokeUserAccessToken(tokenID string) *model.AppError {
|
||||||
@@ -683,7 +683,7 @@ func (api *PluginAPI) UpdateEphemeralPost(userID string, post *model.Post) *mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) DeleteEphemeralPost(userID, postID string) {
|
func (api *PluginAPI) DeleteEphemeralPost(userID, postID string) {
|
||||||
api.app.DeleteEphemeralPost(userID, postID)
|
api.app.DeleteEphemeralPost(api.ctx, userID, postID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) DeletePost(postID string) *model.AppError {
|
func (api *PluginAPI) DeletePost(postID string) *model.AppError {
|
||||||
@@ -948,7 +948,7 @@ func (api *PluginAPI) KVCompareAndSet(key string, oldValue, newValue []byte) (bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) KVCompareAndDelete(key string, oldValue []byte) (bool, *model.AppError) {
|
func (api *PluginAPI) KVCompareAndDelete(key string, oldValue []byte) (bool, *model.AppError) {
|
||||||
return api.app.CompareAndDeletePluginKey(api.id, key, oldValue)
|
return api.app.CompareAndDeletePluginKey(api.ctx, api.id, key, oldValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) KVSetWithExpiry(key string, value []byte, expireInSeconds int64) *model.AppError {
|
func (api *PluginAPI) KVSetWithExpiry(key string, value []byte, expireInSeconds int64) *model.AppError {
|
||||||
@@ -1211,7 +1211,7 @@ func (api *PluginAPI) UpdateOAuthApp(app *model.OAuthApp) (*model.OAuthApp, *mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) DeleteOAuthApp(appID string) *model.AppError {
|
func (api *PluginAPI) DeleteOAuthApp(appID string) *model.AppError {
|
||||||
return api.app.DeleteOAuthApp(appID)
|
return api.app.DeleteOAuthApp(api.ctx, appID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublishPluginClusterEvent broadcasts a plugin event to all other running instances of
|
// PublishPluginClusterEvent broadcasts a plugin event to all other running instances of
|
||||||
@@ -1296,11 +1296,11 @@ func (api *PluginAPI) GetUploadSession(uploadID string) (*model.UploadSession, e
|
|||||||
|
|
||||||
func (api *PluginAPI) SendPushNotification(notification *model.PushNotification, userID string) *model.AppError {
|
func (api *PluginAPI) SendPushNotification(notification *model.PushNotification, userID string) *model.AppError {
|
||||||
// Ignoring skipSessionId because it's only used internally to clear push notifications
|
// Ignoring skipSessionId because it's only used internally to clear push notifications
|
||||||
return api.app.sendPushNotificationToAllSessions(notification, userID, "")
|
return api.app.sendPushNotificationToAllSessions(api.ctx, notification, userID, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (remoteID string, err error) {
|
func (api *PluginAPI) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (remoteID string, err error) {
|
||||||
return api.app.RegisterPluginForSharedChannels(opts)
|
return api.app.RegisterPluginForSharedChannels(api.ctx, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PluginAPI) UnregisterPluginForSharedChannels(pluginID string) error {
|
func (api *PluginAPI) UnregisterPluginForSharedChannels(pluginID string) error {
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ func (ch *Channels) installPluginFromClusterMessage(pluginID string) {
|
|||||||
defer signature.Close()
|
defer signature.Close()
|
||||||
|
|
||||||
if err := ch.verifyPlugin(bundle, signature); err != nil {
|
if err := ch.verifyPlugin(bundle, signature); err != nil {
|
||||||
mlog.Error("Failed to validate plugin signature.", mlog.Err(appErr))
|
logger.Error("Failed to validate plugin signature.", mlog.Err(appErr))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||||
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ func (a *App) SetPluginKeyWithOptions(pluginID string, key string, value []byte,
|
|||||||
return a.Srv().Platform().SetPluginKeyWithOptions(pluginID, key, value, options)
|
return a.Srv().Platform().SetPluginKeyWithOptions(pluginID, key, value, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CompareAndDeletePluginKey(pluginID string, key string, oldValue []byte) (bool, *model.AppError) {
|
func (a *App) CompareAndDeletePluginKey(rctx request.CTX, pluginID string, key string, oldValue []byte) (bool, *model.AppError) {
|
||||||
kv := &model.PluginKeyValue{
|
kv := &model.PluginKeyValue{
|
||||||
PluginId: pluginID,
|
PluginId: pluginID,
|
||||||
Key: key,
|
Key: key,
|
||||||
@@ -52,7 +53,7 @@ func (a *App) CompareAndDeletePluginKey(pluginID string, key string, oldValue []
|
|||||||
|
|
||||||
deleted, err := a.Srv().Store().Plugin().CompareAndDelete(kv, oldValue)
|
deleted, err := a.Srv().Store().Plugin().CompareAndDelete(kv, oldValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Error("Failed to compare and delete plugin key value", mlog.String("plugin_id", pluginID), mlog.String("key", key), mlog.Err(err))
|
rctx.Logger().Error("Failed to compare and delete plugin key value", mlog.String("key", key), mlog.Err(err))
|
||||||
var appErr *model.AppError
|
var appErr *model.AppError
|
||||||
switch {
|
switch {
|
||||||
case errors.As(err, &appErr):
|
case errors.As(err, &appErr):
|
||||||
@@ -64,7 +65,7 @@ func (a *App) CompareAndDeletePluginKey(pluginID string, key string, oldValue []
|
|||||||
|
|
||||||
// Clean up a previous entry using the hashed key, if it exists.
|
// Clean up a previous entry using the hashed key, if it exists.
|
||||||
if err := a.Srv().Store().Plugin().Delete(pluginID, getKeyHash(key)); err != nil {
|
if err := a.Srv().Store().Plugin().Delete(pluginID, getKeyHash(key)); err != nil {
|
||||||
mlog.Warn("Failed to clean up previously hashed plugin key value", mlog.String("plugin_id", pluginID), mlog.String("key", key), mlog.Err(err))
|
rctx.Logger().Warn("Failed to clean up previously hashed plugin key value", mlog.String("key", key), mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return deleted, nil
|
return deleted, nil
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ func TestHandlePluginRequest(t *testing.T) {
|
|||||||
*cfg.ServiceSettings.EnableUserAccessTokens = true
|
*cfg.ServiceSettings.EnableUserAccessTokens = true
|
||||||
})
|
})
|
||||||
|
|
||||||
token, err := th.App.CreateUserAccessToken(&model.UserAccessToken{
|
token, err := th.App.CreateUserAccessToken(th.Context, &model.UserAccessToken{
|
||||||
UserId: th.BasicUser.Id,
|
UserId: th.BasicUser.Id,
|
||||||
})
|
})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ func (a *App) CreatePostMissingChannel(c request.CTX, post *model.Post, triggerW
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deduplicateCreatePost attempts to make posting idempotent within a caching window.
|
// deduplicateCreatePost attempts to make posting idempotent within a caching window.
|
||||||
func (a *App) deduplicateCreatePost(post *model.Post) (foundPost *model.Post, err *model.AppError) {
|
func (a *App) deduplicateCreatePost(rctx request.CTX, post *model.Post) (foundPost *model.Post, err *model.AppError) {
|
||||||
// We rely on the client sending the pending post id across "duplicate" requests. If there
|
// We rely on the client sending the pending post id across "duplicate" requests. If there
|
||||||
// isn't one, we can't deduplicate, so allow creation normally.
|
// isn't one, we can't deduplicate, so allow creation normally.
|
||||||
if post.PendingPostId == "" {
|
if post.PendingPostId == "" {
|
||||||
@@ -135,13 +135,13 @@ func (a *App) deduplicateCreatePost(post *model.Post) (foundPost *model.Post, er
|
|||||||
return nil, model.NewAppError("deduplicateCreatePost", "api.post.deduplicate_create_post.failed_to_get", nil, "", http.StatusInternalServerError).Wrap(err)
|
return nil, model.NewAppError("deduplicateCreatePost", "api.post.deduplicate_create_post.failed_to_get", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mlog.Debug("Deduplicated create post", mlog.String("post_id", actualPost.Id), mlog.String("pending_post_id", post.PendingPostId))
|
rctx.Logger().Debug("Deduplicated create post", mlog.String("post_id", actualPost.Id), mlog.String("pending_post_id", post.PendingPostId))
|
||||||
|
|
||||||
return actualPost, nil
|
return actualPost, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError) {
|
func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError) {
|
||||||
foundPost, err := a.deduplicateCreatePost(post)
|
foundPost, err := a.deduplicateCreatePost(c, post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -588,7 +588,7 @@ func (a *App) UpdateEphemeralPost(c request.CTX, userID string, post *model.Post
|
|||||||
|
|
||||||
sanitizedPost, appErr := a.SanitizePostMetadataForUser(c, post, userID)
|
sanitizedPost, appErr := a.SanitizePostMetadataForUser(c, post, userID)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
mlog.Error("Failed to sanitize post metadata for user", mlog.String("user_id", userID), mlog.Err(appErr))
|
c.Logger().Error("Failed to sanitize post metadata for user", mlog.String("user_id", userID), mlog.Err(appErr))
|
||||||
|
|
||||||
// If we failed to sanitize the post, we still want to remove the metadata.
|
// If we failed to sanitize the post, we still want to remove the metadata.
|
||||||
sanitizedPost = post.Clone()
|
sanitizedPost = post.Clone()
|
||||||
@@ -607,7 +607,7 @@ func (a *App) UpdateEphemeralPost(c request.CTX, userID string, post *model.Post
|
|||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) DeleteEphemeralPost(userID, postID string) {
|
func (a *App) DeleteEphemeralPost(rctx request.CTX, userID, postID string) {
|
||||||
post := &model.Post{
|
post := &model.Post{
|
||||||
Id: postID,
|
Id: postID,
|
||||||
UserId: userID,
|
UserId: userID,
|
||||||
@@ -619,7 +619,7 @@ func (a *App) DeleteEphemeralPost(userID, postID string) {
|
|||||||
message := model.NewWebSocketEvent(model.WebsocketEventPostDeleted, "", "", userID, nil, "")
|
message := model.NewWebSocketEvent(model.WebsocketEventPostDeleted, "", "", userID, nil, "")
|
||||||
postJSON, jsonErr := post.ToJSON()
|
postJSON, jsonErr := post.ToJSON()
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
mlog.Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
rctx.Logger().Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
||||||
}
|
}
|
||||||
message.Add("post", postJSON)
|
message.Add("post", postJSON)
|
||||||
a.Publish(message)
|
a.Publish(message)
|
||||||
@@ -2137,7 +2137,7 @@ func (a *App) GetEditHistoryForPost(postID string) ([]*model.Post, *model.AppErr
|
|||||||
return posts, nil
|
return posts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SetPostReminder(postID, userID string, targetTime int64) *model.AppError {
|
func (a *App) SetPostReminder(rctx request.CTX, postID, userID string, targetTime int64) *model.AppError {
|
||||||
// Store the reminder in the DB
|
// Store the reminder in the DB
|
||||||
reminder := &model.PostReminder{
|
reminder := &model.PostReminder{
|
||||||
PostId: postID,
|
PostId: postID,
|
||||||
@@ -2185,12 +2185,12 @@ func (a *App) SetPostReminder(postID, userID string, targetTime int64) *model.Ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
message := model.NewWebSocketEvent(model.WebsocketEventEphemeralMessage, "", ephemeralPost.ChannelId, userID, nil, "")
|
message := model.NewWebSocketEvent(model.WebsocketEventEphemeralMessage, "", ephemeralPost.ChannelId, userID, nil, "")
|
||||||
ephemeralPost = a.PreparePostForClientWithEmbedsAndImages(request.EmptyContext(a.Log()), ephemeralPost, true, false, true)
|
ephemeralPost = a.PreparePostForClientWithEmbedsAndImages(rctx, ephemeralPost, true, false, true)
|
||||||
ephemeralPost = model.AddPostActionCookies(ephemeralPost, a.PostActionCookieSecret())
|
ephemeralPost = model.AddPostActionCookies(ephemeralPost, a.PostActionCookieSecret())
|
||||||
|
|
||||||
postJSON, jsonErr := ephemeralPost.ToJSON()
|
postJSON, jsonErr := ephemeralPost.ToJSON()
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
mlog.Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
rctx.Logger().Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
||||||
}
|
}
|
||||||
message.Add("post", postJSON)
|
message.Add("post", postJSON)
|
||||||
a.Publish(message)
|
a.Publish(message)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func (a *App) SaveAcknowledgementForPost(c request.CTX, postID, userID string) (
|
|||||||
// The post is always modified since the UpdateAt always changes
|
// The post is always modified since the UpdateAt always changes
|
||||||
a.Srv().Store().Post().InvalidateLastPostTimeCache(channel.Id)
|
a.Srv().Store().Post().InvalidateLastPostTimeCache(channel.Id)
|
||||||
|
|
||||||
a.sendAcknowledgementEvent(model.WebsocketEventAcknowledgementAdded, acknowledgement, post)
|
a.sendAcknowledgementEvent(c, model.WebsocketEventAcknowledgementAdded, acknowledgement, post)
|
||||||
|
|
||||||
return acknowledgement, nil
|
return acknowledgement, nil
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ func (a *App) DeleteAcknowledgementForPost(c request.CTX, postID, userID string)
|
|||||||
// The post is always modified since the UpdateAt always changes
|
// The post is always modified since the UpdateAt always changes
|
||||||
a.Srv().Store().Post().InvalidateLastPostTimeCache(channel.Id)
|
a.Srv().Store().Post().InvalidateLastPostTimeCache(channel.Id)
|
||||||
|
|
||||||
a.sendAcknowledgementEvent(model.WebsocketEventAcknowledgementRemoved, oldAck, post)
|
a.sendAcknowledgementEvent(c, model.WebsocketEventAcknowledgementRemoved, oldAck, post)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -130,13 +130,13 @@ func (a *App) GetAcknowledgementsForPostList(postList *model.PostList) (map[stri
|
|||||||
return acknowledgementsMap, nil
|
return acknowledgementsMap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) sendAcknowledgementEvent(event model.WebsocketEventType, acknowledgement *model.PostAcknowledgement, post *model.Post) {
|
func (a *App) sendAcknowledgementEvent(rctx request.CTX, event model.WebsocketEventType, acknowledgement *model.PostAcknowledgement, post *model.Post) {
|
||||||
// send out that a acknowledgement has been added/removed
|
// send out that a acknowledgement has been added/removed
|
||||||
message := model.NewWebSocketEvent(event, "", post.ChannelId, "", nil, "")
|
message := model.NewWebSocketEvent(event, "", post.ChannelId, "", nil, "")
|
||||||
|
|
||||||
acknowledgementJSON, err := json.Marshal(acknowledgement)
|
acknowledgementJSON, err := json.Marshal(acknowledgement)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Failed to encode acknowledgement to JSON", mlog.Err(err))
|
rctx.Logger().Warn("Failed to encode acknowledgement to JSON", mlog.Err(err))
|
||||||
}
|
}
|
||||||
message.Add("acknowledgement", string(acknowledgementJSON))
|
message.Add("acknowledgement", string(acknowledgementJSON))
|
||||||
a.Publish(message)
|
a.Publish(message)
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ func (a *App) getEmbedsAndImages(c request.CTX, post *model.Post, isNewPost bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Embeds and image dimensions
|
// Embeds and image dimensions
|
||||||
firstLink, images := a.getFirstLinkAndImages(post.Message)
|
firstLink, images := a.getFirstLinkAndImages(c, post.Message)
|
||||||
|
|
||||||
if unsafeLinksProp := post.GetProp(UnsafeLinksPostProp); unsafeLinksProp != nil {
|
if unsafeLinksProp := post.GetProp(UnsafeLinksPostProp); unsafeLinksProp != nil {
|
||||||
if prop, ok := unsafeLinksProp.(string); ok && prop == "true" {
|
if prop, ok := unsafeLinksProp.(string); ok && prop == "true" {
|
||||||
@@ -361,7 +361,7 @@ func (a *App) getImagesForPost(c request.CTX, post *model.Post, imageURLs []stri
|
|||||||
imageURLs = append(imageURLs, embed.URL)
|
imageURLs = append(imageURLs, embed.URL)
|
||||||
|
|
||||||
case model.PostEmbedMessageAttachment:
|
case model.PostEmbedMessageAttachment:
|
||||||
imageURLs = append(imageURLs, a.getImagesInMessageAttachments(post)...)
|
imageURLs = append(imageURLs, a.getImagesInMessageAttachments(c, post)...)
|
||||||
|
|
||||||
case model.PostEmbedOpengraph:
|
case model.PostEmbedOpengraph:
|
||||||
openGraph, ok := embed.Data.(*opengraph.OpenGraph)
|
openGraph, ok := embed.Data.(*opengraph.OpenGraph)
|
||||||
@@ -483,12 +483,12 @@ func (a *App) getCustomEmojisForPost(c request.CTX, post *model.Post, reactions
|
|||||||
return a.GetMultipleEmojiByName(c, names)
|
return a.GetMultipleEmojiByName(c, names)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) isLinkAllowedForPreview(link string) bool {
|
func (a *App) isLinkAllowedForPreview(rctx request.CTX, link string) bool {
|
||||||
domains := normalizeDomains(*a.Config().ServiceSettings.RestrictLinkPreviews)
|
domains := normalizeDomains(*a.Config().ServiceSettings.RestrictLinkPreviews)
|
||||||
for _, d := range domains {
|
for _, d := range domains {
|
||||||
parsed, err := url.Parse(link)
|
parsed, err := url.Parse(link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Unable to parse the link", mlog.String("link", link), mlog.Err(err))
|
rctx.Logger().Warn("Unable to parse the link", mlog.String("link", link), mlog.Err(err))
|
||||||
// We disable link preview if link is badly formed
|
// We disable link preview if link is badly formed
|
||||||
// to remain on the safe side
|
// to remain on the safe side
|
||||||
return false
|
return false
|
||||||
@@ -496,7 +496,7 @@ func (a *App) isLinkAllowedForPreview(link string) bool {
|
|||||||
// Conforming to IDNA2008 using the UTS-46 standard.
|
// Conforming to IDNA2008 using the UTS-46 standard.
|
||||||
cleaned, err := idna.Lookup.ToASCII(parsed.Hostname())
|
cleaned, err := idna.Lookup.ToASCII(parsed.Hostname())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Unable to lookup hostname to ASCII", mlog.String("hostname", parsed.Hostname()), mlog.Err(err))
|
rctx.Logger().Warn("Unable to lookup hostname to ASCII", mlog.String("hostname", parsed.Hostname()), mlog.Err(err))
|
||||||
// Same applies if compatibility processing fails.
|
// Same applies if compatibility processing fails.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -525,22 +525,22 @@ func normalizeDomains(domains string) []string {
|
|||||||
// Given a string, returns the first autolinked URL in the string as well as an array of all Markdown
|
// Given a string, returns the first autolinked URL in the string as well as an array of all Markdown
|
||||||
// images of the form . Note that this does not return Markdown links of the
|
// images of the form . Note that this does not return Markdown links of the
|
||||||
// form [text](url).
|
// form [text](url).
|
||||||
func (a *App) getFirstLinkAndImages(str string) (string, []string) {
|
func (a *App) getFirstLinkAndImages(c request.CTX, str string) (string, []string) {
|
||||||
firstLink := ""
|
firstLink := ""
|
||||||
images := []string{}
|
images := []string{}
|
||||||
|
|
||||||
markdown.Inspect(str, func(blockOrInline any) bool {
|
markdown.Inspect(str, func(blockOrInline any) bool {
|
||||||
switch v := blockOrInline.(type) {
|
switch v := blockOrInline.(type) {
|
||||||
case *markdown.Autolink:
|
case *markdown.Autolink:
|
||||||
if link := v.Destination(); firstLink == "" && a.isLinkAllowedForPreview(link) {
|
if link := v.Destination(); firstLink == "" && a.isLinkAllowedForPreview(c, link) {
|
||||||
firstLink = link
|
firstLink = link
|
||||||
}
|
}
|
||||||
case *markdown.InlineImage:
|
case *markdown.InlineImage:
|
||||||
if link := v.Destination(); a.isLinkAllowedForPreview(link) {
|
if link := v.Destination(); a.isLinkAllowedForPreview(c, link) {
|
||||||
images = append(images, link)
|
images = append(images, link)
|
||||||
}
|
}
|
||||||
case *markdown.ReferenceImage:
|
case *markdown.ReferenceImage:
|
||||||
if link := v.ReferenceDefinition.Destination(); a.isLinkAllowedForPreview(link) {
|
if link := v.ReferenceDefinition.Destination(); a.isLinkAllowedForPreview(c, link) {
|
||||||
images = append(images, link)
|
images = append(images, link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,14 +551,14 @@ func (a *App) getFirstLinkAndImages(str string) (string, []string) {
|
|||||||
return firstLink, images
|
return firstLink, images
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) getImagesInMessageAttachments(post *model.Post) []string {
|
func (a *App) getImagesInMessageAttachments(rctx request.CTX, post *model.Post) []string {
|
||||||
var images []string
|
var images []string
|
||||||
|
|
||||||
for _, attachment := range post.Attachments() {
|
for _, attachment := range post.Attachments() {
|
||||||
_, imagesInText := a.getFirstLinkAndImages(attachment.Text)
|
_, imagesInText := a.getFirstLinkAndImages(rctx, attachment.Text)
|
||||||
images = append(images, imagesInText...)
|
images = append(images, imagesInText...)
|
||||||
|
|
||||||
_, imagesInPretext := a.getFirstLinkAndImages(attachment.Pretext)
|
_, imagesInPretext := a.getFirstLinkAndImages(rctx, attachment.Pretext)
|
||||||
images = append(images, imagesInPretext...)
|
images = append(images, imagesInPretext...)
|
||||||
|
|
||||||
for _, field := range attachment.Fields {
|
for _, field := range attachment.Fields {
|
||||||
@@ -566,7 +566,7 @@ func (a *App) getImagesInMessageAttachments(post *model.Post) []string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if value, ok := field.Value.(string); ok {
|
if value, ok := field.Value.(string); ok {
|
||||||
_, imagesInFieldValue := a.getFirstLinkAndImages(value)
|
_, imagesInFieldValue := a.getFirstLinkAndImages(rctx, value)
|
||||||
images = append(images, imagesInFieldValue...)
|
images = append(images, imagesInFieldValue...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -604,8 +604,8 @@ func looksLikeAPermalink(url, siteURL string) bool {
|
|||||||
return matched
|
return matched
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) containsPermalink(post *model.Post) bool {
|
func (a *App) containsPermalink(rctx request.CTX, post *model.Post) bool {
|
||||||
link, _ := a.getFirstLinkAndImages(post.Message)
|
link, _ := a.getFirstLinkAndImages(rctx, post.Message)
|
||||||
if link == "" {
|
if link == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -667,7 +667,7 @@ func (a *App) getLinkMetadata(c request.CTX, requestURL string, timestamp int64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get metadata for embedded post
|
// Get metadata for embedded post
|
||||||
if a.containsPermalink(referencedPost) {
|
if a.containsPermalink(c, referencedPost) {
|
||||||
// referencedPost contains a permalink: we don't get its metadata
|
// referencedPost contains a permalink: we don't get its metadata
|
||||||
permalink = &model.Permalink{PreviewPost: model.NewPreviewPost(referencedPost, referencedTeam, referencedChannel)}
|
permalink = &model.Permalink{PreviewPost: model.NewPreviewPost(referencedPost, referencedTeam, referencedChannel)}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1715,7 +1715,7 @@ func TestGetFirstLinkAndImages(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
firstLink, images := th.App.getFirstLinkAndImages(testCase.Input)
|
firstLink, images := th.App.getFirstLinkAndImages(th.Context, testCase.Input)
|
||||||
|
|
||||||
assert.Equal(t, firstLink, testCase.ExpectedFirstLink)
|
assert.Equal(t, firstLink, testCase.ExpectedFirstLink)
|
||||||
assert.Equal(t, images, testCase.ExpectedImages)
|
assert.Equal(t, images, testCase.ExpectedImages)
|
||||||
@@ -1800,7 +1800,7 @@ func TestGetFirstLinkAndImages(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
firstLink, images := th.App.getFirstLinkAndImages(testCase.Input)
|
firstLink, images := th.App.getFirstLinkAndImages(th.Context, testCase.Input)
|
||||||
|
|
||||||
assert.Equal(t, firstLink, testCase.ExpectedFirstLink)
|
assert.Equal(t, firstLink, testCase.ExpectedFirstLink)
|
||||||
assert.Equal(t, images, testCase.ExpectedImages)
|
assert.Equal(t, images, testCase.ExpectedImages)
|
||||||
@@ -2016,7 +2016,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(test.Name, func(t *testing.T) {
|
t.Run(test.Name, func(t *testing.T) {
|
||||||
images := th.App.getImagesInMessageAttachments(test.Post)
|
images := th.App.getImagesInMessageAttachments(th.Context, test.Post)
|
||||||
|
|
||||||
assert.ElementsMatch(t, images, test.Expected)
|
assert.ElementsMatch(t, images, test.Expected)
|
||||||
})
|
})
|
||||||
@@ -2831,7 +2831,7 @@ func TestContainsPermalink(t *testing.T) {
|
|||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
testCase := testCase
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
actual := th.App.containsPermalink(testCase.Post)
|
actual := th.App.containsPermalink(th.Context, testCase.Post)
|
||||||
assert.Equal(t, testCase.Expected, actual)
|
assert.Equal(t, testCase.Expected, actual)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ func (a *App) SaveReactionForPost(c request.CTX, reaction *model.Reaction) (*mod
|
|||||||
}, plugin.ReactionHasBeenAddedID)
|
}, plugin.ReactionHasBeenAddedID)
|
||||||
})
|
})
|
||||||
|
|
||||||
a.sendReactionEvent(model.WebsocketEventReactionAdded, reaction, post)
|
a.sendReactionEvent(c, model.WebsocketEventReactionAdded, reaction, post)
|
||||||
|
|
||||||
return reaction, nil
|
return reaction, nil
|
||||||
}
|
}
|
||||||
@@ -161,17 +161,17 @@ func (a *App) DeleteReactionForPost(c request.CTX, reaction *model.Reaction) *mo
|
|||||||
}, plugin.ReactionHasBeenRemovedID)
|
}, plugin.ReactionHasBeenRemovedID)
|
||||||
})
|
})
|
||||||
|
|
||||||
a.sendReactionEvent(model.WebsocketEventReactionRemoved, reaction, post)
|
a.sendReactionEvent(c, model.WebsocketEventReactionRemoved, reaction, post)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) sendReactionEvent(event model.WebsocketEventType, reaction *model.Reaction, post *model.Post) {
|
func (a *App) sendReactionEvent(rctx request.CTX, event model.WebsocketEventType, reaction *model.Reaction, post *model.Post) {
|
||||||
// send out that a reaction has been added/removed
|
// send out that a reaction has been added/removed
|
||||||
message := model.NewWebSocketEvent(event, "", post.ChannelId, "", nil, "")
|
message := model.NewWebSocketEvent(event, "", post.ChannelId, "", nil, "")
|
||||||
reactionJSON, err := json.Marshal(reaction)
|
reactionJSON, err := json.Marshal(reaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Failed to encode reaction to JSON", mlog.Err(err))
|
rctx.Logger().Warn("Failed to encode reaction to JSON", mlog.Err(err))
|
||||||
}
|
}
|
||||||
message.Add("reaction", string(reactionJSON))
|
message.Add("reaction", string(reactionJSON))
|
||||||
a.Publish(message)
|
a.Publish(message)
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||||
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *App) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (remoteID string, err error) {
|
func (a *App) RegisterPluginForSharedChannels(rctx request.CTX, opts model.RegisterPluginOpts) (remoteID string, err error) {
|
||||||
// check for pluginID already registered
|
// check for pluginID already registered
|
||||||
rc, err := a.Srv().Store().RemoteCluster().GetByPluginID(opts.PluginID)
|
rc, err := a.Srv().Store().RemoteCluster().GetByPluginID(opts.PluginID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -28,7 +29,7 @@ func (a *App) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (re
|
|||||||
|
|
||||||
// if plugin is already registered then treat this as an update.
|
// if plugin is already registered then treat this as an update.
|
||||||
if rc != nil {
|
if rc != nil {
|
||||||
a.Log().Debug("Plugin already registered for Shared Channels",
|
rctx.Logger().Debug("Plugin already registered for Shared Channels",
|
||||||
mlog.String("plugin_id", opts.PluginID),
|
mlog.String("plugin_id", opts.PluginID),
|
||||||
mlog.String("remote_id", rc.RemoteId),
|
mlog.String("remote_id", rc.RemoteId),
|
||||||
)
|
)
|
||||||
@@ -57,7 +58,7 @@ func (a *App) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (re
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
a.Log().Debug("Registered new plugin for Shared Channels",
|
rctx.Logger().Debug("Registered new plugin for Shared Channels",
|
||||||
mlog.String("plugin_id", opts.PluginID),
|
mlog.String("plugin_id", opts.PluginID),
|
||||||
mlog.String("remote_id", rcSaved.RemoteId),
|
mlog.String("remote_id", rcSaved.RemoteId),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ func (a *App) SendReportToUser(rctx request.CTX, job *model.Job, format string)
|
|||||||
return model.NewAppError("SendReportToUser", "app.report.send_report_to_user.failed_to_save", nil, "", http.StatusInternalServerError).Wrap(fileErr)
|
return model.NewAppError("SendReportToUser", "app.report.send_report_to_user.failed_to_save", nil, "", http.StatusInternalServerError).Wrap(fileErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
channel, err := a.GetOrCreateDirectChannel(request.EmptyContext(a.Log()), requestingUserId, systemBot.UserId)
|
channel, err := a.GetOrCreateDirectChannel(rctx, requestingUserId, systemBot.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ func (a *App) StartUsersBatchExport(rctx request.CTX, dateRange string, startAt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
channel, err := a.GetOrCreateDirectChannel(request.EmptyContext(a.Log()), rctx.Session().UserId, systemBot.UserId)
|
channel, err := a.GetOrCreateDirectChannel(rctx, rctx.Session().UserId, systemBot.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.Logger().Error("Failed to get or create the DM", mlog.Err(err))
|
rctx.Logger().Error("Failed to get or create the DM", mlog.Err(err))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ func (a *App) SetSessionExpireInHours(session *model.Session, hours int) {
|
|||||||
a.ch.srv.platform.SetSessionExpireInHours(session, hours)
|
a.ch.srv.platform.SetSessionExpireInHours(session, hours)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
func (a *App) CreateUserAccessToken(rctx request.CTX, token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
||||||
user, nErr := a.ch.srv.userService.GetUser(token.UserId)
|
user, nErr := a.ch.srv.userService.GetUser(token.UserId)
|
||||||
if nErr != nil {
|
if nErr != nil {
|
||||||
var nfErr *store.ErrNotFound
|
var nfErr *store.ErrNotFound
|
||||||
@@ -389,7 +389,7 @@ func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAc
|
|||||||
// Don't send emails to bot users.
|
// Don't send emails to bot users.
|
||||||
if !user.IsBot {
|
if !user.IsBot {
|
||||||
if err := a.Srv().EmailService.SendUserAccessTokenAddedEmail(user.Email, user.Locale, a.GetSiteURL()); err != nil {
|
if err := a.Srv().EmailService.SendUserAccessTokenAddedEmail(user.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||||
a.Log().Error("Unable to send user access token added email", mlog.Err(err), mlog.String("user_id", user.Id))
|
rctx.Logger().Error("Unable to send user access token added email", mlog.Err(err), mlog.String("user_id", user.Id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func (*ExportLinkProvider) DoCommand(a *app.App, c request.CTX, args *model.Comm
|
|||||||
}
|
}
|
||||||
t, err := b.FileModTime(f)
|
t, err := b.FileModTime(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Failed to get file mod time", mlog.String("file", f), mlog.Err(err))
|
c.Logger().Warn("Failed to get file mod time", mlog.String("file", f), mlog.Err(err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if t.After(latestFound) {
|
if t.After(latestFound) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func (*InvitePeopleProvider) DoCommand(a *app.App, c request.CTX, args *model.Co
|
|||||||
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command.invite_people.no_email")}
|
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command.invite_people.no_email")}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.InviteNewUsersToTeam(emailList, args.TeamId, args.UserId); err != nil {
|
if err := a.InviteNewUsersToTeam(c, emailList, args.TeamId, args.UserId); err != nil {
|
||||||
c.Logger().Error(err.Error())
|
c.Logger().Error(err.Error())
|
||||||
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command.invite_people.fail")}
|
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command.invite_people.fail")}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1365,7 +1365,7 @@ func (a *App) prepareInviteNewUsersToTeam(teamID, senderId string, channelIds []
|
|||||||
return user, team, channels, nil
|
return user, team, channels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) InviteNewUsersToTeamGracefully(memberInvite *model.MemberInvite, teamID, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError) {
|
func (a *App) InviteNewUsersToTeamGracefully(rctx request.CTX, memberInvite *model.MemberInvite, teamID, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||||
return nil, model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
return nil, model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
@@ -1405,10 +1405,10 @@ func (a *App) InviteNewUsersToTeamGracefully(memberInvite *model.MemberInvite, t
|
|||||||
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
||||||
senderProfileImage, _, err := a.GetProfileImage(user)
|
senderProfileImage, _, err := a.GetProfileImage(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Unable to get the sender user profile image.", mlog.String("user_id", user.Id), mlog.String("team_id", team.Id), mlog.Err(err))
|
rctx.Logger().Warn("Unable to get the sender user profile image.", mlog.String("user_id", user.Id), mlog.String("team_id", team.Id), mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
userIsFirstAdmin := a.UserIsFirstAdmin(user)
|
userIsFirstAdmin := a.UserIsFirstAdmin(rctx, user)
|
||||||
var eErr error
|
var eErr error
|
||||||
var invitesWithErrors2 []*model.EmailInviteWithError
|
var invitesWithErrors2 []*model.EmailInviteWithError
|
||||||
if len(channels) > 0 {
|
if len(channels) > 0 {
|
||||||
@@ -1504,7 +1504,7 @@ func (a *App) prepareInviteGuestsToChannels(teamID string, guestsInvite *model.G
|
|||||||
return user, team, channels, nil
|
return user, team, channels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) InviteGuestsToChannelsGracefully(teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
func (a *App) InviteGuestsToChannelsGracefully(rctx request.CTX, teamID string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError) {
|
||||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||||
return nil, model.NewAppError("InviteGuestsToChannelsGracefully", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
return nil, model.NewAppError("InviteGuestsToChannelsGracefully", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
@@ -1533,10 +1533,10 @@ func (a *App) InviteGuestsToChannelsGracefully(teamID string, guestsInvite *mode
|
|||||||
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
||||||
senderProfileImage, _, err := a.GetProfileImage(user)
|
senderProfileImage, _, err := a.GetProfileImage(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Unable to get the sender user profile image.", mlog.String("user_id", user.Id), mlog.String("team_id", team.Id), mlog.Err(err))
|
rctx.Logger().Warn("Unable to get the sender user profile image.", mlog.String("user_id", user.Id), mlog.String("team_id", team.Id), mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
eErr := a.Srv().EmailService.SendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, senderProfileImage, goodEmails, a.GetSiteURL(), guestsInvite.Message, true, user.IsSystemAdmin(), a.UserIsFirstAdmin(user))
|
eErr := a.Srv().EmailService.SendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, senderProfileImage, goodEmails, a.GetSiteURL(), guestsInvite.Message, true, user.IsSystemAdmin(), a.UserIsFirstAdmin(rctx, user))
|
||||||
if eErr != nil {
|
if eErr != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(eErr, email.SendMailError):
|
case errors.Is(eErr, email.SendMailError):
|
||||||
@@ -1562,7 +1562,7 @@ func (a *App) InviteGuestsToChannelsGracefully(teamID string, guestsInvite *mode
|
|||||||
return inviteListWithErrors, nil
|
return inviteListWithErrors, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) InviteNewUsersToTeam(emailList []string, teamID, senderId string) *model.AppError {
|
func (a *App) InviteNewUsersToTeam(rctx request.CTX, emailList []string, teamID, senderId string) *model.AppError {
|
||||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||||
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
@@ -1592,7 +1592,7 @@ func (a *App) InviteNewUsersToTeam(emailList []string, teamID, senderId string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
||||||
eErr := a.Srv().EmailService.SendInviteEmails(team, user.GetDisplayName(nameFormat), user.Id, emailList, a.GetSiteURL(), nil, false, user.IsSystemAdmin(), a.UserIsFirstAdmin(user))
|
eErr := a.Srv().EmailService.SendInviteEmails(team, user.GetDisplayName(nameFormat), user.Id, emailList, a.GetSiteURL(), nil, false, user.IsSystemAdmin(), a.UserIsFirstAdmin(rctx, user))
|
||||||
if eErr != nil {
|
if eErr != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(eErr, email.NoRateLimiterError):
|
case errors.Is(eErr, email.NoRateLimiterError):
|
||||||
@@ -1607,7 +1607,7 @@ func (a *App) InviteNewUsersToTeam(emailList []string, teamID, senderId string)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) InviteGuestsToChannels(teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError {
|
func (a *App) InviteGuestsToChannels(rctx request.CTX, teamID string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError {
|
||||||
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
if !*a.Config().ServiceSettings.EnableEmailInvitations {
|
||||||
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
@@ -1632,10 +1632,10 @@ func (a *App) InviteGuestsToChannels(teamID string, guestsInvite *model.GuestsIn
|
|||||||
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
||||||
senderProfileImage, _, err := a.GetProfileImage(user)
|
senderProfileImage, _, err := a.GetProfileImage(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Warn("Unable to get the sender user profile image.", mlog.String("user_id", user.Id), mlog.String("team_id", team.Id), mlog.Err(err))
|
rctx.Logger().Warn("Unable to get the sender user profile image.", mlog.String("user_id", user.Id), mlog.String("team_id", team.Id), mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
eErr := a.Srv().EmailService.SendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, senderProfileImage, guestsInvite.Emails, a.GetSiteURL(), guestsInvite.Message, false, user.IsSystemAdmin(), a.UserIsFirstAdmin(user))
|
eErr := a.Srv().EmailService.SendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, senderProfileImage, guestsInvite.Emails, a.GetSiteURL(), guestsInvite.Message, false, user.IsSystemAdmin(), a.UserIsFirstAdmin(rctx, user))
|
||||||
if eErr != nil {
|
if eErr != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(eErr, email.NoRateLimiterError):
|
case errors.Is(eErr, email.NoRateLimiterError):
|
||||||
@@ -1866,7 +1866,7 @@ func (a *App) GetTeamStats(teamID string, restrictions *model.ViewUsersRestricti
|
|||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetTeamIdFromQuery(query url.Values) (string, *model.AppError) {
|
func (a *App) GetTeamIdFromQuery(rctx request.CTX, query url.Values) (string, *model.AppError) {
|
||||||
tokenID := query.Get("t")
|
tokenID := query.Get("t")
|
||||||
inviteId := query.Get("id")
|
inviteId := query.Get("id")
|
||||||
|
|
||||||
@@ -1895,7 +1895,7 @@ func (a *App) GetTeamIdFromQuery(query url.Values) (string, *model.AppError) {
|
|||||||
return team.Id, nil
|
return team.Id, nil
|
||||||
}
|
}
|
||||||
// soft fail, so we still create user but don't auto-join team
|
// soft fail, so we still create user but don't auto-join team
|
||||||
mlog.Warn("Error getting team by inviteId.", mlog.String("invite_id", inviteId), mlog.Err(err))
|
rctx.Logger().Warn("Error getting team by inviteId.", mlog.String("invite_id", inviteId), mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|||||||
@@ -1471,7 +1471,7 @@ func TestInviteNewUsersToTeamGracefully(t *testing.T) {
|
|||||||
emailServiceMock.On("Stop").Once().Return()
|
emailServiceMock.On("Stop").Once().Return()
|
||||||
th.App.Srv().EmailService = &emailServiceMock
|
th.App.Srv().EmailService = &emailServiceMock
|
||||||
|
|
||||||
res, err := th.App.InviteNewUsersToTeamGracefully(memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
res, err := th.App.InviteNewUsersToTeamGracefully(th.Context, memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Len(t, res, 1)
|
require.Len(t, res, 1)
|
||||||
require.Nil(t, res[0].Error)
|
require.Nil(t, res[0].Error)
|
||||||
@@ -1496,7 +1496,7 @@ func TestInviteNewUsersToTeamGracefully(t *testing.T) {
|
|||||||
emailServiceMock.On("Stop").Once().Return()
|
emailServiceMock.On("Stop").Once().Return()
|
||||||
th.App.Srv().EmailService = &emailServiceMock
|
th.App.Srv().EmailService = &emailServiceMock
|
||||||
|
|
||||||
res, err := th.App.InviteNewUsersToTeamGracefully(memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
res, err := th.App.InviteNewUsersToTeamGracefully(th.Context, memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Len(t, res, 1)
|
require.Len(t, res, 1)
|
||||||
require.NotNil(t, res[0].Error)
|
require.NotNil(t, res[0].Error)
|
||||||
@@ -1525,7 +1525,7 @@ func TestInviteNewUsersToTeamGracefully(t *testing.T) {
|
|||||||
emailServiceMock.On("Stop").Once().Return()
|
emailServiceMock.On("Stop").Once().Return()
|
||||||
th.App.Srv().EmailService = &emailServiceMock
|
th.App.Srv().EmailService = &emailServiceMock
|
||||||
|
|
||||||
res, err := th.App.InviteNewUsersToTeamGracefully(memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
res, err := th.App.InviteNewUsersToTeamGracefully(th.Context, memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Len(t, res, 1)
|
require.Len(t, res, 1)
|
||||||
require.Nil(t, res[0].Error)
|
require.Nil(t, res[0].Error)
|
||||||
@@ -1550,7 +1550,7 @@ func TestInviteNewUsersToTeamGracefully(t *testing.T) {
|
|||||||
emailServiceMock.On("Stop").Once().Return()
|
emailServiceMock.On("Stop").Once().Return()
|
||||||
th.App.Srv().EmailService = &emailServiceMock
|
th.App.Srv().EmailService = &emailServiceMock
|
||||||
|
|
||||||
res, err := th.App.InviteNewUsersToTeamGracefully(memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
res, err := th.App.InviteNewUsersToTeamGracefully(th.Context, memberInvite, th.BasicTeam.Id, th.BasicUser.Id, "")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Len(t, res, 1)
|
require.Len(t, res, 1)
|
||||||
require.Nil(t, res[0].Error)
|
require.Nil(t, res[0].Error)
|
||||||
@@ -1583,7 +1583,7 @@ func TestInviteGuestsToChannelsGracefully(t *testing.T) {
|
|||||||
emailServiceMock.On("Stop").Once().Return()
|
emailServiceMock.On("Stop").Once().Return()
|
||||||
th.App.Srv().EmailService = &emailServiceMock
|
th.App.Srv().EmailService = &emailServiceMock
|
||||||
|
|
||||||
res, err := th.App.InviteGuestsToChannelsGracefully(th.BasicTeam.Id, &model.GuestsInvite{
|
res, err := th.App.InviteGuestsToChannelsGracefully(th.Context, th.BasicTeam.Id, &model.GuestsInvite{
|
||||||
Emails: []string{"idontexist@mattermost.com"},
|
Emails: []string{"idontexist@mattermost.com"},
|
||||||
Channels: []string{th.BasicChannel.Id},
|
Channels: []string{th.BasicChannel.Id},
|
||||||
}, th.BasicUser.Id)
|
}, th.BasicUser.Id)
|
||||||
@@ -1610,7 +1610,7 @@ func TestInviteGuestsToChannelsGracefully(t *testing.T) {
|
|||||||
emailServiceMock.On("Stop").Once().Return()
|
emailServiceMock.On("Stop").Once().Return()
|
||||||
th.App.Srv().EmailService = &emailServiceMock
|
th.App.Srv().EmailService = &emailServiceMock
|
||||||
|
|
||||||
res, err := th.App.InviteGuestsToChannelsGracefully(th.BasicTeam.Id, &model.GuestsInvite{
|
res, err := th.App.InviteGuestsToChannelsGracefully(th.Context, th.BasicTeam.Id, &model.GuestsInvite{
|
||||||
Emails: []string{"idontexist@mattermost.com"},
|
Emails: []string{"idontexist@mattermost.com"},
|
||||||
Channels: []string{th.BasicChannel.Id},
|
Channels: []string{th.BasicChannel.Id},
|
||||||
}, th.BasicUser.Id)
|
}, th.BasicUser.Id)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||||
"github.com/mattermost/mattermost/server/v8/platform/services/telemetry"
|
"github.com/mattermost/mattermost/server/v8/platform/services/telemetry"
|
||||||
@@ -160,14 +161,14 @@ func (a *App) GetTrueUpProfile() (map[string]any, error) {
|
|||||||
return telemetryProperties, nil
|
return telemetryProperties, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetOrCreateTrueUpReviewStatus() (*model.TrueUpReviewStatus, *model.AppError) {
|
func (a *App) GetOrCreateTrueUpReviewStatus(rctx request.CTX) (*model.TrueUpReviewStatus, *model.AppError) {
|
||||||
nextDueDate := utils.GetNextTrueUpReviewDueDate(time.Now())
|
nextDueDate := utils.GetNextTrueUpReviewDueDate(time.Now())
|
||||||
status, err := a.Srv().Store().TrueUpReview().GetTrueUpReviewStatus(nextDueDate.UnixMilli())
|
status, err := a.Srv().Store().TrueUpReview().GetTrueUpReviewStatus(nextDueDate.UnixMilli())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var nfErr *store.ErrNotFound
|
var nfErr *store.ErrNotFound
|
||||||
switch {
|
switch {
|
||||||
case errors.As(err, &nfErr):
|
case errors.As(err, &nfErr):
|
||||||
a.Log().Warn("Could not find true up review status")
|
rctx.Logger().Warn("Could not find true up review status")
|
||||||
default:
|
default:
|
||||||
return nil, model.NewAppError("requestTrueUpReview", "api.license.true_up_review.get_status_error", nil, "Could not get true up status records", http.StatusInternalServerError).Wrap(err)
|
return nil, model.NewAppError("requestTrueUpReview", "api.license.true_up_review.get_status_error", nil, "Could not get true up status records", http.StatusInternalServerError).Wrap(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,10 +337,10 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m
|
|||||||
if limitErr != nil {
|
if limitErr != nil {
|
||||||
// we don't want to break the create user flow just because of this.
|
// we don't want to break the create user flow just because of this.
|
||||||
// So, we log the error, not return
|
// So, we log the error, not return
|
||||||
mlog.Error("Error fetching user limits in createUserOrGuest", mlog.Err(limitErr))
|
c.Logger().Error("Error fetching user limits in createUserOrGuest", mlog.Err(limitErr))
|
||||||
} else {
|
} else {
|
||||||
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
|
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
|
||||||
mlog.Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Created user exceeds the total activated users limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
c.Logger().Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Created user exceeds the total activated users limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1072,10 +1072,10 @@ func (a *App) UpdateActive(c request.CTX, user *model.User, active bool) (*model
|
|||||||
if active {
|
if active {
|
||||||
userLimits, appErr := a.GetServerLimits()
|
userLimits, appErr := a.GetServerLimits()
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
mlog.Error("Error fetching user limits in UpdateActive", mlog.Err(appErr))
|
c.Logger().Error("Error fetching user limits in UpdateActive", mlog.Err(appErr))
|
||||||
} else {
|
} else {
|
||||||
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
|
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
|
||||||
mlog.Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Activated user exceeds the total active user limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
c.Logger().Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Activated user exceeds the total active user limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1533,7 +1533,7 @@ func (a *App) resetPasswordFromToken(c request.CTX, userSuppliedTokenString, new
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SendPasswordReset(email string, siteURL string) (bool, *model.AppError) {
|
func (a *App) SendPasswordReset(rctx request.CTX, email string, siteURL string) (bool, *model.AppError) {
|
||||||
user, err := a.GetUserByEmail(email)
|
user, err := a.GetUserByEmail(email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
@@ -1543,7 +1543,7 @@ func (a *App) SendPasswordReset(email string, siteURL string) (bool, *model.AppE
|
|||||||
return false, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.sso.app_error", nil, "userId="+user.Id, http.StatusBadRequest)
|
return false, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.sso.app_error", nil, "userId="+user.Id, http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := a.CreatePasswordRecoveryToken(user.Id, user.Email)
|
token, err := a.CreatePasswordRecoveryToken(rctx, user.Id, user.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -1556,7 +1556,7 @@ func (a *App) SendPasswordReset(email string, siteURL string) (bool, *model.AppE
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CreatePasswordRecoveryToken(userID, email string) (*model.Token, *model.AppError) {
|
func (a *App) CreatePasswordRecoveryToken(rctx request.CTX, userID, email string) (*model.Token, *model.AppError) {
|
||||||
tokenExtra := struct {
|
tokenExtra := struct {
|
||||||
UserId string
|
UserId string
|
||||||
Email string
|
Email string
|
||||||
@@ -1572,7 +1572,7 @@ func (a *App) CreatePasswordRecoveryToken(userID, email string) (*model.Token, *
|
|||||||
// remove any previously created tokens for user
|
// remove any previously created tokens for user
|
||||||
appErr := a.InvalidatePasswordRecoveryTokensForUser(userID)
|
appErr := a.InvalidatePasswordRecoveryTokensForUser(userID)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
mlog.Warn("Error while deleting additional user tokens.", mlog.Err(err))
|
rctx.Logger().Warn("Error while deleting additional user tokens.", mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
token := model.NewToken(TokenTypePasswordRecovery, string(jsonData))
|
token := model.NewToken(TokenTypePasswordRecovery, string(jsonData))
|
||||||
@@ -2863,14 +2863,14 @@ func getProfileImageDirectory(userID string) string {
|
|||||||
return filepath.Join("users", userID)
|
return filepath.Join("users", userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) UserIsFirstAdmin(user *model.User) bool {
|
func (a *App) UserIsFirstAdmin(rctx request.CTX, user *model.User) bool {
|
||||||
if !user.IsSystemAdmin() {
|
if !user.IsSystemAdmin() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
systemAdminUsers, errServer := a.Srv().Store().User().GetSystemAdminProfiles()
|
systemAdminUsers, errServer := a.Srv().Store().User().GetSystemAdminProfiles()
|
||||||
if errServer != nil {
|
if errServer != nil {
|
||||||
mlog.Warn("Failed to get system admins to check for first admin from Mattermost.")
|
rctx.Logger().Warn("Failed to get system admins to check for first admin from Mattermost.")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1122,7 +1122,7 @@ func TestPasswordRecovery(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
t.Run("password token with same email as during creation", func(t *testing.T) {
|
t.Run("password token with same email as during creation", func(t *testing.T) {
|
||||||
token, err := th.App.CreatePasswordRecoveryToken(th.BasicUser.Id, th.BasicUser.Email)
|
token, err := th.App.CreatePasswordRecoveryToken(th.Context, th.BasicUser.Id, th.BasicUser.Email)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
tokenData := struct {
|
tokenData := struct {
|
||||||
@@ -1140,7 +1140,7 @@ func TestPasswordRecovery(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("password token with modified email as during creation", func(t *testing.T) {
|
t.Run("password token with modified email as during creation", func(t *testing.T) {
|
||||||
token, err := th.App.CreatePasswordRecoveryToken(th.BasicUser.Id, th.BasicUser.Email)
|
token, err := th.App.CreatePasswordRecoveryToken(th.Context, th.BasicUser.Id, th.BasicUser.Email)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(c *model.Config) {
|
th.App.UpdateConfig(func(c *model.Config) {
|
||||||
@@ -1156,7 +1156,7 @@ func TestPasswordRecovery(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("non-expired token", func(t *testing.T) {
|
t.Run("non-expired token", func(t *testing.T) {
|
||||||
token, err := th.App.CreatePasswordRecoveryToken(th.BasicUser.Id, th.BasicUser.Email)
|
token, err := th.App.CreatePasswordRecoveryToken(th.Context, th.BasicUser.Id, th.BasicUser.Email)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
err = th.App.resetPasswordFromToken(th.Context, token.Token, "abcdefgh", model.GetMillis())
|
err = th.App.resetPasswordFromToken(th.Context, token.Token, "abcdefgh", model.GetMillis())
|
||||||
@@ -1164,7 +1164,7 @@ func TestPasswordRecovery(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("expired token", func(t *testing.T) {
|
t.Run("expired token", func(t *testing.T) {
|
||||||
token, err := th.App.CreatePasswordRecoveryToken(th.BasicUser.Id, th.BasicUser.Email)
|
token, err := th.App.CreatePasswordRecoveryToken(th.Context, th.BasicUser.Id, th.BasicUser.Email)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
err = th.App.resetPasswordFromToken(th.Context, token.Token, "abcdefgh", model.GetMillisForTime(time.Now().Add(25*time.Hour)))
|
err = th.App.resetPasswordFromToken(th.Context, token.Token, "abcdefgh", model.GetMillisForTime(time.Now().Add(25*time.Hour)))
|
||||||
@@ -1197,10 +1197,10 @@ func TestInvalidatePasswordRecoveryTokens(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("add multiple tokens, should only be one valid", func(t *testing.T) {
|
t.Run("add multiple tokens, should only be one valid", func(t *testing.T) {
|
||||||
_, appErr := th.App.CreatePasswordRecoveryToken(th.BasicUser.Id, th.BasicUser.Email)
|
_, appErr := th.App.CreatePasswordRecoveryToken(th.Context, th.BasicUser.Id, th.BasicUser.Email)
|
||||||
assert.Nil(t, appErr)
|
assert.Nil(t, appErr)
|
||||||
|
|
||||||
token, appErr := th.App.CreatePasswordRecoveryToken(th.BasicUser.Id, th.BasicUser.Email)
|
token, appErr := th.App.CreatePasswordRecoveryToken(th.Context, th.BasicUser.Id, th.BasicUser.Email)
|
||||||
assert.Nil(t, appErr)
|
assert.Nil(t, appErr)
|
||||||
|
|
||||||
tokens, err := th.App.Srv().Store().Token().GetAllTokensByType(TokenTypePasswordRecovery)
|
tokens, err := th.App.Srv().Store().Token().GetAllTokensByType(TokenTypePasswordRecovery)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||||
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/jobs"
|
"github.com/mattermost/mattermost/server/v8/channels/jobs"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||||
"github.com/mattermost/mattermost/server/v8/platform/services/configservice"
|
"github.com/mattermost/mattermost/server/v8/platform/services/configservice"
|
||||||
@@ -22,7 +23,7 @@ type AppIface interface {
|
|||||||
configservice.ConfigService
|
configservice.ConfigService
|
||||||
GetUserByEmail(email string) (*model.User, *model.AppError)
|
GetUserByEmail(email string) (*model.User, *model.AppError)
|
||||||
GetTeamMembersByIds(teamID string, userIDs []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError)
|
GetTeamMembersByIds(teamID string, userIDs []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError)
|
||||||
InviteNewUsersToTeamGracefully(memberInvite *model.MemberInvite, teamID, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError)
|
InviteNewUsersToTeamGracefully(rctx request.CTX, memberInvite *model.MemberInvite, teamID, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResendInvitationEmailWorker struct {
|
type ResendInvitationEmailWorker struct {
|
||||||
@@ -175,6 +176,8 @@ func (rseworker *ResendInvitationEmailWorker) TearDown(logger mlog.LoggerIFace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rseworker *ResendInvitationEmailWorker) ResendEmails(logger mlog.LoggerIFace, job *model.Job, interval string) {
|
func (rseworker *ResendInvitationEmailWorker) ResendEmails(logger mlog.LoggerIFace, job *model.Job, interval string) {
|
||||||
|
rctx := request.EmptyContext(logger)
|
||||||
|
|
||||||
teamID := job.Data["teamID"]
|
teamID := job.Data["teamID"]
|
||||||
emailListData := job.Data["emailList"]
|
emailListData := job.Data["emailList"]
|
||||||
channelListData := job.Data["channelList"]
|
channelListData := job.Data["channelList"]
|
||||||
@@ -203,7 +206,7 @@ func (rseworker *ResendInvitationEmailWorker) ResendEmails(logger mlog.LoggerIFa
|
|||||||
memberInvite.ChannelIds = channelList
|
memberInvite.ChannelIds = channelList
|
||||||
}
|
}
|
||||||
|
|
||||||
_, appErr := rseworker.app.InviteNewUsersToTeamGracefully(&memberInvite, teamID, job.Data["senderID"], interval)
|
_, appErr := rseworker.app.InviteNewUsersToTeamGracefully(rctx, &memberInvite, teamID, job.Data["senderID"], interval)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
logger.Error("Worker: Failed to send emails", mlog.Err(appErr))
|
logger.Error("Worker: Failed to send emails", mlog.Err(appErr))
|
||||||
rseworker.setJobError(logger, job, appErr)
|
rseworker.setJobError(logger, job, appErr)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func Init(api4 *api4.API) {
|
|||||||
|
|
||||||
func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
||||||
// Let the world know
|
// Let the world know
|
||||||
mlog.Info("Setting up for manual test...")
|
c.Logger.Info("Setting up for manual test...")
|
||||||
|
|
||||||
// URL Parameters
|
// URL Parameters
|
||||||
params, err := url.ParseQuery(r.URL.RawQuery)
|
params, err := url.ParseQuery(r.URL.RawQuery)
|
||||||
@@ -58,7 +58,7 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
hash := hasher.Sum32()
|
hash := hasher.Sum32()
|
||||||
rand.Seed(int64(hash))
|
rand.Seed(int64(hash))
|
||||||
} else {
|
} else {
|
||||||
mlog.Debug("No uid in URL")
|
c.Logger.Debug("No uid in URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a client for tests to use
|
// Create a client for tests to use
|
||||||
@@ -70,7 +70,7 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
var teamID string
|
var teamID string
|
||||||
var userID string
|
var userID string
|
||||||
if ok1 && ok2 {
|
if ok1 && ok2 {
|
||||||
mlog.Info("Creating user and team")
|
c.Logger.Info("Creating user and team")
|
||||||
// Create team for testing
|
// Create team for testing
|
||||||
team := &model.Team{
|
team := &model.Team{
|
||||||
DisplayName: teamDisplayName[0],
|
DisplayName: teamDisplayName[0],
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
session, err := c.App.DoLogin(c.AppContext, w, r, user, "", isMobile, false, false)
|
session, err := c.App.DoLogin(c.AppContext, w, r, user, "", isMobile, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err.Translate(c.AppContext.T)
|
err.Translate(c.AppContext.T)
|
||||||
mlog.Error(err.Error())
|
c.Logger.Error(err.Error())
|
||||||
renderError(err)
|
renderError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -395,7 +395,7 @@ func loginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
teamId, err := c.App.GetTeamIdFromQuery(r.URL.Query())
|
teamId, err := c.App.GetTeamIdFromQuery(c.AppContext, r.URL.Query())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
@@ -424,7 +424,7 @@ func mobileLoginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
teamId, err := c.App.GetTeamIdFromQuery(r.URL.Query())
|
teamId, err := c.App.GetTeamIdFromQuery(c.AppContext, r.URL.Query())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
@@ -452,7 +452,7 @@ func signupWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
teamId, err := c.App.GetTeamIdFromQuery(r.URL.Query())
|
teamId, err := c.App.GetTeamIdFromQuery(c.AppContext, r.URL.Query())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
teamId, err := c.App.GetTeamIdFromQuery(r.URL.Query())
|
teamId, err := c.App.GetTeamIdFromQuery(c.AppContext, r.URL.Query())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ func jobserverCmdF(command *cobra.Command, args []string) error {
|
|||||||
rctx := request.EmptyContext(a.Log())
|
rctx := request.EmptyContext(a.Log())
|
||||||
|
|
||||||
// Run jobs
|
// Run jobs
|
||||||
a.Log().Info("Starting Mattermost job server")
|
rctx.Logger().Info("Starting Mattermost job server")
|
||||||
defer a.Log().Info("Stopped Mattermost job server")
|
defer rctx.Logger().Info("Stopped Mattermost job server")
|
||||||
|
|
||||||
if !noJobs {
|
if !noJobs {
|
||||||
a.Srv().Jobs.StartWorkers()
|
a.Srv().Jobs.StartWorkers()
|
||||||
@@ -68,7 +68,7 @@ func jobserverCmdF(command *cobra.Command, args []string) error {
|
|||||||
<-signalChan
|
<-signalChan
|
||||||
|
|
||||||
// Cleanup anything that isn't handled by a defer statement
|
// Cleanup anything that isn't handled by a defer statement
|
||||||
a.Log().Info("Stopping Mattermost job server")
|
rctx.Logger().Info("Stopping Mattermost job server")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func (s *MmctlE2ETestSuite) TestPluginMarketplaceInstallCmd() {
|
|||||||
s.RunForSystemAdminAndLocal("install a plugin", func(c client.Client) {
|
s.RunForSystemAdminAndLocal("install a plugin", func(c client.Client) {
|
||||||
printer.Clean()
|
printer.Clean()
|
||||||
|
|
||||||
marketPlacePlugins, appErr := s.th.App.GetMarketplacePlugins(&model.MarketplacePluginFilter{
|
marketPlacePlugins, appErr := s.th.App.GetMarketplacePlugins(s.th.Context, &model.MarketplacePluginFilter{
|
||||||
Page: 0,
|
Page: 0,
|
||||||
PerPage: 100,
|
PerPage: 100,
|
||||||
Filter: "jira",
|
Filter: "jira",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user