diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-27 16:13:02 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-16 14:03:23 +0100 |
commit | bc743d9fc8c8f740f37b91cbe374c6ae20b10619 (patch) | |
tree | cc6608daf4ad6bc8d2e0c17c2436d6976694e2c5 /app/models/info_request.rb | |
parent | 7cf64ac6665c8349c8b31120d6e22b800b99c3ab (diff) |
Add public criteria for message event access methods
get_last_response_event and get_last_outgoing_event are used in various
places to determine which events to link to, use in queries etc.
Restrict them to refer to the last publicly visible event of the
relevant type, and rename them to make that clear.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index fe0c94056..847a57ef4 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -733,28 +733,30 @@ public self.info_request_events.create!(:event_type => type, :params => params) end - def response_events - self.info_request_events.select{|e| e.response?} + def public_response_events + self.info_request_events.select{|e| e.response? && e.incoming_message.all_can_view? } end - # The last response is the default one people might want to reply to - def get_last_response_event_id - get_last_response_event.id if get_last_response_event + # The last public response is the default one people might want to reply to + def get_last_public_response_event_id + get_last_public_response_event.id if get_last_public_response_event end - def get_last_response_event - response_events.last + + def get_last_public_response_event + public_response_events.last end - def get_last_response - get_last_response_event.incoming_message if get_last_response_event + + def get_last_public_response + get_last_public_response_event.incoming_message if get_last_public_response_event end - def outgoing_events - info_request_events.select{|e| e.outgoing? } + def public_outgoing_events + info_request_events.select{|e| e.outgoing? && e.outgoing_message.all_can_view? } end - # The last outgoing message - def get_last_outgoing_event - outgoing_events.last + # The last public outgoing message + def get_last_public_outgoing_event + public_outgoing_events.last end # Text from the the initial request, for use in summary display @@ -989,8 +991,8 @@ public end def is_old_unclassified? - !is_external? && awaiting_description && url_title != 'holding_pen' && get_last_response_event && - Time.now > get_last_response_event.created_at + OLD_AGE_IN_DAYS + !is_external? && awaiting_description && url_title != 'holding_pen' && get_last_public_response_event && + Time.now > get_last_public_response_event.created_at + OLD_AGE_IN_DAYS end # List of incoming messages to followup, by unique email |