Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -10,30 +10,38 @@
*/
namespace IPS\forums\api\GraphQL\Mutations;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\SafeException;
use IPS\Api\GraphQL\TypeRegistry;
use IPS\Content\Api\GraphQL\CommentMutator;
use IPS\Content\Comment;
use IPS\forums\api\GraphQL\Types\PostType;
use IPS\forums\Topic;
use IPS\forums\Topic\Post;
use IPS\Member;
use OutOfRangeException;
use function defined;
/* 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;
}
/**
* Reply to topic mutation for GraphQL API
*/
class _ReplyTopic extends \IPS\Content\Api\GraphQL\CommentMutator
class ReplyTopic extends CommentMutator
{
/**
* Class
*/
protected $class = 'IPS\forums\Topic\Post';
protected string $class = 'IPS\forums\Topic\Post';
/*
* @brief Query description
*/
public static $description = "Create a new post";
public static string $description = "Create a new post";
/*
* Mutation arguments
@@ -50,42 +58,45 @@ class _ReplyTopic extends \IPS\Content\Api\GraphQL\CommentMutator
/**
* Return the mutation return type
*
* @return PostType
*/
public function type()
public function type() : PostType
{
return \IPS\forums\api\GraphQL\TypeRegistry::post();
}
/**
* Resolves this mutation
* Resolves this query
*
* @param mixed Value passed into this resolver
* @param array Arguments
* @param array Context values
* @return \IPS\forums\Forum
* @param mixed $val Value passed into this resolver
* @param array $args Arguments
* @param array $context Context values
* @param array $info
* @return Post
*/
public function resolve($val, $args, $context, $info)
public function resolve( mixed $val, array $args, array $context, array $info ) : Comment
{
/* Get topic */
try
{
$topic = \IPS\forums\Topic::loadAndCheckPerms( $args['topicID'] );
$topic = Topic::loadAndCheckPerms( $args['topicID'] );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_TOPIC', '1F295/1_graphl', 403 );
throw new SafeException( 'NO_TOPIC', '1F295/1_graphl', 403 );
}
/* Get author */
if ( !$topic->canComment( \IPS\Member::loggedIn() ) )
if ( !$topic->canComment( Member::loggedIn() ) )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_PERMISSION', '2F294/A_graphl', 403 );
throw new SafeException( 'NO_PERMISSION', '2F294/A_graphl', 403 );
}
/* Check we have a post */
if ( !$args['content'] )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_POST', '1F295/3_graphl', 403 );
throw new SafeException( 'NO_POST', '1F295/3_graphl', 403 );
}
$originalPost = NULL;
@@ -94,9 +105,9 @@ class _ReplyTopic extends \IPS\Content\Api\GraphQL\CommentMutator
{
try
{
$originalPost = \IPS\forums\Topic\Post::loadAndCheckPerms( $args['replyingTo'] );
$originalPost = Post::loadAndCheckPerms( $args['replyingTo'] );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
// Just ignore it
}