Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -10,25 +10,31 @@
|
||||
*/
|
||||
|
||||
namespace IPS\core\api\GraphQL\Queries;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\SafeException;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\core\api\GraphQL\Types\StreamType;
|
||||
use IPS\core\Stream as StreamClass;
|
||||
use IPS\Member;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream query for GraphQL API
|
||||
*/
|
||||
class _Stream
|
||||
class Stream
|
||||
{
|
||||
/*
|
||||
* @brief Query description
|
||||
*/
|
||||
public static $description = "Returns an activity stream";
|
||||
public static string $description = "Returns an activity stream";
|
||||
|
||||
/*
|
||||
* Query arguments
|
||||
@@ -43,7 +49,7 @@ class _Stream
|
||||
/**
|
||||
* Return the query return type
|
||||
*/
|
||||
public function type()
|
||||
public function type() : StreamType
|
||||
{
|
||||
return \IPS\core\api\GraphQL\TypeRegistry::stream();
|
||||
}
|
||||
@@ -51,34 +57,34 @@ class _Stream
|
||||
/**
|
||||
* Resolves this query
|
||||
*
|
||||
* @param mixed Value passed into this resolver
|
||||
* @param array Arguments
|
||||
* @param array Context values
|
||||
* @return \IPS\core\Stream
|
||||
* @param mixed $val Value passed into this resolver
|
||||
* @param array $args Arguments
|
||||
* @param array $context Context values
|
||||
* @return StreamClass|null
|
||||
*/
|
||||
public function resolve($val, $args, $context)
|
||||
public function resolve( mixed $val, array $args, array $context ) : ?StreamClass
|
||||
{
|
||||
if( isset( $args['id'] ) && \intval( $args['id'] ) )
|
||||
if( isset( $args['id'] ) && intval( $args['id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$stream = \IPS\core\Stream::load( $args['id'] );
|
||||
$stream = StreamClass::load( $args['id'] );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Suitable for guests? */
|
||||
if ( !\IPS\Member::loggedIn()->member_id and !( ( $stream->ownership == 'all' or $stream->ownership == 'custom' ) and $stream->read == 'all' and $stream->follow == 'all' and $stream->date_type != 'last_visit' ) )
|
||||
if ( !Member::loggedIn()->member_id and !( ( $stream->ownership == 'all' or $stream->ownership == 'custom' ) and $stream->read == 'all' and $stream->follow == 'all' and $stream->date_type != 'last_visit' ) )
|
||||
{
|
||||
throw new \IPS\Api\GraphQL\SafeException( 'INVALID_STREAM', 'GQL/0003/1', 403 );
|
||||
throw new SafeException( 'INVALID_STREAM', 'GQL/0003/1', 403 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Start with a blank stream */
|
||||
$stream = \IPS\core\Stream::allActivityStream();
|
||||
$stream = StreamClass::allActivityStream();
|
||||
}
|
||||
|
||||
return $stream;
|
||||
|
||||
Reference in new issue
Block a user