Skip to content

Commit

Permalink
Fix failed releases handling
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Sep 8, 2018
1 parent 3f9d6e5 commit f093b8b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 59 deletions.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2018-09-08 DariusIII
* Fix: Fix failed releases handling
2018-09-07 DariusIII
* Chg: Use transaction function for inserts in Binaries class
* Chg: Add email verification message to login page for non-verified users
Expand Down
13 changes: 7 additions & 6 deletions app/Http/Controllers/FailedReleasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,28 @@ public function show(Request $request)
$rssToken = $this->userdata['api_token'];
} else {
if (! $request->has('userid') || ! $request->has('api_token')) {
return response('Error!', 400)->withHeaders(['X-DNZB-RCode' => 400, 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
return response('Bad request, please supply all parameters!', 400)->withHeaders(['X-DNZB-RCode' => 400, 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
}

$res = User::getByIdAndRssToken($request->input('userid'), $request->input('api_token'));
if ($res === null) {
return response('Error!', 401)->withHeaders(['X-DNZB-RCode' => 401, 'X-DNZB-RText' => 'Unauthorised, wrong user ID or rss key!']);
return response('Unauthorised, wrong user ID or rss key!', 401)->withHeaders(['X-DNZB-RCode' => 401, 'X-DNZB-RText' => 'Unauthorised, wrong user ID or rss key!']);
}

$uid = $res['id'];
$rssToken = $res['api_token'];
}

if (isset($uid, $rssToken) && is_numeric($uid) && $request->has('guid')) {
if (isset($uid, $rssToken) && $request->has('guid')) {
$alt = Release::getAlternate($request->input('guid'), $uid);
if ($alt === null) {
return response('Error!', 404)->withHeaders(['X-DNZB-RCode' => 404, 'X-DNZB-RText' => 'No NZB found for alternate match.']);

if (empty($alt)) {
return response('No NZB found for alternate match!', 404)->withHeaders(['X-DNZB-RCode' => 404, 'X-DNZB-RText' => 'No NZB found for alternate match.']);
}

return response('Success', 200)->withHeaders(['Location' => $this->serverurl.'getnzb?id='.$alt['guid'].'&i='.$uid.'&r='.$rssToken]);
}

return response('Error!', 400)->withHeaders(['X-DNZB-RCode' => 400, 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
return response('Bad request, please supply all parameters!', 400)->withHeaders(['X-DNZB-RCode' => 400, 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
}
}
82 changes: 29 additions & 53 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f093b8b

Please sign in to comment.