-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Improve remote report display #7062
Feature: Improve remote report display #7062
Conversation
Have just fixed the failing test — didn't realise there wasn't an admin account by default for tests. |
Hmm, this is an improvement, but it still doesn't make clear that the person listed is not necessarily the person who has actually filed the report. |
@ThibG welcome to suggestions, at least now it's guaranteed to be an admin on the remote server, rather than any random first unsuspended user. |
app/services/report_service.rb
Outdated
def some_local_account | ||
@some_local_account ||= Account.local.where(suspended: false).first | ||
def local_admin_account | ||
@local_admin_account ||= User.admins.first.account |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea: Why not use "contact account" when it's set? Also idea: Abstract it out into, for example, Account.representative
... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in Settings.site_contact_username
?
I didn't know it existed, but we certainly could use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ThibG this change should make the remote user the admin / contact person
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gargron I started doing this, and the I realised: there's absolutely no validation on the Setting.site_contact_username value — you can set it to pretty much anything.
Interestingly the about page doesn't show the correct user is site_contact_username is a remote user, despite this being accepted in settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we'd end up with probably this:
def representative
return nil unless local?
site_contact = Account.find_local(Setting.site_contact_username) if Setting.site_contact_username.present?
site_contact || User.admins.first.account
end
If we're to follow the lead from InstancePresenter, then:
def representative
return nil unless local?
site_contact = Account.find_local(Setting.site_contact_username)
site_contact || User.admins.first.account
end
Which relies on the fact that username can't be an empty string
@ThisIsMissEm maybe “Report made on remote instance” instead of “Report by remote account”, as the latter suggests that the listed account is the person who made the report? |
@ThibG how about "reports created from this instance" / "reports about from this instance" and "Report made on remote instance (admin)" i.e., the idea is that the user below is the person to contact on the remote instance about the report created on their instance. |
“Reports created from this instance” / “Reports about this instance” and “Report made on a remote instance (admin)” sounds good to me. With the small caveat that with the “representative” user selection not quite addressed yet, remote reports might be split across a few different users… |
See the comment about the change of the representative user, essentially we'll change this to be the instance contact user or the first administrator found. So perhaps just: "Report made on a remote instance (representative)" |
@ThisIsMissEm yeah, I've seen this change and I'm in favor of it. But not everyone has applied this change yet, and the “representative” may change over time, hence the caveat that the “Reports created from this instance” / “Reports about this instance” might be misleading if that points to reports made by/about the representative account and they change over time. |
2bb514d
to
aef560b
Compare
|
||
def targeting_domain | ||
Report.where(target_account: Account.by_domain(account.domain)) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried about the performances here, but I'm no Rails expert, so I'll let someone more knowledgeable comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it'd probably be better to include domain
on the Report object, such that we could just do Report.where(target_domain: domain).count
and Report.where(domain: domain).count
But this would require database changes, and be backwards incompatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This becomes a SELECT ... WHERE id IN (SELECT ... )
query which is fine, it's not like all accounts are loaded into Rails before being passed into the where clause
%td= link_to pluralize(@report.from_domain.count, t('admin.accounts.show.report')), admin_reports_path(account_id: @report.account.id) | ||
%tr | ||
%td= t('admin.reports.targeting_remote_instance') | ||
%td= link_to pluralize(@report.targeting_domain.count, t('admin.accounts.show.report')), admin_reports_path(target_account_id: @report.account.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The links still point to reports attributed to / against the particular account and not reports against / reported by users on the instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.. this would require changes to ReportFilter to support domains, so you'd end up with a url like /admin/reports?domain=switter.at
or /admin/reports?targeted_domain=switter.at
I'm not sure if that's a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gargron would there be any support for a "domains" model which was just the string of the domain + an ID which we could use for joins? It feels a little odd to use the domain in the filter URL — alternatively, I could do the hash of the domain, as prevent the raw domain being in the URL.
@ThisIsMissEm To be honest I would prefer if this PR contained the least possible amount of changes, aka just the display and the some_local_account change. I don't think there's a pressing need for new filtering functionality |
@Gargron I would agree — I can just remove the links here, as that'd probably make most sense. |
Having an issue running the tests, something about rPam2 missing, yet bundler says everything is installed correctly?
|
I think I want to make the PAM test suite optional because it's really annoying, but anyway to make it work currently you need to |
aef560b
to
ce06236
Compare
@Gargron okay, I managed to get the tests running, but I still have like, 30 failures locally. I don't think they're related to anything I've done, a lot are about this new rails 6 issue then there are issues with the URLs mismatching. I use .dotenv locally whenever I switch directories to load up the correct .env configuration, so I'm guessing that's something to do with it. |
Closing this as it now is obsolete / conflicts heavily due to #7188 |
Resolves #6994