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)
- [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)
- [Roma](https://play.google.com/store/apps/details?id=tech.bigfig.roma)
- [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
- [Amaroq](https://github.com/ReticentJohn/Amaroq/tree/master)
- [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.
- [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
#### 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
- [Mammut](https://github.com/jamiesanson/Mammut) There are problems with the token request, see issue https://github.com/jamiesanson/Mammut/issues/19
#### 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)")
- [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)
- [Tootle](https://apps.apple.com/de/app/tootle-for-mastodon/id1236013466) Doesn't recognize server, loads /api/v1/instance in some endless loop
#### Other
- [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?"
## 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
*
* @param App $a App
* @param bool $do_login try to log in when not logged in, otherwise quit silently
* @throws ForbiddenException
* @throws InternalServerErrorException
* @throws UnauthorizedException
@ -192,7 +191,7 @@ function api_register_func($path, $func, $auth = false, $method = API_METHOD_ANY
* 'authenticated' => return status,
* 'user_record' => return authenticated user record
*/
function api_login(App $a, bool $do_login = true)
function api_login(App $a)
{
$_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()]);
}
if (!$do_login) {
return;
}
Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]);
header('WWW-Authenticate: Basic realm="Friendica"');
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 (!$do_login) {
return;
}
Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]);
header('WWW-Authenticate: Basic realm="Friendica"');
//header('HTTP/1.0 401 Unauthorized');
@ -608,7 +600,7 @@ function api_get_user(App $a, $contact_id = null)
api_login($a);
return false;
} else {
$user = $_SESSION['uid'];
$user = api_user();
$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);
}
} else {
$url = '';
$preview = '';
$url = Proxy::proxifyUrl($attachment['url']);
$preview = Proxy::proxifyUrl($attachment['preview'] ?? '');
}
$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)
{
$this->id = $id;
$this->id = (string)$id;
$this->accounts = $accounts;
$this->unread = $unread;
$this->last_status = $last_status;

View file

@ -39,6 +39,8 @@ class Instance extends BaseDataTransferObject
/** @var string */
protected $title;
/** @var string */
protected $short_description;
/** @var string */
protected $description;
/** @var string */
protected $email;
@ -58,8 +60,12 @@ class Instance extends BaseDataTransferObject
protected $registrations;
/** @var bool */
protected $approval_required;
/** @var bool */
protected $invites_enabled;
/** @var Account|null */
protected $contact_account = null;
/** @var array */
protected $rules = [];
/**
* Creates an instance record
@ -77,7 +83,7 @@ class Instance extends BaseDataTransferObject
$instance = new Instance();
$instance->uri = $baseUrl->get();
$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->version = FRIENDICA_VERSION;
$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->registrations = ($register_policy != Register::CLOSED);
$instance->approval_required = ($register_policy == Register::APPROVE);
$instance->invites_enabled = false;
$instance->contact_account = [];
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)
{
$this->id = $contact['id'] ?? 0;
$this->id = (string)($contact['id'] ?? 0);
$this->username = $tag['name'];
$this->url = $tag['url'];
@ -59,6 +59,8 @@ class Mention extends BaseDataTransferObject
strpos($contact['url'], $baseUrl->get() . '/') === 0 ?
$contact['nick'] :
$contact['addr'];
$this->username = $contact['nick'];
} else {
$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)
{
$this->id = $contactId;
$this->id = (string)$contactId;
$this->following = false;
$this->requested = false;
$this->endorsed = false;