FIX: Featuring topic on other users profile shows their topics (#8769)
This commit is contained in:
parent
4b54791bcc
commit
c5eec19368
|
@ -3,12 +3,18 @@ import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import { none } from "@ember/object/computed";
|
import { none } from "@ember/object/computed";
|
||||||
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Controller.extend(ModalFunctionality, {
|
export default Controller.extend(ModalFunctionality, {
|
||||||
newFeaturedTopic: null,
|
newFeaturedTopic: null,
|
||||||
saving: false,
|
saving: false,
|
||||||
noTopicSelected: none("newFeaturedTopic"),
|
noTopicSelected: none("newFeaturedTopic"),
|
||||||
|
|
||||||
|
@discourseComputed("model")
|
||||||
|
additionalFilters(model) {
|
||||||
|
return `status:public created:@${model.username}`;
|
||||||
|
},
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
this.set("newFeaturedTopic", null);
|
this.set("newFeaturedTopic", null);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{#d-modal-body class="feature-topic-on-profile" id='choosing-topic'}}
|
{{#d-modal-body class="feature-topic-on-profile" id='choosing-topic'}}
|
||||||
{{choose-topic currentTopicId=model.featured_topic.id
|
{{choose-topic currentTopicId=model.featured_topic.id
|
||||||
selectedTopicId=newFeaturedTopicId
|
selectedTopicId=newFeaturedTopicId
|
||||||
additionalFilters="in:created status:public"
|
additionalFilters=additionalFilters
|
||||||
label="user.feature_topic_on_profile.search_label"
|
label="user.feature_topic_on_profile.search_label"
|
||||||
topicChangedCallback=(action "newTopicSelected")
|
topicChangedCallback=(action "newTopicSelected")
|
||||||
loadOnInit=true
|
loadOnInit=true
|
||||||
|
|
|
@ -382,6 +382,11 @@ class Search
|
||||||
posts.where(user_id: @guardian.user.id, post_number: 1) if @guardian.user
|
posts.where(user_id: @guardian.user.id, post_number: 1) if @guardian.user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
advanced_filter(/^created:@(.*)$/) do |posts, match|
|
||||||
|
user_id = User.where(username: match.downcase).pluck_first(:id)
|
||||||
|
posts.where(user_id: user_id, post_number: 1)
|
||||||
|
end
|
||||||
|
|
||||||
advanced_filter(/^in:(watching|tracking)$/) do |posts, match|
|
advanced_filter(/^in:(watching|tracking)$/) do |posts, match|
|
||||||
if @guardian.user
|
if @guardian.user
|
||||||
level = TopicUser.notification_levels[match.to_sym]
|
level = TopicUser.notification_levels[match.to_sym]
|
||||||
|
|
|
@ -1044,12 +1044,20 @@ describe Search do
|
||||||
|
|
||||||
expect(Search.execute('test in:posted', guardian: Guardian.new(topic.user)).posts.length).to eq(2)
|
expect(Search.execute('test in:posted', guardian: Guardian.new(topic.user)).posts.length).to eq(2)
|
||||||
|
|
||||||
expect(Search.execute('test in:created', guardian: Guardian.new(topic.user)).posts.length).to eq(1)
|
in_created = Search.execute('test in:created', guardian: Guardian.new(topic.user)).posts
|
||||||
|
created_by_user = Search.execute("test created:@#{topic.user.username}", guardian: Guardian.new(topic.user)).posts
|
||||||
|
expect(in_created.length).to eq(1)
|
||||||
|
expect(created_by_user.length).to eq(1)
|
||||||
|
expect(in_created).to eq(created_by_user)
|
||||||
|
|
||||||
|
expect(Search.execute("test created:@#{second_topic.user.username}", guardian: Guardian.new(topic.user)).posts.length).to eq(1)
|
||||||
|
|
||||||
|
new_user = Fabricate(:user)
|
||||||
|
expect(Search.execute("test created:@#{new_user.username}", guardian: Guardian.new(topic.user)).posts.length).to eq(0)
|
||||||
|
|
||||||
TopicUser.change(topic.user.id, topic.id, notification_level: TopicUser.notification_levels[:tracking])
|
TopicUser.change(topic.user.id, topic.id, notification_level: TopicUser.notification_levels[:tracking])
|
||||||
expect(Search.execute('test in:watching', guardian: Guardian.new(topic.user)).posts.length).to eq(0)
|
expect(Search.execute('test in:watching', guardian: Guardian.new(topic.user)).posts.length).to eq(0)
|
||||||
expect(Search.execute('test in:tracking', guardian: Guardian.new(topic.user)).posts.length).to eq(1)
|
expect(Search.execute('test in:tracking', guardian: Guardian.new(topic.user)).posts.length).to eq(1)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can find posts with images' do
|
it 'can find posts with images' do
|
||||||
|
|
Loading…
Reference in New Issue