File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,8 +23,28 @@ export async function GET(request: Request) {
2323 const type = searchParams . get ( "type" ) ;
2424 const q = searchParams . get ( "q" ) ;
2525 const sort = searchParams . get ( "sort" ) || "downloads" ;
26+ const author = searchParams . get ( "author" ) ;
2627
2728 let conditions = [ eq ( projects . status , "public" ) ] ;
29+
30+ // 自分自身のリクエストかチェックするため、APIキーがあるか確認する
31+ let isMine = false ;
32+ if ( author ) {
33+ const auth = await validateApiKey ( request ) ;
34+ if ( auth . valid && auth . userId ) {
35+ const [ u ] = await db . select ( ) . from ( userProfiles ) . where ( eq ( userProfiles . username , author ) ) . limit ( 1 ) ;
36+ if ( u && u . userId === auth . userId ) {
37+ isMine = true ;
38+ }
39+ }
40+
41+ if ( isMine ) {
42+ // 自分の場合は、status=public の条件を外し、全て表示するか、削除済み以外とする
43+ conditions = [ ] ;
44+ }
45+ conditions . push ( eq ( userProfiles . username , author ) ) ;
46+ }
47+
2848 if ( type === "mod" || type === "plugin" ) {
2949 conditions . push ( eq ( projects . type , type as "mod" | "plugin" ) ) ;
3050 }
You can’t perform that action at this time.
0 commit comments