File tree 3 files changed +23
-3
lines changed
web/api/server/v1/contexts/torrent
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ pub enum ACTION {
48
48
GetTorrent ,
49
49
AddTorrent ,
50
50
GetCanonicalInfoHash ,
51
+ GenerateTorrentInfoListing ,
51
52
}
52
53
53
54
pub struct Service {
@@ -190,20 +191,23 @@ impl CasbinConfiguration {
190
191
admin, GetTorrent
191
192
admin, AddTorrent
192
193
admin, GetCanonicalInfoHash
194
+ admin, GenerateTorrentInfoListing
193
195
registered, GetCategories
194
196
registered, GetImageByUrl
195
197
registered, GetPublicSettings
196
198
registered, GetTags
197
199
registered, GetTorrent
198
200
registered, AddTorrent
199
201
registered, GetCanonicalInfoHash
202
+ registered, GenerateTorrentInfoListing
200
203
guest, GetCategories
201
204
guest, GetTags
202
205
guest, GetAboutPage
203
206
guest, GetLicensePage
204
207
guest, GetPublicSettings
205
208
guest, GetTorrent
206
209
guest, GetCanonicalInfoHash
210
+ guest, GenerateTorrentInfoListing
207
211
" ,
208
212
) ,
209
213
}
Original file line number Diff line number Diff line change @@ -347,7 +347,15 @@ impl Index {
347
347
/// # Errors
348
348
///
349
349
/// Returns a `ServiceError::DatabaseError` if the database query fails.
350
- pub async fn generate_torrent_info_listing ( & self , request : & ListingRequest ) -> Result < TorrentsResponse , ServiceError > {
350
+ pub async fn generate_torrent_info_listing (
351
+ & self ,
352
+ request : & ListingRequest ,
353
+ opt_user_id : Option < UserId > ,
354
+ ) -> Result < TorrentsResponse , ServiceError > {
355
+ self . authorization_service
356
+ . authorize ( ACTION :: GenerateTorrentInfoListing , opt_user_id)
357
+ . await ?;
358
+
351
359
let torrent_listing_specification = self . listing_specification_from_user_request ( request) . await ;
352
360
353
361
let torrents_response = self
Original file line number Diff line number Diff line change @@ -131,8 +131,16 @@ async fn redirect_to_download_url_using_canonical_info_hash_if_needed(
131
131
///
132
132
/// It returns an error if the database query fails.
133
133
#[ allow( clippy:: unused_async) ]
134
- pub async fn get_torrents_handler ( State ( app_data) : State < Arc < AppData > > , Query ( criteria) : Query < ListingRequest > ) -> Response {
135
- match app_data. torrent_service . generate_torrent_info_listing ( & criteria) . await {
134
+ pub async fn get_torrents_handler (
135
+ State ( app_data) : State < Arc < AppData > > ,
136
+ Query ( criteria) : Query < ListingRequest > ,
137
+ ExtractOptionalLoggedInUser ( opt_user_id) : ExtractOptionalLoggedInUser ,
138
+ ) -> Response {
139
+ match app_data
140
+ . torrent_service
141
+ . generate_torrent_info_listing ( & criteria, opt_user_id)
142
+ . await
143
+ {
136
144
Ok ( torrents_response) => Json ( OkResponseData { data : torrents_response } ) . into_response ( ) ,
137
145
Err ( error) => error. into_response ( ) ,
138
146
}
You can’t perform that action at this time.
0 commit comments