FIX: Remove mentions filters from user and groups
Additionally return no data if disabled
This commit is contained in:
parent
fd99e1ef56
commit
74b9828731
|
@ -2,7 +2,9 @@
|
|||
{{#mobile-nav class='group-activity-nav' desktopClass="pull-left nav nav-stacked" currentPath=application.currentPath}}
|
||||
{{group-activity-filter filter="posts" categoryId=category_id}}
|
||||
{{group-activity-filter filter="topics" categoryId=category_id}}
|
||||
{{#if siteSettings.enable_mentions}}
|
||||
{{group-activity-filter filter="mentions" categoryId=category_id}}
|
||||
{{/if}}
|
||||
{{#if showGroupMessages}}
|
||||
{{group-activity-filter filter="messages"}}
|
||||
{{/if}}
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
{{i18n 'user_action_groups.2'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{#if siteSettings.enable_mentions}}
|
||||
<li>
|
||||
{{#link-to 'userNotifications.mentions'}}
|
||||
{{i18n 'user_action_groups.7'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/if}}
|
||||
<li>
|
||||
{{#link-to 'userNotifications.edits'}}
|
||||
{{i18n 'user_action_groups.11'}}
|
||||
|
|
|
@ -98,6 +98,7 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def mentions
|
||||
raise Discourse::NotFound unless SiteSetting.enable_mentions?
|
||||
group = find_group(:group_id)
|
||||
posts = group.mentioned_posts_for(
|
||||
guardian,
|
||||
|
@ -107,6 +108,7 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def mentions_feed
|
||||
raise Discourse::NotFound unless SiteSetting.enable_mentions?
|
||||
group = find_group(:group_id)
|
||||
@posts = group.mentioned_posts_for(
|
||||
guardian,
|
||||
|
|
|
@ -7,12 +7,13 @@ class UserActionsController < ApplicationController
|
|||
per_chunk = 30
|
||||
|
||||
user = fetch_user_from_params(include_inactive: current_user.try(:staff?) || (current_user && SiteSetting.show_inactive_accounts))
|
||||
action_types = (params[:filter] || "").split(",").map(&:to_i)
|
||||
|
||||
opts = { user_id: user.id,
|
||||
user: user,
|
||||
offset: params[:offset].to_i,
|
||||
limit: per_chunk,
|
||||
action_types: (params[:filter] || "").split(",").map(&:to_i),
|
||||
action_types: action_types,
|
||||
guardian: guardian,
|
||||
ignore_private_messages: params[:filter] ? false : true }
|
||||
|
||||
|
|
|
@ -209,6 +209,11 @@ SQL
|
|||
else
|
||||
builder.where("a.user_id = :user_id", user_id: user_id.to_i)
|
||||
builder.where("a.action_type in (:action_types)", action_types: action_types) if action_types && action_types.length > 0
|
||||
|
||||
unless SiteSetting.enable_mentions?
|
||||
builder.where("a.action_type <> :mention_type", mention_type: UserAction::MENTION)
|
||||
end
|
||||
|
||||
builder
|
||||
.order_by("a.created_at desc")
|
||||
.offset(offset.to_i)
|
||||
|
|
|
@ -83,6 +83,12 @@ describe GroupsController do
|
|||
expect(response).to be_success
|
||||
expect(response.content_type).to eq('application/rss+xml')
|
||||
end
|
||||
|
||||
it 'fails when disabled' do
|
||||
SiteSetting.enable_mentions = false
|
||||
get :mentions_feed, params: { group_id: group.name }, format: :rss
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -33,6 +33,7 @@ describe UserAction do
|
|||
}.merge(opts))
|
||||
end
|
||||
|
||||
describe "integration" do
|
||||
before do
|
||||
# Create some test data using a helper
|
||||
log_test_action
|
||||
|
@ -100,9 +101,36 @@ describe UserAction do
|
|||
expect(action.acting_user_id).to eq(admin.id)
|
||||
expect(action.action_type).to eq(UserAction::EDIT)
|
||||
end
|
||||
end
|
||||
|
||||
describe "mentions" do
|
||||
before do
|
||||
log_test_action(action_type: UserAction::MENTION)
|
||||
end
|
||||
|
||||
let(:stream) do
|
||||
UserAction.stream(
|
||||
user_id: user.id,
|
||||
guardian: Guardian.new(user)
|
||||
)
|
||||
end
|
||||
|
||||
it "is returned by the stream" do
|
||||
expect(stream).to be_present
|
||||
end
|
||||
|
||||
it "isn't returned when mentions aren't enabled" do
|
||||
SiteSetting.enable_mentions = false
|
||||
expect(stream).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "mentions" do
|
||||
it "returns the mention in the stream" do
|
||||
end
|
||||
end
|
||||
describe 'when user likes' do
|
||||
|
||||
let(:post) { Fabricate(:post) }
|
||||
|
|
|
@ -88,6 +88,7 @@ Discourse.SiteSettingsOriginal = {
|
|||
"highlighted_languages":"apache|bash|cs|cpp|css|coffeescript|diff|xml|http|ini|json|java|javascript|makefile|markdown|nginx|objectivec|ruby|perl|php|python|sql|handlebars",
|
||||
"enable_emoji":true,
|
||||
"emoji_set":"emoji_one",
|
||||
"desktop_category_page_style":"categories_and_latest_topics"
|
||||
"desktop_category_page_style":"categories_and_latest_topics",
|
||||
"enable_mentions":true
|
||||
};
|
||||
Discourse.SiteSettings = jQuery.extend(true, {}, Discourse.SiteSettingsOriginal);
|
||||
|
|
Loading…
Reference in New Issue