@@ -598,7 +598,7 @@ public function add_rest_routes() {
598598 array (
599599 'methods ' => array ( 'GET ' , 'OPTIONS ' ),
600600 'callback ' => array ( $ this , 'api_search ' ),
601- 'permission_callback ' => array ( $ this , 'have_token_permission ' ),
601+ 'permission_callback ' => array ( $ this , 'logged_in_permission ' ),
602602 )
603603 );
604604
@@ -774,18 +774,6 @@ public function logged_in_permission( $request ) {
774774 return is_user_logged_in ();
775775 }
776776
777- public function have_token_permission ( $ request ) {
778- $ this ->allow_cors ();
779- $ token = $ this ->oauth ->get_token ();
780- if ( ! $ token ) {
781- return is_user_logged_in ();
782- }
783- OAuth2 \AccessTokenStorage::was_used ( $ token ['access_token ' ] );
784- $ this ->app = Mastodon_App::get_by_client_id ( $ token ['client_id ' ] );
785- $ this ->app ->was_used ( $ request );
786- return true ;
787- }
788-
789777 public function logged_in_for_private_permission ( $ request ) {
790778 $ post_id = $ request ->get_param ( 'post_id ' );
791779 if ( ! $ post_id ) {
@@ -1574,15 +1562,21 @@ public function api_search( $request ) {
15741562 );
15751563 }
15761564 }
1577- } elseif ( is_user_logged_in () || $ this -> oauth -> get_token () ) {
1565+ } elseif ( is_user_logged_in () ) {
15781566 $ q_param = $ request ->get_param ( 'q ' );
1579- if ( $ q_param != null ) { $ args ['s ' ] = $ q_param ; }
1567+ if ( null !== $ q_param ) {
1568+ $ args ['s ' ] = $ q_param ;
1569+ }
15801570
15811571 $ offset_param = $ request ->get_param ( 'offset ' );
1582- if ( $ offset_param != null ) { $ args ['offset ' ] = $ offset_param ; }
1572+ if ( null !== $ offset_param ) {
1573+ $ args ['offset ' ] = $ offset_param ;
1574+ }
15831575
15841576 $ ppp_param = $ request ->get_param ( 'limit ' );
1585- if ( $ ppp_param != null ) { $ args ['posts_per_page ' ] = $ ppp_param ; }
1577+ if ( null !== $ ppp_param ) {
1578+ $ args ['posts_per_page ' ] = $ ppp_param ;
1579+ }
15861580
15871581 $ ret ['statuses ' ] = array_merge ( $ ret ['statuses ' ], $ this ->get_posts ( $ args ) );
15881582 }
0 commit comments