Merge pull request #10393 from annando/api-more-apps

API: Some more apps are now supported
This commit is contained in:
Hypolite Petovan 2021-06-11 09:02:32 -04:00 committed by GitHub
commit b0242a8bc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 21 deletions

View file

@ -17,6 +17,7 @@ Authentication is the same as described in [Using the APIs](help/api#Authenticat
- [AndStatus](http://andstatus.org) - [AndStatus](http://andstatus.org)
- [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma) - [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma)
- [Fedi](https://play.google.com/store/apps/details?id=com.fediverse.app)
- [Husky](https://husky.fwgs.ru) - [Husky](https://husky.fwgs.ru)
- [Roma](https://play.google.com/store/apps/details?id=tech.bigfig.roma) - [Roma](https://play.google.com/store/apps/details?id=tech.bigfig.roma)
- [Subway Tooter](https://github.com/tateisu/SubwayTooter) - [Subway Tooter](https://github.com/tateisu/SubwayTooter)
@ -28,27 +29,29 @@ Authentication is the same as described in [Using the APIs](help/api#Authenticat
#### iOS #### iOS
- [Amaroq](https://github.com/ReticentJohn/Amaroq/tree/master) - [Amaroq](https://github.com/ReticentJohn/Amaroq/tree/master)
- [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma) - [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma)
- [Fedi](https://apps.apple.com/de/app/fedi-for-pleroma-and-mastodon/id1478806281)
- [Roma](https://apps.apple.com/de/app/roma-for-pleroma-and-mastodon/id1445328699)
- [StarPterano](https://apps.apple.com/de/app/starpterano/id1436972796) Uses an OAuth method where you have to manually copy and paste the provided code. - [StarPterano](https://apps.apple.com/de/app/starpterano/id1436972796) Uses an OAuth method where you have to manually copy and paste the provided code.
- [Stella](https://apps.apple.com/us/app/stella-for-mastodon-twitter/id921372048?l=ms) - [Stella](https://apps.apple.com/us/app/stella-for-mastodon-twitter/id921372048?l=ms)
- [Tootle](https://apps.apple.com/de/app/tootle-for-mastodon/id1236013466) entered hostname must match in upper/lower case. Currently crashes on "Status" type notifications.
#### Desktop
- [Whalebird](https://whalebird.social)
### Unsupported apps ### Unsupported apps
#### Android #### Android
- [Fedi](https://play.google.com/store/apps/details?id=com.fediverse.app) Authenticates, but doesn't load posts and throws several errors
- [Fedilab](https://framagit.org/tom79/fedilab) Automatically uses the legacy API, see issue: https://framagit.org/tom79/fedilab/-/issues/520 - [Fedilab](https://framagit.org/tom79/fedilab) Automatically uses the legacy API, see issue: https://framagit.org/tom79/fedilab/-/issues/520
- [Mammut](https://github.com/jamiesanson/Mammut) There are problems with the token request, see issue https://github.com/jamiesanson/Mammut/issues/19 - [Mammut](https://github.com/jamiesanson/Mammut) There are problems with the token request, see issue https://github.com/jamiesanson/Mammut/issues/19
#### iOS #### iOS
- [Fedi](https://apps.apple.com/de/app/fedi-for-pleroma-and-mastodon/id1478806281) Authenticates, but doesn't load posts and throws several errors
- [Mast](https://github.com/Beesitech/Mast) Doesn't accept the entered instance name. Claims that it is invalid (Message is: "Not a valid instance (may be closed or dead)") - [Mast](https://github.com/Beesitech/Mast) Doesn't accept the entered instance name. Claims that it is invalid (Message is: "Not a valid instance (may be closed or dead)")
- [Mastonaut](https://mastonaut.app/)
- [Roma](https://apps.apple.com/de/app/roma-for-pleroma-and-mastodon/id1445328699) Authenticates, but doesn't load content
- [Toot!](https://apps.apple.com/app/toot/id1229021451) - [Toot!](https://apps.apple.com/app/toot/id1229021451)
- [Tootle](https://apps.apple.com/de/app/tootle-for-mastodon/id1236013466) Doesn't recognize server, loads /api/v1/instance in some endless loop
#### Other #### Other
- [Halycon](https://www.halcyon.social/) Doesn't load content, creates masses of HTTP requests - [Halycon](https://www.halcyon.social/) Doesn't load content, creates masses of HTTP requests
- [Mastonaut](https://mastonaut.app/)
- [Pinafore](https://github.com/nolanlawson/pinafore) Returns message "Error: NetworkError when attempting to fetch resource.. Is this a valid Mastodon instance?" - [Pinafore](https://github.com/nolanlawson/pinafore) Returns message "Error: NetworkError when attempting to fetch resource.. Is this a valid Mastodon instance?"
## Entities ## Entities

View file

@ -181,7 +181,6 @@ function api_register_func($path, $func, $auth = false, $method = API_METHOD_ANY
* Simple Auth allow username in form of <pre>user@server</pre>, ignoring server part * Simple Auth allow username in form of <pre>user@server</pre>, ignoring server part
* *
* @param App $a App * @param App $a App
* @param bool $do_login try to log in when not logged in, otherwise quit silently
* @throws ForbiddenException * @throws ForbiddenException
* @throws InternalServerErrorException * @throws InternalServerErrorException
* @throws UnauthorizedException * @throws UnauthorizedException
@ -192,7 +191,7 @@ function api_register_func($path, $func, $auth = false, $method = API_METHOD_ANY
* 'authenticated' => return status, * 'authenticated' => return status,
* 'user_record' => return authenticated user record * 'user_record' => return authenticated user record
*/ */
function api_login(App $a, bool $do_login = true) function api_login(App $a)
{ {
$_SESSION["allow_api"] = false; $_SESSION["allow_api"] = false;
@ -225,10 +224,6 @@ function api_login(App $a, bool $do_login = true)
Logger::warning(API_LOG_PREFIX . 'OAuth error', ['module' => 'api', 'action' => 'login', 'exception' => $e->getMessage()]); Logger::warning(API_LOG_PREFIX . 'OAuth error', ['module' => 'api', 'action' => 'login', 'exception' => $e->getMessage()]);
} }
if (!$do_login) {
return;
}
Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]); Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]);
header('WWW-Authenticate: Basic realm="Friendica"'); header('WWW-Authenticate: Basic realm="Friendica"');
throw new UnauthorizedException("This API requires login"); throw new UnauthorizedException("This API requires login");
@ -270,9 +265,6 @@ function api_login(App $a, bool $do_login = true)
} }
if (!DBA::isResult($record)) { if (!DBA::isResult($record)) {
if (!$do_login) {
return;
}
Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]); Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]);
header('WWW-Authenticate: Basic realm="Friendica"'); header('WWW-Authenticate: Basic realm="Friendica"');
//header('HTTP/1.0 401 Unauthorized'); //header('HTTP/1.0 401 Unauthorized');
@ -608,7 +600,7 @@ function api_get_user(App $a, $contact_id = null)
api_login($a); api_login($a);
return false; return false;
} else { } else {
$user = $_SESSION['uid']; $user = api_user();
$extra_query = "AND `contact`.`uid` = %d AND `contact`.`self` "; $extra_query = "AND `contact`.`uid` = %d AND `contact`.`self` ";
} }
} }

View file

@ -86,8 +86,8 @@ class Attachment extends BaseFactory
$preview = Proxy::proxifyUrl($attachment['url'], false, Proxy::SIZE_SMALL); $preview = Proxy::proxifyUrl($attachment['url'], false, Proxy::SIZE_SMALL);
} }
} else { } else {
$url = ''; $url = Proxy::proxifyUrl($attachment['url']);
$preview = ''; $preview = Proxy::proxifyUrl($attachment['preview'] ?? '');
} }
$object = new \Friendica\Object\Api\Mastodon\Attachment($attachment, $type, $url, $preview, $remote); $object = new \Friendica\Object\Api\Mastodon\Attachment($attachment, $type, $url, $preview, $remote);

View file

@ -46,7 +46,7 @@ class Conversation extends BaseDataTransferObject
public function __construct(string $id, array $accounts, bool $unread, \Friendica\Object\Api\Mastodon\Status $last_status) public function __construct(string $id, array $accounts, bool $unread, \Friendica\Object\Api\Mastodon\Status $last_status)
{ {
$this->id = $id; $this->id = (string)$id;
$this->accounts = $accounts; $this->accounts = $accounts;
$this->unread = $unread; $this->unread = $unread;
$this->last_status = $last_status; $this->last_status = $last_status;

View file

@ -39,6 +39,8 @@ class Instance extends BaseDataTransferObject
/** @var string */ /** @var string */
protected $title; protected $title;
/** @var string */ /** @var string */
protected $short_description;
/** @var string */
protected $description; protected $description;
/** @var string */ /** @var string */
protected $email; protected $email;
@ -58,8 +60,12 @@ class Instance extends BaseDataTransferObject
protected $registrations; protected $registrations;
/** @var bool */ /** @var bool */
protected $approval_required; protected $approval_required;
/** @var bool */
protected $invites_enabled;
/** @var Account|null */ /** @var Account|null */
protected $contact_account = null; protected $contact_account = null;
/** @var array */
protected $rules = [];
/** /**
* Creates an instance record * Creates an instance record
@ -77,7 +83,7 @@ class Instance extends BaseDataTransferObject
$instance = new Instance(); $instance = new Instance();
$instance->uri = $baseUrl->get(); $instance->uri = $baseUrl->get();
$instance->title = DI::config()->get('config', 'sitename'); $instance->title = DI::config()->get('config', 'sitename');
$instance->description = DI::config()->get('config', 'info'); $instance->short_description = $instance->description = DI::config()->get('config', 'info');
$instance->email = DI::config()->get('config', 'admin_email'); $instance->email = DI::config()->get('config', 'admin_email');
$instance->version = FRIENDICA_VERSION; $instance->version = FRIENDICA_VERSION;
$instance->urls = null; // Not supported $instance->urls = null; // Not supported
@ -87,6 +93,7 @@ class Instance extends BaseDataTransferObject
$instance->max_toot_chars = (int)DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size')); $instance->max_toot_chars = (int)DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size'));
$instance->registrations = ($register_policy != Register::CLOSED); $instance->registrations = ($register_policy != Register::CLOSED);
$instance->approval_required = ($register_policy == Register::APPROVE); $instance->approval_required = ($register_policy == Register::APPROVE);
$instance->invites_enabled = false;
$instance->contact_account = []; $instance->contact_account = [];
if (!empty(DI::config()->get('config', 'admin_email'))) { if (!empty(DI::config()->get('config', 'admin_email'))) {

View file

@ -50,7 +50,7 @@ class Mention extends BaseDataTransferObject
*/ */
public function __construct(BaseURL $baseUrl, array $tag, array $contact) public function __construct(BaseURL $baseUrl, array $tag, array $contact)
{ {
$this->id = $contact['id'] ?? 0; $this->id = (string)($contact['id'] ?? 0);
$this->username = $tag['name']; $this->username = $tag['name'];
$this->url = $tag['url']; $this->url = $tag['url'];
@ -59,6 +59,8 @@ class Mention extends BaseDataTransferObject
strpos($contact['url'], $baseUrl->get() . '/') === 0 ? strpos($contact['url'], $baseUrl->get() . '/') === 0 ?
$contact['nick'] : $contact['nick'] :
$contact['addr']; $contact['addr'];
$this->username = $contact['nick'];
} else { } else {
$this->acct = ''; $this->acct = '';
} }

View file

@ -79,7 +79,7 @@ class Relationship extends BaseDataTransferObject
*/ */
public function __construct(int $contactId, array $contactRecord = [], bool $blocked = false, bool $muted = false) public function __construct(int $contactId, array $contactRecord = [], bool $blocked = false, bool $muted = false)
{ {
$this->id = $contactId; $this->id = (string)$contactId;
$this->following = false; $this->following = false;
$this->requested = false; $this->requested = false;
$this->endorsed = false; $this->endorsed = false;