Skip to content
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

Conversation

ThisIsMissEm
Copy link
Contributor

@ThisIsMissEm ThisIsMissEm commented Apr 7, 2018

Resolves #6994

screen shot 2018-04-07 at 10 10 09 am

@ThisIsMissEm
Copy link
Contributor Author

Have just fixed the failing test — didn't realise there wasn't an admin account by default for tests.

@ClearlyClaire
Copy link
Contributor

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.

@ThisIsMissEm
Copy link
Contributor Author

@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.

def some_local_account
@some_local_account ||= Account.local.where(suspended: false).first
def local_admin_account
@local_admin_account ||= User.admins.first.account
Copy link
Member

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... 🤔

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

@ClearlyClaire
Copy link
Contributor

@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?
In a similar fashion, “Reports assigned to this account” rather than “Reports created by this account” in the case of remote toots… but this may also be misleading for other reasons…

@ThisIsMissEm
Copy link
Contributor Author

@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.

@ClearlyClaire
Copy link
Contributor

“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…

@ThisIsMissEm
Copy link
Contributor Author

@ThibG

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)"

@ClearlyClaire
Copy link
Contributor

@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.

@ThisIsMissEm
Copy link
Contributor Author

There doesn't seem to be a good way to lay this out..

screen shot 2018-04-08 at 3 14 04 pm

screen shot 2018-04-08 at 3 15 08 pm

It'd be perhaps better if the report stats showed next to the account, rather than beneath the account

@ThisIsMissEm ThisIsMissEm force-pushed the feature/improve-remote-report-display branch from 2bb514d to aef560b Compare April 8, 2018 13:20
@ThisIsMissEm
Copy link
Contributor Author

@ThibG what do you think of the changes in aef560b ?


def targeting_domain
Report.where(target_account: Account.by_domain(account.domain))
end
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@Gargron
Copy link
Member

Gargron commented Apr 16, 2018

@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

@ThisIsMissEm
Copy link
Contributor Author

@Gargron I would agree — I can just remove the links here, as that'd probably make most sense.

@ThisIsMissEm
Copy link
Contributor Author

Having an issue running the tests, something about rPam2 missing, yet bundler says everything is installed correctly?

rspec spec/models/account_spec.rb
                                                                                                                                                                
An error occurred while loading ./spec/models/account_spec.rb.
Failure/Error: require File.expand_path('../../config/environment', __FILE__)

NameError:
  uninitialized constant Rpam2
# ./config/environments/test.rb:65:in `<top (required)>'
# ./config/environment.rb:5:in `<top (required)>'
# ./spec/rails_helper.rb:2:in `<top (required)>'
# ./spec/models/account_spec.rb:1:in `<top (required)>'
# ------------------
# --- Caused by: ---
# NameError:
#   uninitialized constant Rpam2
#   ./config/environments/test.rb:65:in `<top (required)>'
No examples found.                                                                                                                                              
 0/0 |================================================================= 100 ==================================================================>| Time: 00:00:00 
[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See https://github.com/philostler/rspec-sidekiq/wiki/FAQ-&-Troubleshooting

Finished in 0.00099 seconds (files took 3.04 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
Coverage report generated for RSpec to /mastodon/coverage. 65 / 16042 LOC (0.41%) covered.

@Gargron
Copy link
Member

Gargron commented Apr 17, 2018

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 bundle install --with pam_authentication

@ThisIsMissEm ThisIsMissEm force-pushed the feature/improve-remote-report-display branch from aef560b to ce06236 Compare April 18, 2018 01:32
@ThisIsMissEm
Copy link
Contributor Author

ThisIsMissEm commented Apr 18, 2018

@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.

@ThisIsMissEm
Copy link
Contributor Author

Here's the updated UI / Display:
screen shot 2018-04-18 at 3 35 26 am

@ThisIsMissEm
Copy link
Contributor Author

Closing this as it now is obsolete / conflicts heavily due to #7188

@ThisIsMissEm ThisIsMissEm deleted the feature/improve-remote-report-display branch April 23, 2018 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants