<?php

namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;

class About extends Common {
  private $common;
  private $res;

  public function __construct () {
    $this->common = new Common;
    $this->res = [
      'page' => 'about',
      'style' => 'about',
      'userinfo' => $this->common->user,
      'version' => $this->common->version,
    ];
  }

  public function instance () {
    $this->res['about'] = $this->getAbout();
    $this->res['plugins'] = $this->getPlugins();
    $this->res['stats'] = $this->getStats();

    return view('pages.peertube.about.instance', ['res' => $this->res]);
  }

  public function lightpeer () {
    $this->res['about'] = $this->getAbout();

    return view('pages.peertube.about.lightpeer', ['res' => $this->res]);
  }

  public function follows () {
    $this->res['follower'] = $this->getFollower();
    $this->res['following'] = $this->getFollowing();

    return view('pages.peertube.about.follows', ['res' => $this->res]);
  }

  function getAbout () {
    return $this->ptapi('/api/v1/config/about');
  }

  function getPlugins () {
    return $this->ptapi('/api/v1/plugins/peertube-plugin-custome-page/public-settings');
  }

  function getStats () {
    return $this->ptapi('/api/v1/server/stats');
  }

  function getFollower () {
    return $this->ptapi('/api/v1/server/followers?start=0&count=100&sort=-createdAt&state=accepted');
  }

  function getFollowing () {
    return $this->ptapi('/api/v1/server/following?start=0&count=100&sort=-createdAt&state=accepted');
  }
}
