From 7c266630134caa3634bd0318ae02436ea5c4e8f1 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Mon, 17 Feb 2025 14:07:50 -0500 Subject: [PATCH] chore: removed unused endpoint (#16167) --- mobile/lib/services/api.service.dart | 2 - mobile/openapi/README.md | Bin 32623 -> 32428 bytes mobile/openapi/devtools_options.yaml | 3 - mobile/openapi/lib/api.dart | Bin 11873 -> 11769 bytes mobile/openapi/lib/api/audit_api.dart | Bin 2478 -> 0 bytes mobile/openapi/lib/api_client.dart | Bin 30369 -> 30184 bytes mobile/openapi/lib/api_helper.dart | Bin 6484 -> 6386 bytes .../lib/model/audit_deletes_response_dto.dart | Bin 3350 -> 0 bytes mobile/openapi/lib/model/entity_type.dart | Bin 2543 -> 0 bytes open-api/immich-openapi-specs.json | 84 ------------------ open-api/typescript-sdk/src/fetch-client.ts | 24 ----- server/src/controllers/audit.controller.ts | 18 ---- server/src/controllers/index.ts | 2 - server/src/services/audit.service.spec.ts | 46 +--------- server/src/services/audit.service.ts | 30 +------ 15 files changed, 2 insertions(+), 207 deletions(-) delete mode 100644 mobile/openapi/devtools_options.yaml delete mode 100644 mobile/openapi/lib/api/audit_api.dart delete mode 100644 mobile/openapi/lib/model/audit_deletes_response_dto.dart delete mode 100644 mobile/openapi/lib/model/entity_type.dart delete mode 100644 server/src/controllers/audit.controller.ts diff --git a/mobile/lib/services/api.service.dart b/mobile/lib/services/api.service.dart index 0f6fe8a10..c72a4bf1b 100644 --- a/mobile/lib/services/api.service.dart +++ b/mobile/lib/services/api.service.dart @@ -23,7 +23,6 @@ class ApiService implements Authentication { late MapApi mapApi; late PartnersApi partnersApi; late PeopleApi peopleApi; - late AuditApi auditApi; late SharedLinksApi sharedLinksApi; late SyncApi syncApi; late SystemConfigApi systemConfigApi; @@ -56,7 +55,6 @@ class ApiService implements Authentication { mapApi = MapApi(_apiClient); partnersApi = PartnersApi(_apiClient); peopleApi = PeopleApi(_apiClient); - auditApi = AuditApi(_apiClient); sharedLinksApi = SharedLinksApi(_apiClient); syncApi = SyncApi(_apiClient); systemConfigApi = SystemConfigApi(_apiClient); diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 5b0e067dcdf62334a741aa71ce9f5d6d9e0a48b6..d006ef38bb3ea1c08c8979bf02a51a1d87dba3c4 100644 GIT binary patch delta 24 gcmaF=k8#ak#tr7;n`ekGwBKAFK7(bmag2>J0GBEXmjD0& delta 173 zcmZ4Um+}2S#tr7;Q7M@vjs=-o3N;GRT3YF;C61*)5tr1Q)RNRB6UeXt-< znO<&+GEhw-NKFbvjV4g1mX^C~h?bUuK3GB@Dzn)@e1$z1!nnzf5yCvk#!n6m72SLz bYzB*DUP)$2Wk_W~D%3t#n84=LXm@1*X9_3%#ulLVw(>z%W!d(0y*(1sX3`7lNU%TPyWZtzWEVv8}sD*;&PkQ I1t-Y>05eS#fdBvi diff --git a/mobile/openapi/lib/api/audit_api.dart b/mobile/openapi/lib/api/audit_api.dart deleted file mode 100644 index f6d71eafdb30c5fbcebe86e13c62c35471211131..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2478 zcmd5;O>^5e5WVwPY;uUC4lAXZ9x_U7Rk7qmGp*%1%49ko4+D!U3oQjOz%q*J(SPp( zAVj87-5h%8K@dVKRq{`2v2KPiE)8 zJz_B@`BN?oojmLR@H}x_d8f3&Y^6=Mk_8T-QkBI#!vZ&`D2;o$DYc=a8lu>Woz2RM zGJ_v0X;@u}4L?g^_@B^NHg4>3^`%ypgrZF5>`<;G8n14TIxD0?n-yB!u^6p|%AP;X zmTO^blCV1hy#igL5~b|(??sX%%R*QS<0_XlE+yP2aM*OO`Q)sS?05t$9+o#f7&bdN zX{|>i$Z;jA!kG%v>;hmVl_=nF)@b;*0|xpM4THR~AQZe=EH0t*db)staA6H{hMUlK zTYPvIVdpHb~6g?$f%-KnL|po5?;-XW9*S6mLhlCm5*;Q>U;vBlh!g4Uc$ z)A<|ZK0(K<`IK^{EkzOR%x{0kCD%!*ExpqDuGS2x|5%~fUAl}|_VV)A!}j$0=0z)v zHHsWfBN#53)|WlK-?xQb!8|DH4Fj~C_eGwMi=vyg&bpmW3LRewyzu|MUhwmcx=mrQ zfo2n}$Q5)$HNc}2P*qX%>Lh)m{h-XY!y?+*RE1M!~r=EZx9RJ(zIS* zs!#e49AD15HBPPu(t7RMuM;;du;Nk7a@@BQ7tfmf#FKWAeQBqgl6ElikT9ow@zyh9 z(DTXgm;GP%b-R^gk55RCzUuS;thYl?nVRt&18;?-2WiEZb-OrIhzxaLkhTyyu{M+^f5!+V?JC*MQqn`#j73D z`$4v;Z&%(-WbfC=jL&?((S*Rf`iV(9vcJ-B%O+sUEXqP5U^nNUJ^e9-Ez7S(QGn9K zv&lIGNp41X%VYA>gLoJ?m93G)k%!ddcM3n3%y^h{ z%jZs8DjxEWqv>;ICqV}!VCybHX6Nne7zjS$!u8E}{5Ub)Z|+U3a;zIvE- z?d&kKw6df0S>S^vIkEpe_J?8K&yn$zqL6>$*o}|wza@vc@*gU`le!TUz8>n)*6N4A Ts2-iYf7SsxK6LN)$v*iDB$+JB diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index 3721652b8bdd41966b5208ffa34e3a021d5e9d3d..49fbe9464b7dba8d7243fcd28aa3075465490e2f 100644 GIT binary patch delta 19 bcmZ4Zmhr`F#tlxIo0n*QV&DAMaEl87Wg`i} delta 63 zcmaFynsMP<#tlxIT%{?QB`&EssU@kC8{`#{xrrLOo1HX2u}^+zFU#thSCUyWdA^Ow JW@E#xE&wt67~=o{ diff --git a/mobile/openapi/lib/api_helper.dart b/mobile/openapi/lib/api_helper.dart index b7c6ad5e010d38534668b3bcc39d684677932c94..6a917201aabbe0aec70e689faacf33e8726b1723 100644 GIT binary patch delta 12 Tcmca&^vQ6;dd|&)T+aLeCPW0X delta 30 mcmexlc*SVLdd|t&Jd&KQc_o=8l_8Y{lP7XHY+ldl%ntyg;Y8a{i`|ggC zEG1SFG(ZxGy7%X~;|+(s;SkRLzMZ}Ob9yzsKD(Ws!^P$2sSoEfxSHLmz5c0?-fL$vSsMx?5I7OH*eEv`s$w{PA#^$0(lAB!`k-&a{ zK?8hN#=gI?TBWNApcy{A%d!LmY-sTD$Lzb*8taF8EP@r#!e$!AV{dl%RYq7ByOw$Y zV=_i{jzr>7h<^3u#}D@es=Hcm-f#wCEM-3ZR)|E|U4WR2#CYt0680(F0hF@txD_)- z^-K~fwXl*F*21j+$YP0Mv*Vhu#M4wp(iow4#4}83EsZiP=3xLqr8|IM++iz*!{qR(!=h`hwqhj@ogqM`{p`ed>c-8kMXRVotr zibu$tN7DEEQ_cohVy^q>y1zilif#`+x1u-*wvL^O<_=)9bg(B9{!C|pNMms0!ho^{ zzKf)g29`S8lqTnVgw3=>fj%|e94oW%A;ms$EZi!?J=Q=x*K&zX&&{NZ24=#0G(gruoZU+4T8hZ2k?kaHCe<#ZqN*8 z;tc|u(ctk`I@^++5iGH{<)CG6^kATorxu|`uo3w`1p91xyUXQ!8cGum!Ux@N$@T{) zZY%gFD$_^>9LHYiA=~0b!lH-o6vKz+oy zAw*@x2!I0zPjI?o)tZ)xRg_d9;@B~@q3P;P9Zz;z)i1Rkk)kRgTj5DjLem^@9SKZ` z97h4FB6dYWDZ;=FVZW;!lWHJR{uLG&#gkC5+}J_Y)s8s(%H?PT^&S)ADuEjlZAR{< zX~Bx8dRGA((3_HY5#HC$;}Ux@z-%vI@djMa0F7mvJH`LxjxGk)cYHnITjAV78&&I8 z!|d^uMl%;Hb4$cl*)<+fi_xOhf$&==jmqWl$14uCXz?VYSdJrXd9taQGbC}8H!p2$ z^xb6C(;k0@S1+W@OXyc}rZF_0Wf!K`M!o}{fZ(eO*&vw@RbP+lC% diff --git a/mobile/openapi/lib/model/entity_type.dart b/mobile/openapi/lib/model/entity_type.dart deleted file mode 100644 index 93a0d0d3cce15ea8682a2e45e391e0b624d91fb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2543 zcmai0+iv4F5PkPoOn_qJ0IuBjY2mHc>mp8@BAXPA^RO@sftDznU5ZpmDu%Ggzjubz z&5Ab-5L=hwT+W<1Z&V=MMC{<~B8gt2WuH2-#7kQzLJ9~o3Bdcs&lrA>> z-%=Pnu2_zr1vB{VxUuNm*z?B|t*m3p#UjOkA`{&B+pbM^8AtL<$FdB^#$*hGH`gYa2DmZ)_0Zg&>+YneV$AN+3N8qZ=;V9ez z+<`-3^fM-v!seODl5ZnC=dN{wtol$_@~ zZpdXO6qE4iOl#@geA3U{7>ti5^-HJ2#rO*5AA?hG+P?nNYBhX`;5w1ii7y`?S8JG` z7GN&@<4a5*;MDx?x2Ml%%;_w#xdLZPh{JIO4ueJ zK~$^AU`);csp64+_YUYj682uZRbIHN@rM4ifpK6E#w4`Kw0qw~3=BMJd%>^lPpsYfhLTcpA{fES;B^BwLCccoFyDW|ERaRbk+1N8NHAuO`+`z zG8b_O1B}D&AYlrSNz|w<;I;50oN$`0KDWT>dT1uzBU3oVp}|{dXpu6U+Vi`yI*i}@@47&t~b31c=G#Zp;M}VC4*cppwHPY+}5j qYNU>oAIerB@FR9ca)+ALlas;dBAaT_qBgx+Ujyq!ryn0k9{&RnPeHH% diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 25d649e19..5b5c3a150 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -2079,65 +2079,6 @@ ] } }, - "/audit/deletes": { - "get": { - "operationId": "getAuditDeletes", - "parameters": [ - { - "name": "after", - "required": true, - "in": "query", - "schema": { - "format": "date-time", - "type": "string" - } - }, - { - "name": "entityType", - "required": true, - "in": "query", - "schema": { - "$ref": "#/components/schemas/EntityType" - } - }, - { - "name": "userId", - "required": false, - "in": "query", - "schema": { - "format": "uuid", - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AuditDeletesResponseDto" - } - } - }, - "description": "" - } - }, - "security": [ - { - "bearer": [] - }, - { - "cookie": [] - }, - { - "api_key": [] - } - ], - "tags": [ - "Audit" - ] - } - }, "/auth/admin-sign-up": { "post": { "operationId": "signUpAdmin", @@ -8643,24 +8584,6 @@ ], "type": "string" }, - "AuditDeletesResponseDto": { - "properties": { - "ids": { - "items": { - "type": "string" - }, - "type": "array" - }, - "needsFullSync": { - "type": "boolean" - } - }, - "required": [ - "ids", - "needsFullSync" - ], - "type": "object" - }, "AvatarResponse": { "properties": { "color": { @@ -9075,13 +8998,6 @@ }, "type": "object" }, - "EntityType": { - "enum": [ - "ASSET", - "ALBUM" - ], - "type": "string" - }, "ExifResponseDto": { "properties": { "city": { diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index 0473b5603..d4b36a04f 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -449,10 +449,6 @@ export type AssetMediaReplaceDto = { fileCreatedAt: string; fileModifiedAt: string; }; -export type AuditDeletesResponseDto = { - ids: string[]; - needsFullSync: boolean; -}; export type SignUpDto = { email: string; name: string; @@ -1913,22 +1909,6 @@ export function playAssetVideo({ id, key }: { ...opts })); } -export function getAuditDeletes({ after, entityType, userId }: { - after: string; - entityType: EntityType; - userId?: string; -}, opts?: Oazapfts.RequestOpts) { - return oazapfts.ok(oazapfts.fetchJson<{ - status: 200; - data: AuditDeletesResponseDto; - }>(`/audit/deletes${QS.query(QS.explode({ - after, - entityType, - userId - }))}`, { - ...opts - })); -} export function signUpAdmin({ signUpDto }: { signUpDto: SignUpDto; }, opts?: Oazapfts.RequestOpts) { @@ -3499,10 +3479,6 @@ export enum AssetMediaSize { Preview = "preview", Thumbnail = "thumbnail" } -export enum EntityType { - Asset = "ASSET", - Album = "ALBUM" -} export enum ManualJobName { PersonCleanup = "person-cleanup", TagCleanup = "tag-cleanup", diff --git a/server/src/controllers/audit.controller.ts b/server/src/controllers/audit.controller.ts deleted file mode 100644 index 856a1cc75..000000000 --- a/server/src/controllers/audit.controller.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Controller, Get, Query } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; -import { AuditDeletesDto, AuditDeletesResponseDto } from 'src/dtos/audit.dto'; -import { AuthDto } from 'src/dtos/auth.dto'; -import { Auth, Authenticated } from 'src/middleware/auth.guard'; -import { AuditService } from 'src/services/audit.service'; - -@ApiTags('Audit') -@Controller('audit') -export class AuditController { - constructor(private service: AuditService) {} - - @Get('deletes') - @Authenticated() - getAuditDeletes(@Auth() auth: AuthDto, @Query() dto: AuditDeletesDto): Promise { - return this.service.getDeletes(auth, dto); - } -} diff --git a/server/src/controllers/index.ts b/server/src/controllers/index.ts index f10bf601b..c9d63f8bc 100644 --- a/server/src/controllers/index.ts +++ b/server/src/controllers/index.ts @@ -4,7 +4,6 @@ import { APIKeyController } from 'src/controllers/api-key.controller'; import { AppController } from 'src/controllers/app.controller'; import { AssetMediaController } from 'src/controllers/asset-media.controller'; import { AssetController } from 'src/controllers/asset.controller'; -import { AuditController } from 'src/controllers/audit.controller'; import { AuthController } from 'src/controllers/auth.controller'; import { DownloadController } from 'src/controllers/download.controller'; import { DuplicateController } from 'src/controllers/duplicate.controller'; @@ -40,7 +39,6 @@ export const controllers = [ AppController, AssetController, AssetMediaController, - AuditController, AuthController, DownloadController, DuplicateController, diff --git a/server/src/services/audit.service.spec.ts b/server/src/services/audit.service.spec.ts index c64f6f207..f5e588cdd 100644 --- a/server/src/services/audit.service.spec.ts +++ b/server/src/services/audit.service.spec.ts @@ -1,17 +1,7 @@ import { BadRequestException } from '@nestjs/common'; import { FileReportItemDto } from 'src/dtos/audit.dto'; -import { - AssetFileType, - AssetPathType, - DatabaseAction, - EntityType, - JobStatus, - PersonPathType, - UserPathType, -} from 'src/enum'; +import { AssetFileType, AssetPathType, JobStatus, PersonPathType, UserPathType } from 'src/enum'; import { AuditService } from 'src/services/audit.service'; -import { auditStub } from 'test/fixtures/audit.stub'; -import { authStub } from 'test/fixtures/auth.stub'; import { newTestService, ServiceMocks } from 'test/utils'; describe(AuditService.name, () => { @@ -33,40 +23,6 @@ describe(AuditService.name, () => { }); }); - describe('getDeletes', () => { - it('should require full sync if the request is older than 100 days', async () => { - mocks.audit.getAfter.mockResolvedValue([]); - - const date = new Date(2022, 0, 1); - await expect(sut.getDeletes(authStub.admin, { after: date, entityType: EntityType.ASSET })).resolves.toEqual({ - needsFullSync: true, - ids: [], - }); - - expect(mocks.audit.getAfter).toHaveBeenCalledWith(date, { - action: DatabaseAction.DELETE, - userIds: [authStub.admin.user.id], - entityType: EntityType.ASSET, - }); - }); - - it('should get any new or updated assets and deleted ids', async () => { - mocks.audit.getAfter.mockResolvedValue([auditStub.delete.entityId]); - - const date = new Date(); - await expect(sut.getDeletes(authStub.admin, { after: date, entityType: EntityType.ASSET })).resolves.toEqual({ - needsFullSync: false, - ids: ['asset-deleted'], - }); - - expect(mocks.audit.getAfter).toHaveBeenCalledWith(date, { - action: DatabaseAction.DELETE, - userIds: [authStub.admin.user.id], - entityType: EntityType.ASSET, - }); - }); - }); - describe('getChecksums', () => { it('should fail if the file is not in the immich path', async () => { await expect(sut.getChecksums({ filenames: ['foo/bar'] })).rejects.toBeInstanceOf(BadRequestException); diff --git a/server/src/services/audit.service.ts b/server/src/services/audit.service.ts index a952a0e64..394846976 100644 --- a/server/src/services/audit.service.ts +++ b/server/src/services/audit.service.ts @@ -4,22 +4,12 @@ import { resolve } from 'node:path'; import { AUDIT_LOG_MAX_DURATION, JOBS_ASSET_PAGINATION_SIZE } from 'src/constants'; import { StorageCore } from 'src/cores/storage.core'; import { OnJob } from 'src/decorators'; -import { - AuditDeletesDto, - AuditDeletesResponseDto, - FileChecksumDto, - FileChecksumResponseDto, - FileReportItemDto, - PathEntityType, -} from 'src/dtos/audit.dto'; -import { AuthDto } from 'src/dtos/auth.dto'; +import { FileChecksumDto, FileChecksumResponseDto, FileReportItemDto, PathEntityType } from 'src/dtos/audit.dto'; import { AssetFileType, AssetPathType, - DatabaseAction, JobName, JobStatus, - Permission, PersonPathType, QueueName, StorageFolder, @@ -37,24 +27,6 @@ export class AuditService extends BaseService { return JobStatus.SUCCESS; } - async getDeletes(auth: AuthDto, dto: AuditDeletesDto): Promise { - const userId = dto.userId || auth.user.id; - await this.requireAccess({ auth, permission: Permission.TIMELINE_READ, ids: [userId] }); - - const audits = await this.auditRepository.getAfter(dto.after, { - userIds: [userId], - entityType: dto.entityType, - action: DatabaseAction.DELETE, - }); - - const duration = DateTime.now().diff(DateTime.fromJSDate(dto.after)); - - return { - needsFullSync: duration > AUDIT_LOG_MAX_DURATION, - ids: audits, - }; - } - async getChecksums(dto: FileChecksumDto) { const results: FileChecksumResponseDto[] = []; for (const filename of dto.filenames) {