Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/views/admin/trends/links/index.html.haml`: Not really a conflict, upstream change textually too close to a glitch-soc change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming system). Ported upstream changes. - `app/views/admin/trends/links/preview_card_providers/index.html.haml`: Not really a conflict, upstream change textually too close to a glitch-soc change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming system). Ported upstream changes. - `app/views/admin/trends/statuses/index.html.haml`: Not really a conflict, upstream change textually too close to a glitch-soc change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming system). Ported upstream changes. - `app/views/admin/trends/tags/index.html.haml`: Not really a conflict, upstream change textually too close to a glitch-soc change (removed `javascript_pack_tag` to accomodate for glitch-soc's theming system). Ported upstream changes.pull/1710/head
commit
8743b1ea40
|
@ -10,9 +10,7 @@ class Api::V1::ReportsController < Api::BaseController
|
||||||
@report = ReportService.new.call(
|
@report = ReportService.new.call(
|
||||||
current_account,
|
current_account,
|
||||||
reported_account,
|
reported_account,
|
||||||
status_ids: reported_status_ids,
|
report_params
|
||||||
comment: report_params[:comment],
|
|
||||||
forward: report_params[:forward]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
render json: @report, serializer: REST::ReportSerializer
|
render json: @report, serializer: REST::ReportSerializer
|
||||||
|
@ -20,14 +18,6 @@ class Api::V1::ReportsController < Api::BaseController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def reported_status_ids
|
|
||||||
reported_account.statuses.with_discarded.find(status_ids).pluck(:id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def status_ids
|
|
||||||
Array(report_params[:status_ids])
|
|
||||||
end
|
|
||||||
|
|
||||||
def reported_account
|
def reported_account
|
||||||
Account.find(report_params[:account_id])
|
Account.find(report_params[:account_id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,8 +94,9 @@ class Api::V1::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_thread
|
def set_thread
|
||||||
@thread = status_params[:in_reply_to_id].blank? ? nil : Status.find(status_params[:in_reply_to_id])
|
@thread = Status.find(status_params[:in_reply_to_id]) if status_params[:in_reply_to_id].present?
|
||||||
rescue ActiveRecord::RecordNotFound
|
authorize(@thread, :show?) if @thread.present?
|
||||||
|
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
||||||
render json: { error: I18n.t('statuses.errors.in_reply_not_found') }, status: 404
|
render json: { error: I18n.t('statuses.errors.in_reply_not_found') }, status: 404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -904,6 +904,14 @@ a.name-tag,
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.applications-list__item {
|
||||||
|
padding: 15px 0;
|
||||||
|
background: $ui-base-color;
|
||||||
|
border: 1px solid lighten($ui-base-color, 4%);
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.announcements-list {
|
.announcements-list {
|
||||||
border: 1px solid lighten($ui-base-color, 4%);
|
border: 1px solid lighten($ui-base-color, 4%);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|
|
@ -1069,6 +1069,7 @@ code {
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ class ReportService < BaseService
|
||||||
def call(source_account, target_account, options = {})
|
def call(source_account, target_account, options = {})
|
||||||
@source_account = source_account
|
@source_account = source_account
|
||||||
@target_account = target_account
|
@target_account = target_account
|
||||||
@status_ids = options.delete(:status_ids) || []
|
@status_ids = options.delete(:status_ids).presence || []
|
||||||
@comment = options.delete(:comment) || ''
|
@comment = options.delete(:comment).presence || ''
|
||||||
@category = options.delete(:category) || 'other'
|
@category = options.delete(:category).presence || 'other'
|
||||||
@rule_ids = options.delete(:rule_ids)
|
@rule_ids = options.delete(:rule_ids).presence
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
raise ActiveRecord::RecordNotFound if @target_account.suspended?
|
raise ActiveRecord::RecordNotFound if @target_account.suspended?
|
||||||
|
@ -26,7 +26,7 @@ class ReportService < BaseService
|
||||||
def create_report!
|
def create_report!
|
||||||
@report = @source_account.reports.create!(
|
@report = @source_account.reports.create!(
|
||||||
target_account: @target_account,
|
target_account: @target_account,
|
||||||
status_ids: @status_ids,
|
status_ids: reported_status_ids,
|
||||||
comment: @comment,
|
comment: @comment,
|
||||||
uri: @options[:uri],
|
uri: @options[:uri],
|
||||||
forwarded: forward?,
|
forwarded: forward?,
|
||||||
|
@ -56,6 +56,10 @@ class ReportService < BaseService
|
||||||
!@target_account.local? && ActiveModel::Type::Boolean.new.cast(@options[:forward])
|
!@target_account.local? && ActiveModel::Type::Boolean.new.cast(@options[:forward])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reported_status_ids
|
||||||
|
@target_account.statuses.with_discarded.find(Array(@status_ids)).pluck(:id)
|
||||||
|
end
|
||||||
|
|
||||||
def payload
|
def payload
|
||||||
Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
|
Oj.dump(serialize_payload(@report, ActivityPub::FlagSerializer, account: some_local_account))
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('admin.trends.links.title')
|
= t('admin.trends.links.title')
|
||||||
|
|
||||||
|
%p= t('admin.trends.links.description_html')
|
||||||
|
|
||||||
|
%hr.spacer/
|
||||||
|
|
||||||
= form_tag admin_trends_links_path, method: 'GET', class: 'simple_form' do
|
= form_tag admin_trends_links_path, method: 'GET', class: 'simple_form' do
|
||||||
- Trends::PreviewCardFilter::KEYS.each do |key|
|
- Trends::PreviewCardFilter::KEYS.each do |key|
|
||||||
= hidden_field_tag key, params[key] if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('admin.trends.preview_card_providers.title')
|
= t('admin.trends.preview_card_providers.title')
|
||||||
|
|
||||||
|
%p= t('admin.trends.preview_card_providers.description_html')
|
||||||
|
|
||||||
|
%hr.spacer/
|
||||||
|
|
||||||
.filters
|
.filters
|
||||||
.filter-subset
|
.filter-subset
|
||||||
%strong= t('admin.tags.review')
|
%strong= t('admin.tags.review')
|
||||||
|
@ -14,7 +18,6 @@
|
||||||
= fa_icon 'chevron-left fw'
|
= fa_icon 'chevron-left fw'
|
||||||
= t('admin.trends.links.title')
|
= t('admin.trends.links.title')
|
||||||
|
|
||||||
|
|
||||||
%hr.spacer/
|
%hr.spacer/
|
||||||
|
|
||||||
= form_for(@form, url: batch_admin_trends_links_preview_card_providers_path) do |f|
|
= form_for(@form, url: batch_admin_trends_links_preview_card_providers_path) do |f|
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
- if status.language.present?
|
- if status.language.present?
|
||||||
•
|
•
|
||||||
= standard_locale_name(status.language)
|
= standard_locale_name(status.language)
|
||||||
|
- if status.trendable? && !status.account.discoverable?
|
||||||
|
•
|
||||||
|
= t('admin.trends.statuses.not_discoverable')
|
||||||
- if status.trendable? && (rank = Trends.statuses.rank(status.id))
|
- if status.trendable? && (rank = Trends.statuses.rank(status.id))
|
||||||
•
|
•
|
||||||
%abbr{ title: t('admin.trends.tags.current_score', score: Trends.statuses.score(status.id)) }= t('admin.trends.tags.trending_rank', rank: rank + 1)
|
%abbr{ title: t('admin.trends.tags.current_score', score: Trends.statuses.score(status.id)) }= t('admin.trends.tags.trending_rank', rank: rank + 1)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('admin.trends.statuses.title')
|
= t('admin.trends.statuses.title')
|
||||||
|
|
||||||
|
%p= t('admin.trends.statuses.description_html')
|
||||||
|
|
||||||
|
%hr.spacer/
|
||||||
|
|
||||||
= form_tag admin_trends_statuses_path, method: 'GET', class: 'simple_form' do
|
= form_tag admin_trends_statuses_path, method: 'GET', class: 'simple_form' do
|
||||||
- Trends::StatusFilter::KEYS.each do |key|
|
- Trends::StatusFilter::KEYS.each do |key|
|
||||||
= hidden_field_tag key, params[key] if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('admin.trends.tags.title')
|
= t('admin.trends.tags.title')
|
||||||
|
|
||||||
|
%p= t('admin.trends.tags.description_html')
|
||||||
|
|
||||||
|
%hr.spacer/
|
||||||
|
|
||||||
.filters
|
.filters
|
||||||
.filter-subset
|
.filter-subset
|
||||||
%strong= t('admin.tags.review')
|
%strong= t('admin.tags.review')
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
%hr.spacer/
|
%hr.spacer/
|
||||||
|
|
||||||
.announcements-list
|
.applications-list
|
||||||
- @applications.each do |application|
|
- @applications.each do |application|
|
||||||
.announcements-list__item
|
.applications-list__item
|
||||||
- if application.website.present?
|
- if application.website.present?
|
||||||
= link_to application.name, application.website, target: '_blank', rel: 'noopener noreferrer', class: 'announcements-list__item__title'
|
= link_to application.name, application.website, target: '_blank', rel: 'noopener noreferrer', class: 'announcements-list__item__title'
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -777,6 +777,7 @@ en:
|
||||||
links:
|
links:
|
||||||
allow: Allow link
|
allow: Allow link
|
||||||
allow_provider: Allow publisher
|
allow_provider: Allow publisher
|
||||||
|
description_html: These are links that are currently being shared a lot by accounts that your server sees posts from. It can help your users find out what's going on in the world. No links are displayed publicly until you approve the publisher. You can also allow or reject individual links.
|
||||||
disallow: Disallow link
|
disallow: Disallow link
|
||||||
disallow_provider: Disallow publisher
|
disallow_provider: Disallow publisher
|
||||||
shared_by_over_week:
|
shared_by_over_week:
|
||||||
|
@ -788,14 +789,17 @@ en:
|
||||||
pending_review: Pending review
|
pending_review: Pending review
|
||||||
preview_card_providers:
|
preview_card_providers:
|
||||||
allowed: Links from this publisher can trend
|
allowed: Links from this publisher can trend
|
||||||
|
description_html: These are domains from which links are often shared on your server. Links will not trend publicly unless the domain of the link is approved. Your approval (or rejection) extends to subdomains.
|
||||||
rejected: Links from this publisher won't trend
|
rejected: Links from this publisher won't trend
|
||||||
title: Publishers
|
title: Publishers
|
||||||
rejected: Rejected
|
rejected: Rejected
|
||||||
statuses:
|
statuses:
|
||||||
allow: Allow post
|
allow: Allow post
|
||||||
allow_account: Allow author
|
allow_account: Allow author
|
||||||
|
description_html: These are posts that your server knows about that are currently being shared and favourited a lot at the moment. It can help your new and returning users to find more people to follow. No posts are displayed publicly until you approve the author, and the author allows their account to be suggested to others. You can also allow or reject individual posts.
|
||||||
disallow: Disallow post
|
disallow: Disallow post
|
||||||
disallow_account: Disallow author
|
disallow_account: Disallow author
|
||||||
|
not_discoverable: Author has not opted-in to being discoverable
|
||||||
shared_by:
|
shared_by:
|
||||||
one: Shared or favourited one time
|
one: Shared or favourited one time
|
||||||
other: Shared and favourited %{friendly_count} times
|
other: Shared and favourited %{friendly_count} times
|
||||||
|
@ -808,6 +812,7 @@ en:
|
||||||
tag_servers_dimension: Top servers
|
tag_servers_dimension: Top servers
|
||||||
tag_servers_measure: different servers
|
tag_servers_measure: different servers
|
||||||
tag_uses_measure: total uses
|
tag_uses_measure: total uses
|
||||||
|
description_html: These are hashtags that are currently appearing in a lot of posts that your server sees. It can help your users find out what people are talking the most about at the moment. No hashtags are displayed publicly until you approve them.
|
||||||
listable: Can be suggested
|
listable: Can be suggested
|
||||||
not_listable: Won't be suggested
|
not_listable: Won't be suggested
|
||||||
not_trendable: Won't appear under trends
|
not_trendable: Won't appear under trends
|
||||||
|
|
|
@ -13,22 +13,64 @@ RSpec.describe Api::V1::ReportsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
let(:scopes) { 'write:reports' }
|
let!(:admin) { Fabricate(:user, admin: true) }
|
||||||
let!(:status) { Fabricate(:status) }
|
|
||||||
let!(:admin) { Fabricate(:user, admin: true) }
|
let(:scopes) { 'write:reports' }
|
||||||
|
let(:status) { Fabricate(:status) }
|
||||||
|
let(:target_account) { status.account }
|
||||||
|
let(:category) { nil }
|
||||||
|
let(:forward) { nil }
|
||||||
|
let(:rule_ids){ nil }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil))
|
allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil))
|
||||||
post :create, params: { status_ids: [status.id], account_id: status.account.id, comment: 'reasons' }
|
post :create, params: { status_ids: [status.id], account_id: target_account.id, comment: 'reasons', category: category, rule_ids: rule_ids, forward: forward }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a report' do
|
it 'creates a report' do
|
||||||
expect(status.reload.account.targeted_reports).not_to be_empty
|
expect(target_account.targeted_reports).to_not be_empty
|
||||||
expect(response).to have_http_status(200)
|
end
|
||||||
|
|
||||||
|
it 'saves comment' do
|
||||||
|
expect(target_account.targeted_reports.first.comment).to eq 'reasons'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends e-mails to admins' do
|
it 'sends e-mails to admins' do
|
||||||
expect(AdminMailer).to have_received(:new_report).with(admin.account, Report)
|
expect(AdminMailer).to have_received(:new_report).with(admin.account, Report)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when a status does not belong to the reported account' do
|
||||||
|
let(:target_account) { Fabricate(:account) }
|
||||||
|
|
||||||
|
it 'returns http not found' do
|
||||||
|
expect(response).to have_http_status(404)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when a category is chosen' do
|
||||||
|
let(:category) { 'spam' }
|
||||||
|
|
||||||
|
it 'saves category' do
|
||||||
|
expect(target_account.targeted_reports.first.spam?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when violated rules are chosen' do
|
||||||
|
let(:rule) { Fabricate(:rule) }
|
||||||
|
let(:category) { 'violation' }
|
||||||
|
let(:rule_ids) { [rule.id] }
|
||||||
|
|
||||||
|
it 'saves category' do
|
||||||
|
expect(target_account.targeted_reports.first.violation?).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'saves rule_ids' do
|
||||||
|
expect(target_account.targeted_reports.first.rule_ids).to match_array([rule.id])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:rule) do
|
Fabricator(:rule) do
|
||||||
priority ""
|
priority 0
|
||||||
deleted_at "2021-02-21 05:51:09"
|
deleted_at nil
|
||||||
text "MyText"
|
text { Faker::Lorem.paragraph }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue