From ce01946eb03af28e76730dda455f11a1359e800e Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Sun, 30 Dec 2018 17:04:35 -0500 Subject: [PATCH] Fixed new pronto warnings after develop branch sync --- app/controllers/api/v1/comments_controller.rb | 1 + app/controllers/api/v1/post_interactions_controller.rb | 1 + app/controllers/api/v1/posts_controller.rb | 1 + app/controllers/api/v1/users_controller.rb | 1 + app/models/user/querying.rb | 1 + app/models/user/social_actions.rb | 1 + app/presenters/post_presenter.rb | 3 +-- app/presenters/profile_presenter.rb | 1 + app/services/notification_service.rb | 1 + spec/lib/api/paging/index_paginator_spec.rb | 1 + 10 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/comments_controller.rb b/app/controllers/api/v1/comments_controller.rb index e614a97ce..1a26212a3 100644 --- a/app/controllers/api/v1/comments_controller.rb +++ b/app/controllers/api/v1/comments_controller.rb @@ -110,6 +110,7 @@ module Api def find_post post = post_service.find!(params[:post_id]) return post if post.public? || private_read? + raise ActiveRecord::RecordNotFound end end diff --git a/app/controllers/api/v1/post_interactions_controller.rb b/app/controllers/api/v1/post_interactions_controller.rb index 4e313964a..14809ebb8 100644 --- a/app/controllers/api/v1/post_interactions_controller.rb +++ b/app/controllers/api/v1/post_interactions_controller.rb @@ -81,6 +81,7 @@ module Api def find_post post = post_service.find!(params[:post_id]) raise ActiveRecord::RecordNotFound unless post.public? || private_read? + post end end diff --git a/app/controllers/api/v1/posts_controller.rb b/app/controllers/api/v1/posts_controller.rb index 32ac25807..27c05ebec 100644 --- a/app/controllers/api/v1/posts_controller.rb +++ b/app/controllers/api/v1/posts_controller.rb @@ -59,6 +59,7 @@ module Api def add_location_params(mapped_parameters) return unless params.has_key?(:location) + location = params.require(:location) mapped_parameters[:location_address] = location[:address] mapped_parameters[:location_coords] = "#{location[:lat]},#{location[:lng]}" diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index f407cfd86..4789f4cc2 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -29,6 +29,7 @@ module Api person = if params.has_key?(:id) found_person = Person.find_by!(guid: params[:id]) raise ActiveRecord::RecordNotFound unless found_person.searchable || access_token?("contacts:read") + found_person else current_user.person diff --git a/app/models/user/querying.rb b/app/models/user/querying.rb index 767896c3f..62fb2657f 100644 --- a/app/models/user/querying.rb +++ b/app/models/user/querying.rb @@ -70,6 +70,7 @@ module User::Querying def posts_from(person, with_order=true) base_query = Post.from_person_visible_by_user(self, person) return base_query.order("posts.created_at desc") if with_order + base_query end diff --git a/app/models/user/social_actions.rb b/app/models/user/social_actions.rb index e03d84055..8a6369a18 100644 --- a/app/models/user/social_actions.rb +++ b/app/models/user/social_actions.rb @@ -25,6 +25,7 @@ module User::SocialActions def reshare!(target, opts={}) raise I18n.t("reshares.create.error") if target.author.guid == guid + build_post(:reshare, :root_guid => target.guid).tap do |reshare| reshare.save! update_or_create_participation!(target) diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 2afd5ef1b..d24f5d35a 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -17,7 +17,6 @@ class PostPresenter < BasePresenter end def as_api_response - interactions = PostInteractionPresenter.new(@post, current_user) { guid: @post.guid, body: build_text, @@ -28,7 +27,7 @@ class PostPresenter < BasePresenter nsfw: @post.nsfw, author: PersonPresenter.new(@post.author).as_api_json, provider_display_name: @post.provider_display_name, - interaction_counters: interactions.as_counters, + interaction_counters: PostInteractionPresenter.new(@post, current_user).as_counters, location: @post.post_location, poll: PollPresenter.new(@post.poll, current_user).as_api_json, mentioned_people: build_mentioned_people_json, diff --git a/app/presenters/profile_presenter.rb b/app/presenters/profile_presenter.rb index ab269f4a5..181575a9f 100644 --- a/app/presenters/profile_presenter.rb +++ b/app/presenters/profile_presenter.rb @@ -34,6 +34,7 @@ class ProfilePresenter < BasePresenter def as_other_api_json(all_details) return base_api_json unless all_details + base_api_json.merge(added_details_api_json) end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 71905e19f..755ae7b5c 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -46,6 +46,7 @@ class NotificationService def update_status_by_guid(guid, is_read_status) notification = get_by_guid(guid) raise ActiveRecord::RecordNotFound unless notification + notification.set_read_state(is_read_status) true end diff --git a/spec/lib/api/paging/index_paginator_spec.rb b/spec/lib/api/paging/index_paginator_spec.rb index 5c104ccaa..0f49c6c88 100644 --- a/spec/lib/api/paging/index_paginator_spec.rb +++ b/spec/lib/api/paging/index_paginator_spec.rb @@ -37,6 +37,7 @@ describe Api::Paging::IndexPaginator do until page&.empty? page_count += 1 break unless pager.next_page + np = pager.next_page.split("=").last.to_i pager = Api::Paging::IndexPaginator.new(@alice_search, np, @limit) page = pager.page_data