Skip to content

Commit 44f52c1

Browse files
committed
Allow /feed (Fixes #65)
1 parent c1f92e0 commit 44f52c1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

root/app/www/public/api/index.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
$proxiedApp = $starr->getAppFromProxiedKey($apikey);
160160
$app = $starr->getStarrInterfaceNameFromId($proxiedApp['starrAppDetails']['starr']);
161161

162-
if (!$proxiedApp) {
162+
if (!$proxiedApp || !$proxiedApp['starrApp']) {
163163
logger($logfile, ['req' => $requestCounter, 'apikey' => $apikey, 'endpoint' => $endpoint, 'proxyCode' => 401]);
164164
apiResponse(401, ['error' => sprintf(APP_API_ERROR, 'provided apikey is not valid or has no access')]);
165165
}
@@ -177,6 +177,18 @@
177177
header('Content-disposition: attachment; filename="' . $proxyBackup . '"');
178178
readfile($proxyBackup);
179179
}
180+
} elseif (!$endpoint && $_GET['feed']) { //-- iCal links, let them through
181+
unset($variables['feed'], $variables['apikey']);
182+
$starrUrl = $proxiedApp['starrAppDetails']['url'] . $_GET['feed'] . ($variables ? '?' . http_build_query($variables) : '');
183+
$request = curl($starrUrl, ['X-Api-Key:' . $proxiedApp['starrAppDetails']['apikey']], $method, $json);
184+
185+
logger($logfile, ['req' => $requestCounter, 'apikey' => $apikey, 'endpoint' => $_GET['feed'] . ($variables ? '?' . http_build_query($variables) : ''), 'proxyCode' => 200, 'starrCode' => $request['code']]);
186+
logger($proxiedAppLogfile, ['req' => $requestCounter, 'apikey' => $apikey, 'endpoint' => $_GET['feed'] . ($variables ? '?' . http_build_query($variables) : ''), 'proxyCode' => 200, 'starrCode' => $request['code'], 'starrRequest' => $request]);
187+
188+
$usageDb->adjustAppUsage($proxiedApp['proxiedAppDetails']['id'], $request['code']);
189+
190+
echo $request['response'];
191+
exit();
180192
} else {
181193
$isAllowedEndpoint = $starr->isAllowedEndpoint($app, $proxiedApp['access'], $endpoint);
182194
$starrEndpoint = $isAllowedEndpoint['starrEndpoint'];

root/etc/nginx/nginx.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ http {
114114
try_files $uri /api/index.php?endpoint=/api/$2&$args;
115115
}
116116

117+
location ~ ^(.*)/feed/(.*)$ {
118+
try_files $uri /api/index.php?feed=/feed/$2&$args;
119+
}
120+
117121
location ~ ^(.*)/backup/(.*)$ {
118122
try_files $uri /api/index.php?backup=/backup/$2&$args;
119123
}

0 commit comments

Comments
 (0)