Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
refactor(backend:context): replace `get('headerOriginUrl')` with `headerOriginUrl()` for contextManager consistency
johaven6b9c9afa678d
diff --git a/backend/src/applications/comments/services/comments-manager.service.spec.ts b/backend/src/applications/comments/services/comments-manager.service.spec.tsindex ea44ad22..9fb9897a 100644--- a/backend/src/applications/comments/services/comments-manager.service.spec.ts+++ b/backend/src/applications/comments/services/comments-manager.service.spec.ts@@ -27,7 +27,7 @@ jest.mock('../../files/utils/files', () => ({describe(CommentsManager.name, () => {let commentsManager: CommentsManager- let contextManager: { get: jest.Mock }+ let contextManager: { headerOriginUrl: jest.Mock }let commentQueries: {getComments: jest.MockcreateComment: jest.Mock@@ -74,7 +74,7 @@ describe(CommentsManager.name, () => {create: jest.fn().mockResolvedValue(undefined)}contextManager = {- get: jest.fn().mockReturnValue('https://app.local/path')+ headerOriginUrl: jest.fn().mockReturnValue('https://app.local/path')}const module: TestingModule = await Test.createTestingModule({diff --git a/backend/src/applications/comments/services/comments-manager.service.ts b/backend/src/applications/comments/services/comments-manager.service.tsindex 0f4abbfb..3fc7291f 100644--- a/backend/src/applications/comments/services/comments-manager.service.ts+++ b/backend/src/applications/comments/services/comments-manager.service.ts@@ -117,7 +117,7 @@ export class CommentsManager {this.notificationsManager.create(members, notification, {author: fromUser,- currentUrl: this.contextManager.get('headerOriginUrl'),+ currentUrl: this.contextManager.headerOriginUrl(),content: comment}).catch((e: Error) => this.logger.error(`${this.notify.name} - ${e}`))diff --git a/backend/src/applications/files/services/files-only-office-manager.service.ts b/backend/src/applications/files/services/files-only-office-manager.service.tsindex dc5824be..7a6f0600 100644--- a/backend/src/applications/files/services/files-only-office-manager.service.ts+++ b/backend/src/applications/files/services/files-only-office-manager.service.ts@@ -154,7 +154,7 @@ export class FilesOnlyOfficeManager {): Promise<OnlyOfficeReqConfig> {const documentType = ONLY_OFFICE_EXTENSIONS.EDITABLE.get(fileExtension) || ONLY_OFFICE_EXTENSIONS.VIEWABLE.get(fileExtension)return {- documentServerUrl: this.externalOnlyOfficeServer || `${this.contextManager.get('headerOriginUrl')}${ONLY_OFFICE_INTERNAL_URI}`,+ documentServerUrl: this.externalOnlyOfficeServer || `${this.contextManager.headerOriginUrl()}${ONLY_OFFICE_INTERNAL_URI}`,config: {type: isMobile ? 'mobile' : 'desktop',height: '100%',@@ -207,12 +207,12 @@ export class FilesOnlyOfficeManager {private getDocumentUrl(space: SpaceEnv, token: string): string {// user refresh token is used here for long session- return `${this.contextManager.get('headerOriginUrl')}${API_FILES_ONLY_OFFICE_DOCUMENT}/${space.url}?${ONLY_OFFICE_TOKEN_QUERY_PARAM_NAME}=${token}`+ return `${this.contextManager.headerOriginUrl()}${API_FILES_ONLY_OFFICE_DOCUMENT}/${space.url}?${ONLY_OFFICE_TOKEN_QUERY_PARAM_NAME}=${token}`}private getCallBackUrl(space: SpaceEnv, token: string, fileId: string): string {// user refresh token is used here for long session- return `${this.contextManager.get('headerOriginUrl')}${API_FILES_ONLY_OFFICE_CALLBACK}/${space.url}?fid=${fileId}&${ONLY_OFFICE_TOKEN_QUERY_PARAM_NAME}=${token}`+ return `${this.contextManager.headerOriginUrl()}${API_FILES_ONLY_OFFICE_CALLBACK}/${space.url}?fid=${fileId}&${ONLY_OFFICE_TOKEN_QUERY_PARAM_NAME}=${token}`}private genPayloadToken(payload: OnlyOfficeConfig | OnlyOfficeConvertForm): Promise<string> {diff --git a/backend/src/applications/shares/services/shares-manager.service.spec.ts b/backend/src/applications/shares/services/shares-manager.service.spec.tsindex 471e0659..7c7a3447 100644--- a/backend/src/applications/shares/services/shares-manager.service.spec.ts+++ b/backend/src/applications/shares/services/shares-manager.service.spec.ts@@ -57,7 +57,7 @@ describe(SharesManager.name, () => {// Mocksconst contextManagerMock = {- get: jest.fn()+ headerOriginUrl: jest.fn()}const notificationsManagerMock = {diff --git a/backend/src/applications/shares/services/shares-manager.service.ts b/backend/src/applications/shares/services/shares-manager.service.tsindex b420e8bd..2c9d2f50 100644--- a/backend/src/applications/shares/services/shares-manager.service.ts+++ b/backend/src/applications/shares/services/shares-manager.service.ts@@ -1122,7 +1122,7 @@ export class SharesManager {}this.notificationsManager.create(memberIds, notification, {- currentUrl: this.contextManager.get('headerOriginUrl'),+ currentUrl: this.contextManager.headerOriginUrl(),author: user,action: action})@@ -1154,7 +1154,7 @@ export class SharesManager {author: user,linkUUID: link.linkSettings.uuid,linkPassword: link.linkSettings.password,- currentUrl: this.contextManager.get('headerOriginUrl'),+ currentUrl: this.contextManager.headerOriginUrl(),action: action} satisfies NotificationOptions)diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.tsindex 1e5f15d2..846dc588 100644--- a/backend/src/applications/spaces/services/spaces-manager.service.ts+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts@@ -884,7 +884,7 @@ export class SpacesManager {}this.notificationsManager.create(memberIds, notification, {- currentUrl: this.contextManager.get('headerOriginUrl'),+ currentUrl: this.contextManager.headerOriginUrl(),action: action}).catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))@@ -917,7 +917,7 @@ export class SpacesManager {}this.notificationsManager.create(spaceUserIds, notification, {- currentUrl: this.contextManager.get('headerOriginUrl'),+ currentUrl: this.contextManager.headerOriginUrl(),author: user,action: action})diff --git a/backend/src/applications/sync/services/sync-paths-manager.service.spec.ts b/backend/src/applications/sync/services/sync-paths-manager.service.spec.tsindex a44961bb..623a0fdb 100644--- a/backend/src/applications/sync/services/sync-paths-manager.service.spec.ts+++ b/backend/src/applications/sync/services/sync-paths-manager.service.spec.ts@@ -44,7 +44,7 @@ jest.mock('../../notifications/constants/notifications', () => ({describe(SyncPathsManager.name, () => {let service: SyncPathsManager- let contextManager: { get: jest.Mock }+ let contextManager: { headerOriginUrl: jest.Mock }let spacesManager: { spaceEnv: jest.Mock }let usersQueries: Record<string, jest.Mock>let filesQueries: { getSpaceFileId: jest.Mock; getOrCreateSpaceFile: jest.Mock }@@ -64,7 +64,7 @@ describe(SyncPathsManager.name, () => {const flush = () => new Promise((r) => setImmediate(r))beforeEach(async () => {- contextManager = { get: jest.fn(() => 'http://origin.local') }+ contextManager = { headerOriginUrl: jest.fn(() => 'http://origin.local') }spacesManager = { spaceEnv: jest.fn() }usersQueries = {}filesQueries = {diff --git a/backend/src/applications/sync/services/sync-paths-manager.service.ts b/backend/src/applications/sync/services/sync-paths-manager.service.tsindex c994fe1b..c2dc7094 100644--- a/backend/src/applications/sync/services/sync-paths-manager.service.ts+++ b/backend/src/applications/sync/services/sync-paths-manager.service.ts@@ -238,7 +238,7 @@ export class SyncPathsManager {}this.notificationsManager.create([userId], notification, {- currentUrl: this.contextManager.get('headerOriginUrl'),+ currentUrl: this.contextManager.headerOriginUrl(),action: action}).catch((e: Error) => this.logger.error(`${this.notify.name} - ${e}`))diff --git a/backend/src/infrastructure/context/services/context-manager.service.ts b/backend/src/infrastructure/context/services/context-manager.service.tsindex 07c58f9a..d7098833 100644--- a/backend/src/infrastructure/context/services/context-manager.service.ts+++ b/backend/src/infrastructure/context/services/context-manager.service.ts@@ -17,6 +17,10 @@ export class ContextManager {this.storage = new AsyncLocalStorage<ContextStore>()}+ headerOriginUrl(): string {+ return this.storage.getStore() ? this.storage.getStore().headerOriginUrl : undefined+ }+get(key: keyof ContextStore): any {return this.storage.getStore() ? this.storage.getStore()[key] : undefined}