Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
fix(Torrent): Fix Torrent Download Dict miss
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Mar 16, 2019
1 parent 3101a63 commit 3a1780b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 2 additions & 7 deletions apps/models/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getRawDict()

public function getDownloadDict($encode = true)
{
$userInfo = app()->session->get('userInfo'); // FIXME add remote download by &passkey= (Add change our BeforeMiddle) or token ?
$dict = $this->getRawDict();

$scheme = "http://";
if (filter_var(app()->request->get("https"), FILTER_VALIDATE_BOOLEAN))
Expand All @@ -173,12 +173,7 @@ public function getDownloadDict($encode = true)
else if (app()->request->isSecure())
$scheme = "https://";

// FIXME bad code
$passkey = app()->pdo->createCommand("SELECT `passkey` FROM `users` WHERE id=:id LIMIT 1;")->bindParams([
"id" => $userInfo["uid"]
])->queryScalar();

$announce_suffix = "/announce?passkey=" . $passkey;
$announce_suffix = "/announce?passkey=" . app()->user->getPasskey();
$dict["announce"] = $scheme . app()->config->get("base.site_tracker_url") . $announce_suffix;

/** BEP 0012 Multitracker Metadata Extension
Expand Down
8 changes: 8 additions & 0 deletions framework/User/UserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,12 @@ public function getLang()
{
return $this->lang;
}

/**
* @return mixed
*/
public function getPasskey()
{
return $this->passkey;
}
}

0 comments on commit 3a1780b

Please sign in to comment.