Skip to content

Commit

Permalink
Fix current request logic
Browse files Browse the repository at this point in the history
- to account for a contributor never having received a message
  • Loading branch information
mattwr18 committed Oct 18, 2023
1 parent 7bf4828 commit 0d20844
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ApiController < ApplicationController
skip_before_action :require_login
skip_before_action :require_login, :verify_authenticity_token
before_action :authorize_api_access, :contributor

def show
Expand Down Expand Up @@ -39,13 +39,13 @@ def create

def current_request
if contributor
current_personalized_request = contributor.received_messages.first
current_request = contributor.active_request
render json: {
status: 'ok',
data: {
id: current_personalized_request.id,
personalized_text: current_personalized_request.text,
contributor_replies_count: contributor.replies.where(request_id: current_personalized_request.request.id).count
id: current_request.id,
personalized_text: current_request.personalized_text(contributor),
contributor_replies_count: contributor.replies.where(request_id: current_request.id).count
}
}, status: :ok
else
Expand Down

0 comments on commit 0d20844

Please sign in to comment.