forked from GNUsocial/gnu-social
[COMPONENTS][Conversation] Added missing foreign keys to ConversationMute Entity
Fixed 'is_muted' variable check logic that impeded the Conversation from being muted
This commit is contained in:
parent
fc57b3290e
commit
d17f276419
@ -101,12 +101,12 @@ class Conversation extends FeedController
|
|||||||
$user = Common::ensureLoggedIn();
|
$user = Common::ensureLoggedIn();
|
||||||
$is_muted = ConversationMute::isMuted($conversation_id, $user);
|
$is_muted = ConversationMute::isMuted($conversation_id, $user);
|
||||||
$form = Form::create([
|
$form = Form::create([
|
||||||
['mute_conversation', SubmitType::class, ['label' => $is_muted ? _m('Mute conversation') : _m('Unmute conversation')]],
|
['mute_conversation', SubmitType::class, ['label' => $is_muted ? _m('Unmute conversation') : _m('Mute conversation')]],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
if ($is_muted) {
|
if (!$is_muted) {
|
||||||
DB::persist(ConversationMute::create(['conversation_id' => $conversation_id, 'actor_id' => $user->getId()]));
|
DB::persist(ConversationMute::create(['conversation_id' => $conversation_id, 'actor_id' => $user->getId()]));
|
||||||
} else {
|
} else {
|
||||||
DB::removeBy('conversation_mute', ['conversation_id' => $conversation_id, 'actor_id' => $user->getId()]);
|
DB::removeBy('conversation_mute', ['conversation_id' => $conversation_id, 'actor_id' => $user->getId()]);
|
||||||
|
@ -227,7 +227,7 @@ class Conversation extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
$actions[] = [
|
$actions[] = [
|
||||||
'title' => ConversationMute::isMuted($note, $user) ? _m('Mute conversation') : _m('Unmute conversation'),
|
'title' => ConversationMute::isMuted($note, $user) ? _m('Unmute conversation') : _m('Mute conversation'),
|
||||||
'classes' => '',
|
'classes' => '',
|
||||||
'url' => Router::url('conversation_mute', ['conversation_id' => $note->getConversationId()]),
|
'url' => Router::url('conversation_mute', ['conversation_id' => $note->getConversationId()]),
|
||||||
];
|
];
|
||||||
|
@ -123,6 +123,10 @@ class ConversationMute extends Entity
|
|||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||||
],
|
],
|
||||||
'primary key' => ['conversation_id', 'actor_id'],
|
'primary key' => ['conversation_id', 'actor_id'],
|
||||||
|
'foreign keys' => [
|
||||||
|
'conversation_id_to_id_fkey' => ['conversation', ['conversation_id' => 'id']],
|
||||||
|
'actor_id_to_id_fkey' => ['actor', ['actor_id' => 'id']],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user