]> git.mxchange.org Git - friendica.git/commitdiff
Making the tests happy
authorMichael <heluecht@pirati.ca>
Fri, 11 Jun 2021 06:09:08 +0000 (06:09 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 11 Jun 2021 06:09:08 +0000 (06:09 +0000)
include/api.php

index 92230cc6119d711031c751ff5d2c62cbb431c666..0ebd9b75143b353806c48bdef024e20067b27fac 100644 (file)
@@ -116,11 +116,22 @@ function api_user()
  */
 function api_source()
 {
-       $application = OAuth::getCurrentApplicationToken();
-       if (empty($application)) {
-               $application = BasicAuth::getCurrentApplicationToken();
+       if (requestdata('source')) {
+               return requestdata('source');
        }
-       return $application['name'] ?? 'api';
+
+       // Support for known clients that doesn't send a source name
+       if (!empty($_SERVER['HTTP_USER_AGENT'])) {
+               if(strpos($_SERVER['HTTP_USER_AGENT'], "Twidere") !== false) {
+                       return "Twidere";
+               }
+
+               Logger::info(API_LOG_PREFIX . 'Unrecognized user-agent', ['module' => 'api', 'action' => 'source', 'http_user_agent' => $_SERVER['HTTP_USER_AGENT']]);
+       } else {
+               Logger::info(API_LOG_PREFIX . 'Empty user-agent', ['module' => 'api', 'action' => 'source']);
+       }
+
+       return "api";
 }
 
 /**