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

Expose the email address of the request to its author #121

Open
anas-ambri opened this issue Oct 7, 2022 · 1 comment
Open

Expose the email address of the request to its author #121

anas-ambri opened this issue Oct 7, 2022 · 1 comment

Comments

@anas-ambri
Copy link

Hello there!
For a few years now, Frontex, one of the EU agencies listed on the website, has been using their own portal to respond to FOIs. However, to provide access to requests made through asktheeu, they have usually asked for the email address associated for each request, which is automatically generated by the platform. As of right now, that email address is not public. Therefore, the staff at Access Info had to resort to responding manually to every request to share that email address.

I have been looking into the best way to expose this email address, and therefore saving a bit of Access Info's time.

Originally, the idea was to simply show it in a patched version of the _after_actions.html.erb view. However, it seems that the email address is used to authenticate the public body:

Quoting from the source code:

Checks the hash to ensure the email came from the public body -
only they are sent the email address with the has in it. (We don't check
the prefix and domain, as sometimes those change, or might be elided by
copying an email, and that doesn't matter)
def self.find_by_incoming_email(incoming_email)

Therefore, I think the better approach would simply be to include the email address in a patched version of the response_notification.text.erb.

What does everyone think of this approach?

@anas-ambri
Copy link
Author

I have made the change above here.

Unfortunately, the test is failing with the following stacktrace:

  1) when patched by the asktheeu-theme contains email address of request
     Failure/Error: table_rows = fs.table_rows
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedTable: ERROR:  relation "public_body_category_links" does not exist
       LINE 8:  WHERE a.attrelid = '"public_body_category_links"'::regclass
                                   ^
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in `exec'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in `block (2 levels) in query'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:18:in `block in query'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:696:in `block (2 levels) in log'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:695:in `block in log'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:687:in `log'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:17:in `query'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:820:in `column_definitions'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `columns'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/schema_cache.rb:112:in `block in columns'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/schema_cache.rb:111:in `fetch'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/schema_cache.rb:111:in `columns'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/schema_cache.rb:120:in `block in columns_hash'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/schema_cache.rb:119:in `fetch'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/schema_cache.rb:119:in `columns_hash'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/model_schema.rb:553:in `load_schema!'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/attributes.rb:250:in `load_schema!'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/model_schema.rb:539:in `block in load_schema'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/model_schema.rb:536:in `synchronize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/model_schema.rb:536:in `load_schema'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/model_schema.rb:397:in `columns'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/model_schema.rb:466:in `column_names'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/timestamp.rb:64:in `timestamp_attributes_for_create_in_model'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/timestamp.rb:74:in `all_timestamp_attributes_in_model'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/model_metadata.rb:24:in `timestamp_column_names'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_row.rb:79:in `fill_timestamps'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_row.rb:61:in `fill_row_model_attributes'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_row.rb:43:in `initialize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_rows.rb:36:in `new'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_rows.rb:36:in `block in build_table_rows_from'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_rows.rb:35:in `each'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_rows.rb:35:in `map'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_rows.rb:35:in `build_table_rows_from'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixture_set/table_rows.rb:18:in `initialize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixtures.rb:688:in `new'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/fixtures.rb:688:in `table_rows'
     # ./lib/no_constraint_disabling.rb:81:in `block (3 levels) in create_fixtures'
     # ./lib/no_constraint_disabling.rb:79:in `each'
     # ./lib/no_constraint_disabling.rb:79:in `block (2 levels) in create_fixtures'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activesupport-6.1.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
     # ./lib/no_constraint_disabling.rb:55:in `block in create_fixtures'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/postgresql/referential_integrity.rb:19:in `disable_referential_integrity'
     # ./lib/no_constraint_disabling.rb:40:in `create_fixtures'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/test_fixtures.rb:268:in `load_fixtures'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/test_fixtures.rb:122:in `setup_fixtures'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/test_fixtures.rb:10:in `before_setup'
     # /Users/anasambri/.gems/ruby/2.7.0/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedTable:
     #   ERROR:  relation "public_body_category_links" does not exist
     #   LINE 8:  WHERE a.attrelid = '"public_body_category_links"'::regclass
     #                               ^
     #   /Users/anasambri/.gems/ruby/2.7.0/gems/activerecord-6.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in `exec'

Here is database.yml

test:
  adapter: postgresql
  template: template_utf8
  database: foi_test
  username: postgres
  constraint_disabling: false

storage.yml is a copy of storage.yml-example. general-asktheeu-theme.yml is a copy of general.yml-example, where THEME_URLS and THEME_BRANCH have been modified to point to this branch. However, this should be overridden, since I have used the script/switch_theme.rb to use the local theme folder.

It seems that the issue is related to an improperly configured database. I created my test db using the command

/opt/homebrew/opt/postgresql@14/bin/createdb foi_test --username=postgres

The user postgres is not superuser.

Any idea what the issue could be?

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

No branches or pull requests

1 participant