🧹 chore: Consolidate getSoleOwnedResourceIds into data-schemas and use db object in PermissionService

Move getSoleOwnedResourceIds from PermissionService to data-schemas aclEntry methods,
update PermissionService to use the db object pattern instead of destructured imports
from ~/models, and update UserController + tests accordingly.
This commit is contained in:
Danny Avila 2026-03-21 13:59:00 -04:00
parent 7829fa9eca
commit 87a3b8221a
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
3 changed files with 31 additions and 105 deletions

View file

@ -22,7 +22,6 @@ const { getMCPManager, getFlowStateManager, getMCPServersRegistry } = require('~
const { invalidateCachedTools } = require('~/server/services/Config/getCachedTools');
const { processDeleteRequest } = require('~/server/services/Files/process');
const { getAppConfig } = require('~/server/services/Config');
const { getSoleOwnedResourceIds } = require('~/server/services/PermissionService');
const { getLogStores } = require('~/cache');
const db = require('~/models');
@ -111,7 +110,7 @@ const deleteUserMcpServers = async (userId) => {
}
const userObjectId = new mongoose.Types.ObjectId(userId);
const soleOwnedIds = await getSoleOwnedResourceIds(userObjectId, ResourceType.MCPSERVER);
const soleOwnedIds = await db.getSoleOwnedResourceIds(userObjectId, ResourceType.MCPSERVER);
const authoredServers = await MCPServer.find({ author: userObjectId })
.select('_id serverName')

View file

@ -66,6 +66,7 @@ jest.mock('~/models', () => ({
deleteTokens: jest.fn(),
removeUserFromAllGroups: jest.fn(),
deleteAclEntries: jest.fn(),
getSoleOwnedResourceIds: jest.fn().mockResolvedValue([]),
}));
jest.mock('~/server/services/PluginService', () => ({
@ -100,10 +101,6 @@ jest.mock('~/server/services/Config', () => ({
getAppConfig: jest.fn(),
}));
jest.mock('~/server/services/PermissionService', () => ({
getSoleOwnedResourceIds: jest.fn().mockResolvedValue([]),
}));
jest.mock('~/cache', () => ({
getLogStores: jest.fn(),
}));