From 1d622c80332916dbfe51b7c41ce12e5761364703 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 22 Jun 2023 18:46:43 +0200 Subject: [PATCH] Add POST /api/v1/conversations/:id/unread (#25509) --- app/controllers/api/v1/conversations_controller.rb | 5 +++++ config/routes/api.rb | 1 + 2 files changed, 6 insertions(+) diff --git a/app/controllers/api/v1/conversations_controller.rb b/app/controllers/api/v1/conversations_controller.rb index 63644f85e2..b3ca2f7903 100644 --- a/app/controllers/api/v1/conversations_controller.rb +++ b/app/controllers/api/v1/conversations_controller.rb @@ -19,6 +19,11 @@ class Api::V1::ConversationsController < Api::BaseController render json: @conversation, serializer: REST::ConversationSerializer end + def unread + @conversation.update!(unread: true) + render json: @conversation, serializer: REST::ConversationSerializer + end + def destroy @conversation.destroy! render_empty diff --git a/config/routes/api.rb b/config/routes/api.rb index 19c583b3e1..a10e8058a5 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -81,6 +81,7 @@ namespace :api, format: false do resources :conversations, only: [:index, :destroy] do member do post :read + post :unread end end