Adds includeDeleted flag to get remote cluster app and store methods (#28182)

Этот коммит содержится в:
Miguel de la Cruz
2024-09-13 23:08:53 +02:00
коммит произвёл GitHub
родитель 46ca7747f8
Коммит cae456de2d
19 изменённых файлов: 78 добавлений и 57 удалений

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

@@ -792,7 +792,7 @@ type AppIface interface {
GetReactionsForPost(postID string) ([]*model.Reaction, *model.AppError)
GetRecentlyActiveUsersForTeam(rctx request.CTX, teamID string) (map[string]*model.User, *model.AppError)
GetRecentlyActiveUsersForTeamPage(rctx request.CTX, teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
GetRemoteCluster(remoteClusterId string) (*model.RemoteCluster, *model.AppError)
GetRemoteCluster(remoteClusterId string, includeDeleted bool) (*model.RemoteCluster, *model.AppError)
GetRemoteClusterForUser(remoteID string, userID string) (*model.RemoteCluster, *model.AppError)
GetRemoteClusterService() (remotecluster.RemoteClusterServiceIFace, *model.AppError)
GetRemoteClusterSession(token string, remoteId string) (*model.Session, *model.AppError)

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

@@ -9104,7 +9104,7 @@ func (a *OpenTracingAppLayer) GetRecentlyActiveUsersForTeamPage(rctx request.CTX
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetRemoteCluster(remoteClusterId string) (*model.RemoteCluster, *model.AppError) {
func (a *OpenTracingAppLayer) GetRemoteCluster(remoteClusterId string, includeDeleted bool) (*model.RemoteCluster, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetRemoteCluster")
@@ -9116,7 +9116,7 @@ func (a *OpenTracingAppLayer) GetRemoteCluster(remoteClusterId string) (*model.R
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetRemoteCluster(remoteClusterId)
resultVar0, resultVar1 := a.app.GetRemoteCluster(remoteClusterId, includeDeleted)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))

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

@@ -140,7 +140,7 @@ func handleInvitation(ps *PlatformService, syncService SharedChannelServiceIFace
return nil
}
rc, err := ps.Store.RemoteCluster().Get(*participant.RemoteId)
rc, err := ps.Store.RemoteCluster().Get(*participant.RemoteId, false)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("couldn't find remote cluster %s, for creating shared channel invitation for a DM", *participant.RemoteId))
}

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

@@ -117,7 +117,7 @@ func (a *App) AddRemoteCluster(rc *model.RemoteCluster) (*model.RemoteCluster, *
}
func (a *App) PatchRemoteCluster(rcId string, patch *model.RemoteClusterPatch) (*model.RemoteCluster, *model.AppError) {
rc, err := a.GetRemoteCluster(rcId)
rc, err := a.GetRemoteCluster(rcId, false)
if err != nil {
return nil, err
}
@@ -152,8 +152,8 @@ func (a *App) DeleteRemoteCluster(remoteClusterId string) (bool, *model.AppError
return deleted, nil
}
func (a *App) GetRemoteCluster(remoteClusterId string) (*model.RemoteCluster, *model.AppError) {
rc, err := a.Srv().Store().RemoteCluster().Get(remoteClusterId)
func (a *App) GetRemoteCluster(remoteClusterId string, includeDeleted bool) (*model.RemoteCluster, *model.AppError) {
rc, err := a.Srv().Store().RemoteCluster().Get(remoteClusterId, includeDeleted)
if err != nil {
switch {
case errors.Is(err, sql.ErrNoRows):

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

@@ -68,8 +68,8 @@ func (a *App) GetCloudSession(token string) (*model.Session, *model.AppError) {
}
func (a *App) GetRemoteClusterSession(token string, remoteId string) (*model.Session, *model.AppError) {
rc, appErr := a.GetRemoteCluster(remoteId)
if appErr == nil && rc.DeleteAt == 0 && subtle.ConstantTimeCompare([]byte(rc.Token), []byte(token)) == 1 {
rc, appErr := a.GetRemoteCluster(remoteId, false)
if appErr == nil && subtle.ConstantTimeCompare([]byte(rc.Token), []byte(token)) == 1 {
// Need a bare-bones session object for later checks
session := &model.Session{
Token: token,

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

@@ -248,13 +248,10 @@ func (sp *ShareProvider) doInviteRemote(a *app.App, c request.CTX, args *model.C
}()
}
rc, appErr := a.GetRemoteCluster(remoteID)
rc, appErr := a.GetRemoteCluster(remoteID, false)
if appErr != nil {
return responsef(args.T("api.command_share.remote_id_invalid.error", map[string]any{"Error": appErr.Error()}))
}
if rc.DeleteAt != 0 {
return responsef(args.T("api.command_share.remote_id_invalid.error", map[string]any{"Error": "entity is deleted"}))
}
if err = a.InviteRemoteToChannel(args.ChannelId, remoteID, args.UserId, true); err != nil {
return responsef(args.T("api.command_share.invite_remote_to_channel.error", map[string]any{"Error": err.Error()}))