Some fixes

This commit is contained in:
Thomas 2019-08-12 15:50:41 +02:00
parent f7bb4002b4
commit 79f136e89f
2 changed files with 26 additions and 2 deletions

View file

@ -84,13 +84,37 @@ class FediPlanController extends AbstractController
$mastodon_api->set_client($client->getClientId(), $client->getClientSecret()); $mastodon_api->set_client($client->getClientId(), $client->getClientSecret());
$reply = $mastodon_api->loginAuthorization($code); $reply = $mastodon_api->loginAuthorization($code);
if( isset($reply['error']) ){ if( isset($reply['error']) ){
/* $access_token = $code;
$token_type = "Bearer";
$mastodon_api->set_url("https://" . $client->getHost());
$mastodon_api->set_token($access_token, $token_type);
try {
$accountReply = $mastodon_api->accounts_verify_credentials();
} catch (\ErrorException $e) {
}
if( isset($accountReply['error']) ){
$form->get('code')->addError(new FormError($translator->trans('error.instance.mastodon_account',[],'fediplan','en')));
}else{
$Account = $mastodon_api->getSingleAccount($accountReply['response']);
$Account->setInstance($host);
$Account->setToken($token_type ." ".$access_token);
$token = new UsernamePasswordToken($Account, null, 'main', array('ROLE_USER'));
$this->get('security.token_storage')->setToken($token);
$event = new InteractiveLoginEvent($request, $token);
$eventDispatcher->dispatch("security.interactive_login", $event);
return $this->redirectToRoute('schedule');
}*/
$form->get('code')->addError(new FormError($translator->trans('error.instance.mastodon_token',[],'fediplan','en'))); $form->get('code')->addError(new FormError($translator->trans('error.instance.mastodon_token',[],'fediplan','en')));
}else{ }else{
$access_token = $reply['response']['access_token']; $access_token = $reply['response']['access_token'];
$token_type = $reply['response']['token_type']; $token_type = $reply['response']['token_type'];
$mastodon_api->set_url("https://" . $client->getHost()); $mastodon_api->set_url("https://" . $client->getHost());
$mastodon_api->set_token($access_token, $token_type); $mastodon_api->set_token($access_token, $token_type);
$accountReply = $mastodon_api->accounts_verify_credentials(); try {
$accountReply = $mastodon_api->accounts_verify_credentials();
} catch (\ErrorException $e) {
}
if( isset($accountReply['error']) ){ if( isset($accountReply['error']) ){
$form->get('code')->addError(new FormError($translator->trans('error.instance.mastodon_account',[],'fediplan','en'))); $form->get('code')->addError(new FormError($translator->trans('error.instance.mastodon_account',[],'fediplan','en')));
}else{ }else{

View file

@ -1523,7 +1523,7 @@ class Mastodon_api {
} }
$status->setEmojis($emojis); $status->setEmojis($emojis);
} }
$status->setSensitive($statusParams['params']['sensitive']); $status->setSensitive($statusParams['params']['sensitive']?1:0);
$status->setSpoilerText($statusParams['params']['spoiler_text']);; $status->setSpoilerText($statusParams['params']['spoiler_text']);;
$status->setVisibility($statusParams['params']['visibility']); $status->setVisibility($statusParams['params']['visibility']);
if( isset($statusParams['media_attachments']) && count($statusParams['media_attachments']) > 0){ if( isset($statusParams['media_attachments']) && count($statusParams['media_attachments']) > 0){