diff --git a/components/Conversation/Controller/Conversation.php b/components/Conversation/Controller/Conversation.php index faed6ae52d..dc050a8ff2 100644 --- a/components/Conversation/Controller/Conversation.php +++ b/components/Conversation/Controller/Conversation.php @@ -101,12 +101,12 @@ class Conversation extends FeedController $user = Common::ensureLoggedIn(); $is_muted = ConversationMute::isMuted($conversation_id, $user); $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); if ($form->isSubmitted() && $form->isValid()) { - if ($is_muted) { + if (!$is_muted) { DB::persist(ConversationMute::create(['conversation_id' => $conversation_id, 'actor_id' => $user->getId()])); } else { DB::removeBy('conversation_mute', ['conversation_id' => $conversation_id, 'actor_id' => $user->getId()]); diff --git a/components/Conversation/Conversation.php b/components/Conversation/Conversation.php index be7c2eb76d..e41a47d4cd 100644 --- a/components/Conversation/Conversation.php +++ b/components/Conversation/Conversation.php @@ -227,7 +227,7 @@ class Conversation extends Component } $actions[] = [ - 'title' => ConversationMute::isMuted($note, $user) ? _m('Mute conversation') : _m('Unmute conversation'), + 'title' => ConversationMute::isMuted($note, $user) ? _m('Unmute conversation') : _m('Mute conversation'), 'classes' => '', 'url' => Router::url('conversation_mute', ['conversation_id' => $note->getConversationId()]), ]; diff --git a/components/Conversation/Entity/ConversationMute.php b/components/Conversation/Entity/ConversationMute.php index d44ad43bda..4011e91304 100644 --- a/components/Conversation/Entity/ConversationMute.php +++ b/components/Conversation/Entity/ConversationMute.php @@ -118,11 +118,15 @@ class ConversationMute extends Entity return [ 'name' => 'conversation_mute', 'fields' => [ - 'conversation_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Conversation.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'The conversation being blocked'], - 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'Who blocked the conversation'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'conversation_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Conversation.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'The conversation being blocked'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'Who blocked the conversation'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + ], + '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']], ], - 'primary key' => ['conversation_id', 'actor_id'], ]; } }