|
@@ -14,6 +14,7 @@ use app\Types\DatabaseObjects\Follow;
|
|
use app\Types\DatabaseObjects\Link;
|
|
use app\Types\DatabaseObjects\Link;
|
|
use app\Types\DatabaseObjects\Session;
|
|
use app\Types\DatabaseObjects\Session;
|
|
use app\Types\LinkEnum;
|
|
use app\Types\LinkEnum;
|
|
|
|
+use Exception;
|
|
use Hajeebtok\Types\Exceptions\SecurityFaultException;
|
|
use Hajeebtok\Types\Exceptions\SecurityFaultException;
|
|
use Mimey\MimeTypes;
|
|
use Mimey\MimeTypes;
|
|
use Pecee\SimpleRouter\SimpleRouter;
|
|
use Pecee\SimpleRouter\SimpleRouter;
|
|
@@ -52,6 +53,7 @@ class AccountController implements IRouteController
|
|
public static function getAccount($id): string
|
|
public static function getAccount($id): string
|
|
{
|
|
{
|
|
if($id === "myself") $id = get_token_id(request());
|
|
if($id === "myself") $id = get_token_id(request());
|
|
|
|
+ Logger::Debug($id);
|
|
Logger::Debug("Getting account id ($id).");
|
|
Logger::Debug("Getting account id ($id).");
|
|
|
|
|
|
$account = new Account(id: $id);
|
|
$account = new Account(id: $id);
|
|
@@ -60,8 +62,14 @@ class AccountController implements IRouteController
|
|
$followers = count(new Follow(followee_id: $id)->LoadMany());
|
|
$followers = count(new Follow(followee_id: $id)->LoadMany());
|
|
$following = count(new Follow(follower_id: $id)->LoadMany());
|
|
$following = count(new Follow(follower_id: $id)->LoadMany());
|
|
|
|
|
|
- $links = new Link(account_id: $id)->LoadMany();
|
|
|
|
|
|
+ try {
|
|
|
|
+ $links = new Link(account_id: $id)->LoadMany();
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
+ $links = [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
+ CORSHelper();
|
|
return api_json([
|
|
return api_json([
|
|
"id" => $id,
|
|
"id" => $id,
|
|
"username" => $account->username,
|
|
"username" => $account->username,
|
|
@@ -88,6 +96,8 @@ class AccountController implements IRouteController
|
|
$account = new Account(id: $id);
|
|
$account = new Account(id: $id);
|
|
$data = Hajeebtok::$Database->Query("SELECT * FROM videos WHERE author_id = :author_id", ["author_id" => $account->id]);
|
|
$data = Hajeebtok::$Database->Query("SELECT * FROM videos WHERE author_id = :author_id", ["author_id" => $account->id]);
|
|
if (empty($data)) throw new VideoNotFoundException(0, 404);
|
|
if (empty($data)) throw new VideoNotFoundException(0, 404);
|
|
|
|
+
|
|
|
|
+ CORSHelper();
|
|
return api_json($data);
|
|
return api_json($data);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -97,10 +107,14 @@ class AccountController implements IRouteController
|
|
if($id === "myself") $id = get_token_id(request());
|
|
if($id === "myself") $id = get_token_id(request());
|
|
|
|
|
|
if($signed_in) {
|
|
if($signed_in) {
|
|
- $account = new Account(id: $id);
|
|
|
|
- $account->Load();
|
|
|
|
-
|
|
|
|
- $picture_path = APP_ROOT . "/usercontent/pictures/$account->picture_hash.png";
|
|
|
|
|
|
+ try {
|
|
|
|
+ $account = new Account(id: $id);
|
|
|
|
+ $account->Load();
|
|
|
|
+
|
|
|
|
+ $picture_path = APP_ROOT . "/usercontent/pictures/$account->picture_hash.png";
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
+ $picture_path = APP_ROOT . "/usercontent/pictures/not_found.png";
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
// this is hardcoded because i dont care
|
|
// this is hardcoded because i dont care
|
|
$picture_path = APP_ROOT . "/usercontent/pictures/premium_" . rand(1, 57) . ".png";
|
|
$picture_path = APP_ROOT . "/usercontent/pictures/premium_" . rand(1, 57) . ".png";
|
|
@@ -340,6 +354,8 @@ class AccountController implements IRouteController
|
|
SimpleRouter::post("/addLink", [AccountController::class, "addLink"]);
|
|
SimpleRouter::post("/addLink", [AccountController::class, "addLink"]);
|
|
SimpleRouter::options("/update", "CORSHelper");
|
|
SimpleRouter::options("/update", "CORSHelper");
|
|
SimpleRouter::options("/token", "CORSHelper");
|
|
SimpleRouter::options("/token", "CORSHelper");
|
|
|
|
+ SimpleRouter::options("/{id}/get", "CORSHelper");
|
|
|
|
+ SimpleRouter::options("/{id}/videos", "CORSHelper");
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|