Merge pull request #14675 from annando/get

New function to handle "get" requests
This commit is contained in:
Hypolite Petovan 2025-01-07 06:40:50 -05:00 committed by GitHub
commit f6afc5a2bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 52 additions and 37 deletions

View file

@ -164,6 +164,19 @@ abstract class BaseModule implements ICanHandleRequests
{
}
/**
* Module GET method to process submitted data
*
* Extend this method if the module is supposed to process GET requests.
* Doesn't display any content
*
* @param string[] $request The $_REQUEST content
* @return void
*/
protected function get(array $request = [])
{
}
/**
* {@inheritDoc}
*/
@ -221,6 +234,9 @@ abstract class BaseModule implements ICanHandleRequests
case Router::PUT:
$this->put($request);
return $this->response->generate();
case Router::GET:
$this->get($request);
break;
}
$timestamp = microtime(true);

View file

@ -99,7 +99,7 @@ class Lists extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
protected function rawContent(array $request = [])
protected function get(array $request = [])
{
$this->checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -7,7 +7,6 @@
namespace Friendica\Module\Api\Mastodon\Lists;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Circle;
@ -53,7 +52,7 @@ class Accounts extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
protected function rawContent(array $request = [])
protected function get(array $request = [])
{
$this->checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -51,7 +51,7 @@ class Markers extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
protected function rawContent(array $request = [])
protected function get(array $request = [])
{
$this->checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -116,7 +116,7 @@ class Media extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
protected function rawContent(array $request = [])
protected function get(array $request = [])
{
$this->checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -133,7 +133,7 @@ class PushSubscription extends BaseApi
$this->response->addJsonContent([]);
}
protected function rawContent(array $request = []): void
protected function get(array $request = []): void
{
$this->checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();

View file

@ -8,7 +8,6 @@
namespace Friendica\Module\Api\Mastodon;
use Friendica\App\Router;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Post;
@ -48,7 +47,7 @@ class ScheduledStatuses extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
protected function rawContent(array $request = [])
protected function get(array $request = [])
{
$this->checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -308,6 +308,7 @@ class Statuses extends BaseApi
if (!empty($request['scheduled_at'])) {
$item['guid'] = Item::guid($item, true);
$item['uri'] = Item::newURI($item['guid']);
$id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, DateTimeFormat::utc($request['scheduled_at']));
if (empty($id)) {
$this->logAndJsonError(500, $this->errorFactory->InternalError());
@ -350,7 +351,7 @@ class Statuses extends BaseApi
/**
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
protected function rawContent(array $request = [])
protected function get(array $request = [])
{
$uid = self::getCurrentUserID();

View file

@ -18,7 +18,7 @@ use Friendica\Module\BaseApi;
*/
class Inbox extends DirectMessagesEndpoint
{
protected function rawContent(array $request = [])
protected function get(array $request = [])
{
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();