[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:
Eliseu Amaro 2022-01-07 21:14:13 +00:00
parent fc57b3290e
commit d17f276419
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5
3 changed files with 11 additions and 7 deletions

View File

@ -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()]);

View File

@ -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()]),
]; ];

View File

@ -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']],
],
]; ];
} }
} }