mirror of
https://framagit.org/tom79/fediplan.git
synced 2025-04-06 06:01:50 +02:00
Respect default user visibility and sensitivity of media
This commit is contained in:
parent
50b38ad5ee
commit
e72715f1ab
4 changed files with 64 additions and 5 deletions
|
@ -126,7 +126,7 @@ class FediPlanController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
$compose = new Compose();
|
$compose = new Compose();
|
||||||
$form = $this->createForm(ComposeType::class, $compose);
|
$form = $this->createForm(ComposeType::class, $compose, ['user' => $this->getUser()]);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
/** @var $data Compose */
|
/** @var $data Compose */
|
||||||
|
|
|
@ -36,6 +36,17 @@ class ComposeType extends AbstractType {
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
/**@var $user \App\SocialEntity\MastodonAccount**/
|
||||||
|
$user = $options['user'];
|
||||||
|
|
||||||
|
if( $user->getDefaultSensitivity()) {
|
||||||
|
$checkbox = [
|
||||||
|
'required' => false,
|
||||||
|
'attr' => ['checked' => 'checked'],
|
||||||
|
];
|
||||||
|
}else {
|
||||||
|
$checkbox = ['required' => false];
|
||||||
|
}
|
||||||
|
|
||||||
$builder->add('content_warning', TextType::class, ['required' => false]);
|
$builder->add('content_warning', TextType::class, ['required' => false]);
|
||||||
$builder->add('content', TextareaType::class, ['required' => false]);
|
$builder->add('content', TextareaType::class, ['required' => false]);
|
||||||
|
@ -46,10 +57,11 @@ class ComposeType extends AbstractType {
|
||||||
'status.visibility.unlisted' => 'unlisted',
|
'status.visibility.unlisted' => 'unlisted',
|
||||||
'status.visibility.private' => 'private',
|
'status.visibility.private' => 'private',
|
||||||
'status.visibility.direct' => 'direct',
|
'status.visibility.direct' => 'direct',
|
||||||
]
|
],
|
||||||
|
'data' => $user->getDefaultVisibility(),
|
||||||
]);
|
]);
|
||||||
$builder->add('timeZone', TimezoneType::class);
|
$builder->add('timeZone', TimezoneType::class);
|
||||||
$builder->add('sensitive', CheckboxType::class, ['required' => false]);
|
$builder->add('sensitive', CheckboxType::class, $checkbox);
|
||||||
$builder->add('scheduled_at', \Symfony\Component\Form\Extension\Core\Type\DateTimeType::class,[
|
$builder->add('scheduled_at', \Symfony\Component\Form\Extension\Core\Type\DateTimeType::class,[
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
"data" => new \DateTime()
|
"data" => new \DateTime()
|
||||||
|
@ -63,7 +75,8 @@ class ComposeType extends AbstractType {
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => Compose::class,
|
'data_class' => Compose::class,
|
||||||
'translation_domain' => 'fediplan'
|
'translation_domain' => 'fediplan',
|
||||||
|
'user' => null
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1237,6 +1237,16 @@ class Mastodon_api {
|
||||||
$MastodonAccount->addField($field);
|
$MastodonAccount->addField($field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( $accountParams['source'] && $accountParams['source']['privacy']){
|
||||||
|
$MastodonAccount->setDefaultVisibility($accountParams['source']['privacy']);
|
||||||
|
}else{
|
||||||
|
$MastodonAccount->setDefaultVisibility("public");
|
||||||
|
}
|
||||||
|
if( $accountParams['source'] ){
|
||||||
|
$MastodonAccount->setDefaultSensitivity($accountParams['source']['sensitive']?1:0);
|
||||||
|
}else{
|
||||||
|
$MastodonAccount->setDefaultSensitivity(0);
|
||||||
|
}
|
||||||
return $MastodonAccount;
|
return $MastodonAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@ class MastodonAccount
|
||||||
|
|
||||||
private $Emojis;
|
private $Emojis;
|
||||||
|
|
||||||
|
private $default_sensitivity;
|
||||||
|
|
||||||
|
private $default_visibility;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -386,5 +388,39 @@ class MastodonAccount
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getDefaultSensitivity()
|
||||||
|
{
|
||||||
|
return $this->default_sensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $default_sensitivity
|
||||||
|
*/
|
||||||
|
public function setDefaultSensitivity($default_sensitivity): void
|
||||||
|
{
|
||||||
|
$this->default_sensitivity = $default_sensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getDefaultVisibility()
|
||||||
|
{
|
||||||
|
return $this->default_visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $default_visibility
|
||||||
|
*/
|
||||||
|
public function setDefaultVisibility($default_visibility): void
|
||||||
|
{
|
||||||
|
$this->default_visibility = $default_visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue