Этот коммит содержится в:
Ben Schumacher
2024-04-24 11:52:33 +02:00
коммит произвёл GitHub
родитель 92a6c6517d
Коммит 30d450c4d8
45 изменённых файлов: 221 добавлений и 215 удалений

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

@@ -327,7 +327,7 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
status, appErr := c.App.GetOrCreateTrueUpReviewStatus()
status, appErr := c.App.GetOrCreateTrueUpReviewStatus(c.AppContext)
if appErr != nil {
c.Err = appErr
return
@@ -394,7 +394,7 @@ func trueUpReviewStatus(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
status, appErr := c.App.GetOrCreateTrueUpReviewStatus()
status, appErr := c.App.GetOrCreateTrueUpReviewStatus(c.AppContext)
if appErr != nil {
c.Err = appErr
}

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

@@ -230,7 +230,7 @@ func deleteOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
err = c.App.DeleteOAuthApp(oauthApp.Id)
err = c.App.DeleteOAuthApp(c.AppContext, oauthApp.Id)
if err != nil {
c.Err = err
return

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

@@ -297,7 +297,7 @@ func getMarketplacePlugins(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
plugins, appErr := c.App.GetMarketplacePlugins(filter)
plugins, appErr := c.App.GetMarketplacePlugins(c.AppContext, filter)
if appErr != nil {
c.Err = appErr
return

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

@@ -1005,7 +1005,7 @@ func setPostReminder(c *Context, w http.ResponseWriter, r *http.Request) {
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 {
c.Err = appErr
return

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

@@ -1412,7 +1412,7 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
var invitesWithError []*model.EmailInviteWithError
var appErr *model.AppError
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 {
@@ -1458,7 +1458,7 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write(js)
} 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 {
c.Err = appErr
return
@@ -1528,7 +1528,7 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request)
var appErr *model.AppError
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 {
@@ -1549,7 +1549,7 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request)
w.Write(js)
} 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 {
c.Err = appErr
return

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

@@ -3534,30 +3534,30 @@ func TestInviteGuestsToTeam(t *testing.T) {
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) {
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")
})
t.Run("guest restrictions should affect guest users", func(t *testing.T) {
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")
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.Len(t, res, 2)
require.NotNil(t, res[0].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")
})
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" })
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")
})
@@ -3576,12 +3576,12 @@ func TestInviteGuestsToTeam(t *testing.T) {
Channels: []string{th.BasicChannel.Id},
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)
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
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)
assert.Equal(t, "app.email.rate_limit_exceeded.app_error", err.Id)
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)
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 *c.App.Config().ServiceSettings.ExperimentalEnableHardenedMode {
ReturnStatusOK(w)
@@ -2452,7 +2452,7 @@ func createUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request) {
accessToken.UserId = c.Params.UserId
accessToken.Token = ""
token, err := c.App.CreateUserAccessToken(&accessToken)
token, err := c.App.CreateUserAccessToken(c.AppContext, &accessToken)
if err != nil {
c.Err = err
return