Merge pull request #8363 from cmrd-senya/fix-api-tags-stream-to-hide-ignores
API: update Search endpoint to be aware of ignored users
This commit is contained in:
commit
fddfd8b8c0
4 changed files with 47 additions and 11 deletions
|
|
@ -67,6 +67,7 @@ We recommend setting up new pods using Ruby 3.3, and updating existing pods to t
|
||||||
* Fix scrolling issue after closing photo viewer on photos page [#8404](https://github.com/diaspora/diaspora/pull/8404)
|
* Fix scrolling issue after closing photo viewer on photos page [#8404](https://github.com/diaspora/diaspora/pull/8404)
|
||||||
* Filter unicode emojis from email headers [#8421](https://github.com/diaspora/diaspora/pull/8421)
|
* Filter unicode emojis from email headers [#8421](https://github.com/diaspora/diaspora/pull/8421)
|
||||||
* Do not show disabled services anymore [#8406](https://github.com/diaspora/diaspora/pull/8406)
|
* Do not show disabled services anymore [#8406](https://github.com/diaspora/diaspora/pull/8406)
|
||||||
|
* Update search endpoint to be aware of ignored users [#8363](https://github.com/diaspora/diaspora/pull/8363)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Add client-side cropping of profile image uploads [#7581](https://github.com/diaspora/diaspora/pull/7581)
|
* Add client-side cropping of profile image uploads [#7581](https://github.com/diaspora/diaspora/pull/7581)
|
||||||
|
|
|
||||||
|
|
@ -87,11 +87,9 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts_query
|
def posts_query
|
||||||
if private_read?
|
opts = {}
|
||||||
Stream::Tag.new(current_user, params.require(:tag)).posts
|
opts[:public_only] = !private_read?
|
||||||
else
|
Stream::Tag.new(current_user, params.require(:tag), opts).stream_posts
|
||||||
Stream::Tag.new(nil, params.require(:tag)).posts
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags_query
|
def tags_query
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,13 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class Stream::Tag < Stream::Base
|
class Stream::Tag < Stream::Base
|
||||||
attr_accessor :tag_name, :people_page , :people_per_page
|
attr_accessor :tag_name, :people_page , :people_per_page, :public_only
|
||||||
|
|
||||||
def initialize(user, tag_name, opts={})
|
def initialize(user, tag_name, opts={})
|
||||||
self.tag_name = tag_name
|
self.tag_name = tag_name
|
||||||
self.people_page = opts[:page] || 1
|
self.people_page = opts[:page] || 1
|
||||||
self.people_per_page = 15
|
self.people_per_page = 15
|
||||||
|
self.public_only = opts[:public_only] || false
|
||||||
super(user, opts)
|
super(user, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -31,11 +32,12 @@ class Stream::Tag < Stream::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
@posts ||= if user
|
return @posts unless @posts.nil?
|
||||||
StatusMessage.user_tag_stream(user, tag.id)
|
|
||||||
else
|
if public_only || user.blank?
|
||||||
StatusMessage.public_tag_stream(tag.id)
|
return @posts = StatusMessage.public_tag_stream(tag.id)
|
||||||
end
|
end
|
||||||
|
@posts = StatusMessage.user_tag_stream(user, tag.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stream_posts
|
def stream_posts
|
||||||
|
|
|
||||||
|
|
@ -460,6 +460,41 @@ describe Api::V1::SearchController do
|
||||||
)
|
)
|
||||||
expect(response.status).to eq(401)
|
expect(response.status).to eq(401)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the author is blocked' do
|
||||||
|
before do
|
||||||
|
FactoryBot.create(
|
||||||
|
:block,
|
||||||
|
user: auth_public_only_read_only.user,
|
||||||
|
person: eve.person
|
||||||
|
)
|
||||||
|
FactoryBot.create(
|
||||||
|
:block,
|
||||||
|
user: auth.user,
|
||||||
|
person: eve.person
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "hides the blocked author's posts in with public only scopes" do
|
||||||
|
get(
|
||||||
|
"/api/v1/search/posts",
|
||||||
|
params: {tag: "tag2", access_token: access_token_public_only_read_only}
|
||||||
|
)
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
posts = response_body_data(response)
|
||||||
|
expect(posts.length).to eq(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "hides the blocked author's posts in with default scopes" do
|
||||||
|
get(
|
||||||
|
"/api/v1/search/posts",
|
||||||
|
params: {tag: "tag2", access_token: access_token}
|
||||||
|
)
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
posts = response_body_data(response)
|
||||||
|
expect(posts.length).to eq(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "tag_index" do
|
describe "tag_index" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue