mirror of
https://github.com/friendica/friendica
synced 2025-02-05 02:18:51 +00:00
Merge pull request #14675 from annando/get
New function to handle "get" requests
This commit is contained in:
commit
f6afc5a2bb
9 changed files with 52 additions and 37 deletions
|
@ -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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -221,6 +234,9 @@ abstract class BaseModule implements ICanHandleRequests
|
||||||
case Router::PUT:
|
case Router::PUT:
|
||||||
$this->put($request);
|
$this->put($request);
|
||||||
return $this->response->generate();
|
return $this->response->generate();
|
||||||
|
case Router::GET:
|
||||||
|
$this->get($request);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$timestamp = microtime(true);
|
$timestamp = microtime(true);
|
||||||
|
|
|
@ -99,7 +99,7 @@ class Lists extends BaseApi
|
||||||
/**
|
/**
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
protected function rawContent(array $request = [])
|
protected function get(array $request = [])
|
||||||
{
|
{
|
||||||
$this->checkAllowedScope(self::SCOPE_READ);
|
$this->checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Api\Mastodon\Lists;
|
namespace Friendica\Module\Api\Mastodon\Lists;
|
||||||
|
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Circle;
|
use Friendica\Model\Circle;
|
||||||
|
@ -53,7 +52,7 @@ class Accounts extends BaseApi
|
||||||
/**
|
/**
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
protected function rawContent(array $request = [])
|
protected function get(array $request = [])
|
||||||
{
|
{
|
||||||
$this->checkAllowedScope(self::SCOPE_READ);
|
$this->checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Markers extends BaseApi
|
||||||
/**
|
/**
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
protected function rawContent(array $request = [])
|
protected function get(array $request = [])
|
||||||
{
|
{
|
||||||
$this->checkAllowedScope(self::SCOPE_READ);
|
$this->checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Media extends BaseApi
|
||||||
/**
|
/**
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
protected function rawContent(array $request = [])
|
protected function get(array $request = [])
|
||||||
{
|
{
|
||||||
$this->checkAllowedScope(self::SCOPE_READ);
|
$this->checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -133,7 +133,7 @@ class PushSubscription extends BaseApi
|
||||||
$this->response->addJsonContent([]);
|
$this->response->addJsonContent([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function rawContent(array $request = []): void
|
protected function get(array $request = []): void
|
||||||
{
|
{
|
||||||
$this->checkAllowedScope(self::SCOPE_PUSH);
|
$this->checkAllowedScope(self::SCOPE_PUSH);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
namespace Friendica\Module\Api\Mastodon;
|
namespace Friendica\Module\Api\Mastodon;
|
||||||
|
|
||||||
use Friendica\App\Router;
|
use Friendica\App\Router;
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
@ -48,7 +47,7 @@ class ScheduledStatuses extends BaseApi
|
||||||
/**
|
/**
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
protected function rawContent(array $request = [])
|
protected function get(array $request = [])
|
||||||
{
|
{
|
||||||
$this->checkAllowedScope(self::SCOPE_READ);
|
$this->checkAllowedScope(self::SCOPE_READ);
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
|
@ -308,6 +308,7 @@ class Statuses extends BaseApi
|
||||||
if (!empty($request['scheduled_at'])) {
|
if (!empty($request['scheduled_at'])) {
|
||||||
$item['guid'] = Item::guid($item, true);
|
$item['guid'] = Item::guid($item, true);
|
||||||
$item['uri'] = Item::newURI($item['guid']);
|
$item['uri'] = Item::newURI($item['guid']);
|
||||||
|
|
||||||
$id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, DateTimeFormat::utc($request['scheduled_at']));
|
$id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, DateTimeFormat::utc($request['scheduled_at']));
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$this->logAndJsonError(500, $this->errorFactory->InternalError());
|
$this->logAndJsonError(500, $this->errorFactory->InternalError());
|
||||||
|
@ -350,7 +351,7 @@ class Statuses extends BaseApi
|
||||||
/**
|
/**
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
protected function rawContent(array $request = [])
|
protected function get(array $request = [])
|
||||||
{
|
{
|
||||||
$uid = self::getCurrentUserID();
|
$uid = self::getCurrentUserID();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use Friendica\Module\BaseApi;
|
||||||
*/
|
*/
|
||||||
class Inbox extends DirectMessagesEndpoint
|
class Inbox extends DirectMessagesEndpoint
|
||||||
{
|
{
|
||||||
protected function rawContent(array $request = [])
|
protected function get(array $request = [])
|
||||||
{
|
{
|
||||||
$this->checkAllowedScope(BaseApi::SCOPE_READ);
|
$this->checkAllowedScope(BaseApi::SCOPE_READ);
|
||||||
$uid = BaseApi::getCurrentUserID();
|
$uid = BaseApi::getCurrentUserID();
|
||||||
|
|
Loading…
Add table
Reference in a new issue