@@ -19,7 +19,6 @@ import { AssetEntity } from 'src/entities/asset.entity';
19
19
import { Permission } from 'src/enum' ;
20
20
import { AlbumAssetCount , AlbumInfoOptions } from 'src/interfaces/album.interface' ;
21
21
import { BaseService } from 'src/services/base.service' ;
22
- import { checkAccess , requireAccess } from 'src/utils/access' ;
23
22
import { addAssets , removeAssets } from 'src/utils/asset.util' ;
24
23
25
24
@Injectable ( )
@@ -82,7 +81,7 @@ export class AlbumService extends BaseService {
82
81
}
83
82
84
83
async get ( auth : AuthDto , id : string , dto : AlbumInfoDto ) : Promise < AlbumResponseDto > {
85
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_READ , ids : [ id ] } ) ;
84
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_READ , ids : [ id ] } ) ;
86
85
await this . albumRepository . updateThumbnails ( ) ;
87
86
const withAssets = dto . withoutAssets === undefined ? true : ! dto . withoutAssets ;
88
87
const album = await this . findOrFail ( id , { withAssets } ) ;
@@ -106,7 +105,7 @@ export class AlbumService extends BaseService {
106
105
}
107
106
}
108
107
109
- const allowedAssetIdsSet = await checkAccess ( this . accessRepository , {
108
+ const allowedAssetIdsSet = await this . checkAccess ( {
110
109
auth,
111
110
permission : Permission . ASSET_SHARE ,
112
111
ids : dto . assetIds || [ ] ,
@@ -130,7 +129,7 @@ export class AlbumService extends BaseService {
130
129
}
131
130
132
131
async update ( auth : AuthDto , id : string , dto : UpdateAlbumDto ) : Promise < AlbumResponseDto > {
133
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_UPDATE , ids : [ id ] } ) ;
132
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_UPDATE , ids : [ id ] } ) ;
134
133
135
134
const album = await this . findOrFail ( id , { withAssets : true } ) ;
136
135
@@ -153,13 +152,13 @@ export class AlbumService extends BaseService {
153
152
}
154
153
155
154
async delete ( auth : AuthDto , id : string ) : Promise < void > {
156
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_DELETE , ids : [ id ] } ) ;
155
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_DELETE , ids : [ id ] } ) ;
157
156
await this . albumRepository . delete ( id ) ;
158
157
}
159
158
160
159
async addAssets ( auth : AuthDto , id : string , dto : BulkIdsDto ) : Promise < BulkIdResponseDto [ ] > {
161
160
const album = await this . findOrFail ( id , { withAssets : false } ) ;
162
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_ADD_ASSET , ids : [ id ] } ) ;
161
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_ADD_ASSET , ids : [ id ] } ) ;
163
162
164
163
const results = await addAssets (
165
164
auth ,
@@ -182,7 +181,7 @@ export class AlbumService extends BaseService {
182
181
}
183
182
184
183
async removeAssets ( auth : AuthDto , id : string , dto : BulkIdsDto ) : Promise < BulkIdResponseDto [ ] > {
185
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_REMOVE_ASSET , ids : [ id ] } ) ;
184
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_REMOVE_ASSET , ids : [ id ] } ) ;
186
185
187
186
const album = await this . findOrFail ( id , { withAssets : false } ) ;
188
187
const results = await removeAssets (
@@ -203,7 +202,7 @@ export class AlbumService extends BaseService {
203
202
}
204
203
205
204
async addUsers ( auth : AuthDto , id : string , { albumUsers } : AddUsersDto ) : Promise < AlbumResponseDto > {
206
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_SHARE , ids : [ id ] } ) ;
205
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_SHARE , ids : [ id ] } ) ;
207
206
208
207
const album = await this . findOrFail ( id , { withAssets : false } ) ;
209
208
@@ -247,14 +246,14 @@ export class AlbumService extends BaseService {
247
246
248
247
// non-admin can remove themselves
249
248
if ( auth . user . id !== userId ) {
250
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_SHARE , ids : [ id ] } ) ;
249
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_SHARE , ids : [ id ] } ) ;
251
250
}
252
251
253
252
await this . albumUserRepository . delete ( { albumId : id , userId } ) ;
254
253
}
255
254
256
255
async updateUser ( auth : AuthDto , id : string , userId : string , dto : Partial < AlbumUserEntity > ) : Promise < void > {
257
- await requireAccess ( this . accessRepository , { auth, permission : Permission . ALBUM_SHARE , ids : [ id ] } ) ;
256
+ await this . requireAccess ( { auth, permission : Permission . ALBUM_SHARE , ids : [ id ] } ) ;
258
257
await this . albumUserRepository . update ( { albumId : id , userId } , { role : dto . role } ) ;
259
258
}
260
259
0 commit comments