@@ -94,11 +94,10 @@ use crate::{
94
94
MetadataVideoSource , MovieSpecifics , PartialMetadata , PartialMetadataPerson ,
95
95
PartialMetadataWithoutId , PeopleSearchItem , PersonSourceSpecifics , PodcastSpecifics ,
96
96
PostReviewInput , ProgressUpdateError , ProgressUpdateErrorVariant , ProgressUpdateInput ,
97
- ProgressUpdateResultUnion , PublicCollectionItem , ReviewPostedEvent ,
98
- SeenAnimeExtraInformation , SeenMangaExtraInformation , SeenPodcastExtraInformation ,
99
- SeenShowExtraInformation , ShowSpecifics , UserMediaOwnership , UserMediaReminder ,
100
- UserSummary , UserToMediaReason , VideoGameSpecifics , VisualNovelSpecifics ,
101
- WatchProvider ,
97
+ ProgressUpdateResultUnion , ReviewPostedEvent , SeenAnimeExtraInformation ,
98
+ SeenMangaExtraInformation , SeenPodcastExtraInformation , SeenShowExtraInformation ,
99
+ ShowSpecifics , UserMediaOwnership , UserMediaReminder , UserSummary , UserToMediaReason ,
100
+ VideoGameSpecifics , VisualNovelSpecifics , WatchProvider ,
102
101
} ,
103
102
BackgroundJob , ChangeCollectionToEntityInput , EntityLot , IdAndNamedObject , IdObject ,
104
103
MediaStateChanged , SearchDetails , SearchInput , SearchResults , StoredUrl ,
@@ -369,7 +368,6 @@ struct CollectionItem {
369
368
name : String ,
370
369
num_items : u64 ,
371
370
description : Option < String > ,
372
- visibility : Visibility ,
373
371
}
374
372
375
373
#[ derive( SimpleObject ) ]
@@ -817,25 +815,14 @@ impl MiscellaneousQuery {
817
815
service. user_collections_list ( user_id, name) . await
818
816
}
819
817
820
- /// Get a list of publicly visible collections.
821
- async fn public_collections_list (
822
- & self ,
823
- gql_ctx : & Context < ' _ > ,
824
- input : SearchInput ,
825
- ) -> Result < SearchResults < PublicCollectionItem > > {
826
- let service = gql_ctx. data_unchecked :: < Arc < MiscellaneousService > > ( ) ;
827
- service. public_collections_list ( input) . await
828
- }
829
-
830
818
/// Get the contents of a collection and respect visibility.
831
819
async fn collection_contents (
832
820
& self ,
833
821
gql_ctx : & Context < ' _ > ,
834
822
input : CollectionContentsInput ,
835
823
) -> Result < CollectionContents > {
836
824
let service = gql_ctx. data_unchecked :: < Arc < MiscellaneousService > > ( ) ;
837
- let user_id = service. user_id_from_ctx ( gql_ctx) . await . ok ( ) ;
838
- service. collection_contents ( user_id, input) . await
825
+ service. collection_contents ( input) . await
839
826
}
840
827
841
828
/// Get details about a media present in the database.
@@ -4068,68 +4055,14 @@ impl MiscellaneousService {
4068
4055
id : collection. id ,
4069
4056
name : collection. name ,
4070
4057
description : collection. description ,
4071
- visibility : collection. visibility ,
4072
4058
num_items,
4073
4059
} ) ;
4074
4060
}
4075
4061
Ok ( data)
4076
4062
}
4077
4063
4078
- async fn public_collections_list (
4079
- & self ,
4080
- input : SearchInput ,
4081
- ) -> Result < SearchResults < PublicCollectionItem > > {
4082
- let page: u64 = input. page . unwrap_or ( 1 ) . try_into ( ) . unwrap ( ) ;
4083
- let c_alias = Alias :: new ( "collection" ) ;
4084
- let u_alias = Alias :: new ( "user" ) ;
4085
- let paginator = Collection :: find ( )
4086
- . select_only ( )
4087
- . column_as ( Expr :: col ( ( c_alias. clone ( ) , collection:: Column :: Id ) ) , "id" )
4088
- . column_as ( Expr :: col ( ( u_alias, user:: Column :: Name ) ) , "username" )
4089
- . column ( collection:: Column :: Name )
4090
- . filter ( collection:: Column :: Visibility . eq ( Visibility :: Public ) )
4091
- . apply_if ( input. query , |query, v| {
4092
- query. filter (
4093
- Condition :: any ( )
4094
- . add (
4095
- Expr :: col ( ( c_alias. clone ( ) , collection:: Column :: Name ) )
4096
- . ilike ( ilike_sql ( & v) ) ,
4097
- )
4098
- . add (
4099
- Expr :: col ( ( c_alias. clone ( ) , collection:: Column :: Description ) )
4100
- . ilike ( ilike_sql ( & v) ) ,
4101
- ) ,
4102
- )
4103
- } )
4104
- . left_join ( User )
4105
- . order_by_desc ( collection:: Column :: LastUpdatedOn )
4106
- . into_model :: < PublicCollectionItem > ( )
4107
- . paginate ( & self . db , self . config . frontend . page_size . try_into ( ) . unwrap ( ) ) ;
4108
- let mut data = vec ! [ ] ;
4109
- let ItemsAndPagesNumber {
4110
- number_of_items,
4111
- number_of_pages,
4112
- } = paginator. num_items_and_pages ( ) . await ?;
4113
- for collection in paginator. fetch_page ( page - 1 ) . await ? {
4114
- data. push ( collection) ;
4115
- }
4116
- let results = SearchResults {
4117
- details : SearchDetails {
4118
- total : number_of_items. try_into ( ) . unwrap ( ) ,
4119
- next_page : if page < number_of_pages {
4120
- Some ( ( page + 1 ) . try_into ( ) . unwrap ( ) )
4121
- } else {
4122
- None
4123
- } ,
4124
- } ,
4125
- items : data,
4126
- } ;
4127
- Ok ( results)
4128
- }
4129
-
4130
4064
async fn collection_contents (
4131
4065
& self ,
4132
- user_id : Option < i32 > ,
4133
4066
input : CollectionContentsInput ,
4134
4067
) -> Result < CollectionContents > {
4135
4068
let search = input. search . unwrap_or_default ( ) ;
@@ -4144,20 +4077,6 @@ impl MiscellaneousService {
4144
4077
Some ( c) => c,
4145
4078
None => return Err ( Error :: new ( "Collection not found" . to_owned ( ) ) ) ,
4146
4079
} ;
4147
- if collection. visibility != Visibility :: Public {
4148
- match user_id {
4149
- None => {
4150
- return Err ( Error :: new (
4151
- "Need to be logged in to view a private collection" . to_owned ( ) ,
4152
- ) ) ;
4153
- }
4154
- Some ( u) => {
4155
- if u != collection. user_id {
4156
- return Err ( Error :: new ( "This collection is not public" . to_owned ( ) ) ) ;
4157
- }
4158
- }
4159
- }
4160
- }
4161
4080
4162
4081
let take = input
4163
4082
. take
@@ -4422,16 +4341,13 @@ impl MiscellaneousService {
4422
4341
} else if let Some ( ci) = insert. collection_id . unwrap ( ) {
4423
4342
(
4424
4343
ci,
4425
- self . collection_contents (
4426
- Some ( user_id) ,
4427
- CollectionContentsInput {
4428
- collection_id : ci,
4429
- filter : None ,
4430
- search : None ,
4431
- take : None ,
4432
- sort : None ,
4433
- } ,
4434
- )
4344
+ self . collection_contents ( CollectionContentsInput {
4345
+ collection_id : ci,
4346
+ filter : None ,
4347
+ search : None ,
4348
+ take : None ,
4349
+ sort : None ,
4350
+ } )
4435
4351
. await ?
4436
4352
. details
4437
4353
. name ,
@@ -4525,10 +4441,6 @@ impl MiscellaneousService {
4525
4441
name : ActiveValue :: Set ( new_name) ,
4526
4442
user_id : ActiveValue :: Set ( user_id. to_owned ( ) ) ,
4527
4443
description : ActiveValue :: Set ( input. description ) ,
4528
- visibility : match input. visibility {
4529
- None => ActiveValue :: NotSet ,
4530
- Some ( v) => ActiveValue :: Set ( v) ,
4531
- } ,
4532
4444
..Default :: default ( )
4533
4445
} ;
4534
4446
let inserted = col. save ( & self . db ) . await . map_err ( |_| {
0 commit comments