mirror of https://github.com/pixelfed/pixelfed
commit
160097c287
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Auth;
|
||||
|
||||
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
||||
|
||||
class BearerTokenResponse extends \League\OAuth2\Server\ResponseTypes\BearerTokenResponse
|
||||
{
|
||||
/**
|
||||
* Add custom fields to your Bearer Token response here, then override
|
||||
* AuthorizationServer::getResponseType() to pull in your version of
|
||||
* this class rather than the default.
|
||||
*
|
||||
* @param AccessTokenEntityInterface $accessToken
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExtraParams(AccessTokenEntityInterface $accessToken)
|
||||
{
|
||||
return [
|
||||
'created_at' => time(),
|
||||
'scope' => 'read write follow push'
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Auth\BearerTokenResponse;
|
||||
use Laravel\Passport\Bridge;
|
||||
use League\OAuth2\Server\AuthorizationServer;
|
||||
|
||||
class PassportServiceProvider extends \Laravel\Passport\PassportServiceProvider
|
||||
{
|
||||
/**
|
||||
* Make the authorization service instance.
|
||||
*
|
||||
* @return \League\OAuth2\Server\AuthorizationServer
|
||||
*/
|
||||
public function makeAuthorizationServer()
|
||||
{
|
||||
return new AuthorizationServer(
|
||||
$this->app->make(Bridge\ClientRepository::class),
|
||||
$this->app->make(Bridge\AccessTokenRepository::class),
|
||||
$this->app->make(Bridge\ScopeRepository::class),
|
||||
$this->makeCryptKey('private'),
|
||||
app('encrypter')->getKey(),
|
||||
new BearerTokenResponse()
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Cache;
|
||||
|
||||
class MarkerService
|
||||
{
|
||||
const CACHE_KEY = 'pf:services:markers:timeline:';
|
||||
|
||||
public static function get($profileId, $timeline = 'home')
|
||||
{
|
||||
return Cache::get(self::CACHE_KEY . $timeline . ':' . $profileId);
|
||||
}
|
||||
|
||||
public static function set($profileId, $timeline = 'home', $entityId)
|
||||
{
|
||||
$existing = self::get($profileId, $timeline);
|
||||
$key = self::CACHE_KEY . $timeline . ':' . $profileId;
|
||||
$val = [
|
||||
'last_read_id' => (string) $entityId,
|
||||
'version' => $existing ? ($existing['version'] + 1) : 1,
|
||||
'updated_at' => now()->format('c')
|
||||
];
|
||||
Cache::put($key, $val, 2592000);
|
||||
return $val;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue